I am learning trying to learn GLSL with Java and the LWJGL, but I am currently having problems with a basic Vertex Shader.
Vertex Shader:
#version 120
void main() {
gl_Position = gl_Vertex * 0.5;
}
Fragment Shader:
#version 120
void main() {
gl_FragColor = vec4(1.0, 0.4, 0.4, 1.0);
}
Rendering code:
public void draw() {
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
}
The compilation yields no errors and the Fragment Shader works fine, tinting a simple triangle I draw. The only problem is that I dont see the triangle downscaled (0.5 factor) as expected, it's vertices remain unaltered. What am I doing wrong?
gl_Position = gl_Vertex * 0.5will modify the whole 4 dimensional vector including the w component. Do something likegl_Position = vec4(gl_Vertex.xyz * 0.5, 1.0)