Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/dave/importer/framework.cc @ 3019

Last change on this file since 3019 was 2860, checked in by dave, 20 years ago

orxonox/branches/dave: das level hat jetzt form angenommen, stand:nach der Convention vom Samstag….

File size: 2.6 KB
Line 
1#include "windowHandler.h" // Include the Whandler Basecode
2#include "object.h"
3
4int verbose = 2;
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 
53    obj = new Object();
54 
55  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
56  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
57  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
58  glEnable(GL_LIGHTING);
59  glEnable(GL_LIGHT0);
60  glEnable(GL_DEPTH_TEST);
61
62  // Build the font from a TGA image font.tga in the data directory
63  // Hide the mouse cursor
64  SDL_ShowCursor(0);
65
66  // This is the main loop for the entire program and it will run until done==TRUE
67  while(!done)
68  {
69    // Draw the scene
70    DrawGLScene();
71    // And poll for events
72    SDL_Event event;
73    while ( SDL_PollEvent(&event) ) {
74      switch (event.type) {
75        // If a quit event was recieved
76        case SDL_QUIT:
77          // then we're done and we'll end this program
78          done=TRUE;
79          break;
80        default:
81          break;
82      }
83    }
84
85    // Get the state of the keyboard keys
86    keys = SDL_GetKeyState(NULL);
87
88    // and check if ESCAPE has been pressed. If so then quit
89    if(keys[SDLK_ESCAPE]) done=TRUE;
90  }
91
92  // Kill the GL & SDL screens
93  delete obj;
94  wHandler.KillGLWindow();
95  // And quit
96  return 0;
97}
Note: See TracBrowser for help on using the repository browser.