 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Sonicadvance1
Joined: 13 Oct 2005 Posts: 10
|
Posted: Sat Aug 05, 2006 6:37 pm Post subject: sceGuDrawArray Emulation |
|
|
Right now I'm working on a project, and I need to emulate sceGuDrawArray in OpenGL, but I think I need to convert the vertex and draw it. Only problem is, I can't seem to get it to work. Right now I'm just trying to get vertices to draw and just skipping indices at the moment, also, I'm working with lines only right now so I am not doing anything to draw triangles or quads.
The code below is what I currently have and it looks really ugly because of my constant fiddling with it :D
| Code: | void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices)
{
unsigned int *n=malloc((count)*3*sizeof(int));
int i=0, a=0;
for(a=0;a<count;a+=3,i++){
n[a]=((Vertex*)vertices)[i].x;
n[a+1]=((Vertex*)vertices)[i].y;
n[a+2]=((Vertex*)vertices)[i].z;
}
if(indices!=0)
glDrawRangeElements( GL_MAX_ELEMENTS_INDICES, 0,count, count, vtype+1,indices );
if(vertices!=0){
glDrawElements(GL_LINE_STRIP,count, GL_UNSIGNED_INT,n );
}
while(((unsigned char*)vertices)[i]!=0){
printf("X=%d\tY=%d\tZ=%d\n",((Vertex*)vertices)[i].x,((Vertex*)vertices)[i].y,((Vertex*)vertices)[i].z);
i++;
}
}
|
|
|
| Back to top |
|
 |
siberianstar
Joined: 22 Jun 2006 Posts: 70
|
Posted: Sat Aug 05, 2006 10:27 pm Post subject: |
|
|
| omg |
|
| Back to top |
|
 |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Mon Aug 07, 2006 1:03 am Post subject: |
|
|
Hello,
I don't know what isn't working, but here are some suggestions:
* You may need to convert the vertices to a format supported by OpenGL (whatever is represented by vtype -> GL_FLOAT). 2D vertices will be difficult.
* Make sure the primitive type is converted to one which GL recognises. Have fun with sprites...
* Try not to malloc for every draw - allocate a buffer elsewhere and reuse it. And always free what you malloc. |
|
| Back to top |
|
 |
|
|
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
|