mirror of
https://github.com/libretro/mgba.git
synced 2024-11-23 16:10:01 +00:00
OpenGL: Add texSize uniform
This commit is contained in:
parent
e08087a682
commit
d242638e28
1
CHANGES
1
CHANGES
@ -43,6 +43,7 @@ Misc:
|
||||
- ARM7: Support forcing Thumb mode via MSR
|
||||
- ARM7: Flush prefetch cache when loading CPSR via MSR
|
||||
- Qt: Canonicalize file paths when loading games
|
||||
- OpenGL: Add texSize uniform
|
||||
|
||||
0.4.0: (2016-02-02)
|
||||
Features:
|
||||
|
@ -1,5 +1,6 @@
|
||||
varying vec2 texCoord;
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 texSize;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(tex, texCoord);
|
||||
@ -14,8 +15,8 @@ void main() {
|
||||
arrayY[2] = vec3(1.0, 1.0, 1.0);
|
||||
arrayY[3] = vec3(0.8, 0.8, 0.8);
|
||||
color.rgb = pow(color.rgb * vec3(0.8, 0.8, 0.8), vec3(1.8, 1.8, 1.8)) + vec3(0.16, 0.16, 0.16);
|
||||
color.rgb *= arrayX[int(mod(texCoord.s * 960.0, 4.0))];
|
||||
color.rgb *= arrayY[int(mod(texCoord.t * 640.0, 4.0))];
|
||||
color.rgb *= arrayX[int(mod(texCoord.s * texSize.x * 4.0, 4.0))];
|
||||
color.rgb *= arrayY[int(mod(texCoord.t * texSize.y * 4.0, 4.0))];
|
||||
color.a = 0.5;
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
varying vec2 texCoord;
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 texSize;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(tex, texCoord);
|
||||
@ -14,8 +15,8 @@ void main() {
|
||||
arrayY[2] = vec3(1.0, 1.0, 1.0);
|
||||
arrayY[3] = vec3(0.9, 0.9, 0.9);
|
||||
color.rgb = pow(color.rgb, vec3(1.6, 1.6, 1.6));
|
||||
color.rgb *= arrayX[int(mod(texCoord.s * 960.0, 4.0))];
|
||||
color.rgb *= arrayY[int(mod(texCoord.t * 640.0, 4.0))];
|
||||
color.rgb *= arrayX[int(mod(texCoord.s * texSize.x * 4.0, 4.0))];
|
||||
color.rgb *= arrayY[int(mod(texCoord.t * texSize.y * 4.0, 4.0))];
|
||||
color.a = 0.8;
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ varying vec4 TEX5;
|
||||
varying vec4 TEX6;
|
||||
varying vec4 TEX7;
|
||||
|
||||
const vec2 TextureSize = vec2(240.0, 160.0);
|
||||
uniform vec2 texSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -110,7 +110,7 @@ void main()
|
||||
vec3 res1, res2, pix1, pix2;
|
||||
float blend1, blend2;
|
||||
|
||||
vec2 fp = fract(texCoord * TextureSize);
|
||||
vec2 fp = fract(texCoord * texSize);
|
||||
|
||||
vec3 A1 = COMPAT_TEXTURE(tex, TEX1.xw).rgb;
|
||||
vec3 B1 = COMPAT_TEXTURE(tex, TEX1.yw).rgb;
|
||||
|
@ -34,12 +34,14 @@ varying vec4 TEX6;
|
||||
varying vec4 TEX7;
|
||||
attribute vec4 position;
|
||||
|
||||
uniform vec2 texSize;
|
||||
|
||||
/* VERTEX_SHADER */
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
|
||||
vec2 ps = vec2(1.0/240.0, 1.0/160.0);
|
||||
vec2 ps = vec2(1.0) / texSize;
|
||||
float dx = ps.x;
|
||||
float dy = ps.y;
|
||||
|
||||
|
@ -230,6 +230,7 @@ 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, context->d.height);
|
||||
glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
glEnableVertexAttribArray(shader->positionLocation);
|
||||
size_t u;
|
||||
@ -399,6 +400,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");
|
||||
size_t i;
|
||||
for (i = 0; i < shader->nUniforms; ++i) {
|
||||
|
@ -62,6 +62,7 @@ struct mGLES2Shader {
|
||||
GLuint vertexShader;
|
||||
GLuint program;
|
||||
GLuint texLocation;
|
||||
GLuint texSizeLocation;
|
||||
GLuint positionLocation;
|
||||
|
||||
struct mGLES2Uniform* uniforms;
|
||||
|
Loading…
Reference in New Issue
Block a user