Skip to content
Snippets Groups Projects
Commit 88be24ef authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

make a start on platform APIs

parent c7437a1d
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,9 @@ add_subdirectory(phys/bullet)
# Debug backend
add_subdirectory(debug)
# platform integrations
add_subdirectory(platform)
##
# begin windows support
##
......
if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
add_subdirectory(linux)
endif()
\ No newline at end of file
find_package(Fontconfig)
target_link_libraries(fggl PRIVATE Fontconfig::Fontconfig)
target_sources( fggl
PRIVATE
fonts.cpp
)
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 23/06/22.
//
#include <fontconfig/fontconfig.h>
namespace fggl::platform::Linux {
void get_font() {
/* FcConfig *config = FcInitLoadConfigAndFonts();
FcPattern* pat = FcPatternCreate();
FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT, FC_PIXEL_SIZE, FC_SIZE, nullptr);
FcFontSet* fs = FcFontList(config, pat, os);
if ( fs ) {
FcFontSetDestroy(fs);
}*/
}
} // namespace fggl::platform::linux
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Low-Level Linux-specific path management
// Created by webpigeon on 23/06/22.
// see https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
//
#ifndef FGGL_PLATFORM_LINUX_PATHS_HPP
#define FGGL_PLATFORM_LINUX_PATHS_HPP
#include <filesystem>
#include <array>
namespace fggl::platform::Linux {
constexpr const char* ENV_USER_CONFIG = "XDG_CONFIG_HOME";
constexpr const char* EVN_USER_DATA = "XDG_DATA_HOME";
constexpr const char* ENV_USER_CACHE = "XDG_CACHE_HOME";
constexpr const char* ENV_DATA_DIRS = "XDG_DATA_DIRS";
constexpr const char* ENV_CONFIG_DIRS = "XDG_CONFIG_DIRS";
// fallback user paths defined in the XDG spec
constexpr const char* DEFAULT_USER_CONFIG = "~/.config";
constexpr const char* DEFAULT_USER_DATA = "~/.local/share";
constexpr const char* DEFAULT_USER_CACHE = "~/.cache";
// fallback search paths defined in the XDG spec
constexpr const std::array<const char*, 2> DEFAULT_DATA_DIRS = {"/usr/local/share/", "/usr/share/"};
constexpr const std::array<const char*, 1> DEFAULT_CONFIG_DIRS = {"/etc/xdg"};
// search routines for finding data and configuration files
std::filesystem::path locate_data(const std::string& base, const std::filesystem::path& relPath);
std::filesystem::path locate_config(const std::string& base, const std::filesystem::path& relPath);
// helper functions for getting file pointers
FILE* open_user_config(std::string& base, const std::filesystem::path& relPath);
FILE* open_user_config_rw(std::string& base, const std::filesystem::path& relPath, bool create = true);
FILE* open_user_cache(std::string& base, const std::filesystem::path& relPath);
FILE* open_user_cache_rw(std::string& base, const std::filesystem::path& relPath, bool create = true);
FILE* open_user_data(std::string& base, const std::filesystem::path& relPath);
FILE* open_user_data_rw(std::string& base, const std::filesystem::path& relPath, bool create = true);
// game data is always read only
FILE* open_game_data(std::string& base, const std::filesystem::path& relPath);
}
#endif //FGGL_PLATFORM_LINUX_PATHS_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment