aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/FindOpenGLES2.cmake
blob: a8622f3b26edd9306d23f179099a0dac378590b7 (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
#-------------------------------------------------------------------
# This file is stolen from part of the CMake build system for OGRE (Object-oriented Graphics Rendering Engine) http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------

# - Try to find OpenGLES and EGL
# Once done this will define
#
#  OPENGLES2_FOUND        - system has OpenGLES
#  OPENGLES2_INCLUDE_DIR  - the GL include directory
#  OPENGLES2_LIBRARIES    - Link these to use OpenGLES
#
#  EGL_FOUND        - system has EGL
#  EGL_INCLUDE_DIR  - the EGL include directory
#  EGL_LIBRARIES    - Link these to use EGL

# Win32, Apple, and Android are not tested!
# Linux tested and works

if(WIN32)
	if(CYGWIN)
		find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h)
		find_library(OPENGLES2_LIBRARY libGLESv2)
	else()
		if(BORLAND)
			set(OPENGLES2_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for Win32")
		else()
			# TODO
			# set(OPENGLES_LIBRARY ${SOURCE_DIR}/Dependencies/lib/release/libGLESv2.lib CACHE STRING "OpenGL ES 2.x library for win32"
		endif()
	endif()
elseif(APPLE)
	create_search_paths(/Developer/Platforms)
	findpkg_framework(OpenGLES2)
	set(OPENGLES2_LIBRARY "-framework OpenGLES")
else()
	find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
		PATHS /usr/openwin/share/include
			/opt/graphics/OpenGL/include
			/usr/X11R6/include
			/usr/include
	)

	find_library(OPENGLES2_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
			PATHS /usr/openwin/share/include
				/opt/graphics/OpenGL/include
				/usr/X11R6/include
				/usr/include
		)

		find_library(EGL_LIBRARY
			NAMES EGL
			PATHS /opt/graphics/OpenGL/lib
				/usr/openwin/lib
				/usr/shlib
				/usr/X11R6/lib
				/usr/lib
		)

		# On Unix OpenGL usually requires X11.
		# It doesn't require X11 on OSX.

		if(OPENGLES2_LIBRARY)
			if(NOT X11_FOUND)
				include(FindX11)
			endif()
			if(X11_FOUND)
				set(OPENGLES2_LIBRARIES ${X11_LIBRARIES})
			endif()
		endif()
	endif()
endif()

set(OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARIES} ${OPENGLES2_LIBRARY})

if(BUILD_ANDROID)
	if(OPENGLES2_LIBRARY)
		set(EGL_LIBRARIES)
		set(OPENGLES2_FOUND TRUE)
	endif()
else()
	if(OPENGLES2_LIBRARY AND EGL_LIBRARY)
		set(OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_LIBRARIES})
		set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_LIBRARIES})
		set(OPENGLES2_FOUND TRUE)
	endif()
endif()

mark_as_advanced(
	OPENGLES2_INCLUDE_DIR
	OPENGLES2_LIBRARY
	EGL_INCLUDE_DIR
	EGL_LIBRARY
)

if(OPENGLES2_FOUND)
	message(STATUS "Found system OpenGL ES 2 library: ${OPENGLES2_LIBRARIES}")
else()
	set(OPENGLES2_LIBRARIES "")
endif()

n class="hl opt">(player_name, radius) local player = core.get_player_by_name(player_name) if player == nil then return nil end local p1 = player:getpos() local p2 = p1 if radius then p1 = vector.subtract(p1, radius) p2 = vector.add(p2, radius) end return p1, p2 end function core.hash_node_position(pos) return (pos.z+32768)*65536*65536 + (pos.y+32768)*65536 + pos.x+32768 end function core.get_position_from_hash(hash) local pos = {} pos.x = (hash%65536) - 32768 hash = math.floor(hash/65536) pos.y = (hash%65536) - 32768 hash = math.floor(hash/65536) pos.z = (hash%65536) - 32768 return pos end function core.get_item_group(name, group) if not core.registered_items[name] or not core.registered_items[name].groups[group] then return 0 end return core.registered_items[name].groups[group] end function core.get_node_group(name, group) core.log("deprecated", "Deprecated usage of get_node_group, use get_item_group instead") return core.get_item_group(name, group) end function core.setting_get_pos(name) local value = core.setting_get(name) if not value then return nil end return core.string_to_pos(value) end -- To be overriden by protection mods function core.is_protected(pos, name) return false end function core.record_protection_violation(pos, name) for _, func in pairs(core.registered_on_protection_violation) do func(pos, name) end end local raillike_ids = {} local raillike_cur_id = 0 function core.raillike_group(name) local id = raillike_ids[name] if not id then raillike_cur_id = raillike_cur_id + 1 raillike_ids[name] = raillike_cur_id id = raillike_cur_id end return id end -- HTTP callback interface function core.http_add_fetch(httpenv) httpenv.fetch = function(req, callback) local handle = httpenv.fetch_async(req) local function update_http_status() local res = httpenv.fetch_async_get(handle) if res.completed then callback(res) else core.after(0, update_http_status) end end core.after(0, update_http_status) end return httpenv end function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end function core.cancel_shutdown_requests() core.request_shutdown("", false, -1) end