- [FIX] glViewport() s'ha de fixar quan estem treballant contra la pantalla, al final
- [FIX] invertida la textura en l'eix Y
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
#version 330 core
|
|
||||||
out vec4 FragColor;
|
|
||||||
|
|
||||||
in vec4 vertexColor; // the input variable from the vertex shader (same name and same type)
|
uniform sampler2D tex0;
|
||||||
|
|
||||||
|
varying vec4 v_color; // the input variable from the vertex shader (same name and same type)
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vertexColor;
|
gl_FragColor = texture2D(tex0, v_texCoord);
|
||||||
}
|
}
|
||||||
8
main.cpp
8
main.cpp
@@ -78,7 +78,7 @@ bool initGLExtensions() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLuint compileShader(const char* source, GLuint shaderType) {
|
GLuint compileShader(const char* source, GLuint shaderType) {
|
||||||
std::cout << "Compilando shader:" << std::endl << source << std::endl;
|
//std::cout << "Compilando shader:" << std::endl << source << std::endl;
|
||||||
// Create ID for shader
|
// Create ID for shader
|
||||||
GLuint result = glCreateShader(shaderType);
|
GLuint result = glCreateShader(shaderType);
|
||||||
// Define shader text
|
// Define shader text
|
||||||
@@ -170,14 +170,16 @@ void presentBackBuffer(SDL_Renderer *renderer, SDL_Window* win, SDL_Texture* bac
|
|||||||
// Coordenadas de la ventana donde pintar.
|
// Coordenadas de la ventana donde pintar.
|
||||||
minx = 0.0f;
|
minx = 0.0f;
|
||||||
miny = 0.0f;
|
miny = 0.0f;
|
||||||
maxx = WIN_WIDTH;
|
maxx = WORLD_WIDTH;
|
||||||
maxy = WIN_HEIGHT;
|
maxy = WORLD_HEIGHT;
|
||||||
|
|
||||||
minu = 0.0f;
|
minu = 0.0f;
|
||||||
maxu = 1.0f;
|
maxu = 1.0f;
|
||||||
minv = 0.0f;
|
minv = 0.0f;
|
||||||
maxv = 1.0f;
|
maxv = 1.0f;
|
||||||
|
|
||||||
|
glViewport(0, 0, WIN_WIDTH, WIN_HEIGHT);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glTexCoord2f(minu, minv);
|
glTexCoord2f(minu, minv);
|
||||||
glVertex2f(minx, miny);
|
glVertex2f(minx, miny);
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ varying vec2 v_texCoord;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// gl_Position = vec4(gl_Vertex.x-1.0, gl_Vertex.y-1.0, 0.0, 1.0);
|
||||||
|
// v_color = gl_Color;
|
||||||
|
v_texCoord = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y);
|
||||||
|
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
v_color = gl_Color;
|
v_color = gl_Color;
|
||||||
v_texCoord = vec2(gl_MultiTexCoord0);
|
// v_texCoord = vec2(gl_MultiTexCoord0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user