Is there a good way to unit test a function or a class using OpenGL commands?
For c++, I know I could make the class a template and pass a class doing direct opengl calls :
namespace myNamespace
{
struct RealOpenglCall
{
static inline void glVertex2fv( const GLfloat * v)
{ ::glVertex2fv( v ); }
};
template< typename T >
class SomeRendering
{
public:
SomeRendering() : v()
{
// set v
}
void Draw()
{
T::glVertex2fv(v);
}
GLfloat v[4];
};
}
In C and c++, I could pass function pointers to functions calling opengl functions (then for unit testing passing pointers to mock functions).
I could also link with different library (instead of opengl), but that sounds like a big complication.
So, what are other techniques to unit test code calling opengl functions?