digitalmars.D.learn - Open GL extensions?
- AxelS (8/8) Apr 14 2009 Hello evrybody...
- downs (31/42) Apr 14 2009 This is how we do it in dglut:
- AxelS (1/1) Apr 14 2009 Thank you very much! I hope that will work...
- Jarrett Billingsley (7/11) Apr 14 2009 Sounds like you might not have the right calling convention. Are you
- Spacen Jasset (2/13) Apr 14 2009 You should *really* look at derelict it makes all this easy.
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!
Apr 14 2009
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);
Apr 14 2009
On Tue, Apr 14, 2009 at 6:20 AM, AxelS <a_bothe gmx.net> 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...Sounds like you might not have the right calling convention. Are you sure you put extern(Windows) on your definition of wglGetProc (as well as all the other wgl* funcs)? Also, I don't know whether or not it works with D2, but Derelict has already done all the work of binding to OpenGL and most of the extensions for you. http://dsource.org/projects/derelict
Apr 14 2009
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!You should *really* look at derelict it makes all this easy.
Apr 14 2009