From 6dddceb5330c22a03fd14a4401053e563982278c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 27 Oct 2013 15:08:21 -0400 Subject: [PATCH] create SDL window and GL context --- source/app.d | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/source/app.d b/source/app.d index c3eec7f..f5a19a0 100644 --- a/source/app.d +++ b/source/app.d @@ -1,6 +1,40 @@ import std.stdio; +import derelict.sdl2.sdl; +import derelict.opengl3.gl3; -void main() +int main() { - writeln("Edit source/app.d to start your project."); + DerelictSDL2.load(); + + DerelictGL3.load(); + + if (SDL_Init(SDL_INIT_EVERYTHING)) + { + writeln("Failed to initialize SDL!"); + return 1; + } + + SDL_Window * window = SDL_CreateWindow("d-dub-derelict-sdl2-gl3-demo", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 800, + 600, + SDL_WINDOW_OPENGL); + SDL_GLContext context = SDL_GL_CreateContext(window); + + if (window == null) + { + writeln("Failed to create SDL window!"); + return 1; + } + + DerelictGL3.reload(); + + SDL_Delay(2000); + + SDL_DestroyWindow(window); + + SDL_Quit(); + + return 0; }