I've been rewrapping the entire OpenGL 4.5 api inside classes.
Long story short: Is it worth it? Will somebody find it useful?
Long story long:
Here's my testcase (which shows api and such):
http://pastebin.com/wDXbuEyd
The multiple iterations are simply used to calculate performance.
This (custom, huge, and procedurally generated from glcorearb.h) header is also required:
http://pastebin.com/rsE92pLP (Implementation is somewhere else, this is a library in my project).
For the more curious readers, the shader is a really simple 1-by-1 equivalent of the CPU version, as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#version 430
layout (local_size_x=1, local_size_y=1) in;
layout(std430, binding = 0) buffer Destination {
float result[];
} dst;
layout(std430, binding = 1) buffer SourceA {
float data[];
} srca;
layout(std430, binding = 2) buffer SourceB {
float data[];
} srcb;
uniform uint length;
void main() {
for(uint i = 0; i < length; ++i)
dst.result[i] = sqrt((sqrt(srca.data[i]) * sqrt(srcb.data[i])) *
sqrt(srca.data[i]*srcb.data[i]));
}
| |
Another note about the available customizations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
/* These are all the configuration's defines:
*
* Debug Only (NDEBUG not defined):
* GLPP_DEBUG_NO_COUNT
* Avoid counting OpenGL objects
* GLPP_DEBUG_COUNT_ALL
* Count all OpenGL objects and interfaces
* Neither one:
* Count all OpenGL objects
* Release Only (NDEBUG defined):
*
* Debug/Release Indipendent:
* GLPP_NO_EXCEPTIONS
* Do not throw exception or check glError every time a function is called.
* This also does not throw an exception in case the context is destroyed.
* You may want to define GLPP_NO_KEEP_CONTEXT too, for perfomance reasons.
* GLPP_NO_KEEP_CONTEXT
* Do not store context pointer state in OpenGL objects.
* Note: Also defines GLPP_NO_CHECK_CONTEXT.
* GLPP_NO_CHECK_CONTEXT
* Do not check for context validity every time a function is called
* GLPP_NO_CHECK_FUNCTIONS
* Do not check for functions to be in the current context every time a
* function is called. Only works for OpenGL objects.
* Recommended for Release builds only.
*
*/
| |
Back to the question: Is this an overkill?
All the required items in the snippet over do work, and the test's results are correct, but I had to change the implementation multiple times (context-checking, function-checking, error-checking) and I feel really tired about going through code I already changed to make other changes.
Side note: -- what the hell AMD? I've tried doing the above test using a lot of memory, and you let the gfx card allocate that much memory. Not only it couldn't allocate 0xFFFFFF * 12 bytes of memory (3x67mb contiguous vram chunks), but the drivers also crashed, and the PC froze! Error checking anywhere?
In case an error happens, an exception is correctly thrown, along with a (sadly) english-only description.
Localization not a priority right now, but GLPP_NO_EXCEPTIONS disables exception-throwing and all internal glError calls, even in form of GLContext::CheckErrors.
GLPP_NO_KEEP_CONTEXT disables reference counting, and only stores a plain pointer to the GLContext and GLFunctions.
GLPP_NO_CHECK_CONTEXT disables context checking. Basically only useful if GLPP_NO_KEEP_CONTEXT is disabled.
In case the context has been deleted, GLPP_CONTEXT_DELETED is the error-code.
GLPP_NO_CHECK_FUNCTIONS checks for functions before calling, and throws GLPP_NOT_IN_CONTEXT as error-code.