sdl-opengl-bare-d/sdl_opengl_bare.d
2013-02-02 21:31:37 -05:00

43 lines
801 B
D

import std.stdio;
import derelict.sdl.sdl;
enum int WIDTH = 800;
enum int HEIGHT = 600;
int main(char[][] args)
{
DerelictSDL.load();
if (SDL_Init(SDL_INIT_EVERYTHING))
{
writefln("Failed to initialize SDL!");
return 1;
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Surface *screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);
if (screen == null)
{
printf("Failed to set video mode!\n");
SDL_Quit();
return 2;
}
SDL_Event event;
while (SDL_WaitEvent(&event))
{
if (event.type == SDL_QUIT)
break;
else if (event.type == SDL_KEYDOWN)
{
if (event.key.keysym.sym == SDLK_ESCAPE)
break;
}
}
SDL_Quit();
return 0;
}