Detecting failure to open a context
BlitzMax Forums/BlitzMax Programming/Detecting failure to open a context
| ||
In my lowly iBook, it has support for an OpenGL window as large as you like, even larger than the desktop, but it does not have support for full-screen mode by the hardware. The OpenGL driver is software only and cannot apparently handle proper fullscreen. When trying to open a screen in full-screen mode, it just simply doesn't open and Max complains about invalid pixel format and some other such. Basically it makes an error because it can't do it. That's fine. I want to be able to detect when this error occurs, however, so that if my app tries to open a full-screen display and fails, it will automatically try opening in a window. I would also like to sense when window mode fails so I can try opening fullscreen, on platforms that have fullscreen support. I tried using something like: Try Context=CreateGraphics(640,480,32,60,GRAPHICS_BACKBUFFER) Catch err:Object Context=CreateGraphics(640,480,0,60,GRAPHICS_BACKBUFFER) EndTry But this does not actually catch the exception. The context fails to open and the app exits with the usual error message. How can I detect this failure to open a context, and still remain in the running app so I can try a different angle? |
| ||
I expect you've already tried it like this...SetGraphicsDriver GLMax2DDriver() Local Context:TGraphics Context = CreateGraphics(640,480,32,60,GRAPHICS_BACKBUFFER) If Not context Context = CreateGraphics(640,480,0,60,GRAPHICS_BACKBUFFER) If Not Context RuntimeError "Unable to open a graphics context" EndIf EndIf It works here if I set the screen size to say 1640,480 or something. |
| ||
It doesn't get that far. If you try to create any full-screen context it generates an error. You don't get to say "If Not Context". An exception has to be handled. |
| ||
Bump ..... Anyone got a suggestion how I can work around the exception that's created? |