Hello everybody,
I’m new to OpenGL and I have two basic questions, I’ve been coding in Java using LWJGL :
First of all I’ll quickly explain my model:
In project I have a model class where I load all the all attributes in of a model into a VAO using VBO for every the vertex points, texture and normals.
In my renderer I take a model, I bind his VAO and call glDrawEllements
the render code looks like this :
public void render(Entity entity, StaticShader shader){
TexturedModel TexturedModel = entity.getModel();
RawModel model = TexturedModel.getRawModel();
GL30.glBindVertexArray(model.getVaoID());
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL20.glEnableVertexAttribArray(2);
Matrix4f transformationMatrix = Maths.createTransformationMatrix(entity.getPosition(), entity.getRotx(), entity.getRoty(), entity.getRotz(), entity.getScale());
shader.loadTransformationMatrix(transformationMatrix);
ModelTexture texture = TexturedModel.getTexture();
shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, TexturedModel.getTexture().getTextureID());
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(),GL11.GL_UNSIGNED_INT,0);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(2);
GL30.glBindVertexArray(0);
}
I though I was understanding the way it works, but I’ve realized that the model renders even without the:
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(),GL11.GL_UNSIGNED_INT,0);
Am I missing something ? or if there is no draw call, OpenGL calls one automatically ?
My second questions is, if I’d like to render the VAO content into a depth texture using a FBO, how would I go to render the VAO’s content while the FBO is bind ?
Would I still just call DrawElements ?