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);
51 std::string demo_name = std::string(
"Gamp ").append(
jau::io::fs::basename(sfile, {{
".cpp"}, {
".hpp"}}));
52 std::cout <<
"Launching: " << demo_name <<
", source " << sfile <<
" , exe " << argv[0] <<
"\n";
54 #if defined(__EMSCRIPTEN__)
55 int win_width = 1024, win_height = 576;
57 int win_width = 1920, win_height = 1000;
60 for(
int i=1; i<argc; ++i) {
61 if( 0 == strcmp(
"-gl", argv[i]) && i+1<argc) {
65 }
else if( 0 == strcmp(
"-width", argv[i]) && i+1<argc) {
66 win_width = atoi(argv[i+1]);
68 }
else if( 0 == strcmp(
"-height", argv[i]) && i+1<argc) {
69 win_height = atoi(argv[i+1]);
71 }
else if( 0 == strcmp(
"-fps", argv[i]) && i+1<argc) {
74 }
else if( 0 == strcmp(
"-smsaa", argv[i]) && i+1<argc) {
79 std::cout <<
"-profile " << props.
profile <<
", context flags " << props.
contextFlags <<
"\n";
84 std::cout <<
"Exit (0)...\n";
90 std::cout <<
"Exit (1): Failed to create window.\n";
96 const float a = (float)w / (
float)h;
102 std::cout <<
"Exit (2): Failed to create context\n";
112 #if !defined(__EMSCRIPTEN__)
116 GLuint ids[] = { 0 };
117 ::glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, ids, GL_TRUE);
123 #if defined(__EMSCRIPTEN__)
int launch(std::string_view sfile, GLLaunchProps props, const RenderListenerSRef &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
Specifies a set of OpenGL capabilities.
constexpr GLCapabilities & setMultiSamplesCount(int v) noexcept
Defaults to 0, i.e.
std::string toString() const override
Returns a textual representation of this GLCapabilities object.
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)
static WindowSRef create(const char *title, int wwidth, int wheight, const Capabilities &requested, 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
void addRenderListener(const RenderListenerSRef &l)
std::string toString() const noexcept
#define jau_PLAIN_PRINT(printPrefix, fmt,...)
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
#define jau_printf(fmt,...)
constexpr bool is_set(const E mask, const E bits) noexcept
std::string basename(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< Window > WindowSRef
std::shared_ptr< RenderListener > RenderListenerSRef
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.
gamp::render::RenderContextFlags contextFlags
gamp::render::gl::GLProfile profile
gamp::render::gl::GLCapabilities requestedCaps