I'm designing a user-friendly interface for working with modern OpenGL, and I have a few concerns regarding some areas.
1) Vertex Buffer Objects - would it be safe to assume that the data will always be in a format that has 1 meaning, and 1 meaning only? What I was thinking about doing was hiding the attribute pointers inside the class that wraps the concept of a VBO. However doing so would prevent using the same VBO in a different context without copying it (expensive). I can't for the life of me think of a time when VBO data could be re-used and re-interpreted in a different way, with different attribute pointers. Can you? A small mock-up below:
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 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <array>
#include <cstdint>
#include <list>
#include <string>
/// Basically manages various platform-specific configurations
#include "Platform.hpp"
namespace detail
{
struct AttributePointerBase
{
// Fiddle with state and call glVertexAttrib*Pointer
virtual void bind(GLuint programHandle) = 0;
virtual void unbind() = 0;
}
struct AttributePointer /* : public AttributePointerBase */;
struct AttributeIPointer /* : public AttributePointerBase */;
struct AttributeLPointer /* : public AttributePointerBase */;
}
class VertexBuffer
{
std::list<AttributePointerBase> attributes;
public:
void setAttributePointer(/* ... */);
void setAttributeIPointer(/* ... */);
void setAttributeLPointer(/* ... */);
// ...
void bind(GLuint programHandle)
{
for(AttributePointerBase& attr : attributes)
{
attr.bind(programHandle);
}
}
// ...
};
|
2) http://www.opengl.org/sdk/docs/man4/xhtml/glUseProgram.xml#Errors
"GL_INVALID_OPERATION is generated if program could not be made part of current state."
WHAT! Ambiguous anyone? How am I to report to the user a call to the implementation failed going on that ambiguous failure condition. Is there any more detailed documentation available?
3) I'll re-use this thread if / when a new issue arises.
Thanks in advance for any input!
* Current progress can be tracked @ https://bitbucket.org/DarkHeart/opengl
The license is the most clever part of the whole project.