Here is my test,
…
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Save the matrix state and do the rotations
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
float b[16] =
{1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,-300,1};
glMultMatrixf(b);
// Move the light after we draw the sun!
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
// Draw the Earth
glColor3ub(0,0,255);
float c[16] =
{1,0,0,0,
0,1,0,0,
0,0,1,0,
105,0,0,1};
glMultMatrixf(c);
glutSolidSphere(15.0f, 30, 17);
// Restore the matrix state
glPopMatrix(); // Modelview matrix
}
…
and i change the code link this,
…
// Called to draw scene
void RenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Save the matrix state and do the rotations
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
float b[16] =
{1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,-300,1};
//glMultMatrixf(b);
// Move the light after we draw the sun!
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
// Draw the Earth
glColor3ub(0,0,255);
float c[16] =
{1,0,0,0,
0,1,0,0,
0,0,1,0,
105,0,0,1};
//glMultMatrixf(c);
float product[16];
m3dMatrixMultiply44(product,b,c);
glMultMatrix(product);
glutSolidSphere(15.0f, 30, 17);
// Restore the matrix state
glPopMatrix(); // Modelview matrix
}
…
first i construct two matrix,use glMulMatrix to multiply the first,and then use it again to multiply the sencod.
And the second case is multiply the two matrices and then use glMultiMatrix to mutiply th product,
Do the both of two way get the same result???