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 

Triangle missing... [SOLVED]

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



Joined: 07 Nov 2009
Posts: 12

PostPosted: Fri Jun 25, 2010 2:30 pm    Post subject: Triangle missing... [SOLVED] Reply with quote

Hello forum,

I use the code below to draw a cube. When I draw 3 or more cubes, the last triangle is missing from cube 3 to the last one :/
Also, I would like to know when I have to call sceKernelDcacheWritebackAll() exactly? Is it needed for 2D?

Code:

/** Description of a vertex */
struct Vertex
{
   //f32 u, v;         //   texture coords
   Color color;      //   32-bit color
   f32 nx, ny, nz;      //   normal
   f32 x, y, z;      //   vertex
};

void Core::box(f32 width, f32 height, f32 depth, Color color) const
{
   const u32 n = 12 * 3;
   
   f32 hw = width  * 0.5f;
   f32 hh = height * 0.5f;
   f32 hd = depth  * 0.5f;

   Vertex __attribute__((aligned(16))) vertices[n] =
   {
      //   Front
      { color, 0.0f, 0.0f, 1.0f, -hw,  hh, hd },
      { color, 0.0f, 0.0f, 1.0f,  hw,  hh, hd },
      { color, 0.0f, 0.0f, 1.0f, -hw, -hh, hd },

      { color, 0.0f, 0.0f, 1.0f,  hw, -hh, hd },
      { color, 0.0f, 0.0f, 1.0f, -hw, -hh, hd },
      { color, 0.0f, 0.0f, 1.0f,  hw,  hh, hd },

      //   Back
      { color, 0.0f, 0.0f, -1.0f,  hw,  hh, -hd },
      { color, 0.0f, 0.0f, -1.0f, -hw,  hh, -hd },
      { color, 0.0f, 0.0f, -1.0f,  hw, -hh, -hd },

      { color, 0.0f, 0.0f, -1.0f, -hw, -hh, -hd },
      { color, 0.0f, 0.0f, -1.0f,  hw, -hh, -hd },
      { color, 0.0f, 0.0f, -1.0f, -hw,  hh, -hd },

      //   Left
      { color, -1.0f, 0.0f, 0.0f, -hw,  hh, -hd },
      { color, -1.0f, 0.0f, 0.0f, -hw,  hh,  hd },
      { color, -1.0f, 0.0f, 0.0f, -hw, -hh, -hd },

      { color, -1.0f, 0.0f, 0.0f, -hw, -hh, -hd },
      { color, -1.0f, 0.0f, 0.0f, -hw,  hh,  hd },
      { color, -1.0f, 0.0f, 0.0f, -hw, -hh,  hd },

      //   Right
      { color, 1.0f, 0.0f, 0.0f, hw,  hh,  hd },
      { color, 1.0f, 0.0f, 0.0f, hw,  hh, -hd },
      { color, 1.0f, 0.0f, 0.0f, hw, -hh,  hd },

      { color, 1.0f, 0.0f, 0.0f, hw,  hh, -hd },
      { color, 1.0f, 0.0f, 0.0f, hw, -hh, -hd },
      { color, 1.0f, 0.0f, 0.0f, hw, -hh,  hd },

      //   Top
      { color, 0.0f, 1.0f, 0.0f, -hw, hh, -hd },
      { color, 0.0f, 1.0f, 0.0f,  hw, hh, -hd },
      { color, 0.0f, 1.0f, 0.0f, -hw, hh,  hd },

      { color, 0.0f, 1.0f, 0.0f,  hw, hh,  hd },
      { color, 0.0f, 1.0f, 0.0f, -hw, hh,  hd },
      { color, 0.0f, 1.0f, 0.0f,  hw, hh, -hd },

      //   Bottom
      { color, 0.0f, -1.0f, 0.0f, -hw, -hh,  hd },
      { color, 0.0f, -1.0f, 0.0f,  hw, -hh,  hd },
      { color, 0.0f, -1.0f, 0.0f, -hw, -hh, -hd },

      { color, 0.0f, -1.0f, 0.0f, -hw, -hh, -hd },
      { color, 0.0f, -1.0f, 0.0f,  hw, -hh,  hd },
      { color, 0.0f, -1.0f, 0.0f,  hw, -hh, -hd }
   };

   sceKernelDcacheWritebackAll();
   sceGumDrawArray
   (
      GU_TRIANGLES,
      GU_COLOR_8888 | GU_NORMAL_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D,
      n,
      0,
      vertices
   );
}


Thanks in advance for any response,
G43L


Last edited by G43L on Sat Jun 26, 2010 1:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
Criptych



Joined: 12 Sep 2009
Posts: 79

PostPosted: Sat Jun 26, 2010 8:57 am    Post subject: Reply with quote

Use sceGuGetMemory instead of stack variables; that should solve the "missing triangle" problem. AFAIK sceKernelDcacheWritebackAll is only needed when you're getting a lot of data for the GE from main RAM, and the cache isn't flushing normally, e.g. there are glitches that don't show up consistently.
_________________
PSP-2000 // CFW: 5.50 GEN-D2 ...and not upgrading until OFW supports homebrew!
(But I did downgrade to 1.50 with TimeMachine...)
"I want you to tell me how the machine makes you feel."
Back to top
View user's profile Send private message
G43L



Joined: 07 Nov 2009
Posts: 12

PostPosted: Sat Jun 26, 2010 1:04 pm    Post subject: No missing triangle anymore... Reply with quote

Hello Criptych,

Thank you for the explanations. Everything is displayed correctly now...

Regards,
G43L
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