Changeset 85

Show
Ignore:
Timestamp:
02/17/05 08:37:04 (4 years ago)
Author:
jjr
Message:

FIX: glfw source rearranged while bug hunting. May go back to its
original arrangement if Mike desires it and if original arrangement is
proven correct or if the new arrangement causes more problems.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/DerelictGLFW/derelict/glfw/glfw.d

    r80 r85  
    4343 
    4444private import std.loader; 
     45 
     46private HXModule hglfw; 
     47 
     48private void* getProc(char[] procname) 
     49{ 
     50    void* symbol = ExeModule_GetSymbol(hglfw, procname); 
     51    if (symbol is null) 
     52        throw new Exception("Failed to load glfw proc address " ~ procname); 
     53    return symbol; 
     54} 
     55 
     56private bit exeModuleInited = false; 
     57 
     58public void DerelictGLFW_Load(char[] libName) 
     59{ 
     60    if(hglfw !== null) 
     61        return; 
     62 
     63    // there's no guarantee this will be used in together with DerelictGL, 
     64    // could be used with another OpenGL binding, so initialize std.loader 
     65    // (even though it doesn't do anything). 
     66    if(ExeModule_Init() == -1) 
     67        throw new Exception("ExeModule initialization failed"); 
     68 
     69    exeModuleInited = true; 
     70 
     71    hglfw = ExeModule_Load(libName); 
     72 
     73    if(hglfw is null) 
     74        throw new Exception("Failed to load the GLFW shared library."); 
     75 
     76    load(); 
     77} 
     78 
     79public void DerelictGLFW_Load() 
     80{ 
     81    version(Windows) 
     82        DerelictGLFW_Load("glfw.dll"); 
     83    version(linux) 
     84        DerelictGLFW_Load("libglfw.so"); 
     85} 
     86 
     87static ~this() 
     88{ 
     89    if(exeModuleInited) 
     90    { 
     91        ExeModule_Release(hglfw); 
     92        ExeModule_Uninit(); 
     93    } 
     94} 
     95 
     96version(Windows)  
     97    extern(Windows): 
     98else 
     99    extern(C): 
    45100 
    46101//----------------------------------------------------------- 
     
    199254const float GLFW_INFINITY = 100000.0; 
    200255 
    201 extern(Windows) 
    202 { 
    203     // Intrinsic glfw funtion pointer types 
    204     typedef void function(int, int) GLFWwindowsizefun; 
    205     typedef void function(int, int) GLFWmousebuttonfun; 
    206     typedef void function(int, int) GLFWmouseposfun; 
    207     typedef void function(int)      GLFWmousewheelfun; 
    208     typedef void function(int, int) GLFWkeyfun; 
    209     typedef void function(int, int) GLFWcharfun; 
    210     alias void function(void*)    GLFWthreadfun; 
    211 } 
    212  
    213256struct GLFWvidmode 
    214257{ 
     
    230273 
    231274typedef void* GLFWcond; 
    232  
    233 private HXModule hglfw; 
    234275 
    235276//--------------------------------------------------------------------- 
     
    519560} // end version(default) 
    520561 
    521 private void* getProc(char[] procname) 
    522 
    523     void* symbol = ExeModule_GetSymbol(hglfw, procname); 
    524     if (symbol is null) 
    525         throw new Exception("Failed to load glfw proc address " ~ procname); 
    526     return symbol; 
    527 
    528  
    529 private bit exeModuleInited = false; 
    530  
    531 public void DerelictGLFW_Load(char[] libName) 
    532 
    533     if(hglfw !== null) 
    534         return; 
    535  
    536     // there's no guarantee this will be used in together with DerelictGL, 
    537     // could be used with another OpenGL binding, so initialize std.loader 
    538     // (even though it doesn't do anything). 
    539     if(ExeModule_Init() == -1) 
    540         throw new Exception("ExeModule initialization failed"); 
    541  
    542     exeModuleInited = true; 
    543  
    544     hglfw = ExeModule_Load(libName); 
    545  
    546     if(hglfw is null) 
    547         throw new Exception("Failed to load the GLFW shared library."); 
    548  
    549     load(); 
    550 
    551  
    552 public void DerelictGLFW_Load() 
    553 
    554     version(Windows) 
    555         DerelictGLFW_Load("glfw.dll"); 
    556     version(linux) 
    557         DerelictGLFW_Load("libglfw-2.4.2.so.0"); 
    558 
    559  
    560 static ~this() 
    561 
    562     if(exeModuleInited) 
    563     { 
    564         ExeModule_Release(hglfw); 
    565         ExeModule_Uninit(); 
    566     } 
    567 
    568  
    569 version(Windows) 
    570     extern(Windows): 
    571 else 
    572     extern(C): 
    573  
    574     // GLFW initialization and version query 
     562// GLFW initialization and version query 
    575563    typedef int  function()                         pfglfwInit; 
    576564    typedef void function()                         pfglfwTerminate; 
    577565    typedef void function(int*, int*, int*)         pfglfwGetVersion; 
    578566 
    579     // Window handling 
     567// Window handling 
    580568    typedef int  function(int, int, int, int, int, int, int, int, int) pfglfwOpenWindow; 
    581569    typedef void function(int, int)             pfglfwOpenWindowHint; 
     
    592580    typedef void function( GLFWwindowsizefun )  pfglfwSetWindowSizeCallback; 
    593581 
    594     // Video mode functions 
     582// Video mode functions 
    595583 
    596584    typedef int  function(GLFWvidmode*, int)    pfglfwGetVideoModes; 
     
    612600    typedef void function(GLFWmousewheelfun)    pfglfwSetMouseWheelCallback; 
    613601 
    614     // Joystick input 
     602// Joystick input 
    615603 
    616604    typedef int function(int, int)              pfglfwGetJoystickParam; 
     
    618606    typedef int function(int, char*, int)       pfglfwGetJoystickButtons; 
    619607 
    620     // Time 
     608// Time 
    621609 
    622610    typedef double function()                   pfglfwGetTime; 
     
    624612    typedef void   function(double)             pfglfwSleep; 
    625613 
    626     // Extension support 
     614// Extension support 
    627615 
    628616    typedef int    function(char*)              pfglfwExtensionSupported; 
     
    630618    typedef void   function(int*,int*,int*)     pfglfwGetGLVersion; 
    631619 
    632     // Threading support 
     620// Threading support 
    633621 
    634622    typedef GLFWthread function(GLFWthreadfun, void*) pfglfwCreateThread; 
     
    647635    typedef void       function()                     pfglfwGetNumberOfProcessors; 
    648636 
    649     // Enable/disable functions 
     637// Enable/disable functions 
    650638 
    651639    typedef void       function(int)            pfglfwEnable; 
    652640    typedef void       function(int)            pfglfwDisable; 
    653641 
    654     // Image/texture I/O support 
     642// Image/texture I/O support 
    655643 
    656644    typedef int     function(char*, GLFWimage*, int) pfglfwReadImage; 
    657645    typedef void    function(GLFWimage*)             pfglfwFreeImage; 
    658646    typedef int     function(char*, int)             pfglfwLoadTexture2D; 
     647 
     648// Intrinsic glfw funtion pointer types 
     649 
     650typedef void function(int, int) GLFWwindowsizefun; 
     651typedef void function(int, int) GLFWmousebuttonfun; 
     652typedef void function(int, int) GLFWmouseposfun; 
     653typedef void function(int)      GLFWmousewheelfun; 
     654typedef void function(int, int) GLFWkeyfun; 
     655typedef void function(int, int) GLFWcharfun; 
     656typedef void function(void*)    GLFWthreadfun;