61 lines
1.2 KiB
D
61 lines
1.2 KiB
D
import std.stdio;
|
|
import derelict.sdl.sdl;
|
|
import derelict.opengl.gl;
|
|
import derelict.opengl.glu;
|
|
|
|
enum int WIDTH = 800;
|
|
enum int HEIGHT = 600;
|
|
|
|
void init()
|
|
{
|
|
glClearColor (0.0, 0.0, 0.0, 0.0);
|
|
glShadeModel(GL_SMOOTH);
|
|
glViewport(0, 0, WIDTH, HEIGHT);
|
|
glMatrixMode(GL_PROJECTION);
|
|
glLoadIdentity();
|
|
gluPerspective(60.0, cast(GLfloat)WIDTH/cast(GLfloat)WIDTH, 1.0, 30.0);
|
|
glMatrixMode(GL_MODELVIEW);
|
|
glLoadIdentity();
|
|
glTranslatef(0.0, 0.0, -10.0);
|
|
}
|
|
|
|
int main(char[][] args)
|
|
{
|
|
DerelictSDL.load();
|
|
DerelictGL.load();
|
|
DerelictGLU.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;
|
|
}
|
|
|
|
init();
|
|
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;
|
|
}
|