Wrapping decal updates
by Ronald J Nelson · in Torque Game Engine · 10/01/2007 (8:11 am) · 1 replies
I have been working, with his permission, on updating DavidRM's Wrapping decal code. I have managed to get all of it in except for one section that has been so heavily modified since 1.4.2 to 1.5.2 that I am struggling with it and I might need a little bit of help with it. It is the DecalManager::renderDecal() function.
I am including David's version of it for now since it was already put out in another post made by him. With the batched decal rendering, and integration of the lighting pack , I have been working away at all of the other functions and sections and am pretty sure I have it down.
Also for those interested, he has given me permission to release this as a resource once I get it updated.
His original post is here:
www.garagegames.com/mg/forums/result.thread.php?qt=43775
Thank you in advance for any help you can provide and anyone who adds to this will definitely get credit for it.
I am including David's version of it for now since it was already put out in another post made by him. With the batched decal rendering, and integration of the lighting pack , I have been working away at all of the other functions and sections and am pretty sure I have it down.
Also for those interested, he has given me permission to release this as a resource once I get it updated.
void DecalManager::renderDecal()
{
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glAlphaFunc(GL_GREATER, 0.1f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
DecalData* pLastData = NULL;
for (S32 x = 0; x < mDecalQueue.size(); x++)
{
if (mDecalQueue[x]->decalData != pLastData)
{
glBindTexture(GL_TEXTURE_2D, mDecalQueue[x]->decalData->textureHandle.getGLName());
pLastData = mDecalQueue[x]->decalData;
}
if (mDecalQueue[x]->exData)
{
DecalExData *exData=mDecalQueue[x]->exData;
glPushMatrix();
dglMultMatrix(&exData->mTransform);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3,GL_FLOAT,0,exData->mPartitionVerts.address());
glTexCoordPointer(2,GL_FLOAT,0,exData->mPartitionTVerts.address());
bool lockArrays = dglDoesSupportCompiledVertexArray();
if (lockArrays)
glLockArraysEXT(0,exData->mPartitionVerts.size());
glColor4f(1, 1, 1, mDecalQueue[x]->fade);
for (S32 i=0; i<exData->mPartition.size(); i++)
glDrawArrays(GL_POLYGON,exData->mPartition[i].vertexStart,exData->mPartition[i].vertexCount);
if (lockArrays)
glUnlockArraysEXT();
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
}
else
{
glColor4f(1, 1, 1, mDecalQueue[x]->fade);
glBegin(GL_TRIANGLE_FAN);
{
glTexCoord2f(0, 0); glVertex3fv(mDecalQueue[x]->point[3]);
glTexCoord2f(0, 1); glVertex3fv(mDecalQueue[x]->point[2]);
glTexCoord2f(1, 1); glVertex3fv(mDecalQueue[x]->point[1]);
glTexCoord2f(1, 0); glVertex3fv(mDecalQueue[x]->point[0]);
}
glEnd();
}
}
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
}His original post is here:
www.garagegames.com/mg/forums/result.thread.php?qt=43775
Thank you in advance for any help you can provide and anyone who adds to this will definitely get credit for it.
Torque Owner Ronald J Nelson
Code Hammer Games
The lighting kit transition was actually much easier than I thought it would be.
Unfortunately, I am having a bit of trouble with the Batched Decal rendering system and getting it to work with the code. I have asked Alex Scarborough, the man that made the Batched Decal system for some advice on it and am awaiting a response.