All pastes #408065 Raw Edit

Unnamed

public cpp v1 · immutable
#408065 ·published 2007-03-24 15:36 UTC
rendered paste body
int main(int argc, char *argv[]) {  //Initialize the SDL Window  window.Init(800, 600, 32, "This is a test");   //enables double buffering using SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);  window.SetDoubleBuffered(true);    //gets size of the window    int width, height;    window.GetSize(&width, &height);    //Set the OpenGL viewport    glViewport(0, 0, width, height);    //Clear the screen    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);    glMatrixMode(GL_PROJECTION);    glLoadIdentity();    gluPerspective(60.0f, (GLfloat)width / (GLfloat)height, 1.0f, 50.0f);    glMatrixMode(GL_MODELVIEW);    //Enable depth testing    glEnable(GL_DEPTH_TEST);    glDepthFunc(GL_LEQUAL);    glDepthMask(GL_TRUE);  //test loop  bool running = true;  while (running) {    //Poll events    SDL_Event event;    while (SDL_PollEvent(&event)) {      switch (event.type) {        case SDL_QUIT:          running = false;          break;        case SDL_KEYDOWN:          if (event.key.keysym.sym == SDLK_ESCAPE) running = false;          break;      }    } // End of event polling    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glLoadIdentity();    gluLookAt(0.0f, 0.0f, 0.0f,              0.0f, 0.0f, -5.0f,              0.0f, 1.0f, 0.0f);    //draw a quad    glPushMatrix();      glTranslatef(0.0f, 0.0f, -5.0f);      glBegin(GL_QUADS);        glColor3f(1.0f, 0.25f, 0.25f);        glVertex3f(-1.0f, -1.0f, 0.0f);        glVertex3f(1.0f, -1.0f, 0.0f);        glVertex3f(1.0f, 1.0f, 0.0f);        glVertex3f(-1.0f, 1.0f, 0.0f);      glEnd();    glPopMatrix();    //swap backbuffer to screen buffer    SDL_GL_SwapBuffers();  }  exit(0);   return 0;}