AABB.render(gl2);
gl2.glUseProgram(programId);
elevationMap.getGLTextureObject().activate(gl2, GL2.GL_TEXTURE0);
elevationMap.getGLTextureObject().bind(gl2);
normalMap.getGLTextureObject().activate(gl2, GL2.GL_TEXTURE1);
normalMap.getGLTextureObject().bind(gl2);
int step = layerArray[level].step;
int location = gl2.glGetUniformLocation(programId, "gridScale");
gl2.glUniform2f(location, step, step);
location = gl2.glGetUniformLocation(programId, "gridOrigin");
gl2.glUniform2f(location, originX, originY);
patchVBO.bind(gl2);
patchIBO.bind(gl2);
patchVBO.glEnableClientState(gl2);
patchIBO.glDrawElements(gl2, GL2.GL_TRIANGLE_STRIP);
patchVBO.glDisableClientState(gl2);
patchVBO.unbind(gl2);
patchIBO.unbind(gl2);
elevationMap.getGLTextureObject().unbind(gl2);
normalMap.getGLTextureObject().unbind(gl2);
gl2.glUseProgram(0);
So that's the rendering code, don't be confused by OOP approach, these are my own shell-classes for Textures, VBO's and IBO's - I thnik it's easy to understand what is happening inside. For instance, unbind - is just a call of glBindTexture(0). I'm saying that so you won't assume that the problem is inside my classes since all this was tested lots of times and worked fine until this shader appeared.
uniform sampler2DRect elevationMap;
uniform sampler2DRect normalMap;
uniform vec2 gridScale;
uniform vec2 gridOrigin;
void main()
{
vec2 gridPosition = gridOrigin + gl_Vertex.xy * gridScale;
float elevation = texture2DRect(elevationMap,gridPosition).b;
gl_Position = gl_ModelViewProjectionMatrix * vec4(gridPosition.x,elevation * 255.0,gridPosition.y,1.0);
gl_Color = vec4(elevation,elevation,elevation,1.0);
gl_FrontColor = gl_Color;
}
Now the problem: first of all - text with FPS and etc has disappeared. And the second - texturing in other parts of application works wrong. Consider the following screenshot:
This is how it works when rendering function (which is posted above with shader) is commented. And the code is simple:
gl2.glEnable(GL.GL_TEXTURE_2D);
glTextureObject.bind(gl2);
gl2.glBegin(GL.GL_TRIANGLE_FAN);
gl2.glTexCoord2f(0.0f, 0.0f);
gl2.glVertex3f(-20, -20, 0);
gl2.glTexCoord2f(1.0f, 0.0f);
gl2.glVertex3f(+20, -20, 0);
gl2.glTexCoord2f(0.5f, 1.0f);
gl2.glVertex3f(0, 20, 0);
gl2.glEnd();
glTextureObject.unbind(gl2);
gl2.glDisable(GL.GL_TEXTURE_2D);
But when I uncomment the rendering function with shader (and in code rendering function with shader is located before rendering this single triangle with texture) - I see this:
As you can see texture is gone somehow, as well as text... I'm completely stuck here, could you assist me?