PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

OpenglEs Frustrum..

RapchikProgrammer · 19 Nov 2009, 03:17 UTC
Hey, i am having problems setting up frustrum for ogl.. i am able to get it perfectly running if i do this each frame:

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
GLfloat aspectRatio = (GLfloat)(Ecd->dsp->GetWidth()) / (GLfloat)(Ecd->dsp->GetHeight());
glFrustum( FRUSTUM_LEFT * aspectRatio, FRUSTUM_RIGHT * aspectRatio,
FRUSTUM_BOTTOM, FRUSTUM_TOP,
FRUSTUM_NEAR, FRUSTUM_FAR );

// Restore matrix mode
glMatrixMode( GL_MODELVIEW );


but shouldnt i just be able to set the frustrum once and forget about it.. im sure edgelib is messing with the perspective matrix.. i have tried using display->frustrum function but even if i use -1,1 as near and far values in that function, my game still renders.. any idea what im missing here??

and secondly why do i need to do this every frame?? is edgelib modifying the perspective matrix each frame??
Hi,

EDGELIB doesn't change the perspective matrix unless you're calling ClassEDisplay::Perspective2D or ClassEDisplay::Perspective3D. Perhaps you're setting a 2D perspective to show text or HUD elements?
RapchikProgrammer · 19 Nov 2009, 08:17 UTC
Yes i am using perspective 3d and perspective 2d calls as i need to render hud, gui and stuff.. so how to handle the frustrum culling?? and why wont the display->frustrum call work perfectly??

another question what does exactly the perspective 3d function do?? perspective 2d is just changing the mode to glOrtho2d i think, but i dont understand exactly what perspective 3d is doing..
Hi,

Perspective2D and perspective3D are wrappers for glOrtho and glFrustum respectively. Perhaps you need to enable frustum culling through a glEnable call?