Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version
Go to top

A small VRML viewer using OpenGL and MFC

, 30 Nov 1999
//********************************************
// Color.h
//********************************************
// pierre.alliez@cnet.francetelecom.fr
// Created : 10/12/97
// Modified : 09/02/98
//********************************************

#ifndef _COLOR_
#define _COLOR_

class CColor
{

private :

	// Color
	unsigned char m_Red;
	unsigned char m_Green;
	unsigned char m_Blue;
	unsigned char m_Alpha;

public :

	// Constructor
	CColor() 
	{ 
		m_Red = m_Green = m_Blue = m_Alpha = 0;
	}

	CColor(CColor &color) 
	{ 
		m_Red = color.r();
		m_Green = color.g();
		m_Blue = color.b();
		m_Alpha = color.a();
	}

	~CColor() {}


	// Constructor
	CColor(unsigned char grey) { Set(grey); }
	CColor(unsigned char red,unsigned char green,unsigned char blue) { Set(red,green,blue); }
	CColor(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha) { Set(red,green,blue,alpha); }

	// Data access
	unsigned char r(void) { return m_Red; } 
	unsigned char g(void) { return m_Green; }  
	unsigned char b(void) { return m_Blue; }  
	unsigned char a(void) { return m_Alpha; }  

	// Data setting
	void r(unsigned char red)   { m_Red = red; } 
	void g(unsigned char green) { m_Green = green; }  
	void b(unsigned char blue)  { m_Blue = blue; }  
	void a(unsigned char alpha) { m_Alpha = alpha; }  

	// Data setting
	void Set(CColor &c);
	void Set(unsigned char grey); 
	void Set(unsigned char red,unsigned char green,unsigned char blue); 
	void Set(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha); 

	int operator==(CColor &color) { return (color.r() == m_Red) && (color.g() == m_Green) && (color.b() == m_Blue); }
	int operator==(CColor *pColor) { return (pColor->r() == m_Red) && (pColor->g() == m_Green) && (pColor->b() == m_Blue); }

};

#endif // _COLOR_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Pierre Alliez

France France
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 1 Dec 1999
Article Copyright 1999 by Pierre Alliez
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid