comparison mde/gl/draw.d @ 75:25cb7420dc91

A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken. imde's classes are created in a static this instead of mde's main. gl setup code moved from gl/basic.d to gl/draw.d mergetag.DefaultData: now HIGH_LOW priority instead of LOW_HIGH. Reduced type list to only used types; small fix for indent function. setup.paths: new NoFileException thrown instead of MTFileIOException
author Diggory Hardy <diggory.hardy@gmail.com>
date Mon, 28 Jul 2008 18:17:48 +0100
parents 108d123238c0
children
comparison
equal deleted inserted replaced
74:cee261eba249 75:25cb7420dc91
11 See the GNU General Public License for more details. 11 See the GNU General Public License for more details.
12 12
13 You should have received a copy of the GNU General Public License 13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 15
16 /** The OpenGL draw loop. 16 /** The OpenGL draw loop and some basic OpenGL code to set up a projection.
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.draw; 19 module mde.gl.draw;
20 20
21 import mde.gui.Gui; 21 import mde.gui.WidgetManager;
22 import mde.imde;
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 import tango.time.Time; // TimeSpan (type only; unused) 27 import tango.time.Time; // TimeSpan (type only; unused)
29 import mde.font.font; 30 import mde.font.font;
30 private Logger logger; 31 private Logger logger;
31 static this () { 32 static this () {
32 logger = Log.getLogger ("mde.gl.draw"); 33 logger = Log.getLogger ("mde.gl.draw");
33 } 34 }
35
36 //BEGIN GL & window setup
37 void glSetup () {
38 glDisable(GL_LIGHTING);
39 glDisable(GL_DEPTH_TEST);
40 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
41 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
42 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
43 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
44 glEnable(GL_TEXTURE_2D);
45 glShadeModel(GL_SMOOTH);
46
47 glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
48
49 glMatrixMode(GL_MODELVIEW);
50 glLoadIdentity();
51
52 // Used for font rendering:
53 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
54 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
55 //NOTE: wrap mode may have an effect, but shouldn't be noticed...
56 }
57
58 void setProjection (int w, int h) {
59 glMatrixMode (GL_PROJECTION);
60 glLoadIdentity ();
61
62 glViewport (0,0,w,h);
63
64 // Make the top-left the origin (see gui/GUI notes.txt):
65 // Note that this only affects vertex operations − direct rasterisation operations are
66 // unaffected!
67 glOrtho (0.0,w, h,0.0, -1.0, 1.0);
68
69 glMatrixMode(GL_MODELVIEW);
70
71 // The gui is tied to this viewport.
72 gui.setSize (w,h);
73 }
74 //END GL & window setup
34 75
35 //BEGIN Drawing loop 76 //BEGIN Drawing loop
36 // Temporary draw function 77 // Temporary draw function
37 void draw (TimeSpan) { 78 void draw (TimeSpan) {
38 glClear(GL_COLOR_BUFFER_BIT); 79 glClear(GL_COLOR_BUFFER_BIT);