dhpoware logo
navbar
home products source demos contact us
navbar navbar
box top left corner box top right corner
 
 
OpenGL 3 Framework.

This is the new application framework that we are developing for all future Windows OpenGL 3.x and 4.x demos. All of our existing OpenGL demos are written in C++ but use a very procedural C style. That's fine for small demos and throw away sample applications that only exist to demonstrate a programming concept, but for more substantial applications an object oriented approach is preferable to a procedural approach.

We have taken many of the existing OpenGL demos and consolidated much of the common code into a single GL3Application class. Please refer to the included main.cpp file for an example on how to use the framework.

Note:
This is an OpenGL 3.x and 4.x application framework. Undefined behaviour may result when run on OpenGL 2.x and OpenGL 1.x hardware.

screenshot

zip file Download source, and Visual C++ 2010 solution files.

Change History:

31 January 2012.
gl.h, gl.cpp: The utility functions in the gl namespace are no longer declared as being extern "C". Added new function GetExtensions(). Updated the ExtensionSupported() function to internally call GetExtensions().

main.cpp: Added method testSupportedExtensions() to test the GetExtensions() function.

31 October 2011.
application.cpp: Updated the GL3Application::windowProcImpl() method is process the following Windows events: WM_SYSKEYDOWN, WM_SYSKEYUP, WM_SYSCOMMAND. Updated the GL3Application::windowProcImpl() method to prevent the screensaver from running.

27 August 2011.
application.h, application.cpp: Added new method GL3Application::preferOpenGLVersion(). This method is used to instruct the framework to create a specific version of the OpenGL rendering context. Added a new method GL3Application::glVersion() used to return the actual OpenGL rendering context version created by the framework.

gl.h: Added new symbols and function prototypes for OpenGL 4.2

gl.cpp: Added new functions to support OpenGL 4.2.

26 April 2011.
All of the classes in the OpenGL 3 Framework are now in the dhpoware namespace.

shader.h, shader.cpp: Initial release of the Shader class. The Shader class is a wrapper around the OpenGL Shader APIs. It contains all of the shader utility methods previously in the GL3Application class. Refer to the comments in the shader.h header file for further details and usage examples.

texture.h, texture.cpp: Initial release of the Texture2D class. The Texture2D class expands on the Texture2D structure that was previously declared in the application.h header file. Most of the previous texture loading functionality built into the GL3Application class has been moved into the Texture2D class. Refer to the comments in the texture.h header file for further details and usage examples.

24 October 2010.
The framework now uses a time-based, fixed interval main loop. The maximum frame rate is now capped to 60 frames per second.

24 September 2010.
main.cpp: Updated the init() method to display the OpenGL version in the window's title bar.

application.cpp: Updated the initOpenGL() method to create rendering contexts in the following order:
OpenGL 4.1, OpenGL 4.0, OpenGL 3.3, OpenGL 3.2, OpenGL 3.1, and OpenGL 3.0 forward compatible.

gl.h: Added new symbols and function prototypes for OpenGL 4.1.

gl.cpp: Added new functions to support OpenGL 4.1.

10 July 2010.
Added missing .vcxproj.filters file to the project.

13 June 2010.
Updated solution to Microsoft Visual Studio 2010.

3 April 2010.
Added initial support for OpenGL 3.3 and OpenGL 4.0.

main.cpp: Rewrote sample Demo class to more closely match the new OpenGL 3 demos.

gl.h: Added new symbols and function prototypes for OpenGL 3.3 and OpenGL 4.0.

gl.cpp: Added new functions to support OpenGL 3.3 and OpenGL 4.0.

28 February 2010.
application.cpp:

Fixed bug in initOpenGL() method where the glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) function call was returning 1 because it was being called before a valid OpenGL 3 rendering context was active.

Fixed bug in loadTexture2D(std::tr1::shared_ptr<Gdiplus::Bitmap>&, GLint, GLint, GLint, GLint) method where anisotropic texture filtering was being ignored when m_degreeOfAnisotropy was set to BEST_DEGREE_OF_ANISOTROPY by the preferAnisotropicTextureFiltering() method.

26 February 2010.
application.h, application.cpp:

Documented each of the members of the Texture2D structure.

Removed method: saveTexture2D(const Texture2D *).

Added new public methods: hInstance(), hWnd(), loadFragmentShaderFromResource(int), loadVertexShaderFromResource(int), loadShaderProgramFromResource(int, int), loadTexture2DFromResource(int), loadTexture2DFromResource(int, GLint, GLint, GLint, GLint), saveTexture2D(const Texture2D *, const char *), saveTexture2D(const Texture2D *, const char *, const char *), windowTitle().

Added new protected virtual method wndProc() to allow subclasses of the GL3Application to customize the windows procedure. Added new private methods: loadShaderFromResource(int, GLenum), loadShaderProgramFromResource(GLuint, GLuint), loadTexture2D(std::tr1::shared_ptr<Gdiplus::Bitmap> &, GLint, GLint, GLint, GLint).

Added new member variable: m_shaderFilenames.

Removed the const modifier from the private loadShader() method.

Modified implementation of the loadShader(const char *, GLenum) method to store the shader file name based on the shader object id.

Modified implementation of the loadShaderProgram(const char *, const char *) method to call loadVertexShader(const char *),
loadFragmentShader(const char *), and loadShaderProgram(GLuint, GLuint).

Modified implementation of the loadTexture2D(const char *, GLint, GLint, GLint, GLint) method to call loadTexture2D(std::tr1::shared_ptr<Gdiplus::Bitmap> &, GLint, GLint, GLint, GLint).

Removed existing implementation of the saveTexture2D(const Texture2D *) method.

Added initial implementation of the loadFragmentShaderFromResource(int) method.
Added initial implementation of the loadVertexShaderFromResource(int) method.
Added initial implementation of the loadShaderProgramFromResource(int, int) method.
Added initial implementation of the loadTexture2DFromResource(int) method.
Added initial implementation of the loadTexture2DFromResource(int, GLint, GLint, GLint, GLint) method.
Added initial implementation of the saveTexture2D(const Texture2D *, const char *) method.
Added initial implementation of the saveTexture2D(const Texture2D *, const char *, const char *) method.
Added initial implementation of the loadShaderFromResource(int, GLenum) method.
Added initial implementation of the loadShaderProgram(GLuint, GLuint) method.
Added initial implementation of the loadTexture2D(std::tr1::shared_ptr<Gdiplus::Bitmap> &, GLint, GLint, GLint, GLint) method.
Added initial implementation of the wndProc() virtual method.

26 September 2009.
Updated with latest code changes from the OpenGL 3.1 Hello World Demo released on the 26 September 2009.

11 August 2009.
application.cpp: Updated initOpenGL() method to use the gl::ExtensionSupported() function to query supported OpenGL extensions.

gl.cpp: Added new private functions: DummyGLWndProc(), CreateDummyGLWindow(), and DestroyDummyGLWindow(). Updated ExtensionSupported() function to cache all of the extensions returned by GL_EXTENSIONS and wglGetExtensionsStringARB(). The ExtensionSupported() function creates a dummy hidden window with an OpenGL rendering context in order to retrieve all supported extensions.

WGL_ARB_extensions_string.h, WGL_ARB_extensions_string.cpp: Removed. Functionality moved into the gl::ExtensionSupported() function in the framework's gl module.

10 August 2009.
Updated to match the version of the framework used in the OpenGL 3 Hello World Demo.

application.h: Added new Texture2D structure. The GL3Application class can now load the following image file formats via GDI+: BMP, GIF, JPG, PNG, TGA, and TIF. Added new methods: preferAnisotropicTextureFiltering(), loadFragmentShader(), loadVertexShader(), loadTexture2D(), programInfoLog(), shaderInfoLog(), saveTexture2D(), loadShader(), getEncoderClsid().

application.cpp: Added new methods: preferAnisotropicTextureFiltering(), loadFragmentShader(), loadVertexShader(), loadTexture2D(), programInfoLog(), shaderInfoLog(), saveTexture2D(), loadShader(), getEncoderClsid(). Fixed bug in initOpenGL() method where a default pixelformat was not being used if the specified multisampled pixelformat isn't supported.

gl.cpp: OpenGL 3 deprecates the GL_EXTENSIONS flag for the glGetString() function. The ExtensionSupported() function has been updated to call the glGetStringi() function.

6 July 2009.
application.h: Renamed exit() method to quit(). The GL3Application now caches class instances of the Keyboard and Mouse classes. Added various keyboard convenience methods: keyDown(), keyPressed(), and keyUp(). Added various mouse convenience methods: mouseButtonDown(), mouseButtonPressed(), mouseButtonUp(), mousePositionX(), and mousePositionY().

application.cpp: Renamed exit() method to quit().

main.cpp: Updated to use new keyboard convenience methods.

5 June 2009.
application.h: Made destructor virtual. Made virtual methods protected. Added private copy constructor and assignment operator to prevent GL3Application objects from being copied.

main.cpp: Added missing virtual keyword to the destructor, and the init() and update() methods.

 
box bottom left corner content box box bottom right corner
logo logo