Commit 633e5c06 authored by hnc's avatar hnc

Start thoth::window

parent f2de2c10
......@@ -49,7 +49,7 @@ cmake_minimum_required(VERSION 2.6)
# OpenSceneGraph
message(STATUS "---")
find_package(thoth_openscenegraph PATHS "${THOTH_CMAKE_PATH}" NO_DEFAULT_PATH)
find_package(thoth_osg PATHS "${THOTH_CMAKE_PATH}" NO_DEFAULT_PATH)
# OGRE
message(STATUS "---")
......@@ -109,6 +109,7 @@ cmake_minimum_required(VERSION 2.6)
endif()
message(STATUS "---")
message (STATUS "Thōth uses ${THOTH_BACKEND} as back end")
add_definitions("-DTHOTH_BACKEND_${THOTH_BACKEND}")
# Thōth X11, Cocoa and d2d1
message(STATUS "---")
......@@ -178,9 +179,18 @@ cmake_minimum_required(VERSION 2.6)
install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.hpp")
# .cmake
install(FILES cmake/thoth-config.cmake DESTINATION lib/thoth)
install(FILES cmake/thoth_cocoa-config.cmake DESTINATION lib/thoth_cocoa)
install(FILES cmake/thoth_d2d1-config.cmake DESTINATION lib/thoth_d2d1)
install(FILES cmake/thoth_media-config.cmake DESTINATION lib/thoth_media)
install(FILES cmake/thoth_sfml-config.cmake DESTINATION lib/thoth_sfml)
install(FILES cmake/thoth_ogre-config.cmake DESTINATION lib/thoth_ogre)
install(FILES cmake/thoth_osg-config.cmake DESTINATION lib/thoth_osg)
install(FILES cmake/thoth_sdl1-config.cmake DESTINATION lib/thoth_sdl1)
install(FILES cmake/thoth_sdl2-config.cmake DESTINATION lib/thoth_sdl2)
install(FILES cmake/thoth_sfml_audio-config.cmake DESTINATION lib/thoth_sfml_audio)
install(FILES cmake/thoth_sfml_network-config.cmake DESTINATION lib/thoth_sfml_network)
install(FILES cmake/thoth_sfml_system-config.cmake DESTINATION lib/thoth_sfml_system)
install(FILES cmake/thoth_sfml_window-config.cmake DESTINATION lib/thoth_sfml_window)
install(FILES cmake/thoth_x11-config.cmake DESTINATION lib/thoth_x11)
# media
install(DIRECTORY share/thoth DESTINATION share)
# Doxygen
......
This diff is collapsed.
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_CONVERSION_TO_HOPP_HPP
#define THOTH_CONVERSION_TO_HOPP_HPP
#include <hopp/container/vector2.hpp>
#include <hopp/geometry/rectangle.hpp>
#ifdef thoth_with_SFML_WINDOW
#include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/Rect.hpp>
#endif
namespace thoth
{
#ifdef thoth_with_SFML_WINDOW
/// @brief sf::Vector2<T> to hopp::vector2<T>
/// @param[in] vector2 A sf::Vector2<T>
/// @return hopp::vector2<T> from sf::Vector2<T>
template <class T>
hopp::vector2<T> to_hopp(sf::Vector2<T> const & vector2)
{
return { vector2.x, vector2.y };
}
/// @brief sf::Rect<T> to hopp::rectangle<T>
/// @param[in] rectangle A sf::Rect<T>
/// @return hopp::rectangle<T> from sf::Rect<T>
template <class T>
hopp::rectangle<T> to_hopp(sf::Rect<T> const & rectangle)
{
return { rectangle.left, rectangle.top, rectangle.width, rectangle.height };
}
#endif
}
#endif
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_CONVERSION_TO_OSG_HPP
#define THOTH_CONVERSION_TO_OSG_HPP
#include <hopp/color.hpp>
#ifdef thoth_with_OSG
#include <osg/Vec4f>
#endif
namespace thoth
{
#ifdef thoth_with_OSG
/// @brief hopp::color to osg::Vec4
/// @param[in] color A hopp::color
/// @return osg::Vec4 from hopp::color
inline osg::Vec4 to_osg(hopp::color const & color)
{
return { float(color.r) / 255.f, float(color.g) / 255.f, float(color.b) / 255.f, 1.f };
}
#endif
}
#endif
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_CONVERSION_TO_SFML_HPP
#define THOTH_CONVERSION_TO_SFML_HPP
#include <hopp/container/vector2.hpp>
#include <hopp/geometry/rectangle.hpp>
#include <hopp/int/uint8.hpp>
#include <hopp/color.hpp>
#ifdef thoth_with_SFML_WINDOW
#include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/Rect.hpp>
#endif
namespace thoth
{
#ifdef thoth_with_SFML_WINDOW
/// @brief hopp::vector2<T> to sf::Vector2<T>
/// @param[in] vector2 A hopp::vector2<T>
/// @return sf::Vector2<T> from hopp::vector2<T>
template <class T>
sf::Vector2<T> to_sfml(hopp::vector2<T> const & vector2)
{
return sf::Vector2<T>(vector2.x, vector2.y);
}
/// @brief hopp::rectangle<T> to sf::Rect<T>
/// @param[in] rectangle A hopp::rectangle<T>
/// @return sf::Rect<T> from hopp::rectangle<T>
template <class T>
sf::Rect<T> to_sfml(hopp::rectangle<T> const & rectangle)
{
return sf::Rect<T>(rectangle.left, rectangle.top, rectangle.width, rectangle.height);
}
/// @brief hopp::uint8 to sf::Uint8
/// @param[in] uint8 A hopp::uint8
/// @return sf::Uint8 from hopp::uint8
inline sf::Uint8 to_sfml(hopp::uint8 const & uint8)
{
return sf::Uint8(uint8.i);
}
/// @brief hopp::color to sf::Color
/// @param[in] color A hopp::color
/// @return sf::Color from hopp::color
inline sf::Color to_sfml(hopp::color const & color)
{
return sf::Color(thoth::to_sfml(color.r), thoth::to_sfml(color.g), thoth::to_sfml(color.b), thoth::to_sfml(color.a));
}
#endif
}
#endif
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_CONVERSION_TO_STD_HPP
#define THOTH_CONVERSION_TO_STD_HPP
#include <chrono>
#include <cstdint>
#ifdef thoth_with_sfml
#include <SFML/System/Time.hpp>
#endif
namespace thoth
{
#ifdef thoth_with_sfml
/// @brief sf::Time to std::chrono::duration<int64_t, std::micro>
/// @param[in] time A sf::Time
/// @return std::chrono::duration<int64_t, std::micro> from sf::Time
inline std::chrono::duration<int64_t, std::micro> to_std(sf::Time const & time)
{
return std::chrono::duration<int64_t, std::micro>(time.asMicroseconds());
}
#endif
}
#endif
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
/*! @mainpage Thōth
*
* https://gitlab.com/hnc/thoth @n
* http://hnc.toile-libre.org/index.php?section=dev&page=thoth @n
* https://www.lri.fr/~bagneres/index.php?section=dev&page=thoth
*
* @section section_hopp Thōth
*
* Modern and generic C++14 header-only library for GUI and games
*
* GNU Affero General Public License 3+
*
* @section section_system_requirement System Requirement
*
* Required:
* - hopp @n
* - SFML system audio network @n
* - SFML window || OpenSceneGraph || OGRE || SDL
*
* @section section_installation Installation
*
* With CMake:
* - @code
mkdir build
cd build
cmake .. # -DCMAKE_INSTALL_PREFIX=/path/to/install
#
# -DCMAKE_BUILD_TYPE=Release
# -DCMAKE_BUILD_TYPE=Debug
#
# -DDISABLE_TESTS=TRUE
#
# -DTHOTH_BACKEND=OSG
# -DTHOTH_BACKEND=OGRE
# -DTHOTH_BACKEND=SFML_WINDOW
# -DTHOTH_BACKEND=SDL1
# -DTHOTH_BACKEND=SDL2
#
# -DTHOTH_DISABLE_OSG=1
# -DTHOTH_DISABLE_OGRE=1
# -DTHOTH_DISABLE_SFML_WINDOW=1
# -DTHOTH_DISABLE_SDL1=1
# -DTHOTH_DISABLE_SDL2=1
make
# make doc
# make test
make install # su -c "make install" # sudo make install
@endcode
*
* Without CMake:
* - This project is a header-only library, you can copy the include directory in /usr/local (for example) or in your project. (But you have to define some macros to enable optional parts.)
*
* @section section_utilization Utilization
*
* If you use CMake, add these lines in your CMakeLists.txt:
* @code
# Thōth
message(STATUS "---")
find_package(thoth REQUIRED)
# See /installation/path/lib/thoth/thoth-config.cmake for CMake variables
@endcode
*/
#ifndef THOTH_HPP
#define THOTH_HPP
/**
* @defgroup thoth_about About Thōth
* @copydoc thoth
*/
#include <string>
/**
* @brief Thōth
*
* @code
#include <thoth/thoth.hpp>
@endcode
*/
namespace thoth
{
/// @brief Version of Thōth
/// @return version of Thōth
/// @ingroup thoth_about
inline std::string version() { return "0.0.0"; }
/// @brief Codename of Thōth
/// @return codename of Thōth
/// @ingroup thoth_about
inline std::string codename() { return "A New Way"; }
}
#endif
// Copyright © 2015, 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_WINDOW_HPP
#define THOTH_WINDOW_HPP
/**
* @defgroup thoth_window Window
*
* @brief Window
*
* @code
#include <thoth/window.hpp>
@endcode
*/
// Window
#include "window/window.hpp"
// // Texture & Sprites
// #include "window/texture.hpp"
// #include "window/sprite.hpp"
//
// // Text
// #include "window/text.hpp"
//
// // Primitives
// #include "window/primitives.hpp"
//
// // Mouse & Keyboard
// #include "window/mouse.hpp"
// #include "window/keyboard.hpp"
/**
* @defgroup thoth_window_osg OSG window
*
* @brief OSG window
*
* @code
#include <thoth/window.hpp>
@endcode
*
* @ingroup thoth_window
*/
/**
* @defgroup thoth_window_sfml SFML window
*
* @brief SFML window
*
* @code
#include <thoth/window.hpp>
@endcode
*
* @ingroup thoth_window
*/
#endif
// Copyright © 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_WINDOW_T_WINDOW_STYLE_HPP
#define THOTH_WINDOW_T_WINDOW_STYLE_HPP
#include <string>
#include <hopp/container/vector2.hpp>
#include <hopp/int/uint.hpp>
namespace thoth
{
/**
* @brief Window style
*
* @code
#include <thoth/window.hpp>
@endcode
*
* @ingroup thoth_window
*/
class window_style
{
private:
/// Fullscreen
bool m_fullscreen;
// Can be resized
bool m_resizeable;
// Can be closed
bool m_closeable;
// Has decoration
bool m_decoration;
public:
/// Default constructor
/// @param[in] fullscreen true if fullscreen, false otherwise
/// @param[in] resizeable true if resizeable, false otherwise
/// @param[in] closeable true if closeable, false otherwise
/// @param[in] decoration true if window has decoration, false otherwise
window_style
(
bool const fullscreen = false,
bool const resizeable = true,
bool const closeable = true,
bool const decoration = true
) :
m_fullscreen(fullscreen),
m_resizeable(resizeable),
m_closeable(closeable),
m_decoration(decoration)
{ }
// Getters
/// Fullscreen?
/// @return true if fullscreen, false otherwise
bool is_fullscreen() const { return m_fullscreen; }
/// Can be resized?
/// @return true if resizeable, false otherwise
bool is_resizeable() const { return m_resizeable; }
/// Can be closed?
/// @return true if closeable, false otherwise
bool is_closeable() const { return m_closeable; }
/// Has decoration?
/// @return true if decoration, false otherwise
bool has_decoration() const { return m_decoration; }
// Setters
/// Fullscreen
/// @param[in] b true if fullscreen, false otherwise
/// @return current thoth::window_style to chain setters
window_style & fullscreen(bool const b) { m_fullscreen = b; return *this; }
/// Can be resized
/// @param[in] b true if resizeable, false otherwise
/// @return current thoth::window_style to chain setters
window_style & resizeable(bool const b) { m_resizeable = b; return *this; }
/// Can be closed
/// @param[in] b true if closeable, false otherwise
/// @return current thoth::window_style to chain setters
window_style & closeable(bool const b) { m_closeable = b; return *this; }
/// Decoration
/// @param[in] b true if window has decoration, false otherwise
/// @return current thoth::window_style to chain setters
window_style & decoration(bool const b) { m_decoration = b; return *this; }
};
}
#endif
// Copyright © 2016 Lénaïc Bagnères, hnc@singularity.fr
// This file is part of Thōth.
// Thōth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Thōth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with Thōth. If not, see <http://www.gnu.org/licenses/>
#ifndef THOTH_WINDOW_OSG_WINDOW_HPP
#define THOTH_WINDOW_OSG_WINDOW_HPP
#ifdef thoth_with_OSG
// #include <SFML/Graphics.hpp>
//
// #include <hopp/container/vector2.hpp>
//
// #include "../../conversion/to_hopp.hpp"
// #include "../../conversion/to_sfml.hpp"
#include <memory>
#include <hopp/memory.hpp>
#include <hopp/color.hpp>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include "../../conversion/to_osg.hpp"
#include "../T/window_style.hpp"
namespace thoth
{
namespace osg
{
/**
* @brief OSG window
*
* @code