Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 29 Jul 2012
Offline Last Active Aug 03 2012 05:01 AM

#4964393 OpenGL + SDL

Posted by on 29 July 2012 - 11:50 PM

Sorry to just randomly jump in here but I was looking through gamedev and just decided to create an account because I saw this question. I am new to SDL and openGL but I thought maybe I could help with a bit of code from one of my projects. This may be helpful or may not, but it does seem to answer the question of how to get SDL_SWSURFACE and SDL_OPENGL on at the same time.

[source lang="cpp"] int videoFlags; const SDL_VideoInfo* videoInfo; SDL_Init( SDL_INIT_EVERYTHING ); videoInfo = SDL_GetVideoInfo(); if(!videoInfo) return false; videoFlags = SDL_OPENGL; videoFlags |= SDL_GL_DOUBLEBUFFER; videoFlags |= SDL_HWPALETTE; videoFlags |= SDL_RESIZABLE; if( videoInfo->hw_available ) videoFlags |= SDL_HWSURFACE; else videoFlags |= SDL_SWSURFACE; if( videoInfo->blit_hw ) videoFlags |= SDL_HWACCEL; SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); screen = SDL_SetVideoMode( screenW,screenH,screenBPP,videoFlags );[/source]