view 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
line wrap: on
line source

/* LICENSE BLOCK
Part of mde: a Modular D game-oriented Engine
Copyright © 2007-2008 Diggory Hardy

This program is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, either
version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. */

/** Some basic OpenGL code.
*
* Everything here is really intended as makeshift code to enable GUI development. */
module mde.gl;

import global = mde.global;
import mde.gui.gui;

import derelict.sdl.sdl;
import derelict.opengl.gl;

import tango.time.Time;     // TimeSpan (type only; unused)

//BEGIN GL & window setup
void glSetup () {
    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
}

void setProjection (int w, int h) {
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    
    glViewport (0,0,w,h);
    glOrtho (0.0,w, 0.0,h, -1.0, 1.0);
    //glOrtho (0.0,1.0,0.0,1.0,-1.0,1.0);
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
//END GL & window setup

//BEGIN Drawing utils
// Simple drawing commands for use by GUI
// (temporary)
void setColor (float r, float g, float b) {
    glColor3f (r, g, b);
}
void drawBox (int l, int r, int b, int t) {
    glBegin (GL_QUADS);
    {
        glVertex2i (l, b);
        glVertex2i (r, b);
        glVertex2i (r, t);
        glVertex2i (l, t);
    }
    glEnd();
}
//END Drawing utils

//BEGIN Drawing loop
// Temporary draw function
void draw (TimeSpan) {
    glClear(GL_COLOR_BUFFER_BIT);
    
    gui.draw ();
    
    glFlush();
    SDL_GL_SwapBuffers();
}
//END Drawing loop