Results 1 to 3 of 3

Thread: problem at using function glLoadMatrix

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    17

    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 :

    Code :
    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);
    glLoadMatrixf(gl_para);
    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:

    Code :
    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);
    glLoadMatrixf(gl_para);
    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.


    2) 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?

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: problem at using function glLoadMatrix

    Quote Originally Posted by freesui1984
    it works. i know it's equal to glLoadIdentity(),
    but when i use my Matrix, it dosen't work. why?
    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.

    2) 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?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Mar 2008
    Posts
    17

    reply Xmas

    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?

Similar Threads

  1. Semaphor problem atomic_xchg function
    By Algernon in forum OpenCL
    Replies: 1
    Last Post: 06-23-2012, 10:04 PM
  2. how can Irotate a specific area in opengl? glLoadMatrix
    By and1 in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 12-17-2008, 01:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •