Gamp v0.0.7-36-g24b1eb6
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/file_util.hpp>
22#include <jau/float_math.hpp>
23#include <jau/float_types.hpp>
24#include <jau/fraction_type.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
56struct PMVMat4fUniform {
57 PMVMat4f m;
59
61 : m( PMVMat4f::INVERSE_PROJECTION | PMVMat4f::INVERSE_MODELVIEW | PMVMat4f::INVERSE_TRANSPOSED_MODELVIEW ),
62 u( GLUniformSyncMatrices4f::create("mgl_PMVMatrix", m.getSyncPMvMviMvit()) ) // P, Mv, Mvi and Mvit
63 {}
64};
65
66class Shape;
67typedef std::shared_ptr<Shape> ShapeRef;
68
69class Shape {
70 private:
71 ShaderState& m_st;
72 PMVMat4fUniform& m_pmvMat;
73 OutlineShape m_oshape;
75
76 Vec3f m_position;
77 Quat4f m_rotation;
78 Vec3f m_rotPivot;
79 Vec3f m_scale = Vec3f(1, 1, 1);
80 float m_zOffset;
82 GLUniformVec4fRef m_uColor;
83
84 Mat4f iMat;
85 Mat4f tmpMat;
86 bool iMatIdent = true;
87 bool iMatDirty = false;
88
89 struct Private{ explicit Private() = default; };
90
91 public:
92 Shape(Private, ShaderState &st, PMVMat4fUniform& pmvMatU)
93 : m_st(st), m_pmvMat(pmvMatU), m_oshape(3, 16),
94 m_array(GLFloatArrayDataServer::createGLSLInterleaved(2*3, false, 256, GL_STATIC_DRAW))
95 {
96 m_array->addGLSLSubArray("mgl_Vertex", 3, GL_ARRAY_BUFFER);
97 m_array->addGLSLSubArray("mgl_Normal", 3, GL_ARRAY_BUFFER);
98 m_st.ownAttribute(m_array, true);
99
100 m_uColor = GLUniformVec4f::create("mgl_StaticColor", Vec4f(0, 0, 0, 1));
101 m_st.ownUniform(m_uColor, true);
102 }
103
105 return std::make_shared<Shape>(Private(), st, pmvMatU);
106 }
107
108 constexpr const Vec3f& position() const noexcept { return m_position; }
109 constexpr Vec3f& position() noexcept { iMatDirty=true; return m_position; }
110
111 constexpr const float& zOffset() const noexcept { return m_zOffset; }
112 constexpr float& zOffset() noexcept { iMatDirty=true; return m_zOffset; }
113
114 constexpr const Quat4f& rotation() const noexcept { return m_rotation; }
115 constexpr Quat4f& rotation() noexcept { iMatDirty=true; return m_rotation; }
116
117 constexpr const Vec3f& rotationPivot() const noexcept { return m_rotPivot; }
118 constexpr Vec3f& rotationPivot() noexcept { iMatDirty=true; return m_rotPivot; }
119
120 constexpr const Vec3f& scale() const noexcept { return m_scale; }
121 constexpr Vec3f& scale() noexcept { iMatDirty=true; return m_scale; }
122
123 constexpr const OutlineShape& outlines() const noexcept { return m_oshape; }
124 constexpr OutlineShape& outlines() noexcept { return m_oshape; }
125
126 const Vec4f& color() const noexcept { return m_uColor->vec4f(); }
127 void setColor(const Vec4f& c) noexcept { m_uColor->vec4f()=c; }
128
129 void update(GL& gl) {
131 jau::INFO_PRINT("\n%s", GLUtilTesselator::Segment::toString("- ", m_segments).c_str() );
132 m_array->seal(gl, true);
133 }
134
135 void draw(GL &gl) {
136 m_pmvMat.m.pushMv();
137 applyMatToMv(m_pmvMat.m);
138 m_st.pushUniform(gl, m_pmvMat.u); // automatic sync + update of Mvi + Mvit
139
140 m_st.pushUniform(gl, m_uColor);
141 m_array->enableBuffer(gl, true);
142 for(const GLUtilTesselator::Segment& s : m_segments ) {
143 ::glDrawArrays(s.type, s.first, s.count);
144 }
145 m_array->enableBuffer(gl, false);
146 m_pmvMat.m.popMv();
147 }
148
149 private:
150 /**
151 * Applies the internal {@link Matrix4f} to the given {@link PMVMatrix4f#getMv() modelview matrix},
152 * i.e. {@code pmv.mulMv( getMat() )}.
153 * <p>
154 * Calls {@link #updateMat()} if dirty.
155 * </p>
156 * In case {@link #isMatIdentity()} is {@code true}, implementation is a no-operation.
157 * </p>
158 * @param pmv the matrix
159 * @see #isMatIdentity()
160 * @see #updateMat()
161 * @see #getMat()
162 * @see PMVMatrix4f#mulMv(Matrix4f)
163 */
164 void applyMatToMv(PMVMat4f& pmvMat) noexcept {
165 if( iMatDirty ) {
166 updateMat();
167 }
168 if( !iMatIdent ) {
169 pmvMat.mulMv(iMat);
170 }
171 }
172 void updateMat() noexcept {
173 bool hasPos = !m_position.is_zero();
174 bool hasScale = m_scale != Vec3f::one;
175 bool hasRotate = !m_rotation.isIdentity();
176 bool hasRotPivot = false; // null != rotPivot;
177 const Vec3f& ctr = m_oshape.bounds().center();
178 bool sameScaleRotatePivot = hasScale && hasRotate && ( !hasRotPivot || m_rotPivot == ctr );
179
180 if( sameScaleRotatePivot ) {
181 iMatIdent = false;
182 iMat.setToTranslation(m_position); // identity + translate, scaled
183 // Scale shape from its center position and rotate around its center
184 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
185 iMat.rotate(m_rotation);
186 iMat.scale(m_scale);
187 iMat.translate(-ctr); // move to center
188 } else if( hasRotate || hasScale ) {
189 iMatIdent = false;
190 iMat.setToTranslation(m_position); // identity + translate, scaled
191 if( hasRotate ) {
192 if( hasRotPivot ) {
193 // Rotate shape around its scaled pivot
194 iMat.translate(Vec3f(m_rotPivot).mul(m_scale)); // pivot back from rot-pivot, scaled
195 iMat.rotate(m_rotation);
196 iMat.translate(Vec3f(-m_rotPivot).mul(m_scale)); // pivot to rot-pivot, scaled
197 } else {
198 // Rotate shape around its scaled center
199 iMat.translate(Vec3f(ctr).mul(m_scale)); // pivot back from center-pivot, scaled
200 iMat.rotate(m_rotation);
201 iMat.translate(Vec3f(-ctr).mul(m_scale)); // pivot to center-pivot, scaled
202 }
203 }
204 if( hasScale ) {
205 // Scale shape from its center position
206 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
207 iMat.scale(m_scale);
208 iMat.translate(Vec3f(-ctr).mul(m_scale)); // move to center
209 }
210 } else if( hasPos ) {
211 iMatIdent = false;
212 iMat.setToTranslation(m_position); // identity + translate, scaled
213
214 } else {
215 iMatIdent = true;
216 iMat.loadIdentity();
217 }
218 iMatDirty = false;
219 }
220};
221
223 private:
224 constexpr static jau::math::Vec3f lightPos = jau::math::Vec3f(0.0f, 5.0f, 10.0f);
225 constexpr static float zNear= 1.0f;
226 constexpr static float zFar =100.0f;
227
228 ShaderState m_st;
229 Recti m_viewport;
230 bool m_initialized;
231 bool m_animating = true;
232 bool m_oneframe = false;
234 PMVMat4fUniform m_pmvMat;
235 std::vector<ShapeRef> m_shapes;
236
237 public:
240 m_initialized(false)
241 {
242 }
243
244 Recti& viewport() noexcept { return m_viewport; }
245 const Recti& viewport() const noexcept { return m_viewport; }
246
247 PMVMat4f& pmv() noexcept { return m_pmvMat.m; }
248 const PMVMat4f& pmv() const noexcept { return m_pmvMat.m; }
249 bool animating() const noexcept { return m_animating; }
250 bool& animating() noexcept { return m_animating; }
251 void setOneFrame() noexcept { m_animating=false; m_oneframe=true; }
252
253 bool init(const WindowRef& win, const jau::fraction_timespec& when) override {
254 jau::fprintf_td(when.to_ms(), stdout, "RL::init: %s\n", toString().c_str());
255 m_tlast = when;
256
257 GL& gl = GL::downcast(win->renderContext());
258 ShaderCodeRef vp0 = ShaderCode::create(gl, GL_VERTEX_SHADER, "demos/glsl",
259 "demos/glsl/bin", "SingleLight0");
260 ShaderCodeRef fp0 = ShaderCode::create(gl, GL_FRAGMENT_SHADER, "demos/glsl",
261 "demos/glsl/bin", "SingleLight0");
262 if( !vp0 || !fp0 ) {
263 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
264 win->dispose(when);
265 return false;
266 }
267 {
268 std::string custom = "#define MAX_TEXTURE_UNITS 0\n";
269 size_t vsPos = vp0->defaultShaderCustomization(gl, true, true);
270 size_t fsPos = fp0->defaultShaderCustomization(gl, true, true);
271 vp0->insertShaderSource(0, vsPos, custom);
272 fp0->insertShaderSource(0, fsPos, custom);
273 }
274
276 if( !sp0->add(gl, vp0, true) || !sp0->add(gl, fp0, true) ) {
277 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
278 sp0->destroy(gl);
279 win->dispose(when);
280 return false;
281 }
282 m_st.attachShaderProgram(gl, sp0, true);
283
284 // setup mgl_PMVMatrix
285 m_pmvMat.m.getP().loadIdentity();
286 m_pmvMat.m.getMv().loadIdentity();
287 m_st.ownUniform(m_pmvMat.u, true);
288
289 GLUniformVec3fRef lightU = GLUniformVec3f::create("mgl_LightPos", lightPos);
290 m_st.ownUniform(lightU, true);
291
292 m_st.pushAllUniforms(gl);
293
294 const float lineWidth = 1/2.5f;
295 const float dz = 0.001f;
296 {
297 // Rectangle
298 const float width = 1.5f;
299 const float height = 1.5f;
300 const float x1 = -width/2.0f;
301 const float y1 = -height/2.0f;
302 const float x2 = x1 + width;
303 const float y2 = y1 + height;
304 float z = dz;
305 ShapeRef frontShape = Shape::create(m_st, m_pmvMat);
306 m_shapes.push_back(frontShape);
307 OutlineShape& oshape = frontShape->outlines();
308 {
309 // Outer OutlineShape as Winding.CCW.
310 oshape.moveTo(x1, y1, z);
311 oshape.lineTo(x2, y1, z);
312 oshape.lineTo(x2, y2, z);
313 oshape.lineTo(x1, y2, z);
314 oshape.lineTo(x1, y1, z);
315 oshape.closePath();
316 }
317 {
318 // Inner OutlineShape as Winding.CW.
319 // final float dxy0 = getWidth() < getHeight() ? getWidth() : getHeight();
320 const float dxy = lineWidth; // dxy0 * getDebugBox();
321 oshape.moveTo(x1+dxy, y1+dxy, z);
322 oshape.lineTo(x1+dxy, y2-dxy, z);
323 oshape.lineTo(x2-dxy, y2-dxy, z);
324 oshape.lineTo(x2-dxy, y1+dxy, z);
325 oshape.lineTo(x1+dxy, y1+dxy, z);
326 oshape.closePath();
327 }
328 frontShape->update(gl);
329 frontShape->setColor(Vec4f(0.05f, 0.05f, 0.5f, 1));
330 frontShape->position().x = 1.5f;
331
332 ShapeRef backShape = Shape::create(m_st, m_pmvMat);
333 m_shapes.push_back(backShape);
334 backShape->outlines() = oshape.flipFace();
335 backShape->update(gl);
336 backShape->setColor(Vec4f(0.4f, 0.4f, 0.1f, 1));
337 backShape->position().x = 1.5f;
338 }
339 {
340 // Cross / Plus
341 const float width = 1.5f;
342 const float height = 1.5f;
343
344 float lwh = lineWidth/2.0f;
345
346 float twh = width/2.0f;
347 float thh = height/2.0f;
348
349 float ctrX = 0, ctrY = 0, ctrZ = dz;
350 ShapeRef frontShape = Shape::create(m_st, m_pmvMat);
351 m_shapes.push_back(frontShape);
352 OutlineShape& oshape = frontShape->outlines();
353 // CCW
354 oshape.moveTo(ctrX-lwh, ctrY+thh, ctrZ); // vert: left-top
355 oshape.lineTo(ctrX-lwh, ctrY+lwh, ctrZ);
356 oshape.lineTo(ctrX-twh, ctrY+lwh, ctrZ); // horz: left-top
357 oshape.lineTo(ctrX-twh, ctrY-lwh, ctrZ); // horz: left-bottom
358 oshape.lineTo(ctrX-lwh, ctrY-lwh, ctrZ);
359 oshape.lineTo(ctrX-lwh, ctrY-thh, ctrZ); // vert: left-bottom
360 oshape.lineTo(ctrX+lwh, ctrY-thh, ctrZ); // vert: right-bottom
361 oshape.lineTo(ctrX+lwh, ctrY-lwh, ctrZ);
362 oshape.lineTo(ctrX+twh, ctrY-lwh, ctrZ); // horz: right-bottom
363 oshape.lineTo(ctrX+twh, ctrY+lwh, ctrZ); // horz: right-top
364 oshape.lineTo(ctrX+lwh, ctrY+lwh, ctrZ);
365 oshape.lineTo(ctrX+lwh, ctrY+thh, ctrZ); // vert: right-top
366 oshape.lineTo(ctrX-lwh, ctrY+thh, ctrZ); // vert: left-top
367 oshape.closePath();
368 // shape1->seal(gl, true);
369 frontShape->update(gl);
370 frontShape->setColor(Vec4f(0.5f, 0.05f, 0.05f, 1));
371 frontShape->position().x = -1.5f;
372
373 ShapeRef backShape = Shape::create(m_st, m_pmvMat);
374 m_shapes.push_back(backShape);
375 backShape->outlines() = oshape.flipFace();
376 backShape->update(gl);
377 backShape->setColor(Vec4f(0.2f, 0.2f, 0.2f, 1));
378 backShape->position().x = -1.5f;
379 }
380
381 ::glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
382 ::glEnable(GL_DEPTH_TEST);
383 ::glEnable(GL_CULL_FACE);
384
385 m_initialized = sp0->inUse();
386 if( !m_initialized ) {
387 jau::fprintf_td(when.to_ms(), stdout, "ERROR %s:%d: %s\n", E_FILE_LINE, toString().c_str());
388 m_st.destroy(gl);
389 win->dispose(when);
390 }
391 return m_initialized;
392 }
393
394 void dispose(const WindowRef& win, const jau::fraction_timespec& when) override {
395 jau::fprintf_td(when.to_ms(), stdout, "RL::dispose: %s\n", toString().c_str());
396 m_st.destroy(GL::downcast(win->renderContext()));
397 m_initialized = false;
398 }
399
400 void reshape(const WindowRef& win, const jau::math::Recti& viewport, const jau::fraction_timespec& when) override {
401 GL& gl = GL::downcast(win->renderContext());
402 jau::fprintf_td(when.to_ms(), stdout, "RL::reshape: %s\n", toString().c_str());
403 m_viewport = viewport;
404
405 m_pmvMat.m.getP().loadIdentity();
406 const float aspect = 1.0f;
407 const float fovy_deg=45.0f;
408 const float aspect2 = ( (float) m_viewport.width() / (float) m_viewport.height() ) / aspect;
409 m_pmvMat.m.perspectiveP(jau::adeg_to_rad(fovy_deg), aspect2, zNear, zFar);
410 m_st.useProgram(gl, true);
411 m_st.pushUniform(gl, m_pmvMat.u); // automatic sync + update of Mvi + Mvit
412 // m_st.useProgram(gl, false);
413 }
414
415 void display(const WindowRef& win, const jau::fraction_timespec& when) override {
416 // jau::fprintf_td(when.to_ms(), stdout, "RL::display: %s, %s\n", toString().c_str(), win->toString().c_str());
417 if( !m_initialized ) {
418 return;
419 }
420 GL& gl = GL::downcast(win->renderContext());
421 ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
422
423 m_st.useProgram(gl, true);
424 m_pmvMat.m.getMv().loadIdentity();
425 m_pmvMat.m.translateMv(0, 0, -5);
426
427 for(const ShapeRef& s : m_shapes) {
428 if( animating() || m_oneframe ) {
429 constexpr double angle_per_sec = 30;
430 const float rad = (float) ( (when - m_tlast).to_double() * angle_per_sec );
431 s->rotation().rotateByAngleY(jau::adeg_to_rad( rad ));
432 }
433 s->draw(gl);
434 }
435 m_oneframe = false;
436 // m_st.useProgram(gl, false);
437
438 m_tlast = when;
439 }
440
441 std::string toStringImpl() const noexcept override { return "Primitives02"; }
442};
443
444class Example : public Primitives02 {
445 private:
446 class MyKeyListener : public KeyListener {
447 private:
448 Primitives02& m_parent;
449 public:
450 MyKeyListener(Primitives02& p) : m_parent(p) {}
451
452 void keyPressed(KeyEvent& e, const KeyboardTracker& kt) override {
453 jau::fprintf_td(e.when().to_ms(), stdout, "KeyPressed: %s; keys %zu\n", e.toString().c_str(), kt.pressedKeyCodes().bitCount());
454 if( e.keySym() == VKeyCode::VK_ESCAPE ) {
455 WindowRef win = e.source().lock();
456 if( win ) {
457 win->dispose(e.when());
458 }
459 } else if( e.keySym() == VKeyCode::VK_PAUSE || e.keySym() == VKeyCode::VK_P ) {
460 m_parent.animating() = !m_parent.animating();
461 } else if( e.keySym() == VKeyCode::VK_PERIOD ) {
462 m_parent.setOneFrame();
463 } else if( e.keySym() == VKeyCode::VK_W ) {
464 WindowRef win = e.source().lock();
465 jau::fprintf_td(e.when().to_ms(), stdout, "Source: %s\n", win ? win->toString().c_str() : "null");
466 }
467 }
468 void keyReleased(KeyEvent& e, const KeyboardTracker& kt) override {
469 jau::fprintf_td(e.when().to_ms(), stdout, "KeyRelease: %s; keys %zu\n", e.toString().c_str(), kt.pressedKeyCodes().bitCount());
470 }
471 };
472 typedef std::shared_ptr<MyKeyListener> MyKeyListenerRef;
473 MyKeyListenerRef m_kl;
474
475 public:
477 : Primitives02(),
478 m_kl(std::make_shared<MyKeyListener>(*this)) { }
479
480 bool init(const WindowRef& win, const jau::fraction_timespec& when) override {
481 if( !Primitives02::init(win, when) ) {
482 return false;
483 }
484 win->addKeyListener(m_kl);
485 return true;
486 }
487 void dispose(const WindowRef& win, const jau::fraction_timespec& when) override {
488 win->removeKeyListener(m_kl);
489 Primitives02::dispose(win, when);
490 }
491};
492
493int main(int argc, char *argv[]) // NOLINT(bugprone-exception-escape)
494{
496
497 return launch("Primitives02.cpp",
499 std::make_shared<Example>(), argc, argv);
500}
int launch(std::string_view sfile, const GLLaunchProps &props, const RenderListenerRef &demo, int argc, char *argv[])
std::shared_ptr< Shape > ShapeRef
int main(int argc, char *argv[])
std::shared_ptr< Shape > ShapeRef
#define E_FILE_LINE
bool init(const WindowRef &win, const jau::fraction_timespec &when) override
Called by the drawable immediately after the render context is initialized.
void dispose(const WindowRef &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
Recti & viewport() noexcept
void dispose(const WindowRef &win, const jau::fraction_timespec &when) override
Notifies the listener to perform the release of all renderer resources per context,...
bool animating() const noexcept
void display(const WindowRef &win, const jau::fraction_timespec &when) override
Called by the drawable to initiate rendering by the client.
PMVMat4f & pmv() noexcept
void reshape(const WindowRef &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.
bool init(const WindowRef &win, const jau::fraction_timespec &when) override
Called by the drawable immediately after the render context is initialized.
const PMVMat4f & pmv() const noexcept
const Recti & viewport() const noexcept
constexpr const float & zOffset() const noexcept
void setColor(const Vec4f &c) noexcept
constexpr Vec3f & position() noexcept
static ShapeRef create(ShaderState &st, PMVMat4fUniform &pmvMatU, GraphRenderer &renderer)
void draw(GL &gl)
void update(GL &gl)
constexpr OutlineShape & outlines() noexcept
constexpr const Quat4f & rotation() const noexcept
static ShapeRef create(ShaderState &st, PMVMat4fUniform &pmvMatU)
constexpr const Vec3f & rotationPivot() const noexcept
constexpr float & zOffset() noexcept
constexpr const Vec3f & position() const noexcept
constexpr Vec3f & scale() noexcept
constexpr Vec3f & rotationPivot() noexcept
Shape(Private, ShaderState &st, PMVMat4fUniform &pmvMatU)
const Vec4f & color() const noexcept
constexpr const Vec3f & scale() const noexcept
constexpr const OutlineShape & outlines() 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() and all outlines() vertices()'s z-axis sign-flipped,...
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)
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:41
static constexpr std::string_view GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition GLContext.hpp:64
static std::shared_ptr< GLUniformVec3f > create(const string_t &name, const jau::math::Vec3f &v)
static std::shared_ptr< GLUniformVec4f > create(const string_t &name, const jau::math::Vec4f &v)
size_t defaultShaderCustomization(const GL &gl, bool preludeVersion, bool addDefaultPrecision)
Default customization of this shader source code.
static ShaderCodeRef create(GLenum type, size_t count, const source_list_t &sources) noexcept
size_t insertShaderSource(size_t shaderIdx, stringview_t tag, size_t fromIndex, stringview_t data) noexcept
Adds data after the line containing tag.
void destroy(GL &gl) noexcept
Detaches all shader codes and deletes the program.
static ShaderProgramRef create() noexcept
bool add(const ShaderCodeRef &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:129
size_t removeKeyListener(const KeyListenerRef &l)
Definition Window.hpp:311
void dispose(const jau::fraction_timespec &when) noexcept override
Definition Window.hpp:355
std::string toString() const noexcept
Definition gamp_wt.cpp:145
void addKeyListener(const KeyListenerRef &l)
Definition Window.hpp:310
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_t bitCount() const noexcept
Definition bitfield.hpp:176
static constexpr const value_type one
Definition vec3f.hpp:67
constexpr T adeg_to_rad(const T arc_degree) noexcept
Converts arc-degree to radians.
GLArrayDataServer< float > GLFloatArrayDataServer
GLArrayDataServerRef< float > GLFloatArrayDataServerRef
std::shared_ptr< GLUniformData > GLUniformDataRef
std::shared_ptr< GLUniformVec4f > GLUniformVec4fRef
std::shared_ptr< GLUniformVec3f > GLUniformVec3fRef
std::shared_ptr< ShaderProgram > ShaderProgramRef
std::shared_ptr< ShaderCode > ShaderCodeRef
@ verbose
Verbose operations (debugging).
std::shared_ptr< Window > WindowRef
Definition Event.hpp:36
Matrix4< float > Mat4f
Definition mat4f.hpp:1973
Vector4F< float > Vec4f
Definition vec4f.hpp:375
Quaternion< float > Quat4f
RectI< int > Recti
Definition recti.hpp:139
Vector3F< float > Vec3f
Definition vec3f.hpp:436
PMVMatrix4< float > PMVMat4f
Gamp: Graphics, Audio, Multimedia and Processing Framework (Native C++, WebAssembly,...
Definition Gamp.hpp:29
void INFO_PRINT(const char *format,...) noexcept
Use for unconditional informal messages, prefix '[elapsed_time] Info: '.
Definition debug.cpp:248
int fprintf_td(const uint64_t elapsed_ms, FILE *stream, const char *format,...) noexcept
Convenient fprintf() invocation, prepending the given elapsed_ms timestamp.
Definition debug.cpp:270
STL namespace.
GLUniformDataRef u
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.