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 

My Triangle Dissapears

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



Joined: 15 Sep 2005
Posts: 32

PostPosted: Fri Sep 23, 2005 11:35 am    Post subject: My Triangle Dissapears Reply with quote

Well, I managed to draw a triangle to the screen however it only stays on the screen for half a second and then is cleared. I am swapping buffers so maybe I need to draw my triangle to some other place in emmory as well however the sample graphics demos didn't seem to be doing that. Here is my main loop.

Code:

while(1)
   {

      sceGuStart(GU_DIRECT, list);

      sceGuClearColor(0);
      sceGuClearDepth(0);
      sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);

      sceGuColor(0xFFFFFFFF);

      vertex = (Vertex *)sceGuGetMemory(sizeof(Vertex)*3);
      vertex[0].x = 100;
      vertex[0].y = 100;
      vertex[0].z = 0;

      vertex[1].x = 150;
      vertex[1].y = 50;
      vertex[1].z = 0;

      vertex[2].x = 200;
      vertex[2].y = 100;
      vertex[2].z = 0;
      sceGuDrawArray(GU_TRIANGLES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 3, 0, vertex);

      sceGuFinish();
      sceGuSync(0,0);

      sceDisplayWaitVblankStart();
      sceGuSwapBuffers();

   }


Any ideas?
Back to top
View user's profile Send private message
BlackDragon777



Joined: 15 Sep 2005
Posts: 32

PostPosted: Fri Sep 23, 2005 11:58 am    Post subject: Reply with quote

I guess if I said sceGuInit(), I wouldn't have had to post this. Sorry about this one. It was a careless overlook.

However I do have one other question.

How could I do a goraud shaded triangle based on the code I have provided? It seems that if I use sceGuColor 3 times before drawing the points, the last color I chose is tectured for the whole triangle. How can I send seperate colors for seperate verticies?


Thanks in advance!
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Fri Sep 23, 2005 2:26 pm    Post subject: Reply with quote

BlackDragon777 wrote:
How could I do a goraud shaded triangle based on the code I have provided? It seems that if I use sceGuColor 3 times before drawing the points, the last color I chose is tectured for the whole triangle. How can I send seperate colors for seperate verticies?


You could use a vertex struct like this:

Code:

struct Vertex
{
   unsigned int color;
   float x, y, z;
};


and then sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 3, 0, vertices) and sceGuShadeModel(GU_SMOOTH). See http://forums.ps2dev.org/viewtopic.php?p=24801#24801 for a full example and just add the ShadeModel call.
Back to top
View user's profile Send private message
BlackDragon777



Joined: 15 Sep 2005
Posts: 32

PostPosted: Fri Sep 23, 2005 2:45 pm    Post subject: Reply with quote

Oh ok Cool thanks a lot Shine!
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