Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/importer: added vectors from src. better caseCheck-in object.cc::addGLElement

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