1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
diff --git a/cmake/modules/K3DFindOpenGL.cmake b/cmake/modules/K3DFindOpenGL.cmake
index ea4cf71..0192557 100644
--- a/cmake/modules/K3DFindOpenGL.cmake
+++ b/cmake/modules/K3DFindOpenGL.cmake
@@ -2,15 +2,13 @@ SET(K3D_OPENGL_FOUND 0)
FIND_PACKAGE(OpenGL)
-FIND_LIBRARY(K3D_GLEW_LIBRARY NAMES GLEWmx GLEW
- DOC "The Glew shared library file"
-)
-
-FIND_PATH(K3D_GLEW_INCLUDE_DIR GL/glew.h ${OPENGL_INCLUDE_DIR})
-
-IF(OPENGL_FOUND AND OPENGL_GLU_FOUND AND K3D_GLEW_LIBRARY AND K3D_GLEW_INCLUDE_DIR)
- SET(K3D_OPENGL_INCLUDE_DIR ${OPENGL_INCLUDE_DIR} ${K3D_GLEW_INCLUDE_DIR})
- SET(K3D_OPENGL_LIBRARIES ${K3D_GLEW_LIBRARY} ${OPENGL_LIBRARIES})
+pkg_search_module(GLEW glewmx glew)
+
+IF(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLEW_FOUND)
+ SET(K3D_OPENGL_INCLUDE_DIR ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS})
+ SET(K3D_OPENGL_LIBRARIES ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
+ SET(K3D_GLEW_VERSION ${GLEW_VERSION})
+ string(REPLACE "." ";" GLEW_VERSION_LIST ${GLEW_VERSION})
+ list(GET GLEW_VERSION_LIST 0 K3D_GLEW_MAJOR_VERSION)
SET(K3D_OPENGL_FOUND 1)
ENDIF()
-
diff --git a/k3dsdk/gl/context.h b/k3dsdk/gl/context.h
index 39057d1..6f3cbc6 100644
--- a/k3dsdk/gl/context.h
+++ b/k3dsdk/gl/context.h
@@ -27,6 +27,10 @@
#include <k3dsdk/iunknown.h>
#include <boost/scoped_ptr.hpp>
+#if K3D_GLEW_MAJOR_VERSION > 1
+ struct GLEWContext {};
+#endif
+
namespace k3d
{
@@ -45,13 +49,13 @@ class context :
/// Returns the currently-active context, if any, or NULL.
static context* current();
-
+
/// Returns the currently-active GLEW context, if any, or NULL. Mostly used internally by GLEW
static GLEWContext* current_glew_context();
/// If the context is double-buffered, swaps the front and back buffers. Otherwise, a no-op.
void end();
-
+
/// Return the GLEW context associated with this context, or NULL if there is none
GLEWContext* glew_context();
@@ -76,4 +80,3 @@ class context :
#define glewGetContext() k3d::gl::context::current_glew_context()
#endif // !K3DSDK_GL_CONTEXT_H
-
diff --git a/k3dsdk/k3d-platform-config.h.in b/k3dsdk/k3d-platform-config.h.in
index 63fd3ca..68985e6 100644
--- a/k3dsdk/k3d-platform-config.h.in
+++ b/k3dsdk/k3d-platform-config.h.in
@@ -14,6 +14,8 @@
#cmakedefine K3D_UINT_T_32_BITS
#cmakedefine K3D_UINT_T_64_BITS
+#define K3D_GLEW_MAJOR_VERSION @K3D_GLEW_MAJOR_VERSION@
+
#define K3D_OSX_MAJOR_VERSION @K3D_OSX_MAJOR_VERSION@
#define K3D_OSX_MINOR_VERSION @K3D_OSX_MINOR_VERSION@
@@ -26,4 +28,3 @@
#endif
#endif // !K3DSDK_PLATFORM_CONFIG_H
-
|