Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef INIT_SDL_H
- #define INIT_SDL_H
- /* Include windows.h properly on Windows */
- #if defined(WIN32) || defined(_WINDOWS)
- # define WIN32_LEAN_AND_MEAN
- # define NOMINMAX
- # include <windows.h>
- #endif
- /* SDL */
- #include <SDL.h>
- #include <SDL_opengl.h>
- #ifndef INIT_SDL_MAIN
- # undef main
- #endif
- #endif
- #define INIT_SDL_MAIN
- #include "init_sdl.h"
- static const int window_width = 800;
- static const int window_height = 600;
- int main(int argc, char** argv)
- {
- SDL_Window* win;
- SDL_GLContext ctx;
- int result = SDL_Init(SDL_INIT_VIDEO);
- if (result < 0)
- return 1;
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
- 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_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- win = SDL_CreateWindow("Hello SDL",
- SDL_WINDOWPOS_CENTERED,
- SDL_WINDOWPOS_CENTERED,
- window_width, window_height,
- SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
- if (!win)
- return 2;
- ctx = SDL_GL_CreateContext(win);
- SDL_GL_SetSwapInterval(1);
- SDL_Delay(1000);
- SDL_GL_DeleteContext(ctx);
- SDL_DestroyWindow(win);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement