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::fs::basename(sfile, {{
".cpp"}, {
".hpp"}}));
51 printf(
"Launching: %s, source %s, exe %s\n", demo_name.c_str(), sfile.data(), argv[0]);
53 int win_width = 1920, win_height = 1000;
54 #if defined(__EMSCRIPTEN__)
55 win_width = 1024, win_height = 576;
58 for(
int i=1; i<argc; ++i) {
59 if( 0 == strcmp(
"-width", argv[i]) && i+1<argc) {
60 win_width = atoi(argv[i+1]);
62 }
else if( 0 == strcmp(
"-height", argv[i]) && i+1<argc) {
63 win_height = atoi(argv[i+1]);
65 }
else if( 0 == strcmp(
"-fps", argv[i]) && i+1<argc) {
80 printf(
"Exit (1): Failed to create window.\n");
86 const float a = (float)w / (
float)h;
92 printf(
"Exit (2): Failed to create context\n");
102 #if !defined(__EMSCRIPTEN__)
106 GLuint ids[] = { 0 };
107 ::glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, ids, GL_TRUE);
113 #if defined(__EMSCRIPTEN__)
int launch(std::string_view sfile, const 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.
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.