Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fingers_

OpenGL SDL OpenGL woes

This topic is 5445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have an interesting little problem with SDL and OpenGL under WinXP. When I switch from fullscreen to windowed mode, I''m unable to re-initialize OpenGL. Also, after I''ve used the fullscreen mode I can''t start the program in a windowed mode until I reboot. This seems to prevent me from running various SDL/GL example programs as well. The exact error I get from SDL is "unable to make GL context current". This only happens when switching from fullscreen to windowed mode, but not the other way around, which makes me think that my switching method (basically shutdown app, restart with fullscreen bit flipped) is probably not in error. I googled a bit and found a few old messageboard posts of people having a similar problem, but couldn''t find a workaround. It appears that in fullscreen mode SDL doesn''t properly destroy the OpenGL context when it shuts down. Has anybody else had this problem, and is there a known solution?

Share this post


Link to post
Share on other sites
Advertisement
from the SDL sdk help:


SDL_WM_ToggleFullScreen
Name
SDL_WM_ToggleFullScreen -- Toggles fullscreen mode
Synopsis

#include "SDL.h"
int SDL_WM_ToggleFullScreen(SDL_Surface *surface);


Description
Toggles the application between windowed and fullscreen mode, if supported. (X11 is the only target currently supported, BeOS support is experimental).

Return Value
Returns 0 on failure or 1 on success.


check the description part. Is this what you were looking for?

Because I was gonna implement a toggle-fullscreen thing into my little game made with SDL and OGL, but when I read that description I never bothered trying. Are you using that method or something else?

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
I am afraid it is not that simple, if you use OpenGl, rather than a normal SDL surface.
I have the same problem in my game.
That''s what I do:
Kill SDL, destroy the OpenGL context, then restart SDL, and create another OpenGl context.
On my Win 98 SE this works, but sometimes the system crashes, etc. On other OSes (Linux, XP) people don''t have this problem.


Height Map Editor | Eternal Lands | Fast User Directory

Share this post


Link to post
Share on other sites
Raduprv: Isn''t SDL supposed to create/destroy the OpenGL context for you when you init/deinitialize the video subsystem? I couldn''t even find a way to destroy the context manually when deinitializing SDL. How are you doing it?

I''m not even hoping to toggle window/fullscreen while running, but it ought to be possible to (a) run the app in fullscreen (b) quit, and (c) run the app in a window. But for some reason it isn''t working.

I can run it either fullscreen or in a window as many times as I want, but if I try to run in a window right after running fullscreen I get the error. But I can still run it fullscreen.. It''s quite bizarre. Telling the user to reboot to switch screen modes in a game would be awkward to say the least

Share this post


Link to post
Share on other sites
Hi!

Wow that seems like a hassle don''t it? Glad I didn''t even try! *hehe*

I made it possible to run in a) fullscreen or b) windowed. My method was to always run in windowed mode unless it''s told to run in fullscreen. How did I do that? With a commandline. "main.exe -fullscreen". I parse for commands in the main file and send in the commands to my engine. If I find the -fullscreen command I have a little if( fullscreen ) videoFlags |= SDL_FULLSCREEN;

Works kinda nice. Don''t understand why yours doesn''t work :/

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
all my resources do have an aquire and a release function. as long as you don''t aquire a texture, it does not load its data into opengl.. once you call release, it deletes itself..


now, the whole fullscreen/windowed switch is just

foreachobject { object->release() }
SDL_QuitSubSystem(SDL_INIT_VIDEO)
// set up opengl format
SDL_InitSubSystem(SDL_INIT_VIDEO)
toggleFullScreen(flags)
SDL_SetVideoMode(......,flags)
foreachobject { object->aquire() }

this all nice wrapped in my class..


not much of a hassle actually, if all your objects are derived from that "manageable" class, and support proper aquire/release functions.

note that i got, depending on system and drivers, some hard blue screen crashes when switching too often

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
I''m pretty sure I''m destroying all the textures before I shut down the video. I have an "asset manager" that does it automagically on deinit...

I''ll have to try your game to see if the same problem occurs (e.g. if it''s a driver problem).

Share this post


Link to post
Share on other sites
Seems like it was indeed a driver problem... I got the latest catalyst drivers for my card and now it works fine. Thanks for all the suggestions though

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!