# Problem at using function glLoadMatrix

Hi,
i use opengl es library on symbian. And i have two problems at opengl es . i try to draw a cube on special postion. so i got the axis X,Y,Z, and movement vectors.

1. i want to use the function LoadMatrixf. The codes follows :
``````GLfloat gl_para[16]={0.998029,0.017969,0.060119,0.0,
0.019204,-0.999615,-0.020033,0.0,
0.059735,0.021148,-0.997990,0.0,
4.988117,-2.675533,161.780807,1.0};
glMatrixMode(GL_MODELVIEW);
DrawBox( 15.f, 15.f, 15.f ); //some functions used to draw a cube
``````

but the cube disappeared, there is nothing.
when i use these codes:

``````GLfloat gl_para[16]={1.0f,0.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f};
glMatrixMode(GL_MODELVIEW);
DrawBox( 15.f, 15.f, 15.f );
``````

it works. i know it’s equal to glLoadIdentity(),
but when i use my Matrix, it dosen’t work. why?

i think the matrix is right.
The direction of X axis is (0.998029,0.017969,0.060119,0.0), Y is (0.019204,-0.999615,-0.020033,0.0)and Z is (0.059735,0.021148,-0.997990,0.0). The movement is (4.988117,-2.675533,161.780807,1.0). The axis X,Y,Z are normal axis. i think they are right. but why didn’t it work? could you give me some example datas as parameter in function glLoadMatrix so i can try to test.

1. i try to draw a cube on a picture. i want to draw it on special postion on the picture. could you give me some suggestions? Actually, i captured a picture by camera. There is a special mark in the picture. And i want to detect the mark and draw a cube on the mark. So i get the direction of camera in according with the mark. That is the GLfloat gl_para[16], i got the axis X, Y,Z, and the movement vetors which are mentioned in above threads. That what i want to do. Now, i have got the gl_para, and i want to use glLoadMatrix to result it. So what can i do? how to draw a cube on a picture?

What is your projection matrix? OpenGL calculates the homogeneous clip space position as ProjectionMatrix * ModelViewMatrix * VertexPosition. So if you want to know where your vertices end up, you can just do the math. I’m sure there’s nothing wrong with glLoadMatrix itself.

Note that glFrustum sets up the projection matrix looking along the negative Z axis, so my first guess would be that the translation in positive Z (161.78) moves the cube behind the camera. But again this completely depends on your projection matrix.

1. i try to draw a cube on a picture. i want to draw it on special postion on the picture. could you give me some suggestions? Actually, i captured a picture by camera. There is a special mark in the picture. And i want to detect the mark and draw a cube on the mark. So i get the direction of camera in according with the mark. That is the GLfloat gl_para[16], i got the axis X, Y,Z, and the movement vetors which are mentioned in above threads. That what i want to do. Now, i have got the gl_para, and i want to use glLoadMatrix to result it. So what can i do? how to draw a cube on a picture?

I’m not sure what your question is. Do you want to know how to detect the mark, how to use the picture as a background, or just how to get the right matrix?

Hi,
i think my problem is how to use a pcture as backgroud now. Because i dispaly a picture on the screen. Am i right?

i guess the reason why the cube doesn’t appear is that the picture is at the front of the cube . So what funtion can i do?

Another question: Just like what i have said above, if i want to use the phone’s camera to capture . And when i detect a marker, i wish draw a cube on the marker and the marker and cube appears at the same time.
i guess i needn’t to care about the background and can draw the cube on the scrren successfully. am i right?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.