SetColor, dun wanna it over my Image!!!
BlitzMax Forums/BlitzMax Programming/SetColor, dun wanna it over my Image!!!
| ||
Well, my problem is: if I load a TImage using LoadImage Function called myImage, it's ok :) then in the main loop, if I do this: SetColor( 200, 0, 0 ) 'or whatever between 0 and 255 DrawRect( 10, 10, 100, 100 ) DrawImage( myImage, 200, 10 ) so, myImage receives the SetColor too!!! in this case, myImage receives a lot of red. and become much more red. myImage losts it's natural colors. Can I prevent it??? I mean, do not "colorize" myImage??? thx :) |
| ||
SetColor( 200, 0, 0 ) 'or whatever between 0 and 255 DrawRect( 10, 10, 100, 100 ) SetColor(255, 255, 255) DrawImage( myImage, 200, 10 ) |
| ||
no comments to myself... thanks a lot man it looks so obviously now... thank u :D |
| ||
Thing is, Insane, that whatever you set will affect everything until you change it again. IPete2. |
| ||
No problem--remember, scaling and rotation work the same way, too... |
| ||
It is more efficient to do it that way, especially as BlitzMax was originally mainly designed around working with OpenGL, which is a state machine - ie you set the state of something like `current color` and it stays that way until you set it to something else. That way it is more efficient to access what color to use, rather than having to pass the color every single time with every single graphics command. So yes, to do it `the old less efficient way`, you have to deliberately set the `current` color inbetween stuff to stop it interfering with things in an undesirable way. Or alternatively you can restructure your code with this in mind. Draw your image before the SetColor for example. |
| ||
I actually find this way of doing things with SetColor very useful. I usually design my bitmap fonts in grey scale and then use SetColor to display any text the colour I want it. Saves having to design several different coloured fonts or pre-render them at the beginning of your code. Has lots of other uses too, like the flashing of a big boss in a shoot'em up where it flashes red whenever you hit it. |
| ||
You might possibly be also able to store a grayscale texture, saving lots of video mem, and then coloring it when it is drawn. |
| ||
Would that work, AngelDaniel? Blitz can't load greyscale pngs. And even if it could, would an 8-bit instead of 32 bit image even speed anything up? Byte and Short variables don't give speed advantages. Please correct me if I'm wrong. |
| ||
I know that OpenGL can store textures in a variety of formats including RGBA or even with individual channels like just a `Red` channel texture. You could load in (somehow) a 256-color image (grayscale) and upload it as a Red image, then when you render using that data you can use a particular blend more or whatever to turn the red into RGBA representation of the grays, plus whatever color you want to tint with. It would just save video ram used to store the texture and might be a little faster since less data has to be read in order to draw it. You would have to set this all up with direct OpenGL calls yourself, BM wouldn't do it for you. |
| ||
I use a basic (but very fast) tile lightning system based in setcolor for my sidescroller, amongst other uses. SetColor comes in pretty handy for some things :) Only drawback is you can set the 'component percentage' from 0 to 100% but no more. Would be nice to 'overload' components. |
| ||
Ah, cool. I haven't gone into OpenGL just yet. But it sounds as though you can do more specific and low-level creation with it in BM. When I get some time after this semester-long programming crunch, I'm trying it out. (Being able to write BlitzMax programs for university credit is very exciting.) |