Get errors regarding override (Cooking OpenGL 4.0)

I just tested the code in chapter 1 ( OpenGL 4.0 shaded chef book )

I installed Qt5, qmake -tp vc chapter01.pro then open it in vs2010.

Many bugs have been built and received such as:

1>D:\APP\Qt5\5.0.0\msvc2010\include\GLES2/gl2.h(38): error C2371: 'GLintptr' : redefinition; different basic types
1>          D:\OpenGL\glew-1.5.4\include\GL/glew.h(1615) : see declaration of 'GLintptr'
1>D:\APP\Qt5\5.0.0\msvc2010\include\GLES2/gl2.h(39): error C2371: 'GLsizeiptr' : redefinition; different basic types
1>          D:\OpenGL\glew-1.5.4\include\GL/glew.h(1614) : see declaration of 'GLsizeiptr'
1>D:\APP\Qt5\5.0.0\msvc2010\include\GLES2/gl2.h(96): warning C4005: 'GL_BLEND_EQUATION_RGB' : macro redefinition
1>          D:\OpenGL\glew-1.5.4\include\GL/glew.h(1666) : see previous definition of 'GL_BLEND_EQUATION_RGB'
1>D:\APP\Qt5\5.0.0\msvc2010\include\GLES2/gl2.h(474): error C2365: '__glewActiveTexture' : redefinition; previous definition was 'data variable'
1>          D:\OpenGL\glew-1.5.4\include\GL/glew.h(12027) : see declaration of '__glewActiveTexture'
1>D:\APP\Qt5\5.0.0\msvc2010\include\GLES2/gl2.h(475): error C2365: '__glewAttachShader' : redefinition; previous definition was 'data variable'

      

How can these problems be solved? (Code link here )

0


source to share


2 answers


Not the best answer, but I just checked out the book.

The book seems to be out of date when you get into the Qt version:

For example, in recent versions of Qt (at least version 4.7)



So, for the sake of reading this book, you might consider downgrading your Qt to 4.x (e.g. 4.8) as there can be many changes in the OpenGl requirements, especially if the Qt build you are using is built with various OpenGl libraries.

Another solution is to use updated source code which does not require Qt at all:

These are sample programs from the OpenGL 4.0 Shading Language Cookbook by David Wolf. The source code has been updated to work with MS Visual Studio and no longer requires Qt.

+1


source


Short answer: only include the GLEW header file and not include the OpenGL headers.



Explanation: The GLEW header file effectively includes everything in the OpenGL header files (I've never tried with GLES, but I suspect it's the same), overriding all OpenGL entry points via C preprocessor macros. This is why you see multiple defined characters and types ... More information can be found here .

+2


source







All Articles