On Monday, 5 December 2016 at 13:54:01 UTC, Mike Parker wrote:
On Monday, 5 December 2016 at 11:38:05 UTC, D.Rex wrote:
Hi,

I am sure this has been asked a thousand times before, but can anyone link me to a tutorial on how to set up derelict and GLFW3, I am trying to work on a project and I just can't get it set up regardless of how many times I read the derelict readme's.

See the Derelict documentation (linked from the README) on using Derelict with DUB-managed projects [1]. Summary:

Step 1: Make sure the GLFW 3 library is installed on your system. On Windows, that means you just put the glfw3.dll in the same directory in which your executable will reside. On Mac, it's easiest to install with Homebrew (should be 'brew install glfw' or 'brew install glfw3', can't recall which). On Linux, use your package manager. Get the dev version of the package if you want, but you don't need it with Derelict.

Step 2: Add 'derelict-glfw3' as a dependency to your dub.json or dub.sdl file (assuming you are using dub to manage your project. If not, see the Derelict documentation using Derelict packages with non-DUB projects [2]).

For dub.json:
"dependencies" : {
"derelict-glfw3": "~>3.1.1"
}

For dub.sdl:

dependency "derelict-glfw3" version="~>3.1.1"

Step 3: Import derelict.glfw3.glfw3 and somewhere in your code, preferably during startup, call DerelictGLFW3.load.

```
import derelict.glfw3.glfw3;
void main() { DerelictGLFW3.load(); }
```

[1] http://derelictorg.github.io/building/with-dub/
[2] http://derelictorg.github.io/building/without-dub/

I have done as you have said here, I have glfw3.dll into the same directory as the executable, and included the dependencies in the dub.json file, however when I run my intialization code, it gives me the following error:

derelict.util.exception.SharedLibLoadException@src\derelict-util\source\derelict\util\exception.d(35):
 Failed to load one or more shared libraries:
        glfw3.dll - Access is denied.
----------------
0x004166B3 in void derelict.util.exception.SharedLibLoadException.throwNew(immutable(char)[][], immutable(char)[][]) at L:\dev\D\DEngine\src\derelict-util\source\derelict\util\exception.d(67) 0x0041BA52 in void derelict.util.sharedlib.SharedLib.load(immutable(char)[][]) at L:\dev\D\DEngine\src\derelict-util\source\derelict\util\sharedlib.d(144) 0x00416A78 in void derelict.util.loader.SharedLibLoader.load(immutable(char)[][]) at L:\dev\D\DEngine\src\derelict-util\source\derelict\util\loader.d(197) 0x004169C2 in void derelict.util.loader.SharedLibLoader.load(immutable(char)[]) at L:\dev\D\DEngine\src\derelict-util\source\derelict\util\loader.d(143) 0x004168B1 in void derelict.util.loader.SharedLibLoader.load() at L:\dev\D\DEngine\src\derelict-util\source\derelict\util\loader.d(83)
0x00402028 in _Dmain at L:\dev\D\DEngine\src\app.d(13)
0x0041C263 in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv 0x0041C227 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x0041C128 in _d_run_main
0x00403BA0 in main at L:\dev\D\DEngine\src\app.d(7)
0x00436AF5 in mainCRTStartup
0x73EF62C4 in BaseThreadInitThunk
0x77480719 in RtlSubscribeWnfStateChangeNotification
0x774806E4 in RtlSubscribeWnfStateChangeNotification

The code I have that runs derelictGLFW3.load() etc is as follows:

import derelict.opengl3.gl3;
import derelict.glfw3.glfw3;

int main()
{
        DerelictGL3.load();
        DerelictGLFW3.load();
        
        GLFWwindow* window;
        
        if(!glfwInit())
        {
                return -1;
        }
        
window = glfwCreateWindow(1280,720, "D OpenGL Engine", null, null);
        if(!window)
        {
                glfwTerminate();
                return -1;
        }
        
        /* make window' context current */
        glfwMakeContextCurrent(window);
        DerelictGL3.reload();
        
        while(!glfwWindowShouldClose(window))
        {
                glfwSwapBuffers(window);
                glfwPollEvents();
        }
        
        glfwTerminate();
        return 0;
}

Reply via email to