draw a cube with gles library???

Login to reply to this topic.
Sun, 2008-02-24 10:09
Joined: 2007-12-16
Forum posts: 19

Hi,
i use symbian 9.2 shipped with opengl library. i try to draw a cube on the screen by opengl library. i want to draw the cube on special position, so i used function glLoadMatrixf( gl_para ), gl_para is float array stores matrix which represents some position, but it didn’t work.
the source code follows:

//draw
float gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearDepthf( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);


glMatrixMode(GL_MODELVIEW);
glLoadMatrixf( gl_para );

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);

any suggestion? Thank in advance.
Best wishes.
Mia


Mon, 2008-02-25 11:21
Joined: 2007-12-19
Forum posts: 49
Re: draw a cube with gles library???

Have you properly setup view and frustrum ? Also you can try to use someting like this to test if your model view matrix is ok.

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -4.0f );

Mon, 2008-02-25 11:57
Joined: 2004-11-29
Forum posts: 1134
Re: draw a cube with gles library???

Wouldn't it be a good idea to initalize gl_para with some values before loading the matrix with it?

Right now (if this is all the code) you load it with uninitialized "random" values from the stack...

Mon, 2008-02-25 14:45
Joined: 2007-12-16
Forum posts: 19
Re: draw a cube with gles library???

The gl_para array is gl_para={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}

Wed, 2008-02-27 10:38
Joined: 2007-12-16
Forum posts: 19
Re: draw a cube with gles library???

Hi,
may i ask you a favor?
could you give me a little sample used function glLoadMatrix to draw a cube?
Thank in advace.
Best wishes.
Mia

  • Login to reply to this topic.