modelview matrix question

I have a camera class that has 2 matrices.

projection & modelview

At load time I create the Projection Matrix in OpenGL then grab it (glGetFloatv) and store it in my class projection matrix so I have faster access to it whenever a want.

Now my class view matrix is generated each frame (if anything in the camera class is changed)

I generate it using MY OWN matrix manipluation functions.

Once it is generated I need to some how set this matrix IN OPENGL (I only generated MY matrix in the class). What is a fast way to do this?

The reason why I keep these in my class is so that I can extract Frustum information fast.

Would it be wise to just have opengl calculate the modelview matrix and then just extract it each frame??? or is there a faster why??

If anyone does not understand what i’m doing I will post my small cCamera class…


#ifndef cCamera_h
#define cCamera_h

class cCamera


void Create( 
	const cVector3 a_pv3WorldPos,	// world position
	const cVector3 a_pv3Rotation,	// rotation in radians
	const float a_fFOV,				// field of view in degrees
	const float a_fAspect,			// aspect ratio width/height
	const float a_fNearClip,		// distance to the near clip plane
	const float a_fFarClip )		// distance to the far clip plane			
	// create the camera object with the incoming variables
	m_v3WorldPos.Copy( &a_pv3WorldPos );
	m_v3Rotation.Copy( &a_pv3Rotation );

	// setup openGL's projection matrix
	gluPerspective( a_fFOV, a_fAspect, a_fNearClip, a_fFarClip );

	// now pull the projection matrix out so we 
	// have faster access to it
	glGetFloatv( GL_PROJECTION_MATRIX, m_m44Proj.m_fData );

void Roll( const float a_fRadians )
	// increment the z rotation
	m_v3Rotation.m_fData[2] += a_fRadians;

void Pitch( const float a_fRadians )
	// increment the x rotation
	m_v3Rotation.m_fData[0] += a_fRadians;

void Yaw( const float a_fRadians )
	// increment the y rotation
	m_v3Rotation.m_fData[1] += a_fRadians;

void Move( const float a_fAmount, const bool a_bAlign )
	// move the camera in the current direction
	// the align flag is true if we only move along the xz plane


void Update( void )
	// if the camera information has changed then 
	// create the matrix and set it 
	if ( !m_bUpdate ) return;

	// reset the matrix
	m_m44View.RotateZ( -m_v3Rotation.m_fData[2] );
	m_m44View.RotateX( -m_v3Rotation.m_fData[0] );
	m_m44View.RotateY( -m_v3Rotation.m_fData[1] );

	// set translation
	m_m44View.Translate( -m_v3WorldPos.m_fData[0], -m_v3WorldPos.m_fData[1], -m_v3WorldPos.m_fData[2] );

	// now set this matrix to opengl's modelview matrix

	glSetFloatv( GL_MODELVIEW_MATRIX, m_m44View.m_fData );

	// now create the world fustrum clipping planes
	m_objFustrum.Calculate( &m_m44Proj, &m_m44View );

	// now make the update flag = false

cVector3 m_v3WorldPos;
cVector3 m_v3Rotation;
cViewFustrum m_objFustrum;
cMatrix44 m_m44Proj; // projection matrix from openGL so i don’t have to get access to it once it’s changed
cMatrix44 m_m44View; // modelview matrix
bool m_bUpdate; // if true then the camera needs to be updated for this frame (and the fustrum)


Not sure if I understood your question fully.
I do calc both projection and modelview matrices myself, and load them like:

Never saw that glSetFloatv before…