12#ifndef GAMP_DEMOS_LAUNCHER01_HPP_
13#define GAMP_DEMOS_LAUNCHER01_HPP_
15#include <GLES3/gl32.h>
35#if !defined(__EMSCRIPTEN__)
37 static void GLDebugCallback(GLenum source, GLenum
type, GLuint
id, GLenum severity, GLsizei length,
const GLchar *message,
const void *userParam) {
39 jau::PLAIN_PRINT(
true,
"GL-Debug: src 0x%x, type 0x%x, id 0x%x, serverity 0x%x, len %zu: %s", source,
type,
id, severity, length, message);
50 std::string demo_name = std::string(
"Gamp ").append(
jau::io::fs::basename(sfile, {{
".cpp"}, {
".hpp"}}));
51 std::cout <<
"Launching: " << demo_name <<
", source " << sfile <<
" , exe " << argv[0] <<
"\n";
53 #if defined(__EMSCRIPTEN__)
54 int win_width = 1024, win_height = 576;
56 int win_width = 1920, win_height = 1000;
59 for(
int i=1; i<argc; ++i) {
60 if( 0 == strcmp(
"-gl", argv[i]) && i+1<argc) {
64 }
else if( 0 == strcmp(
"-width", argv[i]) && i+1<argc) {
65 win_width = atoi(argv[i+1]);
67 }
else if( 0 == strcmp(
"-height", argv[i]) && i+1<argc) {
68 win_height = atoi(argv[i+1]);
70 }
else if( 0 == strcmp(
"-fps", argv[i]) && i+1<argc) {
75 std::cout <<
"-profile " << props.
profile <<
", context flags " << props.
contextFlags <<
"\n";
86 printf(
"Exit (1): Failed to create window.\n");
92 const float a = (float)w / (
float)h;
98 printf(
"Exit (2): Failed to create context\n");
108 #if !defined(__EMSCRIPTEN__)
112 GLuint ids[] = { 0 };
113 ::glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, ids, GL_TRUE);
119 #if defined(__EMSCRIPTEN__)
int launch(std::string_view sfile, GLLaunchProps props, const RenderListenerRef &demo, int argc, char *argv[])
static void GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
constexpr RenderContextFlags contextFlags() const noexcept
static GLContext & downcast(RenderContext *rc)
Downcast dereferenced given RenderContext* to GLContext&, throws exception if signature doesn't match...
std::string toString() const override
Specifies the OpenGL profile.
static constexpr bool isValidTag(std::string_view tag) noexcept
const gamp::render::RenderContext * renderContext() const noexcept
constexpr const Vec2i & surfaceSize() const noexcept
Returns the surface size of the client area excluding insets (window decorations) in pixel units.
bool createContext(const gamp::render::RenderProfile &profile, const gamp::render::RenderContextFlags &contextFlags)
void addRenderListener(const RenderListenerRef &l)
static WindowRef create(const char *title, int wwidth, int wheight, bool verbose=false)
Create an new instance using a native windowing toolkit.
constexpr const Recti & windowBounds() const noexcept
Returns the window client-area top-left position and size excluding insets (window decorations) in wi...
void dispose(const jau::fraction_timespec &when) noexcept override
std::string toString() const noexcept
std::string toString() const noexcept
constexpr bool is_set(const E mask, const E bits) noexcept
std::string basename(const std::string_view &path) noexcept
Return stripped leading directory components from given path separated by /.
fraction_timespec getMonotonicTime() noexcept
Returns current monotonic time since Unix Epoch 00:00:00 UTC on 1970-01-01.
RenderContextFlags
OpenGL context flags.
@ verbose
Verbose operations (debugging).
std::shared_ptr< RenderListener > RenderListenerRef
std::shared_ptr< Window > WindowRef
void mainloop_void() noexcept
Calls mainloop_default(), but exits application if returning false.
bool init_gfx_subsystem(const char *exe_path)
GFX Toolkit: Initialize the subsystem once.
bool mainloop_default() noexcept
Performs the whole tasks for all created gamp::wt::Window instances.
int gpu_forced_fps() noexcept
Returns optional forced frames per seconds or -1 if unset, set via set_gpu_forced_fps().
void set_gpu_forced_fps(int fps) noexcept
Optional forced frames per seconds, pass to swap_gpu_buffer() by default.
void PLAIN_PRINT(const bool printPrefix, const char *format,...) noexcept
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
gamp::render::RenderContextFlags contextFlags
gamp::render::gl::GLProfile profile
int printf(const char *format,...)
Operating Systems predefined macros.