Click here to Skip to main content
15,897,518 members
Articles / Desktop Programming / MFC

OpenGL MFC AppWizard

Rate me:
Please Sign up or sign in to vote.
4.79/5 (10 votes)
15 Jan 2009GPL36 min read 155.6K   5.4K   68  
An article showing how to make a Custom AppWizard for OpenGL applications in Visual Studio .NET 2008
//	DIBSurface.h
//	Copyright (C) Dave Kerr
//
//	This is an abstaction of a DIB surface.

#pragma once

#include <atlimage.h>

class CDIBSurface
{
public:
	CDIBSurface();
	virtual ~CDIBSurface();

	//	Creation/Destruction
	virtual bool	Create(int nWidth, int nHeight, int nBitCount = 24, void* pData = NULL);
	virtual void	Destroy(bool bHDC = true, bool bHBMP = true);

	//	Image Functions
	void			CreateImage(CImage& image);

	//	Palette / Pixel format
	void			SetPalette(CPalette* pPal);
	virtual bool	SetPixelFormat(int nBitCount);

	//	Diagnostics
	bool			IsValid();

	//	Device context
	CDC*			GetDC() {return m_pDC;}

	//	Drawing
	virtual void	SetPixel(int x, int y, COLORREF cl);
	virtual void	Draw(CDC* pTargetDC, int x, int y);
	virtual void	Draw(HDC hDC, int x, int y);
	virtual void	DrawMapped(CDC* pTargetDC, int x, int y, int cx, int cy);
	virtual void	Erase(COLORREF clColour);

	//	Accessors
	int				GetWidth() const {return m_szDIB.cx;}
	int				GetHeight() const {return m_szDIB.cy;}
	int				GetBitCount() const {return (int)m_byBitCount;}
	void*			GetData() {return m_pBits;}

protected:
	//	Member data
	CSize			m_szDIB;
	CDC*			m_pDC;
	HBITMAP			m_hBmp;
	HBITMAP			m_hBmpOld;
	void*			m_pBits;
	BYTE			m_byBitCount;	//	8,16,24 supported.
};

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 GNU General Public License (GPLv3)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions