glext++
- From: aku ankka <jukka@xxxxxxxxxxxx>
- Date: Mon, 08 Oct 2007 03:19:04 -0700
Announcing a work-in-progress preview/snaphot of glext++ library @
www.liimatta.org ;
http://www.liimatta.org/misc/glext++105.zip
The purpose of the library is to provide Yet Another OpenGL Extension
Initialization Library (YAOGLEIL) and platform abstraction between
GLX, WGL, AGL and EGL (aka. alphabet soup).
Here is the sourcecode for a simple glext++ application:
#include <cmath>
#include "glext.hpp"
class Application : public WindowMessage
{
glContext* context;
public:
Application()
{
context = glextCreateContext(640, 480, "OpenGL example", 32, 16, 0);
if ( context )
glextEnterMain(context, this);
}
~Application()
{
if ( context )
glextDeleteContext(context);
}
void idle()
{
glClearColor(0.4f, 0.10f, 0.10f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
glextSwapBuffers(context);
}
void resize(int width, int height)
{
glViewport(0, 0, width, height);
glScissor(0, 0, width, height);
}
};
int main()
{
Application application;
return 0;
}
The history behind this is not wheel reinvention related, when the
code was written none of these current extension initialization
libraries existed (GLee, glew, etc.). The approach to extension
initialization is easier to maintain and cleaner than the usual
approaches the author has witnessed over the years. The declaration,
definition AND initialization are all handled with a single entry (see
glextproc.hpp for details).
API
These can be used as stand-alone for extension initialization and
queries:
void glextInitExtensions();
int glextGetVersion();
bool glextIsExtension(const char* name);
The glextGetVersion() returns major version * 100, minor version * 10,
and implementation specific version * 1, so it is easy to detect if
OpenGL 2.1 for example is present:
if ( glextGetVersion() >= 210 ) { ... }
These methods are related to context creation and abstracting platform
specific details:
glContext* glextCreateContext(int width, int height, const char*
title, int colorBits, int depthBits, int stencilBits);
void glextDeleteContext(glContext* context);
void glextSwapBuffers(glContext* context);
void glextEnterMain(glContext* context, WindowMessage* listener);
void glextBreakMain(glContext* context);
The glextEnterMain() starts message handling loop, which will dispatch
messages to the listener object (see the simple glext++ application
source code above for example of this). The glextBreakMain() breaks
out of the message handling loop.
While the render context creation can be kept separate from the
platform specific window creation code, it is not practical; for
example on WGL you need HWND to create the context, and on GLX you
need the context to create the window. It makes sense to combine the
two, however, flexibility for a *specific* platform is lost, hence,
this code is kept separate from the extension initialization code so
that it can be still used in custom application.
Since the library takes over window creation, and needs the window
message handler when creating the window on some platforms (Windows),
it again makes sense we handle the messages and dispatch them to the
client. At this stage the question is how we can send the messages to
the client; glext++ uses the listener object paradigm.
This is still work-in-progress like mentioned before; this is actually
code being taken out of larger, more complicated (!) and mature
library. It is not small amount of work to remove tons of dependencies
to other code in the "other" library (glFusion, OpenGL rendering
engine on top of platform abstraction/foundation library called
fusion). So far glext++ has lifted GLX, WGL, extension initialization
and some of the message handling callback code while doing some minor
re-factoring to satisfy the growing criticism towards old code. :)
The OGL caps enumeration and more detailed initialization is still
taking shape, the old system uses std containers and iterators to
enumerate the combinations. glext++ tries to minimize dependencies to
the C++ Standard Library so that code will take still a while to
refactor so that it satisfies the author(s). ;-)
There is still work to be done and criticism will be totally ignored
(we are perfect).
--
A. Ankka
Disclaimer: The opinions of A.A. do not reflect opinions of Ankkalinna
in anyway.
.
- Follow-Ups:
- Re: glext++
- From: aku ankka
- Re: glext++
- Prev by Date: Re: Display problems in Vista
- Next by Date: Re: Display problems in Vista
- Previous by thread: Glut window with no window decorations,
- Next by thread: Re: glext++
- Index(es):
Relevant Pages
|