Browse Source
One of them is then available through the platform.WindowlessApplication alias. The selection is a bit arbitrary now, but has to suffice.pull/1/head
8 changed files with 345 additions and 1 deletions
@ -0,0 +1,85 @@
|
||||
#.rst: |
||||
# Find EGL |
||||
# -------- |
||||
# |
||||
# Finds the EGL library. This module defines: |
||||
# |
||||
# EGL_FOUND - True if EGL library is found |
||||
# EGL::EGL - EGL imported target |
||||
# |
||||
# Additionally these variables are defined for internal usage: |
||||
# |
||||
# EGL_LIBRARY - EGL library |
||||
# EGL_INCLUDE_DIR - Include dir |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
|
||||
# Library |
||||
if(NOT CORRADE_TARGET_EMSCRIPTEN) |
||||
find_library(EGL_LIBRARY NAMES |
||||
EGL |
||||
|
||||
# ANGLE (CMake doesn't search for lib prefix on Windows) |
||||
libEGL |
||||
|
||||
# On iOS a part of OpenGLES |
||||
OpenGLES) |
||||
set(EGL_LIBRARY_NEEDED EGL_LIBRARY) |
||||
endif() |
||||
|
||||
# Include dir |
||||
find_path(EGL_INCLUDE_DIR NAMES |
||||
EGL/egl.h |
||||
|
||||
# iOS |
||||
EAGL.h) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(EGL DEFAULT_MSG |
||||
${EGL_LIBRARY_NEEDED} |
||||
EGL_INCLUDE_DIR) |
||||
|
||||
if(NOT TARGET EGL::EGL) |
||||
if(EGL_LIBRARY_NEEDED) |
||||
# Work around BUGGY framework support on macOS |
||||
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html |
||||
if(APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$") |
||||
add_library(EGL::EGL INTERFACE IMPORTED) |
||||
set_property(TARGET EGL::EGL APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY}) |
||||
else() |
||||
add_library(EGL::EGL UNKNOWN IMPORTED) |
||||
set_property(TARGET EGL::EGL PROPERTY |
||||
IMPORTED_LOCATION ${EGL_LIBRARY}) |
||||
endif() |
||||
else() |
||||
add_library(EGL::EGL INTERFACE IMPORTED) |
||||
endif() |
||||
|
||||
set_target_properties(EGL::EGL PROPERTIES |
||||
INTERFACE_INCLUDE_DIRECTORIES ${EGL_INCLUDE_DIR}) |
||||
endif() |
||||
@ -0,0 +1,52 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
|
||||
# *Not* REQUIRED |
||||
find_package(Magnum COMPONENTS |
||||
WindowlessEglApplication |
||||
WindowlessGlxApplication) |
||||
|
||||
if(Magnum_WindowlessEglApplication_FOUND) |
||||
pybind11_add_module(magnum_platform_egl egl.cpp) |
||||
target_link_libraries(magnum_platform_egl PRIVATE Magnum::WindowlessEglApplication) |
||||
target_include_directories(magnum_platform_egl PRIVATE ${PROJECT_SOURCE_DIR}/src/python) |
||||
set_target_properties(magnum_platform_egl PROPERTIES |
||||
FOLDER "python/platform" |
||||
OUTPUT_NAME "egl" |
||||
LIBRARY_OUTPUT_DIRECTORY ${output_dir}/magnum/platform) |
||||
endif() |
||||
|
||||
if(Magnum_WindowlessGlxApplication_FOUND) |
||||
pybind11_add_module(magnum_platform_glx glx.cpp) |
||||
target_link_libraries(magnum_platform_glx PRIVATE Magnum::WindowlessGlxApplication) |
||||
target_include_directories(magnum_platform_glx PRIVATE ${PROJECT_SOURCE_DIR}/src/python) |
||||
set_target_properties(magnum_platform_glx PROPERTIES |
||||
FOLDER "python/platform" |
||||
OUTPUT_NAME "glx" |
||||
LIBRARY_OUTPUT_DIRECTORY ${output_dir}/magnum/platform) |
||||
endif() |
||||
|
||||
file(GENERATE OUTPUT ${output_dir}/magnum/platform/__init__.py |
||||
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py) |
||||
@ -0,0 +1,34 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
|
||||
"""Platform-specific application and context creation""" |
||||
|
||||
try: |
||||
from .glx import WindowlessApplication |
||||
except ImportError: # pragma: no cover |
||||
try: |
||||
from .egl import WindowlessApplication |
||||
except ImportError: |
||||
pass |
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
#include <Magnum/Platform/WindowlessEglApplication.h> |
||||
|
||||
#include "magnum/bootstrap.h" |
||||
#include "magnum/platform/windowlessapplication.h" |
||||
|
||||
namespace magnum { namespace platform { namespace { |
||||
|
||||
int argc = 0; |
||||
|
||||
void egl(py::module& m) { |
||||
struct PyWindowlessApplication: Platform::WindowlessApplication { |
||||
explicit PyWindowlessApplication(const Configuration& configuration = Configuration{}): Platform::WindowlessApplication{Arguments{argc, nullptr}, configuration} {} |
||||
|
||||
int exec() override { |
||||
PYBIND11_OVERLOAD_PURE_NAME( |
||||
int, |
||||
PyWindowlessApplication, |
||||
"exec", |
||||
); |
||||
} |
||||
}; |
||||
|
||||
py::class_<PyWindowlessApplication> windowlessEglApplication{m, "WindowlessApplication", "Windowless EGL application"}; |
||||
|
||||
windowlessapplication(windowlessEglApplication); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
PYBIND11_MODULE(egl, m) { |
||||
m.doc() = "EGL-based platform integration"; |
||||
|
||||
magnum::platform::egl(m); |
||||
} |
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
#include <Magnum/Platform/WindowlessGlxApplication.h> |
||||
|
||||
#include "magnum/bootstrap.h" |
||||
#include "magnum/platform/windowlessapplication.h" |
||||
|
||||
namespace magnum { namespace platform { namespace { |
||||
|
||||
int argc = 0; |
||||
|
||||
void glx(py::module& m) { |
||||
struct PyWindowlessApplication: Platform::WindowlessApplication { |
||||
explicit PyWindowlessApplication(const Configuration& configuration = Configuration{}): Platform::WindowlessApplication{Arguments{argc, nullptr}, configuration} {} |
||||
|
||||
int exec() override { |
||||
PYBIND11_OVERLOAD_PURE_NAME( |
||||
int, |
||||
PyWindowlessApplication, |
||||
"exec", |
||||
); |
||||
} |
||||
}; |
||||
|
||||
py::class_<PyWindowlessApplication> windowlessGlxApplication{m, "WindowlessApplication", "Windowless GLX application"}; |
||||
|
||||
windowlessapplication(windowlessGlxApplication); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
PYBIND11_MODULE(glx, m) { |
||||
m.doc() = "GLX-based platform integration"; |
||||
|
||||
magnum::platform::glx(m); |
||||
} |
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
|
||||
#include "magnum/bootstrap.h" |
||||
|
||||
namespace magnum { namespace platform { |
||||
|
||||
template<class T> void windowlessapplication(py::class_<T>& c) { |
||||
py::class_<typename T::Configuration> configuration{c, "Configuration", "Configuration"}; |
||||
configuration |
||||
.def(py::init()); |
||||
/** @todo others */ |
||||
|
||||
c |
||||
/* Constructor */ |
||||
.def(py::init<const typename T::Configuration&>(), py::arg("configuration") = typename T::Configuration{}, |
||||
"Constructor") |
||||
/** @todo the nocreate ones */ |
||||
|
||||
.def("exec", &T::exec, "Execute application") |
||||
/** @todo more */ |
||||
; |
||||
} |
||||
|
||||
}} |
||||
Loading…
Reference in new issue