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 

sceGumDrawArray parameters

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



Joined: 04 Aug 2005
Posts: 17

PostPosted: Wed Sep 21, 2005 11:43 pm    Post subject: sceGumDrawArray parameters Reply with quote

returning 3D vertices etc. from a function...

I've written a function that reads out the vertices and indices of an object from a 3DS file.
My question is, I want to be able to return this data from a function, and display the data on the screen (in glorious 3D).
What would be the best way to return this data?
I've checked through the documentation and my best bet looks to be sceGumDrawArray. I'm not really sure I understand the function parameters fully though, since doxygen didn't produce much documentation for this function.

My array format so far is like this:

Code:


struct stVect
{
  float x, y, z;
};

struct stVect vertices[numberOfVertices];



so, its just an array of floats storing the coordinates.
My array of indices (index numbers referring to the vertice array) is similarly defined as:

Code:


struct stFace
{
  unsigned short p1, p2, p3;
};

struct stFace faces[numberOfFaces];



Basically, I'm not sure my array structure is compatible with sceGumDrawArray,
so I'd be very grateful if someone could explain the parameters better to me:
sceGumDrawArray (int prim, int vtype, int count, const void *indices, const void *vertices)
P.S. Should I be using SceGu or SceGum?
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Thu Sep 22, 2005 3:37 am    Post subject: Reply with quote

prim - Primitive type. In your case this should be GU_TRIANGLES.
vtype - Vertex Format. In your case GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D.
count - number of vertices to render. In your case: numberOfFaces * 3.
indices - pointer to the index-buffer. pointing to 'faces' is ok, but make sure you align data properly. __attribute__((aligned(16))) should work for you.
vertices - pointer to the vertex-buffer. Pointing to 'vertices' is ok here aswell. Same rules for alignment applies.

so in the end, the call should be:

sceGumDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,numberOfFaces*3,faces,vertices);

Look at pspgu.h and the documentation for sceGuDrawArray(), it should be a lot better than what's available in pspgum.h.

sceGuDrawArray() is what is doing all the actual work. sceGumDrawArray() is simply a wrapper that makes sure that any transforms done using the matrix routines in GUM is flushed before the render-call is done.
_________________
GE Dominator
Back to top
View user's profile Send private message
TheSamuraiElephant



Joined: 04 Aug 2005
Posts: 17

PostPosted: Fri Sep 23, 2005 2:01 am    Post subject: Reply with quote

Thankyou very much for the reply, I understand the parameters a lot better now.

Cheers :)
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