www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Open GL extensions?

reply AxelS <a_bothe gmx.net> writes:
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
next sibling parent reply downs <default_357-line yahoo.de> writes:
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
parent AxelS <a_bothe gmx.net> writes:
Thank you very much! I hope that will work...
Apr 14 2009
prev sibling next sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
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
prev sibling parent Spacen Jasset <spacenjasset yahoo.co.uk> writes:
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