Setting OpenGL matrices in Cg - Slow

Started by
-1 comments, last by spek 14 years, 10 months ago
Hi, When trying to speed up things, I noticed that setting the ModelViewProjection matrix (OpenGL, Cg) is quite slow. So I tried the tips from this post: http://www.gamedev.net/community/forums/topic.asp?topic_id=501802 It seems that this trick works. But how does it come that the default method, cgGLSetStateMatrixParameter( handle, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY ); shown in many demo's, is so slow? In my engine I have quite many different matrices that need to be set before start rendering. For example, each object has its own transformation/rotation, and background passes that require a different camera need to adjust the ModelViewProjection matrix as well. Is this a OpenGL/Cg problem? And/or should I change the way I render objects?

shaderX.apply();

< for each object that uses shaderX >
glPushMatrix;
glMultMatrixf( object.matrix );

<render object>

glPopMatrix;

shaderX.unApply();
Greetings, Rick

This topic is closed to new replies.

Advertisement