Gamp v0.0.8
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
Primitives02.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 <cstdio>
13#include <cmath>
16#include <memory>
17#include <vector>
18
19#include <jau/basic_types.hpp>
20#include <jau/darray.hpp>
21#include <jau/float_math.hpp>
22#include <jau/float_types.hpp>
23#include <jau/fraction_type.hpp>
24#include <jau/io/file_util.hpp>
25#include <jau/math/vec3f.hpp>
26#include <jau/math/vec4f.hpp>
27#include <jau/math/vec4f.hpp>
32
33#include <gamp/Gamp.hpp>
38
40
42
43using namespace jau::math;
44using namespace jau::math::util;
45using namespace jau::math::geom;
46
47using namespace gamp;
48using namespace gamp::wt;
49using namespace gamp::wt::event;
50
51using namespace gamp::graph;
52using namespace gamp::graph::tess;
53using namespace gamp::render::gl::glsl;
54using namespace gamp::render::gl::data;
55
56class Shape;
57typedef std::shared_ptr<Shape> ShapeRef;
58
59class Shape {
60 private:
61 ShaderState& m_st;
62 GLUniformSyncPMVMat4f& m_pmvMatUni;
63 GLUniformVec4f& m_staticColor;
64 OutlineShape m_oshape;
66
67 Vec3f m_position;
68 Quat4f m_rotation;
69 Vec3f m_rotPivot;
70 Vec3f m_scale = Vec3f(1, 1, 1);
71 float m_zOffset = 0.0f;
72 Vec4f m_color = Vec4f(0, 0, 0, 1);
74
75 Mat4f iMat;
76 Mat4f tmpMat;
77 bool iMatIdent = true;
78 bool iMatDirty = false;
79
80 struct Private{ explicit Private() = default; };
81
82 public:
84 : m_st(st), m_pmvMatUni(pmvMatU), m_staticColor(color),
85 m_oshape(3, 16),
86 m_array(GLFloatArrayDataServer::createGLSLInterleaved(2*3, false, 256, GL_STATIC_DRAW))
87 {
88 m_array->addGLSLSubArray("gca_Vertex", 3, GL_ARRAY_BUFFER);
89 m_array->addGLSLSubArray("gca_Normal", 3, GL_ARRAY_BUFFER);
90 m_st.manage(m_array);
91 }
92
94 return std::make_shared<Shape>(Private(), st, pmvMatU, color);
95 }
96
97 constexpr const Vec3f& position() const noexcept { return m_position; }
98 constexpr Vec3f& position() noexcept { iMatDirty=true; return m_position; }
99
100 constexpr const float& zOffset() const noexcept { return m_zOffset; }
101 constexpr float& zOffset() noexcept { iMatDirty=true; return m_zOffset; }
102
103 constexpr const Quat4f& rotation() const noexcept { return m_rotation; }
104 constexpr Quat4f& rotation() noexcept { iMatDirty=true; return m_rotation; }
105
106 constexpr const Vec3f& rotationPivot() const noexcept { return m_rotPivot; }
107 constexpr Vec3f& rotationPivot() noexcept { iMatDirty=true; return m_rotPivot; }
108
109 constexpr const Vec3f& scale() const noexcept { return m_scale; }
110 constexpr Vec3f& scale() noexcept { iMatDirty=true; return m_scale; }
111
112 constexpr const OutlineShape& outlineShape() const noexcept { return m_oshape; }
113 constexpr OutlineShape& outlineShape() noexcept { return m_oshape; }
114
115 const Vec4f& color() const noexcept { return m_color; }
116 void setColor(const Vec4f& c) noexcept { m_color=c; }
117
118 void update(GL& gl) {
120 jau_INFO_PRINT("\n%s", GLUtilTesselator::Segment::toString("- ", m_segments).c_str() );
121 m_array->seal(gl, true);
122 }
123
124 void draw(GL &gl) {
125 m_pmvMatUni.pmv().pushMv();
126 applyMatToMv(m_pmvMatUni.pmv());
127 m_st.send(gl, m_pmvMatUni); // automatic sync + update of Mvi + Mvit
128
129 m_staticColor.vec4f() = m_color;
130 m_st.send(gl, m_staticColor);
131 m_array->enableBuffer(gl, true);
132 for(const GLUtilTesselator::Segment& s : m_segments ) {
133 ::glDrawArrays(s.type, s.first, s.count);
134 }
135 m_array->enableBuffer(gl, false);
136 m_pmvMatUni.pmv().popMv();
137 }
138
139 private:
140 /**
141 * Applies the internal {@link Matrix4f} to the given {@link PMVMatrix4f#getMv() modelview matrix},
142 * i.e. {@code pmv.mulMv( getMat() )}.
143 * <p>
144 * Calls {@link #updateMat()} if dirty.
145 * </p>
146 * In case {@link #isMatIdentity()} is {@code true}, implementation is a no-operation.
147 * </p>
148 * @param pmv the matrix
149 * @see #isMatIdentity()
150 * @see #updateMat()
151 * @see #getMat()
152 * @see PMVMatrix4f#mulMv(Matrix4f)
153 */
154 void applyMatToMv(PMVMat4f& pmvMat) noexcept {
155 if( iMatDirty ) {
156 updateMat();
157 }
158 if( !iMatIdent ) {
159 pmvMat.mulMv(iMat);
160 }
161 }
162 void updateMat() noexcept {
163 bool hasPos = !m_position.is_zero();
164 bool hasScale = m_scale != Vec3f::one;
165 bool hasRotate = !m_rotation.isIdentity();
166 bool hasRotPivot = false; // null != rotPivot;
167 const Vec3f& ctr = m_oshape.bounds().center();
168 bool sameScaleRotatePivot = hasScale && hasRotate && ( !hasRotPivot || m_rotPivot == ctr );
169
170 if( sameScaleRotatePivot ) {
171 iMatIdent = false;
172 iMat.setToTranslation(m_position); // identity + translate, scaled
173 // Scale shape from its center position and rotate around its center
174 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
175 iMat.rotate(m_rotation);
176 iMat.scale(m_scale);
177 iMat.translate(-ctr); // move to center
178 } else if( hasRotate || hasScale ) {
179 iMatIdent = false;
180 iMat.setToTranslation(m_position); // identity + translate, scaled
181 if( hasRotate ) {
182 if( hasRotPivot ) {
183 // Rotate shape around its scaled pivot
184 iMat.translate(Vec3f(m_rotPivot).mul(m_scale)); // pivot back from rot-pivot, scaled
185 iMat.rotate(m_rotation);
186 iMat.translate(Vec3f(-m_rotPivot).mul(m_scale)); // pivot to rot-pivot, scaled
187 } else {
188 // Rotate shape around its scaled center
189 iMat.translate(Vec3f(ctr).mul(m_scale)); // pivot back from center-pivot, scaled
190 iMat.rotate(m_rotation);
191 iMat.translate(Vec3f(-ctr).mul(m_scale)); // pivot to center-pivot, scaled
192 }
193 }
194 if( hasScale ) {
195 // Scale shape from its center position
196 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
197 iMat.scale(m_scale);
198 iMat.translate(Vec3f(-ctr).mul(m_scale)); // move to center
199 }
200 } else if( hasPos ) {
201 iMatIdent = false;
202 iMat.setToTranslation(m_position); // identity + translate, scaled
203
204 } else {
205 iMatIdent = true;
206 iMat.loadIdentity();
207 }
208 iMatDirty = false;
209 }
210};
211
213 private:
214 constexpr static jau::math::Vec3f lightPos = jau::math::Vec3f(0.0f, 5.0f, 10.0f);
215 constexpr static float zNear= 1.0f;
216 constexpr static float zFar =100.0f;
217
218 ShaderState m_st;
219 Recti m_viewport;
220 bool m_initialized;
221 bool m_animating = true;
222 bool m_oneframe = false;
224 GLUniformSyncPMVMat4f m_pmvMat;
225 GLUniformVec3f m_light0Pos;
226 GLUniformVec4f m_staticColor;
227 std::vector<ShapeRef> m_shapes;
228 bool m_once = true;
229
230 public:
233 m_initialized(false),
234 m_pmvMat("gcu_PMVMatrix", PMVData::inv_proj | PMVData::inv_mv | PMVData::inv_tps_mv), // P, Mv, Mvi and Mvit
235 m_light0Pos("gcu_Light0Pos", lightPos),
236 m_staticColor("gcu_StaticColor", Vec4f(0, 0, 0, 1))
237 {
238 m_st.manage(m_pmvMat);
239 m_st.manage(m_light0Pos);
240 m_st.manage(m_staticColor);
241 }
242
243 Recti& viewport() noexcept { return m_viewport; }
244 const Recti& viewport() const noexcept { return m_viewport; }
245
246 PMVMat4f& pmv() noexcept { return m_pmvMat.pmv(); }
247 const PMVMat4f& pmv() const noexcept { return m_pmvMat.pmv(); }
248 bool animating() const noexcept { return m_animating; }
249 bool& animating() noexcept { return m_animating; }
250 void setOneFrame() noexcept { m_animating=false; m_oneframe=true; }
251
252 bool init(const WindowSRef& win, const jau::fraction_timespec& when) override {
253 jau::fprintf_td(when.to_ms(), stdout, "RL::init: %s\n", toString().c_str());
254 m_tlast = when;
255
256 GL& gl = GL::downcast(win->renderContext());
257 ShaderCodeSRef vp0 = ShaderCode::create(gl, GL_VERTEX_SHADER, "demos/glsl",
258 "demos/glsl/bin", "SingleLight0");
259 ShaderCodeSRef fp0 = ShaderCode::create(gl, GL_FRAGMENT_SHADER, "demos/glsl",
260 "demos/glsl/bin", "SingleLight0");
261 if( !vp0 || !fp0 ) {
262 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
263 win->dispose(when);
264 return false;
265 }
266 {
267 std::string custom = "#define MAX_TEXTURE_UNITS 0\n";
268 size_t vsPos = vp0->defaultShaderCustomization(gl, true, true);
269 size_t fsPos = fp0->defaultShaderCustomization(gl, true, true);
270 vp0->insertShaderSource(0, vsPos, custom);
271 fp0->insertShaderSource(0, fsPos, custom);
272 }
273
275 if( !sp0->add(gl, vp0, true) || !sp0->add(gl, fp0, true) ) {
276 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
277 sp0->destroy(gl);
278 win->dispose(when);
279 return false;
280 }
281 m_st.attachShaderProgram(gl, sp0, true);
282
283 // setup mgl_PMVMatrix
284 m_pmvMat.pmv().getP().loadIdentity();
285 m_pmvMat.pmv().getMv().loadIdentity();
286
287 const float lineWidth = 1/2.5f;
288 const float dz = 0.001f;
289 {
290 // Rectangle
291 const float width = 1.5f;
292 const float height = 1.5f;
293 const float x1 = -width/2.0f;
294 const float y1 = -height/2.0f;
295 const float x2 = x1 + width;
296 const float y2 = y1 + height;
297 float z = dz;
298 ShapeRef frontShape = Shape::createShared(m_st, m_pmvMat, m_staticColor);
299 m_shapes.push_back(frontShape);
300 OutlineShape& oshape = frontShape->outlineShape();
301 {
302 // Outer OutlineShape as Winding.CCW.
303 oshape.moveTo(x1, y1, z);
304 oshape.lineTo(x2, y1, z);
305 oshape.lineTo(x2, y2, z);
306 oshape.lineTo(x1, y2, z);
307 oshape.lineTo(x1, y1, z);
308 oshape.closePath();
309 }
310 {
311 // Inner OutlineShape as Winding.CW.
312 // final float dxy0 = getWidth() < getHeight() ? getWidth() : getHeight();
313 const float dxy = lineWidth; // dxy0 * getDebugBox();
314 oshape.moveTo(x1+dxy, y1+dxy, z);
315 oshape.lineTo(x1+dxy, y2-dxy, z);
316 oshape.lineTo(x2-dxy, y2-dxy, z);
317 oshape.lineTo(x2-dxy, y1+dxy, z);
318 oshape.lineTo(x1+dxy, y1+dxy, z);
319 oshape.closePath();
320 }
321 frontShape->update(gl);
322 frontShape->setColor(Vec4f(0.05f, 0.05f, 0.5f, 1));
323 frontShape->position().x = 1.5f;
324
325 ShapeRef backShape = Shape::createShared(m_st, m_pmvMat, m_staticColor);
326 m_shapes.push_back(backShape);
327 backShape->outlineShape() = oshape.flipFace();
328 backShape->update(gl);
329 backShape->setColor(Vec4f(0.4f, 0.4f, 0.1f, 1));
330 backShape->position().x = 1.5f;
331 }
332 {
333 // Cross / Plus
334 const float width = 1.5f;
335 const float height = 1.5f;
336
337 float lwh = lineWidth/2.0f;
338
339 float twh = width/2.0f;
340 float thh = height/2.0f;
341
342 float ctrX = 0, ctrY = 0, ctrZ = dz;
343 ShapeRef frontShape = Shape::createShared(m_st, m_pmvMat, m_staticColor);
344 m_shapes.push_back(frontShape);
345 OutlineShape& oshape = frontShape->outlineShape();
346 // CCW
347 oshape.moveTo(ctrX-lwh, ctrY+thh, ctrZ); // vert: left-top
348 oshape.lineTo(ctrX-lwh, ctrY+lwh, ctrZ);
349 oshape.lineTo(ctrX-twh, ctrY+lwh, ctrZ); // horz: left-top
350 oshape.lineTo(ctrX-twh, ctrY-lwh, ctrZ); // horz: left-bottom
351 oshape.lineTo(ctrX-lwh, ctrY-lwh, ctrZ);
352 oshape.lineTo(ctrX-lwh, ctrY-thh, ctrZ); // vert: left-bottom
353 oshape.lineTo(ctrX+lwh, ctrY-thh, ctrZ); // vert: right-bottom
354 oshape.lineTo(ctrX+lwh, ctrY-lwh, ctrZ);
355 oshape.lineTo(ctrX+twh, ctrY-lwh, ctrZ); // horz: right-bottom
356 oshape.lineTo(ctrX+twh, ctrY+lwh, ctrZ); // horz: right-top
357 oshape.lineTo(ctrX+lwh, ctrY+lwh, ctrZ);
358 oshape.lineTo(ctrX+lwh, ctrY+thh, ctrZ); // vert: right-top
359 oshape.lineTo(ctrX-lwh, ctrY+thh, ctrZ); // vert: left-top
360 oshape.closePath();
361 // shape1->seal(gl, true);
362 frontShape->update(gl);
363 frontShape->setColor(Vec4f(0.5f, 0.05f, 0.05f, 1));
364 frontShape->position().x = -1.5f;
365
366 ShapeRef backShape = Shape::createShared(m_st, m_pmvMat, m_staticColor);
367 m_shapes.push_back(backShape);
368 backShape->outlineShape() = oshape.flipFace();
369 backShape->update(gl);
370 backShape->setColor(Vec4f(0.2f, 0.2f, 0.2f, 1));
371 backShape->position().x = -1.5f;
372 }
373
374 ::glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
375 ::glEnable(GL_DEPTH_TEST);
376 ::glEnable(GL_CULL_FACE);
377
378 m_initialized = sp0->inUse();
379 if( !m_initialized ) {
380 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
381 m_st.destroy(gl);
382 win->dispose(when);
383 }
384 return m_initialized;
385 }
386
387 void dispose(const WindowSRef& win, const jau::fraction_timespec& when) override {
388 jau::fprintf_td(when.to_ms(), stdout, "RL::dispose: %s\n", toString().c_str());
389 m_st.destroy(GL::downcast(win->renderContext()));
390 m_initialized = false;
391 }
392
393 void reshape(const WindowSRef& win, const jau::math::Recti& viewport, const jau::fraction_timespec& when) override {
394 GL& gl = GL::downcast(win->renderContext());
395 jau::fprintf_td(when.to_ms(), stdout, "RL::reshape: %s\n", toString().c_str());
396 m_viewport = viewport;
397
398 m_pmvMat.pmv().getP().loadIdentity();
399 const float aspect = 1.0f;
400 const float fovy_deg=45.0f;
401 const float aspect2 = ( (float) m_viewport.width() / (float) m_viewport.height() ) / aspect;
402 m_pmvMat.pmv().perspectiveP(jau::adeg_to_rad(fovy_deg), aspect2, zNear, zFar);
403 m_st.useProgram(gl, true);
404 m_st.send(gl, m_pmvMat); // automatic sync + update of Mvi + Mvit
405 // m_st.useProgram(gl, false);
406 }
407
408 void display(const WindowSRef& win, const jau::fraction_timespec& when) override {
409 // jau::fprintf_td(when.to_ms(), stdout, "RL::display: %s, %s\n", toString().c_str(), win->toString().c_str());
410 if( !m_initialized ) {
411 return;
412 }
413 GL& gl = GL::downcast(win->renderContext());
414 ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
415
416 m_st.useProgram(gl, true);
417 m_pmvMat.pmv().getMv().loadIdentity();
418 m_pmvMat.pmv().translateMv(0, 0, -5);
419
420 for(const ShapeRef& s : m_shapes) {
421 if( animating() || m_oneframe ) {
422 constexpr double angle_per_sec = 30;
423 const float rad = (float) ( (when - m_tlast).to_double() * angle_per_sec );
424 s->rotation().rotateByAngleY(jau::adeg_to_rad( rad ));
425 }
426 s->draw(gl);
427 }
428 m_oneframe = false;
429 // m_st.useProgram(gl, false);
430
431 if( m_once ) {
432 m_once = false;
433 std::cerr << "XXX draw " << m_st << "\n";
434 }
435
436 m_tlast = when;
437 }
438
439 std::string toStringImpl() const noexcept override { return "Primitives02"; }
440};
441
442class Example : public Primitives02 {
443 private:
444 class MyKeyListener : public KeyListener {
445 private:
446 Primitives02& m_parent;
447 public:
448 MyKeyListener(Primitives02& p) : m_parent(p) {}
449
450 void keyPressed(KeyEvent& e, const KeyboardTracker& kt) override {
451 jau::fprintf_td(e.when().to_ms(), stdout, "KeyPressed: %s; keys %zu\n", e.toString().c_str(), kt.pressedKeyCodes().count());
452 if( e.keySym() == VKeyCode::VK_ESCAPE ) {
453 WindowSRef win = e.source().lock();
454 if( win ) {
455 win->dispose(e.when());
456 }
457 } else if( e.keySym() == VKeyCode::VK_PAUSE || e.keySym() == VKeyCode::VK_P ) {
458 m_parent.animating() = !m_parent.animating();
459 } else if( e.keySym() == VKeyCode::VK_PERIOD ) {
460 m_parent.setOneFrame();
461 } else if( e.keySym() == VKeyCode::VK_W ) {
462 WindowSRef win = e.source().lock();
463 jau::fprintf_td(e.when().to_ms(), stdout, "Source: %s\n", win ? win->toString().c_str() : "null");
464 }
465 }
466 void keyReleased(KeyEvent& e, const KeyboardTracker& kt) override {
467 jau::fprintf_td(e.when().to_ms(), stdout, "KeyRelease: %s; keys %zu\n", e.toString().c_str(), kt.pressedKeyCodes().count());
468 }
469 };
470 typedef std::shared_ptr<MyKeyListener> MyKeyListenerRef;
471 MyKeyListenerRef m_kl;
472
473 public:
475 : Primitives02(),
476 m_kl(std::make_shared<MyKeyListener>(*this)) { }
477
478 bool init(const WindowSRef& win, const jau::fraction_timespec& when) override {
479 if( !Primitives02::init(win, when) ) {
480 return false;
481 }
482 win->addKeyListener(m_kl);
483 return true;
484 }
485 void dispose(const WindowSRef& win, const jau::fraction_timespec& when) override {
486 win->removeKeyListener(m_kl);
487 Primitives02::dispose(win, when);
488 }
489};
490
491int main(int argc, char *argv[]) // NOLINT(bugprone-exception-escape)
492{
494
495 return launch("Primitives02.cpp",
497 std::make_shared<Example>(), argc, argv);
498}
int launch(std::string_view sfile, GLLaunchProps props, const RenderListenerSRef &demo, int argc, char *argv[])
std::shared_ptr< Shape > ShapeRef
int main(int argc, char *argv[])
std::shared_ptr< Shape > ShapeRef
bool init(const WindowSRef &win, const jau::fraction_timespec &when) override
Called by the drawable immediately after the render context is initialized.
void dispose(const WindowSRef &win, const jau::fraction_timespec &when) override
Notifies the listener to perform the release of all renderer resources per context,...
std::string toStringImpl() const noexcept override
void setOneFrame() noexcept
bool & animating() noexcept
void reshape(const WindowSRef &win, const jau::math::Recti &viewport, const jau::fraction_timespec &when) override
Called by the drawable during the first repaint after the component has been resized.
Recti & viewport() noexcept
void dispose(const WindowSRef &win, const jau::fraction_timespec &when) override
Notifies the listener to perform the release of all renderer resources per context,...
void display(const WindowSRef &win, const jau::fraction_timespec &when) override
Called by the drawable to initiate rendering by the client.
bool animating() const noexcept
bool init(const WindowSRef &win, const jau::fraction_timespec &when) override
Called by the drawable immediately after the render context is initialized.
PMVMat4f & pmv() noexcept
const PMVMat4f & pmv() const noexcept
const Recti & viewport() const noexcept
constexpr const float & zOffset() const noexcept
void setColor(const Vec4f &c) noexcept
constexpr const OutlineShape & outlineShape() const noexcept
constexpr Vec3f & position() noexcept
static ShapeRef createShared(ShaderState &st, GraphRenderer &renderer)
void draw(GL &gl)
void update(GL &gl)
constexpr const Quat4f & rotation() const noexcept
Shape(Private, ShaderState &st, GLUniformSyncPMVMat4f &pmvMatU, GLUniformVec4f &color)
constexpr OutlineShape & outlineShape() noexcept
static ShapeRef createShared(ShaderState &st, GLUniformSyncPMVMat4f &pmvMatU, GLUniformVec4f &color)
constexpr const Vec3f & rotationPivot() const noexcept
constexpr float & zOffset() noexcept
constexpr const Vec3f & position() const noexcept
constexpr Vec3f & scale() noexcept
constexpr Vec3f & rotationPivot() noexcept
const Vec4f & color() const noexcept
constexpr const Vec3f & scale() const noexcept
constexpr Quat4f & rotation() noexcept
A Generic shape objects which is defined by a list of Outlines.
void moveTo(float x, float y, float z)
Start a new position for the next line segment at given point x/y (P1).
void closePath()
Closes the current sub-path segment by drawing a straight line back to the coordinates of the last mo...
OutlineShape flipFace(float zoffset=0) const
Returns a copy of this instance with normal() pointing to the opposite direction and all outlines() v...
void lineTo(float x, float y, float z)
Add a line segment, intersecting the last point and the given point x/y (P1).
static SegmentList tesselate(int flags, GLFloatArrayDataServer &array, OutlineShape &outlines)
Specifies a set of OpenGL capabilities.
static GLContext & downcast(RenderContext *rc)
Downcast dereferenced given RenderContext* to GLContext&, throws exception if signature doesn't match...
Specifies the OpenGL profile.
Definition GLContext.hpp:42
static constexpr std::string_view GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition GLContext.hpp:65
size_t defaultShaderCustomization(const GL &gl, bool preludeVersion=true, bool addDefaultPrecision=true, bool addDefaultDefines=true)
Default customization of this shader source code.
static ShaderCodeSRef create(GLenum type, size_t count, const source_list_t &sources)
size_t insertShaderSource(size_t shaderIdx, stringview_t tag, size_t fromIndex, stringview_t data) noexcept
Adds data after the line containing tag.
static ShaderProgramSRef create() noexcept
void destroy(GL &gl) noexcept
Detaches all shader codes and deletes the program.
bool add(const ShaderCodeSRef &shaderCode) noexcept
Adds a new shader to this program.
constexpr bool inUse() const noexcept
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
constexpr RenderListener(Private) noexcept
Private ctor for shared_ptr<RenderListener> instance method w/o public ctor.
Definition Window.hpp:60
std::string toString() const noexcept
Definition Window.hpp:112
const gamp::render::RenderContext * renderContext() const noexcept
Definition Surface.hpp:131
void addKeyListener(const KeyListenerSRef &l)
Definition Window.hpp:310
void dispose(const jau::fraction_timespec &when) noexcept override
Definition Window.hpp:355
size_t removeKeyListener(const KeyListenerSRef &l)
Definition Window.hpp:311
std::string toString() const noexcept
Definition gamp_wt.cpp:145
std::string toString() const noexcept
Definition KeyEvent.hpp:855
constexpr VKeyCode keySym() const noexcept
Returns the virtual key symbol reflecting the current keyboard layout.
Definition KeyEvent.hpp:798
virtual const PressedKeyCodes & pressedKeyCodes() const noexcept=0
constexpr const WindowWeakPtr & source() const noexcept
Definition Event.hpp:85
constexpr const jau::fraction_timespec & when() const noexcept
Definition Event.hpp:84
size_type count() const noexcept
Definition bitfield.hpp:368
value_type x
Definition vec3f.hpp:66
static constexpr const value_type one
Definition vec3f.hpp:64
#define jau_INFO_PRINT(fmt,...)
Use for unconditional informal messages, prefix '[elapsed_time] Info: '.
Definition debug.hpp:167
std::shared_ptr< Shape > ShapeRef
#define E_FILE_LINE
constexpr T adeg_to_rad(const T arc_degree) noexcept
Converts arc-degree to radians.
GLArrayDataServer< float > GLFloatArrayDataServer
GLArrayDataServerSRef< float > GLFloatArrayDataServerSRef
std::shared_ptr< ShaderCode > ShaderCodeSRef
std::shared_ptr< ShaderProgram > ShaderProgramSRef
@ verbose
Verbose operations (debugging).
std::shared_ptr< Window > WindowSRef
Definition Event.hpp:36
Matrix4< float > Mat4f
Definition mat4f.hpp:1968
Vector4F< float > Vec4f
Definition vec4f.hpp:360
PMVData
PMVMatrix4 derived matrices and values.
Definition pmvmat4.hpp:57
Quaternion< float > Quat4f
RectI< int > Recti
Definition recti.hpp:146
Vector3F< float > Vec3f
Definition vec3f.hpp:422
PMVMatrix4< float > PMVMat4f
Definition pmvmat4.hpp:1463
@ inv_mv
Bit value for inverse modelview matrix (Mvi), updated via update().
Definition pmvmat4.hpp:60
@ inv_proj
Bit value for inverse projection matrix (Pi), updated via update().
Definition pmvmat4.hpp:64
@ inv_tps_mv
Bit value for inverse transposed modelview matrix (Mvit), updated via update().
Definition pmvmat4.hpp:62
Gamp: Graphics, Audio, Multimedia and Processing Framework (Native C++, WebAssembly,...
Definition PTS.hpp:24
ssize_t fprintf_td(const uint64_t elapsed_ms, FILE *stream, std::string_view format, const Args &...args) noexcept
Convenient secure fprintf() invocation, prepending the given elapsed_ms timestamp and using jau:forma...
Definition debug.hpp:188
STL namespace.
static std::string toString(const std::string &pre, const SegmentList &segments) noexcept
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...
constexpr uint64_t to_ms() const noexcept
Returns time in milliseconds.