Click here to Skip to main content
15,886,362 members
Articles / Multimedia / OpenGL

Generating Outlines in OpenGL

Rate me:
Please Sign up or sign in to vote.
4.78/5 (12 votes)
7 Oct 20045 min read 199K   5K   52  
Using multi-pass techniques to generate outlines in OpenGL.
// OGLDemoView.h : interface of the COGLDemoView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_OGLDEMOVIEW_H__B1294A49_C25D_4B21_9705_6C704D184C84__INCLUDED_)
#define AFX_OGLDEMOVIEW_H__B1294A49_C25D_4B21_9705_6C704D184C84__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class COGLDemoView : public CView
{
protected: // create from serialization only
	COGLDemoView();
	DECLARE_DYNCREATE(COGLDemoView)

// Attributes
public:
	COGLDemoDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(COGLDemoView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void OnInitialUpdate();
	//}}AFX_VIRTUAL

// Implementation
public:
	int DrawGLScenePolygonOffset();
	int DrawGLSceneStencil();
	int DrawGLSceneStencilDisplayList();
	int CreateDisplayLists();
	virtual ~COGLDemoView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CWGL m_wgl;
	float m_rtri;
	float m_rquad;
	bool m_bResizing;

	void RenderMesh1();
	void RenderMesh2();
	void RenderMesh3();
	bool m_listCreated;

	enum RenderType {
		eRenderPolygon,
		eRenderStencilBuffer,
		eRenderStencilBufferWithDisplayList
	};

	RenderType m_renderType;

// Generated message map functions
protected:
	//{{AFX_MSG(COGLDemoView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnRenderPolygonoffset();
	afx_msg void OnRenderStencilbuffer();
	afx_msg void OnRenderStencilbufferwithdisplaylist();
};

#ifndef _DEBUG  // debug version in OGLDemoView.cpp
inline COGLDemoDoc* COGLDemoView::GetDocument()
   { return (COGLDemoDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_OGLDEMOVIEW_H__B1294A49_C25D_4B21_9705_6C704D184C84__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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
I started programming on 8 bit machines as a teenager, writing my first compiled programming language before I was 16. I went on to study Engineering and Computer Science at Oxford University, getting a first and the University Prize for the best results in Computer Science. Since then I have worked in a variety of roles, involving systems management and development management on a wide variety of platforms. Now I manage a software development company producing CAD software for Windows using C++.

My 3 favourite reference books are: Design Patterns, Gamma et al; The C++ Standard Library, Josuttis; and Computer Graphics, Foley et al.

Outside computers, I am also the drummer in a band, The Unbelievers and we have just released our first album. I am a pretty good juggler and close up magician, and in my more insane past, I have cycled from Spain to Eastern Turkey, and cycled across the Namib desert.

Comments and Discussions