Last active
January 4, 2019 21:09
-
-
Save ruby0x1/46e4f5b4e3e6de7ad50d to your computer and use it in GitHub Desktop.
Revisions
-
ruby0x1 revised this gist
Mar 27, 2015 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ static SDL_GLContext gl_context; void render() { SDL_GL_MakeCurrent(window, gl_context); r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); glClearColor( r, 0.4f, 0.1f, 1.0f ); @@ -43,16 +43,24 @@ int main(int argc, char *argv[]) { return 1; } window = SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 512, 512, SDL_WINDOW_OPENGL); gl_context = SDL_GL_CreateContext(window); SDL_AddEventWatch(watch, NULL); while(!quitting) { SDL_Event event; while( SDL_PollEvent(&event) ) { if(event.type == SDL_QUIT) { quitting = true; } } render(); SDL_Delay(2); } -
ruby0x1 revised this gist
Mar 25, 2015 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ //SDL2 flashing random color example //Should work on iOS/Android/Mac/Windows/Linux #include <SDL.h> #include <SDL_opengl.h> #include <stdlib.h> //rand() -
ruby0x1 created this gist
Mar 25, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ //SDL2 android OpenGL ES2 flashing random color example #include <SDL.h> #include <SDL_opengles2.h> #include <stdlib.h> //rand() static bool quitting = false; static float r = 0.0f; static SDL_Window *window = NULL; static SDL_GLContext gl_context; void render() { SDL_GL_MakeCurrent(window, gl_context); r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); glClearColor( r, 0.4f, 0.1f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT ); SDL_GL_SwapWindow(window); } //render int SDLCALL watch(void *userdata, SDL_Event* event) { if (event->type == SDL_APP_WILLENTERBACKGROUND) { quitting = true; } return 1; } int main(int argc, char *argv[]) { if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS) != 0) { SDL_Log("Failed to initialize SDL: %s", SDL_GetError()); return 1; } window = SDL_CreateWindow("title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS); gl_context = SDL_GL_CreateContext(window); SDL_AddEventWatch(watch, NULL); while(!quitting) { render(); } SDL_DelEventWatch(watch, NULL); SDL_GL_DeleteContext(gl_context); SDL_DestroyWindow(window); SDL_Quit(); exit(0); } //main