Click here to Skip to main content
15,894,176 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 56.3K   56  
OAG is a library written in C++. With this library, you can create OpenGL based applications.
#ifndef OAG_OAGTEXTURE_H
#define OAG_OAGTEXTURE_H

#ifdef _MSC_VER

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

#endif

#ifdef _WIN32
#include <gl/gl.h>
#include <gl/glu.h>
#include "..\..\..\Common\include\OAGVector3f.h"
#include "..\..\..\IOSystem\include\FileSystemFilter.h"
#endif

typedef enum _OAG_TEXTURE_FILTER_TYPE{
	txNoFilter	= 0,
	txBilinear	= 1,
	txTrilinear	= 2,
}OAG_TEXTURE_FILTER_TYPE;

typedef	struct _OAG_TEXTURE
{
	GLubyte					*imageData;
	GLuint					glTexture[1];	// Texture ID Used To Select A Texture
	//glTextureFilterType	glTexTureType;	// Texture Format
	GLuint					Width;			// Image Width
	GLuint					Height;			// Image Height
	GLuint					Bpp;			//Image Color Depth In Bits Per Pixel
	GLuint					Type;
  
	GLenum format;  
	GLint internalFormat;

}OAG_TEXTURE;

typedef enum _OAG_TEXTURE_MAPPING
{
	OAG_TEXTURE_NOT_DEFINED
	,OAG_TEXTURE_MAP_RECT
	,OAG_TEXTURE_MAP_TRIANGLE
}OAG_TEXTURE_MAPPING;

namespace oag
{
	class OAGTexture
	{
	public:
		OAGTexture(void);
		virtual ~OAGTexture(void);

	//Attributes
	protected:
		bool					m_bIsTextureLoaded;
		GLuint					m_nWidth, m_nHeight;

		int						m_nVectorPos;
		oag::OAGVector3f		m_position;
		oag::OAGVector3f 		m_TextureVertices;

		OAG_TEXTURE				m_glTexture;

		BYTE					m_RedAlphaMatch, m_GreenAlphaMatch, m_BlueAlphaMatch;
		bool					m_bApplyAlphaColor;

		std::string				m_strName;
		std::string				m_strFolderPath, m_strFilename;

	public:
		GLuint					m_glTextureId;
		OAG_TEXTURE_MAPPING		m_enumTextureMapping;		
		std::vector<float>		m_nTextureCoordinates;
		std::vector<double>		m_nTextureVertices;		
		int						m_nNumberOfPoints;

	//Operations
	private:
		
	public:
		void CreateTextureVertices();

		std::string GetFileName()
		{
			return m_strFilename;
		}

		//Gets the current name set for the texture
		std::string GetTextureName()
		{ 
			return m_strName; 
		}

		GLuint GetTextureWidth()
		{ 
			return m_nWidth;
		}
		
		GLuint GetTextureHeight()
		{ 
			return m_nHeight;
		}
		
		GLuint GetTextureId()
		{ 
			return m_glTextureId;
		}		
		
		bool IsTextureLoaded()
		{ 
			return m_bIsTextureLoaded;
		}
		
		//Sets the position for the texture or translation
		void SetPosition(oag::OAGVector3f vector)
		{ 
			m_position = vector;
		}

		//Sets the position for the texture or translation
		void SetPosition(float x, float y, float z)
		{ 
			m_position.SetVertex(x, y, z);
		}

		//Sets a for the object
		void SetTextureName(std::string strName)
		{
			m_strName = strName; 
		}

		void SetTextureWidth(GLuint nWidth)
		{ 
			m_nWidth = nWidth;
		}
		
		void SetTextureHeight(GLuint nHeight)
		{ 
			m_nHeight = nHeight;
		}
		
		void SetIOSystemFilter(std::string folderPath, std::string fileName)
		{
			m_strFolderPath = folderPath;
			m_strFilename = fileName;
		}


	
	//static
		static std::string GetExtension (const std::string& pFile);

	//virtual
	protected:

	public:
		virtual bool LoadTextureFromDisk(std::string strFileName){ return false; }	// Loads a file as a texture
		virtual void CreateTextureCoordinates();
		virtual void BuildTexture(){}
		virtual void SetDefaultFilter(){}

		//Filters
		void SetFilterTexParameteri(GLenum target, GLenum pname, GLint param)
		{
			glTexParameteri(target, pname, param);
		}

	};
};

#endif //OAG_OAGTEXTURE_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