Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 2878 times)
0 Members and 1 Guest are viewing this topic.
Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Posted 2013-01-04 16: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 17: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 20:42:03 »

In Slick you tint images like so:
4; //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 Kernel

Medals: 138
Projects: 3

You think about my Avatar right now!

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

If you want to "reset" your tinting, use this:

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: 26
Projects: 3
Exp: 6 years

One for all!

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

Beautiful guys! Thank you so much. Smiley

Pages: [1]
  ignore  |  Print  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (27 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (211 views)
2018-05-13 18:23:11

nelsongames (128 views)
2018-04-24 18:15:36

nelsongames (127 views)
2018-04-24 18:14:32

ivj94 (868 views)
2018-03-24 14:47:39

ivj94 (129 views)
2018-03-24 14:46:31

ivj94 (780 views)
2018-03-24 14:43:53

Solater (144 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!