-
-
Save UplinkCoder/51696104aa4c3e9e81571acd94ef35f6 to your computer and use it in GitHub Desktop.
Load sdl and gl into cling
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 characters
| #include "cling/Interpreter/Interpreter.h" | |
| #include "SDL2/SDL.h" | |
| #include "GL/gl.h" | |
| SDL_GLContext ctx; | |
| SDL_Window* win; | |
| bool loadSDL(); | |
| bool loadGL(); | |
| bool sdlLoaded = false; | |
| bool glLoaded = false; | |
| void p() | |
| { | |
| sdlLoaded = loadSDL(); | |
| if (sdlLoaded) | |
| { | |
| gCling->execute("SDL_Init(SDL_INIT_VIDEO);"); | |
| } | |
| glLoaded = loadGL(); | |
| if (glLoaded && sdlLoaded) | |
| { | |
| gCling->execute("win = SDL_CreateWindow(\"Hello Cling\", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 786, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);"); | |
| gCling->execute("ctx = SDL_GL_CreateContext(win)"); | |
| } | |
| } | |
| void swap() | |
| { | |
| gCling->execute("glEnd(); SDL_GL_SwapWindow(win);"); | |
| } | |
| bool loadSDL() | |
| { | |
| return (gCling->loadLibrary("SDL2") == | |
| cling::Interpreter::CompilationResult::kSuccess | |
| ); | |
| } | |
| bool loadGL() | |
| { | |
| return (gCling->loadLibrary("GL") == | |
| cling::Interpreter::CompilationResult::kSuccess | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment