forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GU(ru's needed) related

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Mon Apr 28, 2008 12:00 am    Post subject: GU(ru's needed) related Reply with quote

(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:

//             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.
Back to top
View user's profile Send private message
quadrizo



Joined: 23 Aug 2007
Posts: 21

PostPosted: Mon Apr 28, 2008 1:32 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Mon Apr 28, 2008 3:40 am    Post subject: Reply with quote

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:
// 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.
Back to top
View user's profile Send private message
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Mon Apr 28, 2008 10:45 pm    Post subject: Reply with quote

I see. thanks both for helping me out !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group