Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.c.time;
- import derelict.opengl3.gl3;
- import derelict.sdl2.sdl;
- void main () {
- DerelictGL3.load();
- DerelictSDL2.load();
- SDL_Window* mainwindow;
- if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- writeln("SDL_Init failed");
- }
- mainwindow = SDL_CreateWindow("SDL OpenGL test",
- SDL_WINDOWPOS_CENTERED,
- SDL_WINDOWPOS_CENTERED,
- 512, 512,
- SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
- if (!mainwindow)
- writeln("Unable to create window");
- SDL_GLContext maincontext;
- maincontext = SDL_GL_CreateContext(mainwindow);
- SDL_GL_SetSwapInterval(1);
- bool quit_triggered = false;
- while (!quit_triggered) {
- glClearColor (0.0, 0.6, 0.8, 1.0);
- glClear (GL_COLOR_BUFFER_BIT);
- SDL_GL_SwapWindow(mainwindow);
- SDL_PumpEvents();
- ubyte *state = SDL_GetKeyboardState(null);
- if (state[SDL_SCANCODE_ESCAPE]) {
- quit_triggered = true;
- }
- }
- SDL_GL_DeleteContext(maincontext);
- SDL_DestroyWindow(mainwindow);
- SDL_Quit();
- return;
- }
Add Comment
Please, Sign In to add comment