From: Dr. Michael Weller (eowmob@exp-math.uni-essen.de)
Date: Fri 27 Oct 2000 - 17:34:58 IST
On Fri, 27 Oct 2000, Remenic wrote: I don't know the exact example you are referring too, but I think there is a lack of understanding how the 'not' true or direct color graphics modes work (the 256 color modes are the most prominent ones). What you have there is that there are exactly 256 colors on the screen. It would be boring if these were fixed, so the graphix hardware maintains a list of 256 choices for colors. This table contains 256 triples of red, green, blue values to make up the color. (typically 6 bit per base color). What you declare a color here, 'c' is merely an index into this table. > Everytime you want to change the color c, you first do a c++, then you change > it with gl_setpalettecolor. why can't this be done without the 'c++'? Consider you want a red and a green line on the screen, like in: c=0, gl_setpalettecolor(c, 255,0,0); /* red */ ... draw line in 'c' (red) c++; gl_setpalettecolor(c, 0,255,0); /* green */ ... draw line in 'c' (green) W/o the c++ what happens: c=0 gl_setpalettecolor(c, 255,0,0); /* red */ ... draw line in 'c' (red) gl_setpalettecolor(c, 0,255,0); /* green */ Hoppla! You just redefined the color of index 0 to green. The red line you've drawn actually is a line painted with color '0' on the graphics card. It will automagically become green now ... draw line in 'c' (green), however first line is now also green. so on for other colors, you'll get a one color pic this way only. > I tried this, and it didn't work without it. I really had to change the value > of c... what actually happens when i do c++? > > And another thing about the color issue, I've tried playing around with this > for quite a long time now, and I've noticed that the more variables I create, > the less colors I can use.... for example, there was a moment that when I > added just one more integer, my red color (wich was c_red, set with > gl_setpalettecolor(c_red,63,0,0);) would just dissapear! I would assume that c_other == c_red, so you just redefined your red to other color. Just ensure your c_* values are different (#defines are OK!) in the range 0..255. the variable 'c' above is probably just used to loop over the defined colors in an easy way. gl_setpalettecolor does not touch 'c' at all. It just sets the 'c'-th color. Just imagine, there are 256 colors drawn on the screen simultaneously and you choose which they are (like a painter on his palette). I hope this clarifies things. Michael. -- Michael Weller: eowmob@exp-math.uni-essen.de, eowmob@ms.exp-math.uni-essen.de, or even mat42b@spi.power.uni-essen.de. If you encounter an eowmob account on any machine in the net, it's very likely it's me. ------------------------------------------------------------------ Unsubscribe: To: listbot@svgalib.org Body: unsubscribe linux-svgalib
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST