• Advertisement
Sign in to follow this  

a simple matrix problem

This topic is 4463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Am just doin an exercise and have a problem...the idea is 2 shear a 2d image. when trying 2 set up the matrix and ran into a problem. The full program with everythin else is fine. it still compiles and runs but this viewport does not display as i get 2 warnings saying warning C4047: 'function' : 'const float *' differs in levels of indirection from 'float [4][4]' warning C4024: 'glLoadMatrixf' : different types for formal and actual parameter 1 the code is below... float shearMatrix[4][4]; //decared earlier void display(void) { shearMatrix[0][0] = 1.0; shearMatrix[0][1] = 0.0; shearMatrix[0][2] = 0.0; shearMatrix[0][3] = 0.0; shearMatrix[1][0] = 2.0; shearMatrix[1][1] = 1.0; shearMatrix[1][2] = 0.0; shearMatrix[1][3] = 0.0; shearMatrix[2][0] = 0.0; shearMatrix[2][1] = 0.0; shearMatrix[2][2] = 1.0; shearMatrix[2][3] = 0.0; shearMatrix[3][0] = 0.0; shearMatrix[3][1] = 0.0; shearMatrix[3][2] = 0.0; shearMatrix[3][3] = 1.0; glClear(GL_COLOR_BUFFER_BIT) ; // clear the background glMatrixMode(GL_PROJECTION) ; glPushMatrix(); glViewport(200,0,200,200); glMatrixMode(GL_PROJECTION); glLoadMatrixf(shearMatrix); initials(); //calls polygon co-ordinates for the image glPopMatrix(); glutSwapBuffers() ; } Any guidance or a solution would be excellent. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Change shearMatrix to float shearMatrix[16], or change the code to glLoadMatrixf((float *)shearMatrix);

Share this post


Link to post
Share on other sites
cheers mate thats perfect!

i tried the first 1 originally this mornin but i still had problems but the 2nd worked fine so im chuffed

i used the rating thing for u...extremely helpful :)

Share this post


Link to post
Share on other sites
Although, you can use float shearMatrix[4][4] if you like also, it's much simpler since it makes it more obvious how to access row and column info. Just cast it to float* of GLfloat* as JohnBolton told you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement