From 34223e94038d6e9bb377975ca685bc53dc40282b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 2 Feb 2013 21:27:56 -0500 Subject: [PATCH] call SDL_SetVideoMode(); working, but crashing on exit --- Makefile | 2 +- sdl_opengl_bare.d | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0684f09..5147691 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TARGET := sdl_opengl_bare -DFLAGS := -I/usr/local/include/d +DFLAGS := -I/usr/local/include/d -g LDFLAGS := -lDerelictSDL -lDerelictUtil -ldl all: $(TARGET) diff --git a/sdl_opengl_bare.d b/sdl_opengl_bare.d index 4c3241d..cc5ae36 100644 --- a/sdl_opengl_bare.d +++ b/sdl_opengl_bare.d @@ -1,6 +1,9 @@ import std.stdio; import derelict.sdl.sdl; +enum int WIDTH = 800; +enum int HEIGHT = 600; + int main(char[][] args) { DerelictSDL.load(); @@ -11,5 +14,15 @@ int main(char[][] args) return 1; } + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + SDL_Surface *screen; + if ((screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL)) == null) + { + printf("Failed to set video mode!\n"); + SDL_Quit(); + return 2; + } + return 0; }