This site is no longer active and is available for archival purposes only. Registration and login is disabled.

N95 OpenGL Question


N95 OpenGL Question

Postby lanceabson » Apr 30, 2008 @ 4:54pm

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);
lanceabson
pm Member
 
Posts: 16
Joined: Apr 10, 2008 @ 4:12pm


Postby edge » May 2, 2008 @ 7:44am

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Re Model Matrix

Postby lanceabson » May 2, 2008 @ 2:49pm

lanceabson
pm Member
 
Posts: 16
Joined: Apr 10, 2008 @ 4:12pm


Postby edge » May 2, 2008 @ 3:16pm

EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Re Model Matrix

Postby lanceabson » May 2, 2008 @ 5:15pm

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);
lanceabson
pm Member
 
Posts: 16
Joined: Apr 10, 2008 @ 4:12pm


Postby edge » May 5, 2008 @ 10:14am

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.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron