aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/FindOpenGLES2.cmake
blob: a47126705290ef6ee6f128fff9781f40f98f8783 (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
#-------------------------------------------------------------------
# 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 and Apple are not tested!
# Linux tested and works

if(WIN32)
	find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h)
	find_library(OPENGLES2_LIBRARY libGLESv2)
elseif(APPLE)
	create_search_paths(/Developer/Platforms)
	findpkg_framework(OpenGLES2)
	set(OPENGLES2_LIBRARY "-framework OpenGLES")
else()
	# Unix
	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/X11R6/lib
			/usr/lib
	)

	include(FindPackageHandleStandardArgs)
	find_package_handle_standard_args(OPENGLES2 DEFAULT_MSG OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR)

	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/X11R6/lib
			/usr/lib
	)

	include(FindPackageHandleStandardArgs)
	find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
endif()

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

mark_as_advanced(
	OPENGLES2_INCLUDE_DIR
	OPENGLES2_LIBRARY
	EGL_INCLUDE_DIR
	EGL_LIBRARY
)
uot;porting.h" #include "log.h" #include "container.h" template<typename T> class MutexedVariable { public: MutexedVariable(const T &value): m_value(value) {} T get() { MutexAutoLock lock(m_mutex); return m_value; } void set(const T &value) { MutexAutoLock lock(m_mutex); m_value = value; } // You pretty surely want to grab the lock when accessing this T m_value; private: std::mutex m_mutex; }; /* A single worker thread - multiple client threads queue framework. */ template<typename Key, typename T, typename Caller, typename CallerData> class GetResult { public: Key key; T item; std::pair<Caller, CallerData> caller; }; template<typename Key, typename T, typename Caller, typename CallerData> class ResultQueue : public MutexedQueue<GetResult<Key, T, Caller, CallerData> > { }; template<typename Caller, typename Data, typename Key, typename T> class CallerInfo { public: Caller caller; Data data; ResultQueue<Key, T, Caller, Data> *dest; }; template<typename Key, typename T, typename Caller, typename CallerData> class GetRequest { public: GetRequest() = default; ~GetRequest() = default; GetRequest(const Key &a_key): key(a_key) { } Key key; std::list<CallerInfo<Caller, CallerData, Key, T> > callers; }; /** * Notes for RequestQueue usage * @param Key unique key to identify a request for a specific resource * @param T ? * @param Caller unique id of calling thread * @param CallerData data passed back to caller */ template<typename Key, typename T, typename Caller, typename CallerData> class RequestQueue { public: bool empty() { return m_queue.empty(); } void add(const Key &key, Caller caller, CallerData callerdata, ResultQueue<Key, T, Caller, CallerData> *dest) { typename std::deque<GetRequest<Key, T, Caller, CallerData> >::iterator i; typename std::list<CallerInfo<Caller, CallerData, Key, T> >::iterator j; { MutexAutoLock lock(m_queue.getMutex()); /* If the caller is already on the list, only update CallerData */ for (i = m_queue.getQueue().begin(); i != m_queue.getQueue().end(); ++i) { GetRequest<Key, T, Caller, CallerData> &request = *i; if (request.key != key) continue; for (j = request.callers.begin(); j != request.callers.end(); ++j) { CallerInfo<Caller, CallerData, Key, T> &ca = *j; if (ca.caller == caller) { ca.data = callerdata; return; } } CallerInfo<Caller, CallerData, Key, T> ca; ca.caller = caller; ca.data = callerdata; ca.dest = dest; request.callers.push_back(ca); return; } } /* Else add a new request to the queue */ GetRequest<Key, T, Caller, CallerData> request; request.key = key; CallerInfo<Caller, CallerData, Key, T> ca; ca.caller = caller; ca.data = callerdata; ca.dest = dest; request.callers.push_back(ca); m_queue.push_back(request); } GetRequest<Key, T, Caller, CallerData> pop(unsigned int timeout_ms) { return m_queue.pop_front(timeout_ms); } GetRequest<Key, T, Caller, CallerData> pop() { return m_queue.pop_frontNoEx(); } void pushResult(GetRequest<Key, T, Caller, CallerData> req, T res) { for (typename std::list<CallerInfo<Caller, CallerData, Key, T> >::iterator i = req.callers.begin(); i != req.callers.end(); ++i) { CallerInfo<Caller, CallerData, Key, T> &ca = *i; GetResult<Key,T,Caller,CallerData> result; result.key = req.key; result.item = res; result.caller.first = ca.caller; result.caller.second = ca.data; ca.dest->push_back(result); } } private: MutexedQueue<GetRequest<Key, T, Caller, CallerData> > m_queue; }; class UpdateThread : public Thread { public: UpdateThread(const std::string &name) : Thread(name + "Update") {}