Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: glEnableVertexAttribArray is undefined.  (Read 4754 times)

0 Members and 1 Guest are viewing this topic.

randomman159

  • Newbie
  • *
  • Posts: 2
    • View Profile
glEnableVertexAttribArray is undefined.
« on: November 29, 2014, 05:16:38 am »
From what I can tell, SFML claims to provide access to OpenGL functionality.

I have included and linked the appropriate libraries, and successfully rendered a cube to the screen, so I know I've gotten it working for the most part. (I have access to functions such as glBegin).

Some functions however, are marked as undefined.
glGenVertexArrays, glBindVertexArray, glEnableVertexAttribArray, glVertexAttribPointer

Are these outdated, not working with SFML, or am I doing something else wrong?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: glEnableVertexAttribArray is undefined.
« Reply #1 on: November 29, 2014, 05:34:10 am »
From what I can tell, SFML claims to provide access to OpenGL functionality.
SFML provides you with a functioning OpenGL context. I don't know how you define "functionality" but if you imply that it includes every single usable OpenGL entry point, then no, SFML does not do that. You will have to load them yourself.

I have included and linked the appropriate libraries, and successfully rendered a cube to the screen, so I know I've gotten it working for the most part. (I have access to functions such as glBegin).
Actually, you have barely got it working ;). Access to glBegin() and its friends is just a small fraction of the whole API. You should read up a bit more on how to use OpenGL in your application. The fact that glBegin() works does not mean that everything else will as well. OpenGL isn't just one big blob of a library. You will need to assemble together the pieces that you need, and that is where extension loaders come into play. Read up on them if you are trying to use entry points that are not available by default (default being the stuff that is provided automatically by the operating system's OpenGL implementation). Any decent OpenGL tutorial (SFML tutorials are not OpenGL tutorials and vice versa) will explain how to do this.

Some functions however, are marked as undefined.
glGenVertexArrays, glBindVertexArray, glEnableVertexAttribArray, glVertexAttribPointer

Are these outdated, not working with SFML, or am I doing something else wrong?
They aren't outdated. In fact, they are much newer than the stuff you do have access to (i.e. glBegin() and friends), and that is the reason why you don't have access to them up front.

I don't know what you are including to get the definitions for those functions, but normally, headers that provide the definitions for those functions come with some form of loader library that you will have to use to actually fill in the entry points.

Just do a bit more reading on loading OpenGL extensions (preferably as part of a bigger OpenGL tutorial series) and you should be up and running in no time.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

randomman159

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: glEnableVertexAttribArray is undefined.
« Reply #2 on: November 29, 2014, 06:10:58 am »
Thanks for the quick reply.

It's been a while since I last used OpenGL, and never with SFML so I'm a bit lost with the whole subject.
I'm including SFML/OpenGL.hpp

I also just read somewhere that I shouldn't be including things like glew because SFML already does that.

Grundkurs

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: glEnableVertexAttribArray is undefined.
« Reply #3 on: November 29, 2014, 10:58:02 pm »
seems like you did not include all the openGL extentions with glew. Did you try to initialize glew after(!) you set the SFML Window as current context? I didn't try it with sfml yet, but in glfw it looks kind of this, it may be helpful:
GLFWwindow* mWindow = glfwCreateWindow(800, 600, "Triangles", nullptr, nullptr);
        if(!mWindow){
                //error handling
        }
        glfwMakeContextCurrent(mWindow);
        glewExperimental = GL_TRUE;
        GLenum err = glewInit();
        if(err != GLEW_OK) {
                std::cout << "error: " << glewGetErrorString(err);
                glfwDestroyWindow(mWindow);
                glfwTerminate();
                return -1;
        }