Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/importer/importer/framework.cc @ 2748

Last change on this file since 2748 was 2748, checked in by bensch, 20 years ago

orxonox/branches/importer: added a framework for easy testing of openGL stuff

File size: 1.8 KB
Line 
1#include "windowHandler.h" // Include the Whandler Basecode
2#include "object.h"
3
4
5WindowHandler wHandler;  // Create an instance of the whandler basecode class
6Object* obj;
7
8
9void DrawGLScene()
10{
11
12  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
13  glLoadIdentity(); // Reset the view
14 
15  obj->draw();
16
17  SDL_GL_SwapBuffers(); // Swap the buffers
18}
19
20
21int main(int argc, char *argv[])
22{
23  Uint8* keys; // This variable will be used in the keyboard routine
24  int done=FALSE; // We aren't done yet, are we?
25
26  // Create a new OpenGL window with the title "Cone3D Basecode" at
27  // 640x480x32, fullscreen and check for errors along the way
28  if(wHandler.CreateGLWindow("Whandler Basecode", 500, 375, 32, FALSE) == FALSE)
29  {
30    // If an error is found, display a message, kill the GL and SDL screens (if they were created) and exit
31    printf("Could not initalize OpenGL :(\n\n");
32    wHandler.KillGLWindow();
33    return 0;
34  }
35
36
37  obj = new Object ();
38
39  // Build the font from a TGA image font.tga in the data directory
40  // Hide the mouse cursor
41  SDL_ShowCursor(0);
42
43  // This is the main loop for the entire program and it will run until done==TRUE
44  while(!done)
45  {
46    // Draw the scene
47    DrawGLScene();
48    // And poll for events
49    SDL_Event event;
50    while ( SDL_PollEvent(&event) ) {
51      switch (event.type) {
52        // If a quit event was recieved
53        case SDL_QUIT:
54          // then we're done and we'll end this program
55          done=TRUE;
56          break;
57        default:
58          break;
59      }
60    }
61
62    // Get the state of the keyboard keys
63    keys = SDL_GetKeyState(NULL);
64
65    // and check if ESCAPE has been pressed. If so then quit
66    if(keys[SDLK_ESCAPE]) done=TRUE;
67  }
68
69  // Kill the GL & SDL screens
70  wHandler.KillGLWindow();
71  // And quit
72  return 0;
73}
Note: See TracBrowser for help on using the repository browser.