OpenGL: VBO functions are not defined - c++

I'm trying to use OpenGL VBO's, but the functions associated with their use, glGenBuffersARB() for instance, are all undefined. Immediate mode functions are fine of course, it's only these.
I'm using VS2010, with the SFML library. One of the include headers in that library includes both <GL/gl.h> and <GL/glu.h>, and the executable is linked against glu32.lib and opengl32.lib
Why are only these functions missing, and how would I be able to include their use?

GLEW will define them, as will other GL extension libraries.
Information can be found here: http://www.opengl.org/resources/features/OGLextensions/
Using an extension that includes new function call entry-points is harder in Win32 because you must first request the function pointer from the OpenGL ICD driver before you can call the OpenGL function.
GLEW does this for you.

Related

Why do I need to link against opengl32 when I have glew32?

Why do I need both the libopengl32.dll and the libglew32 libraries when compiling an OpenGL program? What's the difference between the libraries and why do I need both?
You do not (always) need both the libopengl32.dll and the libglew32 libraries when compiling an OpenGL program. You need both when compiling a GLEW program (which implies also being an OpenGL program since GLEW builds upon OpenGL). For some people, this difference is academic since they would never consider writing an OpenGL program without the convenience of GLEW (et al.). However, GLEW is not required by OpenGL.
Your OpenGL library is the base upon which your GLEW library depends. You can use OpenGL without GLEW, but you cannot use GLEW without OpenGL. If your program uses GLEW, then you need to link your GLEW library because you are using it, and you need to link your OpenGL library because GLEW (and probably your code as well) uses that. If you are using pure OpenGL with no elements of GLEW, you need just to link your OpenGL library.

OpenGL functions missing in SFML environment

Following this tutorial I was trying to manage my OpenGL buffers for an OpenGL context I created using SFML, under a visual studio environment. I installed SFML and Glew in their latest versions, did correct linking, and I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d.
However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why. I noticed that the default OpenGL version set by SFML context is 4.6 but I can t find proper documentation for these functions on khronos website for this version. Moreover my visual studio doesn t even recognize theses functions as part of any library but I might have missed some includes given that I rely on SFML/OpenGL.hpp. Documentation on SFML side is very ligth on this subject...
Thanks !
I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d. However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why.
The reason for this is that the opengl32 library on windows only provides OpenGL 1.1 functionality, everything else is brought in by your graphics card driver. To actually access these functions, windows provides a function to load them. However, writing all the declarations and loading all functions is a lot of work (See Load OpenGL Functions in the OpenGL Wiki) so libraries exist which do this for you, one such library is glew, "The OpenGL Extension Wrangler Library". After you created your OpenGL context (which SFML does), you must call glewInit() which then loads all the other functions. The declarations for those functions are also provided by glew, so make sure to include the glew header instead of your systems or SFMLs opengl header.

GLEW is just and extension library or it contains OpenGL ES 2.0 implementation as well?

GLEW is just and extension library or it contains OpenGL ES 2.0 implementation as well?
The OpenGL Extension Wrangler Library (GLEW) is a cross-platform
open-source C/C++ extension loading library. GLEW provides efficient
run-time mechanisms for determining which OpenGL extensions are
supported on the target platform. OpenGL core and extension
functionality is exposed in a single header file.
I am confused as I find the following in glew.h:
#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram)
where __glewLinkProgram is
GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram;
where PFNGLLINKPROGRAMPROC is obtained from a lib or a dll, I guess. I cannot find it anywhere.
The first line of your quote states what GLEW is:
The OpenGL Extension Wrangler Library (GLEW) is a ... extension loading library.
It loads OpenGL extension functions from the OpenGL implementation (typically provided by GPU drivers). It doesn't implement them themselves.
Those PFN... typedefs are provided by glext.h and are function pointer types. GLEW simply defines some variables to hold the function pointers, and to load them using using the wglGetProcAddress or glXGetProcAddress functions.
The official version of glew does not support OpenGL ES at all, only desktop OpenGL. However, some unofficial adaptations / forks of glew have sprung up, such as Linaro's glew-es, that do support OpenGL ES.

Running OpenGL without installing?

I am writing an OpenGL based game. It includes just these two libraries: glew, glfw3. In order to run it the user must obviously have OpenGL installed, an assumption which I'd like to bypass.
I've gathered all the appropriate binaries inside the game directory and tried linking to these libraries locally but the compiler claims undefined reference to all their functions. Am I doing something wrong or is it just impossible? I'm using Windows but it fails on Linux for the same reason.
OpenGL is not a library you install, it's an API that's implemented as part of the driver. Your compiler complaining about symbols not resolving is completely unrelated to the situation on the end user's computer. And in your case it simply sounds that you did not tell the compiler / linker which libraries and API interfaces to link into your program binary; your compiler is hence complaining, that some of the internal references don't redolve.
So here it goes: OpenGL is not something you ship with your program, it's part of the graphics drivers and your program must use whatever OpenGL version is installed on the user's machine. For this you dynamically link against libGL.so by passing the compiler-linker option -lGL.
GLEW is a helper library that post-loads dynamically all OpenGL functions not found in the system OpenGL ABI, which hence are not exported through the public symbol table of libGL.so. Rather they're to be loaded dynamically using glXGetProcAddress – a rather tedious task. Be advised that GLEW has some serious issues when it comes to OpenGL-3 and later core profiles.
GLFW is a simplistic framework library for setting up a window having an OpenGL context.
GLEW and GLFW are safe to link statically with your program, and I recommend you do that. Instead of using the -l… flag, add libGLEW.a and libGLFW.a to the list of source files / compilation units to be linked.

OpenGL.org down, any mirror sites for libraries and include downloads?

http://opengl.org/ and http://www.khronos.org/ seems to be currently unavailable. Is there any good alternative mirror sites?
I am looking for OpenGL 4.4 Libraries and Includes download for VC.
OpenGL is not a library, it's an API specification. What you can download at http://opengl.org are just the specification documents and reference C include headers. But there are no library downloads there because, well, OpenGL is not a library.
The actual OpenGL implementation ships as part of your GPU's driver. That's also what ultimately determines which version of OpenGL you can use: The GPU on the system the program is executed on. The major OpenGL version designates the hardware class. A OpenGL-3 class GPU can not do OpenGL-4 (but a OpenGL-4 can do OpenGL-3 of course).
For all practical means there's nothing you need to download or to install to get working with OpenGL. This is different from DirectX where you need a special SDK. OpenGL has been included into the ABI (Application Binary Interface) of the major operating systems, including Windows, and hence the standard headers ship with compilers targeted at this system.
In your case you'll find the OpenGL base headers being preinstalled with the default installation of Visual-C++.
However newer versions of OpenGL require additional tokens and functions to be defined. That's where extension headers come into play. But since there's no change in the ABI, the actual functions do not come as part of a library but must be loaded at runtime using wglGetProcAddress for each function.
Since this is a tedious process there are OpenGL extension loader wrapper libraries, like GLEW (available at http://glew.sf.net) which package up the extension headers and some library code to do the whole loading thing with just a single command. Since there are things to consider like namespace pollution and interoperability with other means of extension loading, GLEW patches into the regular OpenGL headers with preprocessor macro definitions, so that all compilation units that include GLEW just use GLEW. This makes it look like GLEW replaces the regular headers and interface libraries, but in reality it just builds on and defers to them.
Well, usually you want to use glew or a similiar library in order to get the OpenGL functions. You can grab a copy of glew here: http://glew.sourceforge.net/. The libraries should come bundled with VC so you simply add OpenGL32.lib to your linker's additional dependencies.