Access Violation while trying to use OpenGL

spec00 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 1 13:15:27 PDT 2015


I'am trying to play a bit with D and OpenGL by using the 
available Derelict bindings, but i'am even failing to create a 
window.

At the moment my code is as simple as:
-----------------------------------------
import derelict.glfw3.glfw3;

import std.c.stdio : fputs, fputc, stderr;

extern(C) nothrow void glfwPrintError(int error, const(char)* 
description) {
     fputs(description, stderr);
     fputc('\n', stderr);
}

void main() {
     DerelictGLFW3.load();

     glfwSetErrorCallback(&glfwPrintError);

     if(!glfwInit()) {
         glfwTerminate();
         throw new Exception("Failed to create glcontext");
     }
}
------------------------------------------

When i try to run it using dub i get the following:
{ test }  ยป dub run                                               
                                                                   
                                                                   
                 /c/git/opengl/test 2
Target derelict-util 2.0.3 is up to date. Use --force to rebuild.
Target derelict-glfw3 1.1.0 is up to date. Use --force to rebuild.
Target derelict-gl3 1.0.15 is up to date. Use --force to rebuild.
Building test ~master configuration "application", build type 
debug.
Compiling using dmd...
Linking...
Running .\test.exe
object.Error@(0): Access Violation
----------------
0x001D1C61
0x0040204E in _Dmain at C:\git\opengl\test\source\main.d(15)
0x0041B262 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x0041B237 in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()
0x0041B14B in _d_run_main
0x004184E4 in main
0x00430489 in mainCRTStartup
0x77C13744 in BaseThreadInitThunk
0x77DDA064 in RtlSetCurrentTransaction
0x77DDA02F in RtlSetCurrentTransaction
Error executing command run:
Program exited with code 1
----------------------------------

If i leave only the line DerelictGLFW3.load() it doesn't crashes.

I'am running windows 10 x64 and and dmd says: DMD32 D Compiler 
v2.068.0

Anyone has an idea of might be going on?

Thanks,



More information about the Digitalmars-d-learn mailing list