Page 1 of 1
Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 1:34 am
by coco2
Code: Select all
;InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 256, 256, "Test Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 256, 256)
Repeat
Event = WindowEvent()
Delay(1)
ClearScreen(#Blue)
FlipBuffers()
Until Event = #PB_Event_CloseWindow
This code shows a blue screen. If you uncomment InitEngine3D() there is no longer a blue screen. Why is the 3D initialise affecting the screen behaviour?
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:09 am
by miso
If initengine3d, you will need a camera, a camerabackcolor(color) and a renderworld() before flipbuffers to work. The two modes are not identical.
Also with screens don't:
instead
Or else soon you will backlog tracking for mouse events for example.
miso
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:16 am
by coco2
I couldn't get that working, can you show me?
Code: Select all
Define Quit.i = 0
InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 256, 256, "Test Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 256, 256)
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, #Black)
Repeat
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Event = 0
Delay(1)
RenderWorld()
ClearScreen(#Blue)
FlipBuffers()
Until Quit
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:20 am
by miso
It was almost perfect. No need for clearscreen though in 3d.
Code: Select all
Define Quit.i = 0
InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 256, 256, "Test Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 256, 256)
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, #Blue)
Repeat
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Event = 0
RenderWorld()
FlipBuffers()
Delay(1)
Until Quit
If you use sprites or the new gui, render and draw them after renderworld() and before flipbuffers().
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:26 am
by coco2
Ok thanks, I think I know what I need to do now. I'm creating a "retro" 3D game engine where it renders the 3D world, then enlarges it so the pixels are some multiple. ClearScreen() was causing the problem.
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:31 am
by miso
You might check bug planet in game section. That pretty much do that with a quad. Looks 2d only because the orthographic camera, it's 3d in reality. Very messy code of mine though...
Or a bigger but clean and modular framework of mine in intro player has a ready to use setup for this in module sys. You just have to remove the pb version check, as it checks explicitly against version pb621 or something.
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:48 am
by coco2
Fun little game, althought I had to change line 445 to:
Code: Select all
OpenWindowedScreen(WindowID(#MAINWINDOW_H),0,0,WindowWidth(#MAINWINDOW_H)*DesktopResolutionX(),WindowHeight(#MAINWINDOW_H)*DesktopResolutionY(),#AUTOSTRETCH_ON,0,0,#SCREEN_FLAGS)
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 4:53 am
by miso
Oh. What OS do you use? I was sure it's dpi aware the way it is now... Now thats something I need as an information.

Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 5:18 am
by coco2
I'm using Windows 11 with a ultrawide screen 1.5x scaling.
Re: Initialising 3D changes screen behaviour
Posted: Wed Dec 24, 2025 6:04 am
by miso
coco2 wrote: Wed Dec 24, 2025 5:18 am
I'm using Windows 11 with a ultrawide screen 1.5x scaling.
Thanks. Maybe we gamemakers should create a topic later in 3d and or in game creation with some simple instructions and codes like in this post, how to start, what to do, what to avoid and why. Without fancy extra additions. There are some pitfalls one can fall...