PBv6.30 Drawing in Texture, RGB becomes BGR

Everything related to 3D programming
PeDe
Enthusiast
Enthusiast
Posts: 355
Joined: Sun Nov 26, 2017 3:13 pm

PBv6.30 Drawing in Texture, RGB becomes BGR

Post 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)
miso
Enthusiast
Enthusiast
Posts: 714
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

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

Post 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.
PeDe
Enthusiast
Enthusiast
Posts: 355
Joined: Sun Nov 26, 2017 3:13 pm

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

Post by PeDe »

The constants and the RGB() function generate BGR colors.

Peter
miso
Enthusiast
Enthusiast
Posts: 714
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

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

Post 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?
PeDe
Enthusiast
Enthusiast
Posts: 355
Joined: Sun Nov 26, 2017 3:13 pm

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

Post 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)
Post Reply