Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

OAG Library (OpenGL) Part 1 - Setting Up the Library for an MFC Application

Rate me:
Please Sign up or sign in to vote.
4.40/5 (11 votes)
7 Aug 2011CPOL3 min read 56K   56  
OAG is a library written in C++. With this library, you can create OpenGL based applications.
#ifndef OAG_OAGCOLOR_H
#define OAG_OAGCOLOR_H

#ifdef _MSC_VER

#ifndef _WINDOWS_
#include <windows.h>
#endif

#endif

namespace oag
{

	class OAGColor
	{
	public:
		OAGColor(void):m_Red(255), m_Green(255), m_Blue(255), m_Alpha(255) {};
		OAGColor(OAGColor& color) :  m_Red(color.GetRed()), m_Green(color.GetGreen()), m_Blue(color.GetBlue()), m_Alpha(color.GetAlpha()) {};
		OAGColor(BYTE red, BYTE green, BYTE blue, BYTE alpha = 255) : m_Red(red), m_Green(green), m_Blue(blue), m_Alpha(alpha) {};
        ~OAGColor(void){};

		//Attributes
	private:
		BYTE  m_Red, m_Green, m_Blue, m_Alpha;

		//Operations
	public:
		void SetColor( OAGColor& color, BYTE Alpha = 255);
		void SetColor( BYTE red, BYTE green, BYTE blue, BYTE Alpha = 255);
		void SetAlpha( BYTE alpha ) { m_Alpha = alpha; };
		BYTE GetRed()	{ return m_Red; };
		BYTE GetGreen()	{ return m_Green; };
		BYTE GetBlue()	{ return m_Blue; };
		BYTE GetAlpha()	{ return m_Alpha; };

		BYTE* GetColor3ubv()
		{
			static BYTE ubv_color[3];

			ubv_color[0] = m_Red;//m_Palette[color].GetR();
			ubv_color[1] = m_Green;//m_Palette[color].GetG();
			ubv_color[2] = m_Blue;//m_Palette[color].GetB();

			return ubv_color;
		}

		BYTE* GetColor4ubv()
		{
			static BYTE ubv_color[4];

			ubv_color[0] = m_Red;
			ubv_color[1] = m_Green;
			ubv_color[2] = m_Blue;
			ubv_color[3] = m_Alpha;
			return ubv_color;
		}

		float* GetFloatValues()
		{
			static float values[4];

			float fRed, fGreen, fBlue, fAlpha;
			fRed = m_Red; fGreen = m_Green; fBlue = m_Blue; fAlpha = m_Alpha;		

			values[0] = fRed/255;
			values[1] = fGreen/255;
			values[2] = fBlue/255;
			values[3] = fAlpha/255;

			return values;
		}


	};
};

#endif //OAG_OAGCOLOR_H

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Brazil Brazil
I live in Matão, a small city in Brazil. I studied as Programmer in a College for Software Development in Database.
After finishing the College I have been working with java, c# and Computer Graphics with searches for OpenGL.

Comments and Discussions