| |
---|
| | #ifndef UNIX |
---|
| | #include <windows.h> // Only required under Windows :-D |
---|
| | #endif |
---|
| | |
---|
| | #ifndef UNIX |
---|
| | #include <SDL.h> // This file import the SDL inteface |
---|
| | //#include <SDL/SDL.h> // This file import the SDL inteface |
---|
| | #else |
---|
| | #include <SDL/SDL.h> // This file import the SDL inteface |
---|
| | #endif |
---|
| | |
---|
| | #include <GL/gl.h> // This file import the OpenGL interface |
---|
| | #include <GL/glu.h> // This file offers some OpenGL-related utilities |
---|
| | |
---|
| | #include <stdio.h> |
---|
| |
---|
| | #include <fstream> |
---|
| | |
---|
| | #include <math.h> |
---|
| | |
---|
| | //#ifndef UNIX |
---|
| | #ifndef UNIX |
---|
| | ///////////// |
---|
| | // #PRAGMA // |
---|
| | ///////////// |
---|
| | // Visual Studio specific: you can import libraries directly by |
---|
| | // specifing them through a #pragma. On other compilters/platforms add |
---|
| | // the required .lib to the makefile or project proprieties |
---|
| | //#pragma comment(lib, "opengl32.lib") |
---|
| | //#pragma comment(lib, "glu32.lib") |
---|
| | //#pragma comment(lib, "sdl.lib") |
---|
| | //#pragma comment(lib, "sdlmain.lib") |
---|
| | //#endif |
---|
| | #pragma comment(lib, "opengl32.lib") |
---|
| | #pragma comment(lib, "glu32.lib") |
---|
| | #pragma comment(lib, "sdl.lib") |
---|
| | #pragma comment(lib, "sdlmain.lib") |
---|
| | #endif |
---|
| | |
---|
| | #include "vec.h" |
---|
| | #include "color.h" |
---|
| | #include "poly.h" |
---|
| |
---|
| | int debugct = 0; |
---|
| | |
---|
| | #define DD() do { printf("DD:%d\n", debugct); debugct++;} while(0); |
---|
| | |
---|
| | #ifndef UNIX |
---|
| | #define mysleep(x) do {Sleep(x/100);} while (0); |
---|
| | #else |
---|
| | #define mysleep(x) do {usleep(x);} while (0); |
---|
| | #endif |
---|
| | /////////////////////////////////////////////////////////////////////////// |
---|
| | // GLOBAL VARS |
---|
| | |
---|
| | int MouseX, MouseY, OldMouseX, OldMouseY; |
---|
| |
---|
| | // Draw a rotating triangle: |
---|
| | glRotatef(deltay, 0.0f, 1.0f, 0.0f); // Rotation around the Y axis |
---|
| | glRotatef(deltaz, 1.0f, 0.0f, 0.0f); |
---|
| | |
---|
| | //cube->draw(); |
---|
| | //cube->rotate(Vec(0.0f, 0.01f, 0.01f)); |
---|
| | |
---|
| | |
---|
| | myModel->draw(); |
---|
| | cube->draw(); |
---|
| | cube->rotate(Vec(0.0f, 0.01f, 0.01f)); |
---|
| | |
---|
| | |
---|
| | //myModel->draw(); |
---|
| | |
---|
| | light0.draw(); |
---|
| | light0.trace(); |
---|
| | |
---|
| |
---|
| | |
---|
| | |
---|
| | //////////////// |
---|
| | // Swap buffers: |
---|
| | //TODO: usleep(2000); // Just don't kill computer resources ;) |
---|
| | mysleep(2000); // Just don't kill computer resources ;) |
---|
| | SDL_GL_SwapBuffers(); |
---|
| | |
---|
| | // Plain stupid log, just to show values: |
---|
| | //printf("X: %d, Y: %d, but1: %d, but2: %d\n", |
---|
| |
---|
| | if (deltacolor > 1.0f) { |
---|
| | deltacolor = 0.0f; |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |
---|
| | //////////////// |
---|
| | // Swap buffers: |
---|
| | //TODO usleep(2000); // Just don't kill computer resources ;) |
---|
| | SDL_GL_SwapBuffers(); |
---|
| | |
---|
| | // Plain stupid log, just to show values: |
---|
| | //printf("X: %d, Y: %d, but1: %d, but2: %d\n", |
---|
| | // MouseX, MouseY, MouseButtonLeft, MouseButtonRight); |
---|
| | } |
---|
| | |
---|
| | // Ok, release everything and byebye: |
---|
| | SDL_Quit(); |
---|
| | |