| View previous topic :: View next topic |
| Author |
Message |
BlackDragon777
Joined: 15 Sep 2005 Posts: 32
|
Posted: Fri Sep 23, 2005 11:35 am Post subject: My Triangle Dissapears |
|
|
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 |
|
 |
BlackDragon777
Joined: 15 Sep 2005 Posts: 32
|
Posted: Fri Sep 23, 2005 11:58 am Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Fri Sep 23, 2005 2:26 pm Post subject: |
|
|
| 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 |
|
 |
BlackDragon777
Joined: 15 Sep 2005 Posts: 32
|
Posted: Fri Sep 23, 2005 2:45 pm Post subject: |
|
|
| Oh ok Cool thanks a lot Shine! |
|
| Back to top |
|
 |
|