I'm trying to build an extension that will render the manipulators for an editor. I've based the extension on the terrain one and started with the grid drawn with GL_Line(s).
The node registers and it is outputted in the log, but it doesn't draw anything. I have the following drawing code:
Code:
void GridNode::renderFunc(uint32 firstItem, uint32 lastItem, const std::string &shaderContext,
const std::string &theClass, bool debugView, const Frustum *frust1, const Frustum *frust2,
RenderingOrder::List order, int occSet )
{
CameraNode *curCam = Modules::renderer().getCurCamera();
if( curCam == 0x0 ) return;
const RenderQueue &renderQueue = Modules::sceneMan().getRenderQueue();
for( uint32 i = firstItem; i <= lastItem; ++i )
{
GridNode *grid = (GridNode *)renderQueue[i].node;
drawGrid(grid, curCam, frust1, frust2);
}
}
void GridNode::drawGrid(GridNode *grid, CameraNode *cam, const Frustum *frust1, const Frustum *frust2)
{
// TODO fustrum culling check
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT |
GL_ENABLE_BIT | GL_HINT_BIT | GL_LIGHTING_BIT);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(cam->getProjMat().x);
const float* camTrans = 0;
cam->getTransMatrices(0, &camTrans);
Matrix4f transMat (camTrans);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(transMat.inverted().x);
glPushMatrix();
const float* gridTrans = 0;
grid->getTransMatrices(0, &gridTrans);
Matrix4f gridTransMat (gridTrans);
glMultMatrixf(gridTransMat.inverted().x);
glColor4f(grid->_col_R, grid->_col_G, grid->_col_B, grid->_colMult);
glBegin(GL_LINE);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f(100.0f, 100.0f, 100.0f);
glEnd();
glPopMatrix();
glPopAttrib();
}