title: Rendering from SDL and OpenGL at the Same Time
body: <p>Hey all, I'm very new to OpenGL (just started seriously programming with it today) and I'm trying to use it to give my SDL games a 3D boost. I've setup a small test program below:</p>
  
  <pre><code>#include &lt;SDL/SDL.h&gt;
  #include &lt;gl/gl.h&gt;
  
  int main(int argc, char *argv[])
  {
     SDL_Event event;
     float theta = 0.0f;
  
     SDL_Init(SDL_INIT_VIDEO);
     SDL_Surface *screen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE | SDL_FULLSCREEN);
  
     glViewport(0, 0, 800, 600);
     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
     glClearDepth(1.0);
     glDepthFunc(GL_LESS);
     glEnable(GL_DEPTH_TEST);
     glShadeModel(GL_SMOOTH);
     glMatrixMode(GL_PROJECTION);
     glMatrixMode(GL_MODELVIEW);
  
     int done;
  
     for(done = 0; !done;)
     {
  
        SDL_FillRect(screen, 0, SDL_MapRGB(screen-&gt;format, 255, 0, 0));
  
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
        glLoadIdentity();
        glTranslatef(0.0f,0.0f,0.0f);
        glRotatef(theta, 0.0f, 0.0f, 1.0f);
        glBegin(GL_TRIANGLES);
        glColor3f(0.83f, 0.83f, 0.0f);
        glVertex2f(0.0f, 1.0f);
        glColor3f(0.83f, 0.83f, 0.0f);
        glVertex2f(0.87f, -0.5f);
        glColor3f(0.83f, 0.83f, 0.0f);
        glVertex2f(-0.87f, -0.5f);
        glEnd();
  
        theta += 10.0f;
        SDL_Flip(screen);
        SDL_GL_SwapBuffers();
        SDL_PollEvent(&amp;event);
        if(event.key.keysym.sym == SDLK_ESCAPE)
           done = 1;
     }
  }
  </code></pre>
  
  <p>My problem is that the red background I'm trying to rendered is never rendered, only the OpenGL Triangle is rendered.</p>
  
  <p>Thanks in advance to anyone who can help me. It's much appreciated.</p>