# simple problem with a matrix

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

I always use float[16] for matrices. OpenGL handles matrices in column major order, so the indices map to:

0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15

set the matrix with:
glLoadMatrixf(your_matrix);

yeah i did try it like that but had problems…

i changed a line of code in the end and it worked…

changed “glLoadMatrixf(shearMatrix);” to “glLoadMatrixf((float *)shearMatrix);”