Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
gamp.cpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#include "gamp/Gamp.hpp"
13
14#include <ctime>
15#include <jau/debug.hpp>
16#include <jau/environment.hpp>
17#include <jau/file_util.hpp>
18#include <jau/string_util.hpp>
19
23#include <gamp/graph/Graph.hpp>
24
25static std::string m_asset_dir;
26
27//
28//
29//
30
31std::string gamp::lookup_and_register_asset_dir(const char* exe_path, const char* asset_file, const char* asset_install_subdir) noexcept {
32 m_asset_dir = jau::fs::lookup_asset_dir(exe_path, asset_file, asset_install_subdir);
33 return m_asset_dir;
34}
35std::string gamp::asset_dir() noexcept { return m_asset_dir; }
36
37std::string gamp::resolve_asset(const std::string &asset_file, bool lookup_direct) noexcept {
38 if( lookup_direct && jau::fs::exists(asset_file) ) {
39 return asset_file;
40 }
41 if( m_asset_dir.size() ) {
42 std::string fname1 = m_asset_dir+"/"+asset_file;
43 if( jau::fs::exists(fname1) ) {
44 return fname1;
45 }
46 }
47 return "";
48}
49
50gamp::GampEnv::GampEnv() noexcept
51: DEBUG_GLOBAL( jau::environment::get("gamp").debug ),
52 exploding( true ), // jau::environment::getExplodingProperties("gamp_debug") ),
53 DEBUG_WT_EVENT( jau::environment::getBooleanProperty("gamp.debug.wt.event", false) ),
54 DEBUG_RENDER_GL_GLSL_CODE( jau::environment::getBooleanProperty("gamp.debug.render.gl.glsl.code", false) ),
55 DEBUG_RENDER_GL_GLSL_STATE( jau::environment::getBooleanProperty("gamp.debug.render.gl.glsl.state", false) ),
56 DEBUG_GRAPH_RENDER( jau::environment::getBooleanProperty("gamp.debug.graph.render", false) )
57{
58 jau::INFO_PRINT("GampEnv: Debug[global %d, wt.event %d, render.gl.glsl[code %d, state %d]]",
60}
61
63 return std::string("RC[")
64 .append(signature().name()).append(", ")
65 .append(jau::to_hexstring(m_context)).append(", ")
66 .append(to_string(contextFlags())).append(", ")
67 .append(version().toString()).append(" -> surface ")
68 .append(m_surface?jau::to_hexstring(m_surface->surfaceHandle()):"nil").append("]");
69}
70
const bool DEBUG_WT_EVENT
Debug all WT event communication.
Definition Gamp.hpp:143
static GampEnv & get() noexcept
Definition Gamp.hpp:170
const bool DEBUG_RENDER_GL_GLSL_CODE
Debug shader code, i.e.
Definition Gamp.hpp:151
const bool DEBUG_GLOBAL
Global Debug flag, retrieved first to triggers GampEnv initialization.
Definition Gamp.hpp:131
const bool DEBUG_GRAPH_RENDER
Debug Graph Renderer.
Definition Gamp.hpp:167
const bool DEBUG_RENDER_GL_GLSL_STATE
Debug shader state, i.e.
Definition Gamp.hpp:159
static bool DEBUG_MODE
Definition Graph.hpp:24
virtual std::string toString() const
Definition gamp.cpp:62
gamp::wt::SurfaceRef m_surface
virtual const jau::type_info & signature() const noexcept
constexpr RenderContextFlags contextFlags() const noexcept
constexpr const jau::util::VersionNumber & version() const
static std::string m_asset_dir
Definition gamp.cpp:25
consteval_cxx20 std::string_view name() noexcept
bool exists(const std::string &path, bool verbose_on_error=false) noexcept
Returns true if path exists and is accessible.
std::string lookup_asset_dir(const char *exe_path, const char *asset_file, const char *asset_install_subdir) noexcept
Returns located asset directory if found, otherwise an empty string.
std::string lookup_and_register_asset_dir(const char *exe_path, const char *asset_file="fonts/freefont/FreeSansBold.ttf", const char *asset_install_subdir="gamp") noexcept
Definition gamp.cpp:31
std::string resolve_asset(const std::string &asset_file, bool lookup_direct=false) noexcept
Definition gamp.cpp:37
std::string asset_dir() noexcept
Definition gamp.cpp:35
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition backtrace.hpp:32
void INFO_PRINT(const char *format,...) noexcept
Use for unconditional informal messages, prefix '[elapsed_time] Info: '.
Definition debug.cpp:248