AxelS wrote: > Hello evrybody... > > I want to use all the opengl extensions like Shaders in my D2.0 prog... > I already got the opengl32.lib and also the headers... > > I tried it wglGetProc (similar name...)! I could compile it but it hangs up > runtime and creates errors which dont tell me the actual problem... > and yes, I'm sure that these functions which I want to get are existing! > I know the usage of predefined function variables is recommended... > I tried but failed... > > Thanks in advance!
This is how we do it in dglut: version(Win32) { extern(System) void* wglGetProcAddress(char* procName); alias wglGetProcAddress getExtProc; } else { extern(C) void* glXGetProcAddressARB(char* procName); alias glXGetProcAddressARB getExtProc; } template SysFunc(C) { extern(System) alias ReturnType!(C) function(ParameterTypeTuple!(C)) SysFunc; } struct ExtFunc(C, string name) { static { SysFunc!(C) load() { static if (is(typeof(&getExtProc))) { return cast(SysFunc!(C)) getExtProc(toStringz("gl"~name)); } else static assert(false, "Platform not supported (yet)"); } SysFunc!(C) fn; ReturnType!(C) opCall(ParameterTypeTuple!(C) params) { if (!fn) fn=cast(typeof(fn)) load(); if (!fn) throw new Exception("Extension function \""~name~"\" not found in lookup table!"); return fn(params); } } } Then later on, they're used like this: alias ExtFunc!(void function(GLenum, GLenum, GLenum, int *), "GetFramebufferAttachmentParameterivEXT") getpar; foreach (where, obj; attachedObjects) { int res, res2; getpar(GL_FRAMEBUFFER_EXT, where, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT, &res); getpar(GL_FRAMEBUFFER_EXT, where, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &res2);