Click here to Skip to main content
15,892,005 members
Articles / Multimedia / OpenGL

anyTex - a class for non-restrictive textures in OpenGL

Rate me:
Please Sign up or sign in to vote.
4.85/5 (12 votes)
24 Jul 2005CPOL4 min read 62.9K   2.9K   20  
anyTex - a class for non-restrictive textures in OpenGL.
#if !defined(AFX_ANYTEX_H__INCLUDED_)
#define AFX_ANYTEX_H__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AnyTex.h : header file
//

#include <afxtempl.h> // for CList support

// OpenGL staff
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>

/////////////////////////////////////////////////////////////////////////////
class DibSupport
{
// Construction / Distruction
public:
	DibSupport() { hDIBMap = NULL; }
	virtual ~DibSupport() {}
public:
	HGLOBAL hDIBMap;
	void * lpBits;
	BITMAPINFO * lpBitmapInfo;
};

/////////////////////////////////////////////////////////////////////////////
// AnyTex window

class AnyTex
{
// Construction / destruction
public:
	AnyTex();
	virtual ~AnyTex();

// Attributes
public:
	DibSupport m_dib;
	CDC	*m_pDC;
protected:
	int m_nTexRows;
	int m_nTexCols;
	CList <UINT, UINT> m_listTex;
	int m_nTexCellSize;
	int m_nSceneHeight;
	int m_nSceneWidth;
	HGLRC m_hRC;

// Methods
public:
	UINT RetrieveTexCell(double atX, double atY, double &renLeft, double &renTop, double &renSize);
	int SetTexCellSize(int nSize);
	void CreateTex(bool asMipmaps = false);
	void Render();
	virtual void PreRender();
	HANDLE DDB2DIB(CBitmap *pBmp, DWORD dwCompression, CPalette *pPal);
	bool LoadBmpImage(char far *filename);
	bool SpecifyPixelFormat(PIXELFORMATDESCRIPTOR *pPFD = NULL);
	void ResizeGLScene(int width, int height);
	COLORREF m_colorBkGnd;
	bool InitializeOpenGL(CWnd *pOglWnd);
};

#endif // !defined(AFX_ANYTEX_H__INCLUDED_)

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 (Senior)
Europe Europe
More than 30 years of software development experience.
(also playing the SCRUM Master role depending on the project)

Comments and Discussions