OpenGL: Export output buffer size to shader

This commit is contained in:
Vicki Pfau 2023-02-11 22:03:31 -08:00
parent 7b979a679e
commit 422439f0a6
2 changed files with 4 additions and 1 deletions

View File

@ -301,7 +301,8 @@ void _drawShader(struct mGLES2Context* context, struct mGLES2Shader* shader) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shader->filter ? GL_LINEAR : GL_NEAREST);
glUseProgram(shader->program);
glUniform1i(shader->texLocation, 0);
glUniform2f(shader->texSizeLocation, context->d.width - padW, context->d.height - padH);
glUniform2f(shader->texSizeLocation, context->d.width, context->d.height);
glUniform2f(shader->outputSizeLocation, drawW, drawH);
#ifdef BUILD_GLES3
if (shader->vao != (GLuint) -1) {
glBindVertexArray(shader->vao);
@ -532,6 +533,7 @@ void mGLES2ShaderInit(struct mGLES2Shader* shader, const char* vs, const char* f
shader->texLocation = glGetUniformLocation(shader->program, "tex");
shader->texSizeLocation = glGetUniformLocation(shader->program, "texSize");
shader->positionLocation = glGetAttribLocation(shader->program, "position");
shader->outputSizeLocation = glGetUniformLocation(shader->program, "outputSize");
size_t i;
for (i = 0; i < shader->nUniforms; ++i) {
shader->uniforms[i].location = glGetUniformLocation(shader->program, shader->uniforms[i].name);

View File

@ -70,6 +70,7 @@ struct mGLES2Shader {
GLuint texLocation;
GLuint texSizeLocation;
GLuint positionLocation;
GLuint outputSizeLocation;
struct mGLES2Uniform* uniforms;
size_t nUniforms;