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: 2 Boxes get the same color :(

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



Joined: 20 Jul 2007
Posts: 21
Location: Denmark

PostPosted: Sat Aug 25, 2007 10:46 pm    Post subject: GU: 2 Boxes get the same color :( Reply with quote

Hi, I'm trying to draw a box with a frame around, but they get the same color even though I use to different textures.
Can someone see what's wrong with my code?
Code:

  unsigned char  __attribute__((aligned(16))) solid_tex1[2] = { 0xff, 0x00 }; //YELLOW
  unsigned char  __attribute__((aligned(16))) solid_tex2[2] = { 0xf0, 0x00 }; //RED
....
  // setup GU

  sceGuInit();

  sceGuStart(GU_DIRECT,list);
  sceGuDrawBuffer(GU_PSM_8888,(void*)0,BUF_WIDTH);
  sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)0x88000,BUF_WIDTH);
  sceGuDepthBuffer((void*)0x110000,BUF_WIDTH);
  sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
  sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
  sceGuDepthRange(0xc350,0x2710);
  sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
  sceGuEnable(GU_SCISSOR_TEST);
  sceGuDepthFunc(GU_GEQUAL);
  sceGuEnable(GU_DEPTH_TEST);
  sceGuFrontFace(GU_CCW);
  sceGuShadeModel(GU_SMOOTH);
  sceGuEnable(GU_CULL_FACE);
  sceGuFinish();
  sceGuSync(0,0);

  sceDisplayWaitVblankStart();
  sceGuDisplay(GU_TRUE);

  // run sample

  int val = 0;

  for(;;)
    {
      sceGuStart(GU_DIRECT,list);

      // clear screen

      sceGuClearColor(0xff554433);
      sceGuClearDepth(0);
      sceGuClearStencil(0);
      sceGuClear(GU_COLOR_BUFFER_BIT   |
       GU_STENCIL_BUFFER_BIT |
       GU_DEPTH_BUFFER_BIT);

      // setup matrices for cube
      sceGumMatrixMode(GU_PROJECTION);
      sceGumLoadIdentity();
      sceGumOrtho(0,480,272,0, -250, 250);

      sceGumMatrixMode(GU_VIEW);
      {
        ScePspFVector3 pos = {xx, yy, zz};
        ScePspFVector3 rot = {rot_xx, rot_yy, rot_zz};

        sceGumLoadIdentity();
        sceGumTranslate(&pos);
        sceGumRotateXYZ(&rot);
      }
      sceGumMatrixMode(GU_MODEL);
      sceGumLoadIdentity();
      sceGuEnable(GU_TEXTURE_2D);
      sceGuTexMode(GU_PSM_4444,0,0,0);
      sceGuTexImage(0,1,1,1,solid_tex1);
      sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
      sceGuTexFilter(GU_LINEAR,GU_LINEAR);
      sceGuTexScale(1.0f,1.0f);
      sceGuTexOffset(0.0f,0.0f);
      sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF  |
            GU_COLOR_8888 | GU_VERTEX_32BITF |
            GU_TRANSFORM_3D, 36, 0, left_box);
      sceGuDisable(GU_TEXTURE_2D);

      sceGumMatrixMode(GU_MODEL);
      sceGumLoadIdentity();
      sceGuEnable(GU_TEXTURE_2D);
      sceGuTexMode(GU_PSM_4444,0,0,0);
      sceGuTexImage(0,1,1,1,solid_tex2);
      sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
      sceGuTexFilter(GU_LINEAR,GU_LINEAR);
      sceGuTexScale(1.0f,1.0f);
      sceGuTexOffset(0.0f,0.0f);
      sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF  |
            GU_COLOR_8888 | GU_VERTEX_32BITF |
            GU_TRANSFORM_3D, 36, 0, left_frame);
      sceGuDisable(GU_TEXTURE_2D);
      
      sceGuFinish();
      sceGuSync(0,0);

      sceDisplayWaitVblankStart();
      sceGuSwapBuffers();
    }

  sceGuTerm();
Back to top
View user's profile Send private message
thomas_fogh



Joined: 20 Jul 2007
Posts: 21
Location: Denmark

PostPosted: Tue Aug 28, 2007 1:23 am    Post subject: Reply with quote

Anyone?
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Tue Aug 28, 2007 2:21 am    Post subject: Reply with quote

Why do you draw a second GU_TRIANGLES (should it not a GU_LINES instead ?) for the frame over the box ?
Back to top
View user's profile Send private message
thomas_fogh



Joined: 20 Jul 2007
Posts: 21
Location: Denmark

PostPosted: Tue Aug 28, 2007 10:22 pm    Post subject: Reply with quote

The frame is just another box slightly larger than the main box to get a wider frame.
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Wed Aug 29, 2007 12:00 am    Post subject: Reply with quote

thomas_fogh wrote:
The frame is just another box slightly larger than the main box to get a wider frame.


so always draw the largest one first then the smallest one. That is first left_frame, then left_box.
Back to top
View user's profile Send private message
thomas_fogh



Joined: 20 Jul 2007
Posts: 21
Location: Denmark

PostPosted: Wed Aug 29, 2007 3:29 pm    Post subject: Reply with quote

The box is slightly thicker (z-axis) than the frame so that the frame doesn't overlap the box.
It's actually the frame that gets the same color as the box. (yellow).
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