Mercurial > projects > mde
comparison mde/gl.d @ 30:467c74d4804d
Major changes to the scheduler, previously only used by the main loop.
Revamped Scheduler. Functions can be removed, have multiple schedules, have their scheduling changed, etc.
Scheduler has a unittest. Checked all pass.
Main loop scheduler moved to mde. Draw-on-demand currently disabled, simplifying this.
Made mtunitest.d remove the temporary file it uses afterwards.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 28 Apr 2008 10:59:47 +0100 |
parents | 0aa621b3e070 |
children |
comparison
equal
deleted
inserted
replaced
29:f985c28c0ec9 | 30:467c74d4804d |
---|---|
16 /** Some basic OpenGL code. | 16 /** Some basic OpenGL code. |
17 * | 17 * |
18 * Everything here is really intended as makeshift code to enable GUI development. */ | 18 * Everything here is really intended as makeshift code to enable GUI development. */ |
19 module mde.gl; | 19 module mde.gl; |
20 | 20 |
21 import mde.scheduler.runTime; | 21 import global = mde.global; |
22 import mde.gui.gui; | |
22 | 23 |
23 import derelict.sdl.sdl; | 24 import derelict.sdl.sdl; |
24 import derelict.opengl.gl; | 25 import derelict.opengl.gl; |
25 | 26 |
26 static this () { | 27 import tango.time.Time; // TimeSpan (type only; unused) |
27 Scheduler.perRequest (RF_KEYS.DRAW, &mde.gl.draw); | |
28 } | |
29 | 28 |
30 //BEGIN GL & window setup | 29 //BEGIN GL & window setup |
31 void glSetup () { | 30 void glSetup () { |
32 glClearColor (0.0f, 0.0f, 0.0f, 0.0f); | 31 glClearColor (0.0f, 0.0f, 0.0f, 0.0f); |
33 } | 32 } |
63 } | 62 } |
64 //END Drawing utils | 63 //END Drawing utils |
65 | 64 |
66 //BEGIN Drawing loop | 65 //BEGIN Drawing loop |
67 // Temporary draw function | 66 // Temporary draw function |
68 void draw () { | 67 void draw (TimeSpan) { |
69 glClear(GL_COLOR_BUFFER_BIT); | 68 glClear(GL_COLOR_BUFFER_BIT); |
70 | 69 |
71 foreach (func; drawCallbacks) | 70 gui.draw (); |
72 func(); | |
73 | 71 |
74 glFlush(); | 72 glFlush(); |
75 SDL_GL_SwapBuffers(); | 73 SDL_GL_SwapBuffers(); |
76 } | 74 } |
77 | |
78 alias void delegate() DrawingFunc; | |
79 void addDrawCallback (DrawingFunc f) { | |
80 drawCallbacks ~= f; | |
81 } | |
82 private DrawingFunc[] drawCallbacks; | |
83 //END Drawing loop | 75 //END Drawing loop |