Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/importer/framework.cc @ 2846

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

orxonox/trunk/importer: bug-fix. closed file at the wrong position

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