Original Post
Umm I'm having trouble making this template class that uses OpenGL stuf from glext.h. The error message says that "there are no arguments to 'glGenBuffersARB' that depend on a template parameter... bla". It treats all the functions from glext.h the same.
I only get this when I try to make the class as a template and implement stuff in the header file rather than the cpp file.
I'm just not too sure why this happens.
Hope someone can clear this up for me.
Thanks,
Andy
I only get this when I try to make the class as a template and implement stuff in the header file rather than the cpp file.
I'm just not too sure why this happens.
// Apparently this has to go right at the top#define GL_GLEXT_PROTOTYPES#include <GL/gl.h>#include <GL/glu.h>#include <GL/glext.h>#ifndef VBO_H#define VBO_H#include <vector>... template <typename T> class Buffer { protected: unsigned int m_id; unsigned int m_type; BufferNode m_node; unsigned int m_usage; static int s_supported; // Check if VBOs are supported static void checkSupported() { // Get Extensions String std::string extensions = ((char const *)(glGetString(GL_EXTENSIONS))); // Search The Extensions String For An Exact Copy size_t found = extensions.find("GL_ARB_vertex_buffer_object"); if (found != std::string::npos) s_supported = 1; s_supported = -1; }; public: // Get the value of s_supported static bool isSupported() { if (!s_supported) checkSupported(); return s_supported == 1; }; Buffer(unsigned int type, unsigned int size, unsigned int usage) : m_id(0), m_type(type), m_node(0, size - 1), m_usage(usage) { // Make the buffer glGenBuffersARB(1, &m_id); bind(); glBufferDataARB(m_type, sizeof(T) * getSize(), 0, m_usage); unbind(); }; ~Buffer() { if (m_id) glDeleteBuffersARB(1, &m_id); }; unsigned int getId() { return m_id; }; BufferNode* getNode() { return &m_node; }; unsigned int getSize() { return m_node.getSize(); }; unsigned int getUsage() { return m_usage; }; void bind() { glBindBufferARB(m_type, m_id); }; void unbind() { glBindBufferARB(m_type, 0); }; bool subData(BufferNode* node, unsigned int size, T* data) { if (!node || node->getSize() < size) return false; bind(); glBufferSubDataARB(m_id, node->getFirst(), size, data); unbind(); return true; }; };Hope someone can clear this up for me.
Thanks,
Andy