• Advertisement
Sign in to follow this  

Strange behavior with SDL/OpenGL

This topic is 4406 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

Hi, I'm experiencing a weird problem when I try to use SDL and OpenGL (with Dev-C++) to write a simple test app. The code itself is very brief; I just open a window and draw a rotating triangle. Anyway, the main problem is that when the app is executed, it is displayed without a frame, even though I never told SDL to do such a thing. Could this have something to do with my runtime libraries? However, the code I'm using runs fine on Linux, but apparently Windows gives this unexpected result. Any ideas? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I pass certain video flags to SDL_SetVideoMode() based on the result of calling SDL_GetVideoInfo(), but none of them include SDL_NOFRAME. In essence, I'm passing the following:
SDL_OPENGL, SDL_RESIZABLE, SDL_HWPALETTE, either SDL_HWSURFACE or SDL_SWSURFACE, and SDL_HWACCEL if available.

Also, when I used freeglut instead of SDL to try to reproduce this situation, freeglut functioned how I expected, so I'm guessing we can isolate this issue to SDL.

Here is the code in question:
// set video flags based on info returned by sdl
int flags;
const SDL_VideoInfo *info=SDL_GetVideoInfo();
if (!info) {
// this shouldn't happen :s
printf("Unable to get video information!\n");
exit(0);
}

// default stuff
flags |= SDL_OPENGL;
flags |= SDL_RESIZABLE;
flags |= SDL_HWPALETTE;

// now we set flags based on what is available
if (info->blit_hw)
flags |= SDL_HWACCEL;

if (info->hw_available)
flags |= SDL_HWSURFACE;
else
flags |= SDL_SWSURFACE;

// set double buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

// try to set the video mode
screen=SDL_SetVideoMode(640, 480, 32, flags);
if (!screen) {
printf("Unable to set 640x480 video mode!\nReason: %s\n", SDL_GetError());
exit(0);
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement