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