summaryrefslogtreecommitdiff
blob: eebfe280f967081d7a9a0edb52ae1894d89cb254 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
From: Julian Ospald <hasufell@gentoo.org>
Date: Fri Nov 29 19:34:37 UTC 2013

This patch is currently not needed in this form, because gentoo irrlicht
does not yet have gles2 support. However this will be needed
once it does, so we can add a gles2 useflag.

Also fixes
https://bugs.gentoo.org/show_bug.cgi?id=492804

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,6 +7,7 @@
 mark_as_advanced(JSON_INCLUDE_DIR JSON_LIBRARY)
 
 option(ENABLE_CURL "Enable cURL support for fetching media" 1)
+option(ENABLE_GLES2 "Enable GLES2 support with irrlicht" 0)
 
 if (NOT ENABLE_CURL)
 	mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR)
@@ -170,7 +171,10 @@
 
 find_package(Sqlite3 REQUIRED)
 find_package(Json REQUIRED)
-find_package(OpenGLES2)
+if(ENABLE_GLES2 AND BUILD_CLIENT)
+	find_package(OpenGLES2 REQUIRED)
+	add_definitions( -DWITH_GLES2 )
+endif(ENABLE_GLES2 AND BUILD_CLIENT)
 
 if(USE_FREETYPE)
 	find_package(Freetype REQUIRED)
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1331,10 +1331,12 @@
 	else if(driverstring == "ogles1")
 		driverType = video::EDT_OGLES1;
 #endif
+#ifdef WITH_GLES2
 #ifdef _IRR_COMPILE_WITH_OGLES2_
 	else if(driverstring == "ogles2")
 		driverType = video::EDT_OGLES2;
 #endif
+#endif
 	else
 	{
 		errorstream<<"WARNING: Invalid video_driver specified; defaulting "
--- a/cmake/Modules/FindOpenGLES2.cmake
+++ b/cmake/Modules/FindOpenGLES2.cmake
@@ -19,6 +19,7 @@
 # win32, apple, android NOT TESED
 # linux tested and works
 
+
 IF (WIN32)
   IF (CYGWIN)
 
@@ -47,51 +48,57 @@
 
   ELSE(APPLE)
 
-    FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
-      /usr/openwin/share/include
-      /opt/graphics/OpenGL/include /usr/X11R6/include
-      /usr/include
-    )
-
-    FIND_LIBRARY(OPENGLES2_gl_LIBRARY
-      NAMES GLESv2
-      PATHS /opt/graphics/OpenGL/lib
+    # prefer pkg-config
+    INCLUDE(FindPkgConfig)
+    IF (PKG_CONFIG_FOUND)
+        pkg_check_modules(OPENGLES2 QUIET glesv2 egl)
+    ELSE (PKG_CONFIG_FOUND)
+        FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
+            /usr/openwin/share/include
+            /opt/graphics/OpenGL/include /usr/X11R6/include
+            /usr/include
+            )
+
+        FIND_LIBRARY(OPENGLES2_gl_LIBRARY
+            NAMES GLESv2
+            PATHS /opt/graphics/OpenGL/lib
             /usr/openwin/lib
             /usr/shlib /usr/X11R6/lib
             /usr/lib
-    )
+            )
 
-    IF (NOT BUILD_ANDROID)
-		FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
-		  /usr/openwin/share/include
-		  /opt/graphics/OpenGL/include /usr/X11R6/include
-		  /usr/include
-		)
-
-		FIND_LIBRARY(EGL_egl_LIBRARY
-		  NAMES EGL
-		  PATHS /opt/graphics/OpenGL/lib
-				/usr/openwin/lib
-				/usr/shlib /usr/X11R6/lib
-				/usr/lib
-		)
-
-		# On Unix OpenGL most certainly always requires X11.
-		# Feel free to tighten up these conditions if you don't 
-		# think this is always true.
-		# It's not true on OSX.
-
-		IF (OPENGLES2_gl_LIBRARY)
-		  IF(NOT X11_FOUND)
-			INCLUDE(FindX11)
-		  ENDIF(NOT X11_FOUND)
-		  IF (X11_FOUND)
-			IF (NOT APPLE)
-			  SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
-			ENDIF (NOT APPLE)
-		  ENDIF (X11_FOUND)
-		ENDIF (OPENGLES2_gl_LIBRARY)
-    ENDIF ()
+        IF (NOT BUILD_ANDROID)
+            FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
+                /usr/openwin/share/include
+                /opt/graphics/OpenGL/include /usr/X11R6/include
+                /usr/include
+                )
+
+            FIND_LIBRARY(EGL_egl_LIBRARY
+                NAMES EGL
+                PATHS /opt/graphics/OpenGL/lib
+                /usr/openwin/lib
+                /usr/shlib /usr/X11R6/lib
+                /usr/lib
+                )
+
+            # On Unix OpenGL most certainly always requires X11.
+            # Feel free to tighten up these conditions if you don't 
+            # think this is always true.
+            # It's not true on OSX.
+
+            IF (OPENGLES2_gl_LIBRARY)
+                IF(NOT X11_FOUND)
+                    INCLUDE(FindX11)
+                ENDIF(NOT X11_FOUND)
+                IF (X11_FOUND)
+                    IF (NOT APPLE)
+                        SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
+                    ENDIF (NOT APPLE)
+                ENDIF (X11_FOUND)
+            ENDIF (OPENGLES2_gl_LIBRARY)
+        ENDIF (NOT BUILD_ANDROID)
+    ENDIF (PKG_CONFIG_FOUND)
 
   ENDIF(APPLE)
 ENDIF (WIN32)
@@ -126,5 +133,5 @@
 IF(OPENGLES2_FOUND)
     MESSAGE(STATUS "Found system opengles2 library ${OPENGLES2_LIBRARIES}")
 ELSE ()
-    SET(OPENGLES2_LIBRARIES "")
+    MESSAGE(FATAL_ERROR "OpenGLES2 not found!")
 ENDIF ()