Last active
October 4, 2019 18:16
-
-
Save bryphe/602069d32b5ec35728484e249c43ca7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SDL2/SDL.h> | |
#define GL_GLEXT_PROTOTYPES 1 | |
#include <SDL2/SDL_opengles2.h> | |
int main(int argc, char** argv) | |
{ | |
SDL_Init(SDL_INIT_VIDEO); | |
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); | |
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); | |
SDL_GL_SetSwapInterval(0); | |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); | |
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); | |
SDL_Window *wnd = SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, | |
640, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); | |
SDL_GLContext glc = SDL_GL_CreateContext(wnd); | |
int running = 1; | |
while (running) { | |
SDL_Event e; | |
while(SDL_PollEvent(&e)) | |
{ | |
if(e.type == SDL_QUIT) running = 0; | |
} | |
// Clear the screen to blue | |
glClearColor(1.0f, 0.0f, 0.0f, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT); | |
SDL_GL_SwapWindow(wnd); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment