Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL.h>
- #include <sdl_opengl.h>
- #include <iostream>
- using namespace std;
- const float ScreenHeight = 800;
- const float ScreenWidth = 600;
- bool isFullscreen;
- bool Init()
- {
- const SDL_VideoInfo *VideoInfo = NULL;
- int flags = 0;
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- {
- fprintf(stderr, "SDL initialization failed %s\n", SDL_GetError());
- return false;
- }
- atexit(SDL_Quit);
- VideoInfo = SDL_GetVideoInfo();
- if (VideoInfo == NULL)
- {
- fprintf(stderr, "Attempt to get video info failed %s\n", SDL_GetError());
- return false;
- }
- flags = SDL_OPENGL;
- if (isFullscreen)
- flags |= SDL_FULLSCREEN;
- 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_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_SetVideoMode(ScreenWidth, ScreenHeight,
- VideoInfo->vfmt->BitsPerPixel, flags);
- glViewport(0, 0, ScreenWidth, ScreenHeight);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, ScreenWidth-1.0, 0.0, ScreenHeight-1.0, 10.0, -10.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glClearColor(0.0f, 0.f, 0.0f, 1.0f);
- return true;
- }
- int main()
- {
- Init();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement