Page 1 of 1
OpenWindowedScreen() must be called before using any 3D
Posted: Thu Mar 20, 2025 2:11 pm
by tan9p
On my other older machine, when running the same 3D example, the following error occurs. (Strangely enough, it runs without any issues on my current machine.)
Code: Select all
OpenWindowedScreen() must be called before using any 3D
After searching, some posts suggest that the problem might be due to the absence of DirectX 9 or outdated graphics card drivers or can use opengl subsystem..
https://www.purebasic.fr/english/viewtopic.php?t=52048
I'd like to know the exact cause of the above error. Can it be resolved by installing DirectX 9? and how to use openGL subsystem.
Thanks a lot!
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Thu Mar 20, 2025 3:32 pm
by miso
Hello tan9p!
If you use the same PB version, than the subsystem is the same. So I think it's graphics driver. (could not open the screen when called. IT can be checked with an if statement.) OpenGL is the supported subsystem. (and its the default, OpenGL in new, DirectX9 in older PB versions) For 2d there is a DirectX11 option. You can switch the subsystem in the compiler options/library subsystem field. [Personally, I only use the OpenGL default subsystem.]
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Fri Mar 21, 2025 9:20 am
by tan9p
Hello miso!
I installed the DirectX, But the program still reports an error. Is it because the driver doesn't support it? There is no folder named "opengl" under the "subsystem" folder. Does the blank mean the default is OpenGL? Can it be understood that PureBasic 6.20 doesn't support the graphics card on my machine?
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Fri Mar 21, 2025 9:46 am
by Fred
in 6.20, only OpenGL is supported for the 3D engine.
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Fri Mar 21, 2025 9:52 am
by miso
Run this in debug mode. If it says could not open windowed screen, then your older machines videocard is not supported. (changing driver might or might not help) If everything is ok, you will see a black screen, that exits by pressing escape. (borrowed some code from Mijikai to write this test)
Code: Select all
If Not InitEngine3D() : Debug "Could not initialize 3d engine" :End: EndIf
If Not InitSprite() : Debug "could Not initialize sprite engine" :End: EndIf
If Not InitKeyboard() : Debug "could not initialize keyboard" :End: EndIf
If Not OpenWindow(0,0,0,800,800,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered) : Debug "could Not open window" :End: EndIf
If Not OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0)):Debug "could not open windowed screen on this graphic card" :End: EndIf
SetFrameRate(60)
camera = CreateCamera(#PB_Any,0,0,100,100)
MoveCamera(camera,0,0,100,#PB_Absolute)
CameraLookAt(camera,0,0,0)
light = CreateLight(#PB_Any,#White,0,0,100)
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_None
Break
Case #PB_Event_CloseWindow
exit = #True
EndSelect
ForEver
ExamineKeyboard()
RenderWorld()
FlipBuffers()
Until exit Or KeyboardPushed(#PB_Key_Escape)
CloseScreen()
CloseWindow(0)
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Fri Mar 21, 2025 1:27 pm
by tan9p
Thanks!It says could not open windowed screen on this graphic card. So I think the machine does not support PureBasic 6.20.
Re: OpenWindowedScreen() must be called before using any 3D
Posted: Fri Mar 21, 2025 2:16 pm
by miso
Try Pb 5.73. on that computer. You can download it from the archives. (5.73 is DirectX9 by default, if I remember well.)
If that works, you can experiment with versions up to 6.04.