From ec80bfe740f7523cd956adc71a0c0ee283fcfc68 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 9 Feb 2015 23:17:33 +0100 Subject: [PATCH] Switched to using Qt for loading extensions, instead of GLEW. --- examples/Basic/CMakeLists.txt | 8 ++------ examples/DecodeOnGPU/CMakeLists.txt | 8 ++------ examples/OpenGL/CMakeLists.txt | 8 ++------ examples/Paging/CMakeLists.txt | 8 ++------ examples/SmoothLOD/CMakeLists.txt | 8 ++------ examples/common/CMakeLists.txt | 10 ++++------ examples/common/OpenGLWidget.cpp | 7 +++---- examples/common/OpenGLWidget.h | 6 ++++-- 8 files changed, 21 insertions(+), 42 deletions(-) diff --git a/examples/Basic/CMakeLists.txt b/examples/Basic/CMakeLists.txt index 4d1eb751..93fadf85 100644 --- a/examples/Basic/CMakeLists.txt +++ b/examples/Basic/CMakeLists.txt @@ -32,17 +32,13 @@ SET(INC_FILES ../common/OpenGLWidget.h ) -add_definitions(-DGLEW_STATIC) - #"Sources" and "Headers" are the group names in Visual Studio. #They may have other uses too... SOURCE_GROUP("Sources" FILES ${SRC_FILES}) SOURCE_GROUP("Headers" FILES ${INC_FILES}) -FIND_PACKAGE(OpenGL REQUIRED) - #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common) #This will include the shader files inside the compiled binary QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc) @@ -55,7 +51,7 @@ ADD_EXECUTABLE(BasicExample ${SRC_FILES} ${COMMON_RESOURCES_RCC}) IF(MSVC) SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") #All warnings ENDIF(MSVC) -TARGET_LINK_LIBRARIES(BasicExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +TARGET_LINK_LIBRARIES(BasicExample Qt5::OpenGL) SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/DecodeOnGPU/CMakeLists.txt b/examples/DecodeOnGPU/CMakeLists.txt index 071ba223..85099a33 100644 --- a/examples/DecodeOnGPU/CMakeLists.txt +++ b/examples/DecodeOnGPU/CMakeLists.txt @@ -34,12 +34,8 @@ SET(INC_FILES OpenGLWidget.h ) -add_definitions(-DGLEW_STATIC) - -FIND_PACKAGE(OpenGL REQUIRED) - #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR}) #This will include the shader files inside the compiled binary QT4_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc) @@ -53,7 +49,7 @@ ADD_EXECUTABLE(DecodeOnGPUExample ${SRC_FILES} ${COMMON_RESOURCES_RCC} ${DECODE_ IF(MSVC) SET_TARGET_PROPERTIES(DecodeOnGPUExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(DecodeOnGPUExample glew ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +TARGET_LINK_LIBRARIES(DecodeOnGPUExample ${QT_LIBRARIES}) SET_PROPERTY(TARGET DecodeOnGPUExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index f1ac34db..1fab7c69 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -42,17 +42,13 @@ SET(INC_FILES Shapes.h ) -add_definitions(-DGLEW_STATIC) - #"Sources" and "Headers" are the group names in Visual Studio. #They may have other uses too... SOURCE_GROUP("Sources" FILES ${SRC_FILES}) SOURCE_GROUP("Headers" FILES ${INC_FILES}) -FIND_PACKAGE(OpenGL REQUIRED) - #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common) #This will include the shader files inside the compiled binary QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc) @@ -66,7 +62,7 @@ ADD_EXECUTABLE(OpenGLExample ${SRC_FILES} ${COMMON_RESOURCES_RCC} ${OPENGL_EXAMP IF(MSVC) SET_TARGET_PROPERTIES(OpenGLExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(OpenGLExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +TARGET_LINK_LIBRARIES(OpenGLExample Qt5::OpenGL) SET_PROPERTY(TARGET OpenGLExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/Paging/CMakeLists.txt b/examples/Paging/CMakeLists.txt index 88514f15..a0c626ac 100644 --- a/examples/Paging/CMakeLists.txt +++ b/examples/Paging/CMakeLists.txt @@ -34,17 +34,13 @@ SET(INC_FILES Perlin.h ) -add_definitions(-DGLEW_STATIC) - #"Sources" and "Headers" are the group names in Visual Studio. #They may have other uses too... SOURCE_GROUP("Sources" FILES ${SRC_FILES}) SOURCE_GROUP("Headers" FILES ${INC_FILES}) -FIND_PACKAGE(OpenGL REQUIRED) - #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common) #This will include the shader files inside the compiled binary QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc) @@ -57,7 +53,7 @@ ADD_EXECUTABLE(PagingExample ${SRC_FILES} ${COMMON_RESOURCES_RCC}) IF(MSVC) SET_TARGET_PROPERTIES(PagingExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(PagingExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +TARGET_LINK_LIBRARIES(PagingExample Qt5::OpenGL) SET_PROPERTY(TARGET PagingExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/SmoothLOD/CMakeLists.txt b/examples/SmoothLOD/CMakeLists.txt index 702c03e7..9b1ef6fc 100644 --- a/examples/SmoothLOD/CMakeLists.txt +++ b/examples/SmoothLOD/CMakeLists.txt @@ -32,17 +32,13 @@ SET(INC_FILES ../common/OpenGLWidget.h ) -add_definitions(-DGLEW_STATIC) - #"Sources" and "Headers" are the group names in Visual Studio. #They may have other uses too... SOURCE_GROUP("Sources" FILES ${SRC_FILES}) SOURCE_GROUP("Headers" FILES ${INC_FILES}) -FIND_PACKAGE(OpenGL REQUIRED) - #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common) #This will include the shader files inside the compiled binary QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc) @@ -55,7 +51,7 @@ ADD_EXECUTABLE(SmoothLODExample ${SRC_FILES} ${COMMON_RESOURCES_RCC}) IF(MSVC) SET_TARGET_PROPERTIES(SmoothLODExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") #All warnings ENDIF(MSVC) -TARGET_LINK_LIBRARIES(SmoothLODExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) +TARGET_LINK_LIBRARIES(SmoothLODExample Qt5::OpenGL) SET_PROPERTY(TARGET SmoothLODExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index 34752ade..7a385cda 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -19,13 +19,11 @@ # 3. This notice may not be removed or altered from any source # distribution. -project(GLEW) +#project(GLEW) -set(SRC_FILES ../common/glew/glew.cpp) - -add_definitions(-DGLEW_STATIC) +#set(SRC_FILES ../common/glew/glew.cpp) #find_package(OpenGL REQUIRED) #include_directories(${OPENGL_INCLUDE_DIR}) -add_library(glew STATIC ${SRC_FILES}) -SET_PROPERTY(TARGET glew PROPERTY FOLDER "Examples/Common") +#add_library(glew STATIC ${SRC_FILES}) +#SET_PROPERTY(TARGET glew PROPERTY FOLDER "Examples/Common") diff --git a/examples/common/OpenGLWidget.cpp b/examples/common/OpenGLWidget.cpp index d685a3ac..61d23c57 100644 --- a/examples/common/OpenGLWidget.cpp +++ b/examples/common/OpenGLWidget.cpp @@ -61,11 +61,10 @@ void OpenGLWidget::mouseMoveEvent(QMouseEvent* event) //////////////////////////////////////////////////////////////////////////////// void OpenGLWidget::initializeGL() { - GLenum err = glewInit(); - if (GLEW_OK != err) + if (!initializeOpenGLFunctions()) { - /* Problem: glewInit failed, something is seriously wrong. */ - std::cout << "GLEW Error: " << glewGetErrorString(err) << std::endl; + std::cerr << "Could not initialize OpenGL functions" << std::endl; + exit(EXIT_FAILURE); } //Print out some information about the OpenGL implementation. diff --git a/examples/common/OpenGLWidget.h b/examples/common/OpenGLWidget.h index ba8fdedc..35472003 100644 --- a/examples/common/OpenGLWidget.h +++ b/examples/common/OpenGLWidget.h @@ -26,10 +26,12 @@ distribution. #include "PolyVox/Mesh.h" -#include "glew/glew.h" +#include #include #include +#include +#include // This structure holds all the data required // to render one of our meshes through OpenGL. @@ -47,7 +49,7 @@ struct OpenGLMeshData // Our OpenGLWidget is used by all the examples to render the extracted meshes. It is // fairly specific to our needs (you probably won't want to use it in your own project) // but should provide a useful illustration of how PolyVox meshes can be rendered. -class OpenGLWidget : public QGLWidget +class OpenGLWidget : public QGLWidget, protected QOpenGLFunctions_3_1 { public: // Constructor