drawing multiple objects with the GU with different colours?

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

Moderators: cheriff, TyRaNiD

Post Reply
yimtaka
Posts: 8
Joined: Thu Aug 09, 2007 6:12 pm

drawing multiple objects with the GU with different colours?

Post by yimtaka »

Hi all,

this may be a simple question but I have been trying ages to get this to work without any success. The closest I get is being able to draw all the objects but they have the same colour but the colour is not correct, it seems to be a mixture of the colours of both objects.

What I have is:

A list of vertices with colour data which have data to draw a simple square

What I want to do is:

draw multiple copies of vertices but each time with a different colour. Something like

void setColourInVertices(int col)
{
loop through all the vertices and change the color property to 'col'
}

int i;
for(i=0;i<3;i++)
{
setColourInVertices(Red);
drawVerticesAt(i*20,20);
}

for(i=4;i<6;i++)
{
setColourInVertices(blue);
drawVerticesAt(i*20,20);
}

When doing the above is it important where you place the sceGUStart and sceGUFinsih and sceGUsync functions?.

Can someone post a small example of doing this?.

cheers.
yimtaka
Posts: 8
Joined: Thu Aug 09, 2007 6:12 pm

Post by yimtaka »

I know this can be easily done by having 2 objects, each with their own vertices but I need to know if it can be done with one object e.g. draw cube at 10,10 in blue then draw cube at 20,20 in red etc.

please help!
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Maybe you could be playing with light, ambient color or something like this?
Sorry for my bad english
Image Oldschool library for PSP - PC version released
yimtaka
Posts: 8
Joined: Thu Aug 09, 2007 6:12 pm

Post by yimtaka »

Ok another way of describing the problem is say you needed to draw a grid of tiles 5x5 on the screen, each tile had to be a different color. You had the geometry stored in vertices[] which includes gradient color. How would you do it?
yimtaka
Posts: 8
Joined: Thu Aug 09, 2007 6:12 pm

Post by yimtaka »

OK. I have found the solution.

Because I was manipulating the same vertex data each time before drawing to the screen I had to add the line:

sceKernelDcacheWritebackAll();

I added this line after every time I changed something in the vertex object and now everything works as it should.
Post Reply