summaryrefslogtreecommitdiff
path: root/src/plasma-node.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-12-25 22:01:57 -0800
committerVito Caputo <vcaputo@pengaru.com>2021-12-25 22:01:57 -0800
commit189eac273ba14c8ca0d22b31182b030ccc4c7756 (patch)
treec49ac8c15404cb68ae4ccb4cf2a2ba0f7417c705 /src/plasma-node.c
parent8da03aff8bca547bb83f1b049a65232f03123d5a (diff)
*: introduce a projection matrix and winmodesrev3
The bulk of this is mechanical wiring up of a projection_x to all the nodes. But this also introduces maintenance of the projection_x, with aspect-ratio preservation in two of the modes: WINDOWED and FULLSCREEN, with the previously default stretched-to-fill fullscreen mode now relegated to a third FILLSCREEN winmode. The default at startup is now an aspect ratio-preserving windowed mode. Simply press the 'f' key at any time to cycle through them. This was mostly done in sars to provide a source-available test for reproducing a fullscreen SDL2 bug I filed @ https://github.com/libsdl-org/SDL/issues/5139 Otherwise it's pretty silly to bother with doing anything on sars... but it is a handy little mule for such things.
Diffstat (limited to 'src/plasma-node.c')
-rw-r--r--src/plasma-node.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plasma-node.c b/src/plasma-node.c
index 1bc0e40..1eb4c7a 100644
--- a/src/plasma-node.c
+++ b/src/plasma-node.c
@@ -22,19 +22,21 @@
#include "glad.h"
#include "plasma-node.h"
#include "shader-node.h"
+#include "m4f.h"
static const char *plasma_vs = ""
"#version 120\n"
+ "uniform mat4 projection_x;"
+
"attribute vec3 vertex;"
"attribute vec2 texcoord;"
"void main()"
"{"
" gl_TexCoord[0].xy = texcoord;"
- //" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
- " gl_Position = vec4(vertex, 1.f);"
+ " gl_Position = projection_x * vec4(vertex, 1.f);"
"}"
"";
@@ -78,16 +80,18 @@ static void plasma_uniforms(void *uniforms_ctxt, void *render_ctxt, unsigned n_u
glUniform1f(uniforms[0], alpha);
glUniform1f(uniforms[1], play_ticks(play, PLAY_TICKS_TIMER0) * .001f); // FIXME KLUDGE ALERT
+ glUniformMatrix4fv(uniforms[2], 1, GL_FALSE, &model_x->m[0][0]);
}
/* create plasma rendering stage */
-stage_t * plasma_node_new(const stage_conf_t *conf)
+stage_t * plasma_node_new(const stage_conf_t *conf, m4f_t *projection_x)
{
- return shader_node_new_src(conf, plasma_vs, plasma_fs, NULL, plasma_uniforms, NULL, 2,
+ return shader_node_new_src(conf, plasma_vs, plasma_fs, projection_x, plasma_uniforms, NULL, 3,
(const char *[]){
"alpha",
"time",
+ "projection_x",
}
);
}
© All Rights Reserved