Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/importer: now it works on Windows too. The Problem was, that malloc wrote into the wrong memory holes. thats why I rewrote the whole code.
This Problem may araise again, if multiple Models are imported in Windows, because the malloc function is still active.

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