Skip to main content
GameDev.net gamedev.net
🔒 Locked

template problem

Started by andy1984 Nov 9, 2010 at 6:15 PM 2 replies 950+ views
Original Post
andy1984
andy1984
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.

// 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
gtdelarosa2
gtdelarosa2
How are you instantiating the class? Could you post an example?
andy1984
andy1984
I haven't instantiated it, it just shows that error when I try to compile it. Its not really necessary that it be a template, I think I can change things around a little so all the opengl extension calls can go in a non-template class. I am still curious why it wont compile though.
Zahlman
Zahlman
Show the exact error message.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.