Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Altering an already bound texture  (Read 786 times)
0 Members and 1 Guest are viewing this topic.
Offline Mads

JGO Ninja


Medals: 24
Projects: 3


One for all!


« Posted 2013-01-04 17:35:48 »

I'm interested in altering a texture slightly before drawing in, and it's part of a texture atlas. I'd like to tint the sprite a little bit, that's all.

I'm seeing this in Minecraft with the grass and leaves, that's why I'm asking - How is that achieved?

I'm using Slick2D but that's really not important for the question. I'd like to use the speed of drawEmbedded(), but the Graphics context screws up when I'm tinting my sprite.

Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2013-01-04 18:24:50 »

** EDIT: This answer is more OpenGL than Slick oriented **

If it's a solid tint over the entire quad/triangle, you can do it with the texture environment and color of the vertices. Just set the environment to MODULATE and change the vertex color and you should see a tint without having to mutate the texture object (this also means you can tint different meshes separately without re-tinting the texture).

You can also use the BLEND and BLEND_COLOR environment options to specifically tint the texture regardless of what the vertex color has been configured as.

Offline davedes
« Reply #2 - Posted 2013-01-04 21:42:03 »

In Slick you tint images like so:
1  
2  
3  
4  
Color.green.bind(); //can be any color object

//now the sprite will be tinted green
mySprite.drawEmbedded(x, y, width, height);


By default this uses GL_MODULATE -- so each pixel in your texture will be multiplied by your vertex color, e.g. green (R=0, G=1, B=0).

For other modes (such as GL_ADD) you should read up on "Texture Combiners."

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline matheus23

JGO Wizard


Medals: 97
Projects: 3


You think about my Avatar right now!


« Reply #3 - Posted 2013-01-04 21:46:31 »

If you want to "reset" your tinting, use this:
Color.white.bind();

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Mads

JGO Ninja


Medals: 24
Projects: 3


One for all!


« Reply #4 - Posted 2013-01-04 21:52:36 »

Beautiful guys! Thank you so much. Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (18 views)
2014-04-15 18:08:23

BurntPizza (15 views)
2014-04-15 03:46:01

UprightPath (28 views)
2014-04-14 17:39:50

UprightPath (13 views)
2014-04-14 17:35:47

Porlus (29 views)
2014-04-14 15:48:38

tom_mai78101 (54 views)
2014-04-10 04:04:31

BurntPizza (111 views)
2014-04-08 23:06:04

tom_mai78101 (212 views)
2014-04-05 13:34:39

trollwarrior1 (181 views)
2014-04-04 12:06:45

CJLetsGame (187 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!