mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-23 23:33:45 +02:00

PortableGL supports shaders, but requires them to be compiled ahead-of-time to C or C++. I'll write a compiler later to translate from GLSL to this format automatically at build time.
22 lines
1.1 KiB
C
22 lines
1.1 KiB
C
#include "transSimple.pgl.h"
|
|
|
|
void mkxpTransSimpleVS(float *_output, pgl_vec4 *_attribs, Shader_Builtins *builtins, void *_uniforms)
|
|
{
|
|
struct TransSimpleVarying *output = (struct TransSimpleVarying *)_output;
|
|
struct TransSimpleAttribs *attribs = (struct TransSimpleAttribs *)_attribs;
|
|
struct TransSimpleUniforms *uniforms = (struct TransSimpleUniforms *)_uniforms;
|
|
|
|
pgl_vec2 pos = add_vec2s(attribs->position, uniforms->translation);
|
|
builtins->gl_Position = mult_mat4_vec4(uniforms->projMat, (pgl_vec4){pos.x, pos.y, 0, 1});
|
|
output->v_texCoord = mult_vec2s(attribs->texCoord, uniforms->texSizeInv);
|
|
}
|
|
|
|
void mkxpTransSimpleFS(float *_input, Shader_Builtins *builtins, void *_uniforms)
|
|
{
|
|
struct TransSimpleVarying *input = (struct TransSimpleVarying *)_input;
|
|
struct TransSimpleUniforms *uniforms = (struct TransSimpleUniforms *)_uniforms;
|
|
|
|
pgl_vec4 newPixel = mkxp_pgl_texture2D(uniforms->currentScene, input->v_texCoord.x, input->v_texCoord.y);
|
|
pgl_vec4 oldPixel = mkxp_pgl_texture2D(uniforms->frozenScene, input->v_texCoord.x, input->v_texCoord.y);
|
|
builtins->gl_FragColor = pgl_mix_vec4(newPixel, oldPixel, uniforms->prog);
|
|
}
|