Advertisement

Simple color prob.

Started by September 25, 2002 08:35 PM
0 comments, last by Thunder_Hawk 22 years, 5 months ago
I can''t for the life of me figure out what''s wrong with this code, but I haven''t dealt with bitwise operations in a while so I''m probably a little rusty .
  
void MenuMan::Menu(float cx, float cy, unsigned int t_color, unsigned int m_color, unsigned int s_color, char * stuff) {
	...
	t_r = (unsigned char) (t_color & 0xFF0000) >> 16;
	t_g = (unsigned char) (t_color & 0x00FF00) >> 8;
	t_b = (unsigned char) (t_color & 0x0000FF);
	m_r = (unsigned char) (m_color & 0xFF0000) >> 16;
	m_g = (unsigned char) (m_color & 0x00FF00) >> 8;
	m_b = (unsigned char) (m_color & 0x0000FF);
	s_r = (unsigned char) (s_color & 0xFF0000) >> 16;
	s_g = (unsigned char) (s_color & 0x00FF00) >> 8;
	s_b = (unsigned char) (s_color & 0x0000FF);
	...
}
  
and in use...
  
Menu.Menu(0.0f, 0.0f, 0xFF0000, 0x00FF00, 0xFFFFFF, "New Game?\nOne Player\nTwo Player\nCancel");
  
I know the rest of the code works if I use constant values (which it would be anyway, but I like having the flexibility of using variable colors). Obviously t_x, m_x, and s_x are member variables of MenuMan. This code only seems to work if the color being used is white (causing it to only show the selected item on the menu). Hmmmmmmmmm... _____________________________ And the Phoenix shall rise from the ashes... --Thunder_Hawk -- ¦þ ______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
Whoops...answered my own question. The unsigned char typecast was being applied before the shift (I only added it to try and fix this). It seems that the parentheses around the bitmasking had actually fixed the problem.

[EDIT] don't swear using the word shift

_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________


[edited by - Thunder_Hawk on September 25, 2002 9:52:15 PM]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________

This topic is closed to new replies.

Advertisement