Slick Forums

Discuss the Slick 2D Library
It is currently Tue Oct 15, 2019 1:19 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Dec 12, 2010 3:28 pm 
Offline
Regular

Joined: Sat Aug 16, 2008 7:04 pm
Posts: 119
This method would be useful in addition to the existing setColor method:

Code:
/**
    * Set the color of the given corner when this image is rendered. This is
    * useful lots of visual effect but especially light maps
    *
    * @param corner
    *            The corner identifier for the corner to be set
    * @param r
    *            The red component value to set (between 0 and 1)
    * @param g
    *            The green component value to set (between 0 and 1)
    * @param b
    *            The blue component value to set (between 0 and 1)
    */
   public void setColor(int corner, float r, float g, float b) {
      if (corners == null) {
         corners = new Color[] { new Color(1, 1, 1, 1f),
               new Color(1, 1, 1, 1f), new Color(1, 1, 1, 1f),
               new Color(1, 1, 1, 1f) };
      }

      corners[corner].r = r;
      corners[corner].g = g;
      corners[corner].b = b;
   }


Useful for lightning where I do not want to change the alpha.

Also the docs should say "usefol for lots of ..."

_________________
Gamedev link-collection (german page)
My Gamedev Blog
Play Cyber Dungeon Quest!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 12, 2010 3:37 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
If it matters I'm against it... if you don't specify alpha, what would alpha be? If it's 1, you can easily pass that as an parameter.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2010 2:42 pm 
Offline
Regular

Joined: Sat Aug 16, 2008 7:04 pm
Posts: 119
I thought this method would be useful because when I use setAlpha and setColor together on one image then setAlpha becomes irrelevant.

Is this supposed to work like this?

We can see this in the image.drawEmbedded method.
-> if corners are set then their alpha value is used and overwrites the alpha color that is binded before drawEmbedded is called.

Code:
if (alpha != 1) {
         if (filter == null) {
            filter = Color.white;
         }

         filter = new Color(filter);
         filter.a *= alpha;
      }
      if (filter != null) {
         filter.bind();
      }




Code:
public void drawEmbedded(float x, float y, float width, float height) {
      init();

      if (corners == null) {
         GL.glTexCoord2f(textureOffsetX, textureOffsetY);
         GL.glVertex3f(x, y, 0);
         GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight);
         GL.glVertex3f(x, y + height, 0);
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY
               + textureHeight);
         GL.glVertex3f(x + width, y + height, 0);
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY);
         GL.glVertex3f(x + width, y, 0);
      } else {
         corners[TOP_LEFT].bind();
         GL.glTexCoord2f(textureOffsetX, textureOffsetY);
         GL.glVertex3f(x, y, 0);
         corners[BOTTOM_LEFT].bind();
         GL.glTexCoord2f(textureOffsetX, textureOffsetY + textureHeight);
         GL.glVertex3f(x, y + height, 0);
         corners[BOTTOM_RIGHT].bind();
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY
               + textureHeight);
         GL.glVertex3f(x + width, y + height, 0);
         corners[TOP_RIGHT].bind();
         GL.glTexCoord2f(textureOffsetX + textureWidth, textureOffsetY);
         GL.glVertex3f(x + width, y, 0);
      }
   }

_________________
Gamedev link-collection (german page)
My Gamedev Blog
Play Cyber Dungeon Quest!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2011 2:03 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Added in SVN.

Kev


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group