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

OpenGL MFC AppWizard

, 15 Jan 2009
An article showing how to make a Custom AppWizard for OpenGL applictions in Visual Studio .NET 2008
OpenGLApplication.zip
OpenGLApplication
OpenGLApplication
res
OpenGLApplication.ico
Toolbar.bmp
OpenGLWizard.zip
OpenGLWizard
OpenGLWizard
1033
Images
DottedHori.gif
DottedVert.gif
spacer.gif
HTML
1033
Images
OpenGLWizard.png
OpenGLWizard_Background.gif
OpenGLWizard.ico
OpenGLWizard.vsdir
OpenGLWizard.vsz
Scripts
1033
Templates
1033
res
OpenGLApplication.ico
Toolbar.bmp
Templates.inf
//  OGLView.cpp
//  Created by Dave Kerr, 20/04/2002 22:44:15

#include "stdafx.h"
#include "OpenGLView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

IMPLEMENT_DYNCREATE(COpenGLView, CView)

BEGIN_MESSAGE_MAP(COpenGLView, CView)
	ON_WM_ERASEBKGND()
	ON_WM_SIZE()
	ON_WM_DESTROY()
END_MESSAGE_MAP()

void COpenGLView::OnDraw(CDC* pDC)
{
	//	Make the OpenGL Surface current.
	m_openGLSurface.MakeCurrent();

	//	Do any opengl drawing.
	DoOpenGLDraw();

	//	Now blit the lot into the DC.
	m_openGLSurface.Draw(pDC, 0, 0);

	//	Deactivate the surface.
	m_openGLSurface.MakeNoneCurrent();
}

#ifdef _DEBUG
void COpenGLView::AssertValid() const
{
	CView::AssertValid();
}

void COpenGLView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

BOOL COpenGLView::OnEraseBkgnd(CDC* pDC) 
{
	//	The DIB Surface handles erasing the background.
	return TRUE;
}

void COpenGLView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);

	//	If size is silly (x=0 || y=0) don't create.
	if(cx == 0 || cy == 0)
		return;
	
	//	Recreate our DIB surface using the correct size.
	m_openGLSurface.Create(cx, cy, 24);

	//	Call the override - this'll handle the viewport projection.
	DoOpenGLResize(cx, cy);
}

void COpenGLView::OnDestroy() 
{
//	CView::OnDestroy();

	//	Destroy the surface.
	m_openGLSurface.Destroy();	
}

BOOL COpenGLView::PreCreateWindow(CREATESTRUCT& cs) 
{
	cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;

	if(cs.style&CS_PARENTDC)
		cs.style -= CS_PARENTDC;	
	
	return CView::PreCreateWindow(cs);
}

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)

Share

About the Author

Dave Kerr
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.
Follow on   Twitter

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 15 Jan 2009
Article Copyright 2009 by Dave Kerr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid