Im working on my school project and just starting it. Provided with a framework ive managed to load a SGF model and display it, but when i want to use another shader for creating a simple textured floor from vertices it only shows the model (after compilation the floor is visible for like 0.5s but later disapears) Any suggestions how to do it?
public void display(GLAutoDrawable drawable) {
final GL3 gl = drawable.getGL().getGL3();
loader.setUniformMatrix("projection", projection);
gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT);
myTexture.bind(gl, modeling, "my_texture");
myTexture.bind(gl, modeling, "my_texture2");
myTexture.bind(gl, program, "my_texture");
myTexture.bind(gl, program, "my_texture2");
Mat4 mv = MatrixMath.lookAt(this.eyeX,this.eyeY,this.eyeZ,this.at,this.up);
program.setUniformMatrix("model_view", mv);
program.use(gl);
gl.glDrawArrays(GL3.GL_TRIANGLES, 0, numVertices);
// 2nd part
// modeling.setUniformMatrix("model_view", mv);
modeling.setUniformMatrix("model_view", mv);
modeling.use(gl);
for (Map.Entry<String, VertexBufferObject> entry : vboHashMap.entrySet()) {
String key = entry.getKey();
entry.getValue().bind(gl);
gl.glDrawArrays(GL3.GL_TRIANGLES, 0, SGFLoader.getNumVertices(key));
}
}
When i remove lines after the second part (which are responsible for loading the model), the wooden plank is visible, otherwise it only renders the model.
Any sugestions?
It doesn’t look like you’re binding the vertex array for the floor in the display() method. I’m guessing you bind it once when you set everything up, but forget to bind it again each frame, which would explain why it flickers for a fraction of a second.
OpenGL isn’t object oriented under the hood. When you call
glDrawArraysit will draw whichever array you last bound.