GLEnableOutline & Gl Logging
by James Urquhart · in Torque Game Engine · 09/28/2004 (5:27 am) · 2 replies
Here's a quick way to get torque's GLEnableOutline() working on linux, and potentially mac os x (if you change the files for that platform too).
NOTE: There is no real reason why the code can't be platform independant; Its just that nobody seems to have gotten around to cleaning it up. Similar steps can be taken to clean out and make the GL Logger platform independant too.
We will be working in X86UNIXOGLVideo.cc :
Add to the top :
Go to the "OpenGLDevice::swapBuffers()" function, and add the following line to the end of the function :
At the end, insert the following block of code :
Now find the following functions in platformWIN32, and copy them into the file in the corresponding order :
NOTE: for the following, remove the "static" and "APIENTRY" keywords, replace "dllglDrawArrays" and "dllglDrawElements" with "orig_glDrawArrays" and "orig_glDrawElements", then remove the "dll" prefix on all the rest of function calls
Finally, here's the console function for GLEnableOutline() :
I may roll these changes into a patch (in a more platform independant way of course), so stay tuned.
NOTE: There is no real reason why the code can't be platform independant; Its just that nobody seems to have gotten around to cleaning it up. Similar steps can be taken to clean out and make the GL Logger platform independant too.
We will be working in X86UNIXOGLVideo.cc :
Add to the top :
static bool outlineEnabled = false; // For outline code
Go to the "OpenGLDevice::swapBuffers()" function, and add the following line to the end of the function :
if (outlineEnabled) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);NOTE: This will clear the screen each frame so the wireframe doesn't keep drawing over itself.
At the end, insert the following block of code :
// Backup functions (copied from GLCoreFunc.h)
#define GL_FUNCTION(fn_return,fn_name,fn_args,fn_value) fn_return (*fn_name)fn_args;
GL_FUNCTION(void, orig_glDrawArrays, (GLenum mode, GLint first, GLsizei count), return; )
GL_FUNCTION(void, orig_glDrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices), return; )
static U32 getIndex(GLenum type, const void *indices, U32 i)
{
if(type == GL_UNSIGNED_BYTE)
return ((U8 *) indices)[i];
else if(type == GL_UNSIGNED_SHORT)
return ((U16 *) indices)[i];
else
return ((U32 *) indices)[i];
}Now find the following functions in platformWIN32, and copy them into the file in the corresponding order :
static U32 getIndex(GLenum type, const void *indices, U32 i);
NOTE: for the following, remove the "static" and "APIENTRY" keywords, replace "dllglDrawArrays" and "dllglDrawElements" with "orig_glDrawArrays" and "orig_glDrawElements", then remove the "dll" prefix on all the rest of function calls
static void APIENTRY outlineDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) static void APIENTRY outlineDrawArrays(GLenum mode, GLint first, GLsizei count)
Finally, here's the console function for GLEnableOutline() :
ConsoleFunction(GLEnableOutline, void, 2, 2, "GLEnableOutline(bool);")
{
argc;
bool enable = dAtob(argv[1]);
if(outlineEnabled == enable)
return;
/* if(enable && (loggingEnabled || perfEnabled))
return;*/
outlineEnabled = enable;
if ( enable )
{
orig_glDrawArrays = glDrawArrays;
orig_glDrawElements = glDrawElements;
glDrawElements = outlineDrawElements;
glDrawArrays = outlineDrawArrays;
}
else
{
glDrawElements = orig_glDrawElements;
glDrawArrays = orig_glDrawArrays;
}
}I may roll these changes into a patch (in a more platform independant way of course), so stay tuned.
About the author
#2
I already implemented it and sent it off to Ben. Though i'd be happy to send you along a copy :)
I have not tested it on a mac (though i have tested on both win32 and linux). However, it should work fine, since i have implemented the neccesary functions in a platform independant manner. In addition, i don't think there are any endian issues.
The only thing one would need to implement is the glClear() call on a screen refresh if in wireframe mode - thats just 1 line.
On a sidenote, Torque doesn't really need a GL logger, since there are other tools such as gDebugger better suited to the job (imo).
10/03/2004 (9:53 am)
Chris,I already implemented it and sent it off to Ben. Though i'd be happy to send you along a copy :)
I have not tested it on a mac (though i have tested on both win32 and linux). However, it should work fine, since i have implemented the neccesary functions in a platform independant manner. In addition, i don't think there are any endian issues.
The only thing one would need to implement is the glClear() call on a screen refresh if in wireframe mode - thats just 1 line.
On a sidenote, Torque doesn't really need a GL logger, since there are other tools such as gDebugger better suited to the job (imo).
Torque Owner Chris \"Hobbiticus\" Weiland