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

Author Topic: OpenGL 3.x will not work.  (Read 4762 times)

0 Members and 1 Guest are viewing this topic.

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
OpenGL 3.x will not work.
« on: November 17, 2011, 10:28:04 pm »
So I installed SFML 2.0, got it configured on Code::Blocks, and it's all set up on my laptop (Debian). However, it will not compile a simple project that uses OpenGL 3.x functions. It keeps saying they're not declared in scope. I think this is a linker issue. Is there any way to resolve this? I even passed the context settings as a parameter in the render window class that I use.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL 3.x will not work.
« Reply #1 on: November 17, 2011, 10:32:44 pm »
This is just confusing. Please give us the error message instead of your interpretations of it ;)
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
OpenGL 3.x will not work.
« Reply #2 on: November 17, 2011, 10:36:53 pm »
Quote from: "Laurent"
This is just confusing. Please give us the error message instead of your interpretations of it ;)


I'm a bit brain exhausted, because I just got out of calculus. Sorry.

Here are some of the errors I get:
error: 'glBindBuffer' was not declared in this scope.
error: 'glEnableVertexAttribArray' was not declared in this scope
error: 'glVertexAttribPointer' was not declared in this scope

Again, I believe this is a linker issue.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
OpenGL 3.x will not work.
« Reply #3 on: November 17, 2011, 10:44:17 pm »
"not declared" is a compiler error. A linker error would be "undefined reference" or "unresolved symbol".

To get OpenGL 3 functions you need to include (after downloading it) gl3.h, and enable GL 3 functions prototypes with the GL3_PROTOTYPES macros. Do this only if the OpenGL library that you link to your application is recent enough and has these functions -- otherwise you'll get linker errors this time ;)

You can check if you have a GL 3 library easily: check the major version number of libGL.so. It needs to be at least 3 (libGL.so.3 for example).

If you have a libGL.so.1 or .2, you'll have to get and use these functions through extensions instead. Have a look at GLEW or GLEE, they allow to use extensions almost the same way as core functions.
Laurent Gomila - SFML developer

Rosenzweig

  • Newbie
  • *
  • Posts: 13
    • View Profile
OpenGL 3.x will not work.
« Reply #4 on: November 17, 2011, 10:52:00 pm »
I just included glew and it made my problems magically go away. :D