Not logged inGosu Forums
Forum Gosu Homepage Help Search Register Login
Up Topic Gosu / Gosu Exchange / Dynamic palette?
- - By lol_o2 Date 2012-02-26 09:30
Is it possible to make in Gosu some dynamic palette swapping? I know now there's no method for it, but is it doable in future? I mean loading a new palette to a Gosu::Image object from a .pal file or another image. I think it can be done with indexed images and would be very useful for me. So?
Parent - - By jlnr (dev) Date 2012-02-26 14:08
This is not a common feature in OpenGL-based libraries because OpenGL does not work with palettes in its textures. I think the best way to achieve this would be via shaders. Shader support is definitely something I'd love to support more in Gosu, but I am not an expert on them. :/
But is this the use case you would be going for? Having a few images where you vary the color spectrum in real-time? If you just need to load the same image with different palettes, this could be done in the file-to-bitmap loading phase, and even in an external library.

Oh, hacky idea: You can probably also use Image#to_blob and regexps to achieve the same thing relateively efficiently in Ruby, then Image#insert the blob back in...
Parent - - By lol_o2 Date 2012-02-26 14:33
Oh, I'd need it to be fast enough to not lag too much when used per few frames.
Well, it could just speed up loading time of my game, because I have 121 images in 8 different color schemes. I don't need it so much.
Parent - - By jlnr (dev) Date 2012-02-26 15:10
Can you separate the colored portion from the "constant" porton and draw the colorful parts with a color modifier? That would probably be faster than using shaders for lots of images (and work already :) ). I think we've had this topic on IRC recently.
Parent - By lol_o2 Date 2012-02-26 18:24
I could do this, but it's much work for separating it and it wouldn't look as good. Well, if it's impossible to make it fast, I can live with that :)
Parent - By Spooner Date 2012-02-26 18:23
TexPlay could do the same thing massively faster; it still wouldn't be good speed for per-frame manipulation though.
Up Topic Gosu / Gosu Exchange / Dynamic palette?

Powered by mwForum 2.29.0 © 1999-2013 Markus Wichitill