www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DerelictGL3.reload with specified path question.

reply WhatMeWorry <kheaser gmail.com> writes:
I want to store all my shared/dynamic libraries within a special 
directory relative to where the application directory is. All of 
the derelictXX.loads(path) compiles except 
DerelictGL3.reload(lib);  which doesn't seem to be implemented.  
All the reloads in github are either empty or use the version 
specification which I don't believe accomplishes what I want to 
achieve here.

Is there a different approach or some workaround?  Thanks in 
advance.


import derelict.glfw3.glfw3;          // windowing  (1)
import derelict.opengl3.gl3;          // graphics   (2a) (2b)
import derelict.freeimage.freeimage;  // images     (3)
import derelict.openal.al;            // sound      (4)
import derelict.freetype.ft;          // text fonts (5)


auto loadLibraries()
{
     version (Windows)
         string lib = "../libraries/windows/";
     else version (linux)
	string lib = "../libraries/linux/";
     else version (POSIX)
	string lib = "../libraries/apple/";
     else
	throw new Exception("version not found");

     DerelictGLFW3.load(lib);  // (1)
	
     if (glfwInit() == 0)
         throw new Exception("Loading GLFW3 failed");

     DerelictGL3.load(lib);  // (2a) loads only the functions for 
OpenGL 1.0 and 1.1

     glfwSetErrorCallback(&error_callback);		
     // Set all the required options for GLFW
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
     glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
	
     // this window is created because context is required for 
DerelictGL3.reload()
     auto win = glfwCreateWindow(0, 0, "context", null, null);

     if (!win)
         throw new Exception("GLFW failed to creation a window.");

     glfwMakeContextCurrent(win);	

     DerelictGL3.reload(lib); // (2b)  load OpenGL versions 1.2+ 
and ARB and EXT extens

     // ================== ABOVE LINE FAILS TO COMPILE HERE


     DerelictFI.missingSymbolCallback = &myMissingSymbolCallBack;

     DerelictFI.load(lib);  // (3)  Load the FreeImage library
	
     DerelictAL.load(lib);  // (4)  Load the OpenAL library 
called.	

     DerelictFT.load(lib);  // (5)  Load the FreeType library

     return win;
}
Aug 17 2016
parent reply Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote:
 I want to store all my shared/dynamic libraries within a 
 special directory relative to where the application directory 
 is. All of the derelictXX.loads(path) compiles except 
 DerelictGL3.reload(lib);  which doesn't seem to be implemented.
Don't ever ship OpenGL.dll with your application: it's provided by the graphics driver. The only exception to this rule that I can think of is if you want to use a software implementation for some reason.
Aug 17 2016
parent reply WhatMeWorry <kheaser gmail.com> writes:
On Wednesday, 17 August 2016 at 23:21:59 UTC, Rene Zwanenburg 
wrote:
 On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote:
 I want to store all my shared/dynamic libraries within a 
 special directory relative to where the application directory 
 is. All of the derelictXX.loads(path) compiles except 
 DerelictGL3.reload(lib);  which doesn't seem to be implemented.
Don't ever ship OpenGL.dll with your application: it's provided by the graphics driver. The only exception to this rule that I can think of is if you want to use a software implementation for some reason
Understood. Thanks. I assume everything else is good to go.
Aug 17 2016
parent reply WhatMeWorry <kheaser gmail.com> writes:
On Thursday, 18 August 2016 at 03:11:17 UTC, WhatMeWorry wrote:
 On Wednesday, 17 August 2016 at 23:21:59 UTC, Rene Zwanenburg 
 wrote:
 On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry 
 wrote:
 I want to store all my shared/dynamic libraries within a 
 special directory relative to where the application directory 
 is. All of the derelictXX.loads(path) compiles except 
 DerelictGL3.reload(lib);  which doesn't seem to be 
 implemented.
Don't ever ship OpenGL.dll with your application: it's provided by the graphics driver. The only exception to this rule that I can think of is if you want to use a software implementation for some reason
Understood. Thanks. I assume everything else is good to go.
When I saw the .dll in OpenGL.dll, I immediately thought: just Windows. But does this hold true for the linux shared opengl libraries as well? Is this why DerelictGL3.reload() does not take a path argument. But then why doesDerelictGL3.load(lib)take an argument?
Aug 17 2016
parent Mike Parker <aldacron gmail.com> writes:
On Thursday, 18 August 2016 at 03:54:24 UTC, WhatMeWorry wrote:
 When I saw the .dll in OpenGL.dll, I immediately thought: just 
 Windows. But does this hold true for the linux shared opengl 
 libraries as well? Is this why DerelictGL3.reload() does not 
 take a path argument.  But then why 
 doesDerelictGL3.load(lib)take an argument?
The load method is what actually loads the shared library. On Windows, that's OpenGL32.dll. All of the platform-specific library names are configured at the top of gl3.d [1]. In addition to loading the library, it also loads the functions up to OpenGL 1.1, but no higher. This is because the availability of other functions are dependent on the version of the active OpenGL context. The reload method *does not* load the shared library, nor does it load the 1.1 functions. It loads the functions from OpenGL versions 1.2 and higher in addition to all available extensions (well, those for which support has been added to DerelictGL3). It's named reload because it should be called every time you switch contexts to make sure the functions are pointed in the right place. This is an artifact of the way OpenGL is handled on Windows. In practice, it's really only a problem there when switching between contexts that have different properties, but it simplifies the binding implementation and provides a uniform interface across platforms. I'm current working on a new version of the library that will allow you to specify which OpenGL versions and extensions you want to load and will also let you wrap everything in a struct so that you can have one instance for each context, but the distinction between load and reload will still exist. [1] https://github.com/DerelictOrg/DerelictGL3/blob/master/source/derelict/opengl3/gl3.d#L47
Aug 17 2016