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 

sceGuDrawArray Emulation

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



Joined: 13 Oct 2005
Posts: 10

PostPosted: Sat Aug 05, 2006 6:37 pm    Post subject: sceGuDrawArray Emulation Reply with quote

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
View user's profile Send private message
siberianstar



Joined: 22 Jun 2006
Posts: 70

PostPosted: Sat Aug 05, 2006 10:27 pm    Post subject: Reply with quote

omg
Back to top
View user's profile Send private message
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Mon Aug 07, 2006 1:03 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
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