Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include <GL/glew.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <wchar.h>
- #include <math.h>
- static int scrWidth = 640;
- static int scrHeight = 480;
- #undef main
- int main(int argc, char** argv){
- SDL_Init(SDL_INIT_VIDEO);
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
- printf("test");
- if (SDL_SetVideoMode(scrWidth, scrHeight, 32, SDL_OPENGL) == 0){
- fprintf(stderr, "couldn't set mode %dx%d!\n", 640, 480);
- SDL_Quit();
- return -1;
- }
- glewInit();
- SDL_ShowCursor(SDL_DISABLE);
- glClearColor(0.2, 0.2, 0.2, 0.2);
- glClearDepth(1.0);
- glEnable(GL_DEPTH_TEST);
- bool running = true;
- while (running){
- SDL_Event event;
- if (SDL_PollEvent(&event)){
- switch(event.type){
- case SDL_QUIT:
- running = false;
- break;
- };
- }
- timer.update();
- Keyboard::update();
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(-scrWidth/2.0f, scrWidth/2.0f, scrHeight/2.0f, -scrHeight/2.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glDisable(GL_DEPTH_TEST);
- glFlush();
- SDL_GL_SwapBuffers();
- }
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment