wow the zoom is fonctionning
This commit is contained in:
parent
2317ee328e
commit
dda5e2cab0
3 changed files with 27 additions and 10 deletions
|
@ -1,10 +1,18 @@
|
|||
#version 330
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform float zoom;
|
||||
|
||||
in vec2 vsoTexCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(void) {
|
||||
fragColor = texture(tex, vsoTexCoord);
|
||||
void main() {
|
||||
vec2 center = vec2(0.5);
|
||||
vec2 zoomedTexCoord = mix(center, vsoTexCoord, zoom);
|
||||
|
||||
vec4 color1 = texture(tex0, vsoTexCoord);
|
||||
vec4 color2 = texture(tex1, zoomedTexCoord);
|
||||
|
||||
fragColor = mix(color1, color2, smoothstep(0., 1., zoom));
|
||||
}
|
||||
|
|
|
@ -3,12 +3,9 @@
|
|||
layout(location = 0) in vec3 vsiPosition;
|
||||
layout(location = 2) in vec2 vsiTexCoord;
|
||||
|
||||
uniform float zoomAmount;
|
||||
|
||||
out vec2 vsoTexCoord;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = vec4(vsiPosition, 1.0);
|
||||
|
||||
vsoTexCoord = vec2(vsiTexCoord.s * zoomAmount, vsiTexCoord.t * zoomAmount);
|
||||
vsoTexCoord = vsiTexCoord;
|
||||
}
|
||||
|
|
|
@ -84,11 +84,23 @@ static void zoomin_draw(void (*a0)(int), void (*a1)(int), Uint32 t, Uint32 et,
|
|||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
_zoomin_tId, 0);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, _zoomin_tex[0]);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, _zoomin_tex[1]);
|
||||
|
||||
glUseProgram(_zoomin_pId);
|
||||
glUniform1f(glGetUniformLocation(_zoomin_pId, "zoomAmount"),
|
||||
(GLfloat)et / (GLfloat)t);
|
||||
glUniform1i(glGetUniformLocation(_zoomin_pId, "tex"), 0);
|
||||
GLfloat zoom = (GLfloat)et / (GLfloat)t;
|
||||
glUniform1f(glGetUniformLocation(_zoomin_pId, "zoom"), (1.f - zoom));
|
||||
glUniform1i(glGetUniformLocation(_zoomin_pId, "tex1"), 0);
|
||||
glUniform1i(glGetUniformLocation(_zoomin_pId, "tex0"), 1);
|
||||
gl4dgDraw(_quadId);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
static void zoomin_deinit(void) {
|
||||
|
|
Reference in a new issue