Show
Ignore:
Timestamp:
01/25/07 20:13:21 (2 years ago)
Author:
baxissimo
Message:

Took out Derelict libs from sdl build file. Discovered why it was that I had needed them in the first place.

Added more error checking to glddraw.d

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/luigi/gldraw.d

    r33 r41  
    3232import luigi.base; 
    3333import std.math : PI,sin,cos; 
     34 
     35class GLException : Exception 
     36{ 
     37    this(char[] msg) { super(msg); } 
     38} 
     39 
    3440 
    3541void translate(float x, float y) 
     
    365371} 
    366372 
    367 void checkGLErrors(char[] file = null, int line = 0
     373char[] getGLErrors(char[] file = null, int line = -1
    368374{ 
    369375    GLenum err; 
     376    char[] errstr = null; 
     377    int count = 0; 
    370378    while ( (err=glGetError()) != GL_NO_ERROR)  
    371379    { 
    372         char[] errstr; 
    373         if (file) errstr = std.string.format("OpenGL error: %s(%s): ", file, line); 
     380        if (!errstr) errstr = "OpenGL error: "; 
     381        else errstr ~= std.string.format("\nOpenGL error(%d) : ", ++count); 
     382        if (file) errstr ~= std.string.format("%s(%s): ", file, line); 
     383        else if (line >= 0) errstr ~= std.string.format("(%s): ", line); 
    374384        switch(err) { 
    375385        case GL_INVALID_ENUM: 
     
    416426            errstr ~= std.string.format("Unknown error code: %s", err); 
    417427        } 
    418         writefln(errstr); 
     428    } 
     429    return errstr; 
     430
     431 
     432void checkGLErrors(char[] file = null, int line = -1) 
     433
     434    char[] ret = getGLErrors(file,line); 
     435    if (ret) { 
     436        writefln(ret); 
     437    } 
     438
     439void throwGLErrors(char[] file = null, int line = -1) 
     440
     441    char[] ret = getGLErrors(file,line); 
     442    if (ret) { 
     443        throw new GLException(ret); 
    419444    } 
    420445}