Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 

Writing a Platform and GUI Toolkit Independent OpenGL Class

By , 1 Nov 2010
 
basecode.zip
basecode
linux.zip
linux
MultiGL
buildall.sh
GLView
.cproject
.project
aclocal.m4
autom4te.cache
output.0
output.1
output.2
requests
traces.0
traces.1
traces.2
config.guess
config.h.in
config.sub
configure
configure.ac
depcomp
install-sh
ltmain.sh
m4
libtool.m4
lt~obsolete.m4
ltoptions.m4
ltsugar.m4
ltversion.m4
Makefile.am
Makefile.in
missing
src
Makefile.am
Makefile.in
GLViewGTKApp
.cproject
.project
aclocal.m4
AUTHORS
autogen.sh
autom4te.cache
output.0
output.1
requests
traces.0
traces.1
ChangeLog
config.guess
config.h.in
config.sub
configure
configure.in
COPYING
depcomp
glviewgtkapp.glade
glviewgtkapp.gladep
INSTALL
install-sh
Makefile.am
Makefile.in
missing
mkinstalldirs
NEWS
po
ChangeLog
Makefile.in.in
POTFILES.in
README
src
Makefile.am
Makefile.in
stamp-h.in
GLViewMotifApp
.cproject
.project
aclocal.m4
autom4te.cache
output.0
output.1
requests
traces.0
traces.1
config.h.in
configure
configure.ac
depcomp
install-sh
Makefile.am
Makefile.in
missing
src
Makefile.am
Makefile.in
GLViewQtApp
.cproject
.project
GLViewQtApp.ico
GLViewQtApp.pro
GLViewQtApp.pro.user
glviewqtapp.qrc
glviewqtapp.ui
Makefile
Resources
run.sh
win32.zip
win32
MultiGL
GLView
GLView.cpp.bak
GLView.suo
GLViewGTKApp
AUTHORS
autogen.sh
ChangeLog
configure.in
devcpp
glviewgtkapp.dev
glviewgtkapp.glade
glviewgtkapp.gladep
Makefile.am
msvc
glviewgtkapp.suo
NEWS
po
ChangeLog
POTFILES.in
README
src
Makefile.am
stamp-h.in
GLViewMFCDlgApp
GLViewMFCDlgApp.aps
res
GLViewMFCDlgApp.ico
GLViewMFCMDIApp
res
buttons.bmp
filelarge.bmp
filesmall.bmp
GLViewMFCMDIApp.ico
GLViewMFCMDIAppDoc.ico
main.bmp
Toolbar.bmp
Toolbar256.bmp
writelarge.bmp
writesmall.bmp
GLViewQtApp
GLViewQtApp
GLViewQtApp.ico
GLViewQtApp.pro
glviewqtapp.qrc
glviewqtapp.ui
Makefile
moc_glviewqtapp.o
Resources
MultiGL.suo
// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the GLVIEW_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// GLVIEW_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
// We add the condition WIN32 for UNIX/Linux portability
#ifdef GLVIEW_EXPORTS
#ifdef WIN32
#define GLVIEW_API __declspec(dllexport)
#else
#define GLVIEW_API
#endif
#else
#ifdef WIN32
#define GLVIEW_API __declspec(dllimport)
#else
#define GLVIEW_API
#endif
#endif


#ifdef WIN32
#include <windows.h> // required by OpenGL and must be included before gl.h
#include <TCHAR.H>  // for unicode support
#endif

#include <GL/gl.h>
#include <GL/glu.h>

#ifndef WIN32
#include <GL/glx.h>
#endif

// This class is exported from the GLView.dll
class GLVIEW_API CGLView 
{
public:
	CGLView(void);

#ifdef WIN32
	void SetWindow(HWND ihWnd);
#else
	void SetWindow(Display* pDisp, const Window& wnd);
#endif
	bool SetupGLContext(bool iSetPixelFormat);
	void Resize(unsigned short iWidth, unsigned short iHeight);
	void RenderScene(void);
	void Refresh( void);

private:
#ifdef WIN32
	int SetPixelFormat(HDC hdc);
#endif
	void Setup3DEnvironment();
	void DrawGradientBackground();
	void InitDisplayLists();
	void DoAntialiasing();

private:

#ifdef WIN32
	HWND m_hWnd;
	HDC  m_hDC;
	HGLRC m_hGLRC;
#else
	Display* m_pXDisplay;
	int m_iXScreen;
	Window m_iXWindow;
	GLXContext m_hGLContext;
	XVisualInfo *m_hVisual;
	Colormap m_ColMap;
#endif

	GLdouble nRange;	
	GLdouble win_xmax,
		win_xmin,
		win_ymax,
		win_ymin,
		winz,
		winH,
		winW;

	bool m_bGradientBg;
	bool m_bAntiAlias;

	GLubyte bgTopR;
	GLubyte bgTopG;
	GLubyte bgTopB;
	GLubyte bgBotR;
	GLubyte bgBotG;
	GLubyte bgBotB;

	GLfloat ambiLight[4];
	GLfloat diffLight[4];
	GLfloat specLight[4];

};



void GLVIEW_API drawTorus(int numMajor, int numMinor, float majorRadius, float minorRadius, bool bShaded = true);


By viewing downloads associated with this article you agree to the Terms of use 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)

About the Author

Sharjith
Engineer Tata Technologies Inc
United States United States
Member
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 1 Nov 2010
Article Copyright 2010 by Sharjith
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid