comparison mde/gl/basic.d @ 31:baa87e68d7dc

GUI now supports basic interactible widgets, widget colour and border are more unified, and some code cleanup. Removed some circular dependencies which slipped in. As a result, the OpenGL code got separated into different files. Enabled widgets to recieve events. New IParentWidget interface allowing widgets to interact with their parents. New Widget base class. New WidgetDecoration class. New ButtonWidget class responding to events (in a basic way). committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 29 Apr 2008 18:10:58 +0100
parents
children 6b4116e6355c
comparison
equal deleted inserted replaced
30:467c74d4804d 31:baa87e68d7dc
1 /* LICENSE BLOCK
2 Part of mde: a Modular D game-oriented Engine
3 Copyright © 2007-2008 Diggory Hardy
4
5 This program is free software: you can redistribute it and/or modify it under the terms
6 of the GNU General Public License as published by the Free Software Foundation, either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 See the GNU General Public License for more details.
12
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/>. */
15
16 /** Some basic OpenGL code for setting up a projection and drawing.
17 *
18 * Everything here is really intended as makeshift code to enable GUI development. */
19 module mde.gl.basic;
20
21 import derelict.opengl.gl;
22
23 import tango.time.Time; // TimeSpan (type only; unused)
24
25 //BEGIN GL & window setup
26 void glSetup () {
27 glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
28 }
29
30 void setProjection (int w, int h) {
31 glMatrixMode (GL_PROJECTION);
32 glLoadIdentity ();
33
34 glViewport (0,0,w,h);
35
36 // Make the top-left the origin (see gui/GUI notes.txt):
37 glOrtho (0.0,w, h,0.0, -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 //END GL & window setup
44
45 //BEGIN Drawing utils
46 // Simple drawing commands for use by GUI
47 // (temporary)
48 void setColor (float r, float g, float b) {
49 glColor3f (r, g, b);
50 }
51 void drawBox (int x, int y, int w, int h) {
52 glBegin (GL_QUADS);
53 {
54 glVertex2i (x, y+h);
55 glVertex2i (x+w, y+h);
56 glVertex2i (x+w, y);
57 glVertex2i (x, y);
58 }
59 glEnd();
60 }
61 //END Drawing utils