tag:blogger.com,1999:blog-1368731483244051508.post4287160132292005386..comments2007-11-22T00:57:24.890+11:00Comments on while(nan): Wrapping functions for fun and profitDkhttp://www.blogger.com/profile/02909587337938463354noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-1368731483244051508.post-38843706873837105782007-11-22T00:57:00.000+11:002007-11-22T00:57:00.000+11:00Hi Daniel, A couple of months late, but this one i...Hi Daniel, <BR/><BR/>A couple of months late, but this one is very nice, thanks!<BR/><BR/>Regarding the 'no void' variables deal, I usually can work around it by calling the function at the return point and using scope(exit):<BR/><BR/>ReturnTypeOf!(F) foo(alias F)(ParameterTupleOf!(F) args)<BR/>{<BR/> scope(exit) /* error checking for F here */<BR/> return F(args); /* works for void */<BR/>}<BR/><BR/>I've filed a ticket for the derelict 'alias bug' here, it's easy to solve:<BR/>http://www.dsource.org/projects/tango/ticket/729<BR/><BR/>Regards and thanks again.Lutgernoreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-30594920785540451882007-06-15T23:36:00.000+10:002007-06-15T23:36:00.000+10:00Puuh! Could wait. =)Made a version of lesson06 wit...Puuh! Could wait. =)<BR/><BR/>Made a version of lesson06 with the debug GL calls. You can see it <A HREF="http://odefu.googlecode.com/svn/trunk/debugGLTest/" REL="nofollow">here.</A><BR/><BR/>Oh, and the previous URL doesn't work anymore. =)OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-42303184431504102712007-06-15T22:28:00.000+10:002007-06-15T22:28:00.000+10:00Moved the sample version here.Moved the sample version <A HREF="http://odefu.googlecode.com/svn/trunk/lesson01/debuggl.d" REL="nofollow">here.</A>OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-39340546479312488092007-06-15T22:18:00.000+10:002007-06-15T22:18:00.000+10:00Got the template working with the help of larsivi ...Got the template working with the help of larsivi and h3r3tic on #d.tango. :)<BR/><BR/>There's a sample version <A HREF="http://odeamus.org/~odeamus/debuggl.d" REL="nofollow">here.</A><BR/><BR/>I'll make a better example from the NeHe lesson 01 during the weekend, if I have time.<BR/><BR/>Only thing about your notes for Derelict is that you have to dereference the function, like typeof(*Fn), then it works. :)<BR/><BR/>Any idea how to get an opengl error? =)OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-65390570410250983192007-06-15T16:49:00.000+10:002007-06-15T16:49:00.000+10:00Yes, it's a b*tch to write. :) But them it would b...Yes, it's a b*tch to write. :) But them it would be done. Don't know about the extensions though.<BR/><BR/>Tested your template a little, but couldn't get a GL function working. Got one dummy function though, but only by giving the alias a different name from the original function. The typeof(Fn) doesn't do anything for me when using DerelictGL. Although it might be a Tango thing. <BR/><BR/>I'll look into this more later.OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-35808376418997015582007-06-14T21:33:00.000+10:002007-06-14T21:33:00.000+10:00Well, having played around with disassembly of thi...Well, having played around with disassembly of this stuff, DMD seems quite capable of inlining the wrapped function call, so that doesn't really "cost" anything.<BR/><BR/>As for the error checking, I don't really know. I'd <EM>love</EM> to know how often Carmack checks glError (hmm... maybe I should go get the Q3 source). That said, it wouldn't be hard to wrap the error check in a debug {} statement so that the release version doesn't perform any checking, and have an explicit glAssert call in strategic locations.<BR/><BR/>Also, whilst a wrapper class like DebugGL is nice, it's a b*tch to write in the first place, never mind supporting GL extensions! The advantage of this method is that you can use it to wrap stuff as you need it. And if it gets too repetitive, you can always alias the wrapped functions to something shorter.<BR/><BR/>alias glSafe!(glClear) glsClear;Dkhttp://www.blogger.com/profile/02909587337938463354noreply@blogger.comtag:blogger.com,1999:blog-1368731483244051508.post-43735127868633812712007-06-14T21:08:00.000+10:002007-06-14T21:08:00.000+10:00Hi!Nice idea you got there. Do you know how the te...Hi!<BR/><BR/>Nice idea you got there. Do you know how the template affects the runtime speed of a release build, where you don't want to do any error checking?<BR/><BR/>I've been thinking about error checking with OpenGL too, and I'm leaning to the way JOGL does the DebugGL class. There's the initial writing to be done, but afterwards the application code looks the same no matter if you're using a debug version or not.<BR/><BR/>Then of course I'd have to do GLU, SDL, SDL_Image.... =)<BR/><BR/>Anyway, just something that came to mind after reading the post.<BR/><BR/>O.OdeFuhttp://www.blogger.com/profile/13722314480601394379noreply@blogger.com