Changeset 262

Show
Ignore:
Timestamp:
05/17/07 06:31:49 (1 year ago)
Author:
aldacron
Message:

[DerelictGL]
* added an alias DerelictGLContext for platform-specific context handles
* added a method to the DerelictGL object -- getCurrentContext. This is a convenience wrapper for the platform-specific functions.
[DerelictUtil?]
* in loader.d, changed the message for the exception thrown when an internal load function is null

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/DerelictGL/derelict/opengl/gl.d

    r261 r262  
    5454        import derelict.opengl.wgl; 
    5555        import derelict.util.wintypes; 
     56        alias HGLRC DerelictGLContext; 
    5657    } 
    5758    else version(linux) 
     
    6566 
    6667    version(UsingGLX) 
     68    { 
    6769        import derelict.opengl.glx; 
     70        alias GLXContext DerelictGLContext; 
     71    } 
    6872} 
    6973 
     
    114118            HDC hdc = wglGetCurrentDC(); 
    115119            if(hdc is null) 
    116                 throw new Exception("Could not obtain a device context for the current OpenGL context"); 
     120                throw new DerelictException("Could not obtain a device context for the current OpenGL context"); 
    117121 
    118122            if(0  == currentPixelFormat) 
     
    124128            int newFormat = GetPixelFormat(hdc); 
    125129            if(0 == newFormat) 
    126                 throw new Exception("Could not determine current pixel format"); 
     130                throw new DerelictException("Could not determine current pixel format"); 
    127131 
    128132            bool ret = true; 
     
    171175                return false; 
    172176        } 
     177        else throw new DerelictException("DerelictGL.hasValidContext is unimplemented for this platform"); 
     178         
    173179        return true; 
    174180    } 
     181     
     182    static DerelictGLContext getCurrentContext() 
     183    { 
     184        version(Windows) return wglGetCurrentContext(); 
     185        else version(UsingGLX) return glXGetCurrentContext(); 
     186        else throw new DerelictException("DerelictGL.getCurrentContext is Unimplemented for this platform"); 
     187    } 
    175188 
    176189    static void loadVersions(GLVersion minVersion) 
     
    179192        { 
    180193            if(!hasValidContext) 
    181                 throw new Exception("You must create an OpenGL context before attempting to load OpenGL versions later than 1.1"); 
     194                throw new DerelictException("You must create an OpenGL context before attempting to load OpenGL versions later than 1.1"); 
    182195        } 
    183196 
     
    237250    { 
    238251        if(!hasValidContext) 
    239                 throw new Exception("You must create an OpenGL context before attempting to load OpenGL extensions"); 
     252                throw new DerelictException("You must create an OpenGL context before attempting to load OpenGL extensions"); 
    240253 
    241254        if(extensionsOnce) 
     
    293306    { 
    294307        if(!hasValidContext) 
    295             throw new Exception("You must create an OpenGL context before attempting to check the OpenGL version"); 
     308            throw new DerelictException("You must create an OpenGL context before attempting to check the OpenGL version"); 
    296309 
    297310        char[] str = toDString(glGetString(GL_VERSION)); 
  • trunk/DerelictUtil/derelict/util/loader.d

    r261 r262  
    385385        if(userLoad is null) 
    386386        { 
    387             throw new DerelictException("The internal load function has not been configured. You are most likely calling a Derelict load method from a module constructor, or a static class constructor. Don't."); 
     387            // this should never, ever, happen 
     388            throw new DerelictException("Something is horribly wrong -- internal load function not configured"); 
    388389        } 
    389390        userLoad(myLib);