GU(ru's needed) related

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

GU(ru's needed) related

Post by PosX100 »

(lame title , i know :) )

Im trying to add 2d support(for panels/menu..etc) in my simple 3d app(its more like a demo atm),but im not sure how to change the projection.

In opengl , im doing it like this:

Code: Select all

//             Renderer.cpp
inline static  void renderMode(const RendererData& r)
	{
		switch(r.renderer)
			{
			case   RENDERER_OPENGL :
				{
			        glViewport(0, 0, r.getWidth(), r.getHeight());    
			        glMatrixMode(GL_PROJECTION);        
			        glLoadIdentity();  
				if(r.getRenderMode()==RENDER_MODE_2D)
				glOrtho( 0, r.getWidth(),r.getHeight(), 0, -1, 1 );
				else
				gluPerspective(r.getFov(), r.getAspectRatio(), r.getNear(), r.getFar()); 
			        glMatrixMode(GL_MODELVIEW);         
				glLoadIdentity(); 
				return;
				}
			case   RENDERER_PSPGU :
				{
				// -___________________-
				return;
				}
			}
	}
}
Could you help me out so i can add GU support?

Thanks.
quadrizo
Posts: 21
Joined: Thu Aug 23, 2007 10:21 pm

Post by quadrizo »

you don't need to give a specific ortho projection with GU :

when you use sceGuDrawArray to display yours vertices, give the GU_TRANSFORM_2D parameter: all 3d matrices (rotation, project,...) will not be take in account
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

As quadrizo mentioned, if you're passing GU_TRANSFORM_2D then you don't need to do anything.

If you are wanting an ortho projection then you would do something like this:

Code: Select all

// 3D drawing.

sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumOrtho(0.0f, 480.0f, 272.0f, 0.0f, -1.0f, 1.0f);

sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();

sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();

// Ortho drawing.
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

I see. thanks both for helping me out !
Post Reply