OpenGL 3.2 on Windows

opticfroggy wrote on Tuesday, July 24, 2012:

Hi,
I do the majority of my programming on my MBpro so I know that my setup works
fine there. I recently wanted to debug some OpenGL bits using geDebugger, as
well as confirm my cross-platform(ness).
When cloning my codebase down onto Win 7 I am having serious issues getting an
OpenGL 3.2 app to compile.

C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:62:26: error: 'glBindVertexArray' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:64:46: error: 'glBindBuffer' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:66:73: error: 'glVertexAttribPointer' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:69:41: error: 'glEnableVertexAttribArray' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:77:42: error: 'glDisableVertexAttribArray' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp: In member function 'void Actor::UpdateBuffers()':
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:172:36: error: 'glDeleteBuffers' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:177:37: error: 'glDeleteBuffers' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:182:34: error: 'glDeleteVertexArrays' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:194:30: error: 'glGenVertexArrays' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:196:26: error: 'glBindVertexArray' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:198:33: error: 'glGenBuffers' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:199:46: error: 'glBindBuffer' was not declared in this scope
C:\Users\Chris\workspace\OldYoungEngine\src\actors\Actor.cpp:200:78: error: 'glBufferData' was not declared in this scope
mingw32-make[2]: *** [CMakeFiles/main.dir/src/actors/Actor.cpp.obj] Error 1

This is the Errors I am getting and it would appear to be specifically GL3
related looking at the functions that are apparently not declared.

Any ideas ?
Anyone actually successfully get a 3.2 context to work on Windows 7 (Using
Eclipse project generated from CMake here, although whatever IDE etc isn’t
really important)

Thanks in advance!

elmindreda wrote on Tuesday, July 24, 2012:

GLFW does not provide an OpenGL header.

opticfroggy wrote on Tuesday, July 24, 2012:

From what I’ve read and seen from others experiences, getting Glew to work
with GLFW is a PITA.
I did try it early on when I was testing this, putting the GLEW include before
GLFW, but I still ran into issues of GLFW complaining about gl.h being
included before (or something to that affect).

It’s such a shame that this isn’t easier.

elmindreda wrote on Tuesday, July 24, 2012:

If you encounter any problems, or if you know where these discussions took
place, please make a post about it.

Lots of people use GLEW with GLFW with no problems and have for years, myself
included. If there are any issues, I’d like to know about them.

opticfroggy wrote on Tuesday, July 24, 2012:

This could be a stupid question :
Say I have this structure for e.g.

- Main.cpp
- Engine .h/.cpp
- Actors
– Actor.h/.cpp

Engine requires GLFW to do the normal initialisation etc.
Actor requires access to GL for drawing etc.

Currently (which work on OSX) before GLEW :

Actor.cpp
#include <GL/glfw.h>




Engine.h
#include <GL/glfw.h>
...
#include <Actors/Actor.h>

This works fine, obviously this is overly simplified.

Now that I’ve added GLEW to the mix should my includes look like this ?

Actor.cpp
#include <GL/glew.h>
#include <GL/glfw.h>




Engine.h
#include <GL/glew.h>
#include <GL/glfw.h>

This is what Is giving me the error : “GL/glew.h:84:2: error: #error gl.h
included before glew.h”

I know this is likely a really stupid / simple thing e.g. only including 'X’
once in place ‘Y’ instead of all over the place, else it may likely be a bad
habit I’ve picked up which is confusing me.

Thanks in advance for any pointers.

elmindreda wrote on Tuesday, July 24, 2012:

Are you absolutely certain you’re not including the GLFW header or an OpenGL
header before the GLEW one? The GLEW header has inclusion guards, so a second
inclusion of it wouldn’t cause any warnings at all, regardless of what was
included before.

opticfroggy wrote on Tuesday, July 24, 2012:

Hmm, yea after some following of includes I believe I got that sorted, however
a linker error has now presented itself (At-least I’m past compiler errors
lol)

E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x240): undefined reference to `__imp__wglMakeCurrent@8'
mingw32-make[2]: Leaving directory `C:/Users/Chris/workspace/OldYoungEngine'
mingw32-make[1]: Leaving directory `C:/Users/Chris/workspace/OldYoungEngine'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x251): undefined reference to `__imp__wglDeleteContext@4'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0xf99): undefined reference to `__imp__wglGetProcAddress@4'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x1781): undefined reference to `__imp__wglMakeCurrent@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x18c1): undefined reference to `__imp__wglCreateContext@4'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x1d56): undefined reference to `__imp__glGetIntegerv@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_window.o):win32_window.c:(.text+0x1d6d): undefined reference to `__imp__glGetFloatv@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(glext.o):glext.c:(.text+0x1c0): undefined reference to `__imp__glGetIntegerv@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(glext.o):glext.c:(.text+0x1fb): undefined reference to `__imp__glGetIntegerv@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(glext.o):glext.c:(.text+0x2f0): undefined reference to `__imp__glGetIntegerv@8'
E:\Development\C++Libraries\glfw-2.7.6\lib-mingw\x86\libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7e): undefined reference to `__imp__wglGetProcAddress@4'

As I referenced earlier I’m using CMake if that’s any help, MinGW and MSYS on
Win 7.

(Just to test I also tried linking against the VS lib “GLFW.lib” instead of
"libglfw.a")

elmindreda wrote on Tuesday, July 24, 2012:

You should read the section on using GLFW in the
readme file.