Page 1 of 1

PBv6.30 Drawing in Texture, RGB becomes BGR

Posted: Fri Feb 20, 2026 4:06 pm
by PeDe
PBv6.30 arm64, Raspberry Pi OS (Debian 13)

The colors are displayed incorrectly in a texture when drawing; RGB becomes BGR.
Can anyone explain this error?

Peter

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 400, 400, "Test - [Esc] quit", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 400, 400, 0, 0, 0)

AmbientColor(#White)
CreateCube(0, 4)

CreateTexture(0, 64, 64)
CreateMaterial(0, TextureID(0))

StartDrawing(TextureOutput(0))
; Box(0, 0, 64, 64, RGB(0, 0, 255))
; Circle(32, 32, 16, RGB(255, 0, 0))
Box(0, 0, 64, 64, #Blue)
Circle(32, 32, 16, #Red)
StopDrawing()

CreateEntity(0, MeshID(0), MaterialID(0))
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 10, #PB_Absolute)

Repeat
  While WindowEvent():Wend
  ExamineKeyboard()
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)

Re: PBv6.30 Drawing in Texture, RGB becomes BGR

Posted: Fri Feb 20, 2026 5:11 pm
by miso
#Blue is hardcoded constant, and some hardware is bgr, some is rgb, etc. Is the command rgb() works good? (it should)

The true solution is drawingbuffer() and drawingbufferpixelformat(), but I think this should be revised by Fred and team, and set some rules how the rgb() command and fix constants and non buffered drawings should work, and document it with example.

My machine is also bgr with constants.

Re: PBv6.30 Drawing in Texture, RGB becomes BGR

Posted: Fri Feb 20, 2026 5:27 pm
by PeDe
The constants and the RGB() function generate BGR colors.

Peter

Re: PBv6.30 Drawing in Texture, RGB becomes BGR

Posted: Fri Feb 20, 2026 5:51 pm
by miso
Its a bug. The question is only that: command bug or missing documentation bug. Are colors good on for example canvas or on image, or gadget color?

Re: PBv6.30 Drawing in Texture, RGB becomes BGR

Posted: Fri Feb 20, 2026 6:02 pm
by PeDe
When a texture is loaded, the colors are correct.

Peter

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 400, 400, "Test - [Esc] quit", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 400, 400, 0, 0, 0)

Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)

AmbientColor(#White)
CreateCube(0, 4)

; CreateTexture(0, 64, 64)
; CreateMaterial(0, TextureID(0))
CreateMaterial(0, LoadTexture(0, "Caisse.png"))

StartDrawing(TextureOutput(0))
; Box(0, 0, 64, 64, RGB(0, 0, 255))
; Circle(32, 32, 16, RGB(255, 0, 0))
Box(0, 0, 64, 64, #Blue)
Circle(32, 32, 16, #Red)
StopDrawing()

CreateEntity(0, MeshID(0), MaterialID(0))
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 10, #PB_Absolute)

Repeat
  While WindowEvent():Wend
  ExamineKeyboard()
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)