Page 1 of 1

N95 OpenGL Question

PostPosted: Apr 30, 2008 @ 4:54pm
by lanceabson
Hello,

I am using the following code to draw a box on screen... using existing Projection & Modelview Matrix's

glMatrixMode(GL_PROJECTION);
glLoadMatrixf( getProjectionMatrix() );
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf( getModelViewMatrix() );
DrawBox( 20.f, 20.f, 20.f, 0 );

How do I code the same thing with EdgeLib?

i.e. Using my own Projection & Model Matrix's. What do I need to change below? (Taken From the Animate3D Turtle demo.)



display->Perspective3D(display->GetWidth(), display->GetHeight());
display->WorldReset();
display->WorldTranslate(0, 0, zoom);
#if !defined(EGL_USEGL)
display->WorldScale(65536 * 2, 65536 * 2, 65536 * 2);
#endif
display->WorldRotate(256, 0, 0);
display->WorldRotate(0, rotation, 0);
display->BindTexture(&block_tex);
display->SetShading(E3D_GOURAUD | E3D_TEXTURE);
display->Render(&block);

turtle.Animate(anitimer / 2);
display->BindTexture(&turtle_tex);
display->SetShading(rendertype_shading[rendertype]);
display->Render(&turtle);

PostPosted: May 2, 2008 @ 7:44am
by edge

Re Model Matrix

PostPosted: May 2, 2008 @ 2:49pm
by lanceabson

PostPosted: May 2, 2008 @ 3:16pm
by edge

Re Model Matrix

PostPosted: May 2, 2008 @ 5:15pm
by lanceabson
Hello, Thank you again for a quick reply.

I have used your code as below but now no model is displaying.


This Bit Works displaying my own box model....

glMatrixMode(GL_PROJECTION);
glLoadMatrixf( &Proj_Mat_Buff_0[0] );
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf( &View_Mat_Buff_0[0] );

glDrawElements( GL_TRIANGLES, 48 * 3, _UNSIGNED_BYTE, objTriangles); //BOX OBJECT


But this is not displaying anything....

display->Perspective3D(display->GetWidth(), display->GetHeight());

glMatrixMode(GL_PROJECTION);
glLoadMatrixf( &Proj_Mat_Buff_0[0] );
glMatrixMode(GL_MODELVIEW);

E3DSURFACEINFO info;
if (turtle.Lock(&info))
{
for (int i = 0; i < 16; i++)
info.matrix[i] = (int)(View_Mat_Buff_0[ i ] * 4096);
turtle.Unlock();
}

turtle.Animate(anitimer / 2);
display->BindTexture(&turtle_tex);
display->SetShading(rendertype_shading[rendertype]);
display->Render(&turtle);

PostPosted: May 5, 2008 @ 10:14am
by edge
Hi Lance,

I think the error is caused by the values in your matrix. You might want to change the multiplier (now it is set to 4096) so it better matches your projection matrix. In my sample I used 4096 because with the EDGELIB Perspective3D function, x/y coordinates of -4096 to 4096 are shown onscreen.