sceGumDrawArray parameters

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

Moderators: cheriff, TyRaNiD

Post Reply
TheSamuraiElephant
Posts: 17
Joined: Thu Aug 04, 2005 9:10 pm

sceGumDrawArray parameters

Post by TheSamuraiElephant »

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: Select all


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: Select all


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?
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

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
TheSamuraiElephant
Posts: 17
Joined: Thu Aug 04, 2005 9:10 pm

Post by TheSamuraiElephant »

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

Cheers :)
Post Reply