Mercurial > projects > mde
comparison mde/gl.d @ 23:47478557428d
Implemented drawing a very basic gl box, and only drawing when necessary.
Improvements to window resizing, and gl draws a box as a test.
Scheduler has "on request" support to redraws only when requested by an event.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 27 Mar 2008 10:58:57 +0000 |
parents | 838577503598 |
children | 2c28ee04a4ed |
comparison
equal
deleted
inserted
replaced
22:249eb6620685 | 23:47478557428d |
---|---|
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ | 14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ |
15 | 15 |
16 /** Simple OpenGL functions. */ | 16 /** Simple OpenGL functions. */ |
17 module mde.gl; | 17 module mde.gl; |
18 | 18 |
19 import mde.scheduler.runTime; | |
20 | |
21 import derelict.sdl.sdl; | |
19 import derelict.opengl.gl; | 22 import derelict.opengl.gl; |
20 | 23 |
21 static this() { | 24 static this() { |
25 Scheduler.perRequest (RF_KEYS.DRAW, &draw); | |
22 } | 26 } |
27 | |
28 void glSetup () { | |
29 glClearColor (0.0f, 0.0f, 0.0f, 0.0f); | |
30 } | |
31 | |
32 void setProjection (int w, int h) { | |
33 glMatrixMode (GL_PROJECTION); | |
34 glLoadIdentity (); | |
35 | |
36 glViewport (0,0,w,h); | |
37 //glOrtho (0.0,w, 0.0,h, -1.0, 1.0); | |
38 glOrtho (0.0,1.0,0.0,1.0,-1.0,1.0); | |
39 | |
40 glMatrixMode(GL_MODELVIEW); | |
41 glLoadIdentity(); | |
42 } | |
43 | |
44 // Temporary draw function | |
45 void draw () { | |
46 glClear(GL_COLOR_BUFFER_BIT); | |
47 | |
48 glBegin (GL_QUADS); | |
49 { | |
50 glColor3f (0.2f, 0.6f, 0.8f); | |
51 /+glVertex2i (40, 40); | |
52 glVertex2i (200, 40); | |
53 glVertex2i (200, 200); | |
54 glVertex2i (40, 200);+/ | |
55 glVertex2f (0.1f, 0.1f); | |
56 glVertex2f (0.9f, 0.1f); | |
57 glVertex2f (0.9f, 0.9f); | |
58 glVertex2f (0.1f, 0.9f); | |
59 } | |
60 glEnd(); | |
61 | |
62 glFlush(); | |
63 SDL_GL_SwapBuffers(); | |
64 } |