Archived

This topic is now archived and is closed to further replies.

Choosing your background color from a palette

This topic is 5019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well i''ve spent the past couple of hours hunting trying to find out how I can change the background of an openGL window via a selection of colors. I know in many programs both 2d and 3d there is a standard palette that you can choose a color from (like in paint for example). What I want to do is have the user be able to change the background color from such a palette. If anyone could point me in the right direction that would be much appreicated. Thanks, Hades

Share this post


Link to post
Share on other sites
Programs like photoshop show red green and blue between 0-255, you can use glColor4i, ir divide those by 256.0 to get the float value.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think you''ll have to write your own pal. Setup a some quads with the 3 basic colors in the right spots & let gl do the blending for you... & then you''ll have to implement mouse picking to tell where at in that area they clicked... & then do your color math (probably need a few if statements, you''ll see once you start fiddling with it) to generate the right color. That is of course only ONE way to do it, I''m sure there are more ideas out there.

Share this post


Link to post
Share on other sites
Thanks for the ideas. I thought there was some standard way but since i''m using mfc (the program is a map editor) I was able to just make a dialog with bars for the RGB and that seemed to work well =)

--
Ah but you very well mean you can''t take less, it''s very easy to take more than nothing.''

Share this post


Link to post
Share on other sites
why don't you just use the standard colour picker built into windows..

CHOOSECOLOR cc;
memset(cc, 0, sizeof(CHOOSECOLOR));
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwnd;
cc.hInstance = NULL;
cc.rgbResult = backgroundColour;
cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
if (ChooseColor(&cc))
{
backgroundColour= cc.rgbResult;
}


Future Pinball

[edited by - Jumpman on March 21, 2004 11:14:57 PM]

Share this post


Link to post
Share on other sites