Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 20, 2013 4:10 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Dec 26, 2008 1:23 am 
Offline

Joined: Sat Oct 04, 2008 3:58 am
Posts: 99
I'd like to pass a four part array to draw() for the purpose of setting the color of each vertex, but I don't see any easy way to do this in the current version. I noticed the shapefill interface, but the only fill is gradientfill, which is a bit problematic for what I'm doing. Also, the fill interface itself seems a bit bulky for a simply GL vertex color tweak, and eliminates the possibility of four entirely different colors.


Last edited by FireSlash on Mon Dec 29, 2008 7:05 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2008 9:43 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Fill doesn't exclude using a different colour for each vertex. If you keep those colors stored as instances of the fill then the overhead would be pretty minimal.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2008 3:38 am 
Offline

Joined: Sat Oct 04, 2008 3:58 am
Posts: 99
kevglass wrote:
Fill doesn't exclude using a different colour for each vertex. If you keep those colors stored as instances of the fill then the overhead would be pretty minimal.

Kev

Ok, I wrote a fill that works correctly, but now I can't seem to get anything beyond garbage out of ShapeRenderer.texture(). I updated to the latest release (239) but most of the problems still presist.

rect = Rectangle
t = ShapeFill
i = Image
Code:
Rectangle rect = new Rectangle(drawX, drawY,32,32);
ShapeRenderer.fill(rect,t); // Works great.
ShapeRenderer.texture(rect,i,1.0f,1.0f,t); // Renders nothing.
ShapeRenderer.texture(rect,i); // Renders nothing
ShapeRenderer.textureFit(rect,i); // Renders nothing
i.draw(drawX, drawY,32,32,new Color(1f, 1f, 1f, 1f));// Works great.

I have no idea what I'm doing wrong here. :?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2008 10:15 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Nor me, looks like you're right, convoluted approach to get a really common image effect. I think it might be nicer to have the image have state setting methods for each corner's colour, Image.setVertexColor(TOP_LEFT, r,g,b,a) - like what's been added for rotation angle in the past.

I'll take a look at this and why the above doesn't work on my next run through Slick. I'm doing 4k games at the moment and thinking about a new physics thing atm :) So busy!

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 12:46 am 
Offline

Joined: Sat Oct 04, 2008 3:58 am
Posts: 99
Re-tested with the latest svn, still no dice but the results ARE different.

i.draw(drawX, drawY,32,32);
Image

ShapeRenderer.texture(rect,i); (No tile fill)
Image

ShapeRenderer.texture(rect,i,1f,1f,t); (With tile fill)
Image
Note that the tile fill works fine, and shows shades of WHITE when used without an image; it seems the image it causing the grey/brown coloring.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 8:57 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Haven't touched this one yet.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 7:56 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Added some new stuff to be able to store colors for the corners of images (which can be updated or course). See ImageCornerTest for an example of use.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 10:25 pm 
Offline

Joined: Sat Oct 04, 2008 3:58 am
Posts: 99
Works like a charm. Thanks :mrgreen:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group