Skip to content

Renderer

ivanorsolic edited this page Apr 17, 2016 · 2 revisions

#This class renders the model from a VAO

The first thing we need to do is to make a method that prepares OpenGL each frame to render the game:

public void prepare(){
	GL11.glClearColor(1, 0, 0, 1); //clear the color from the last frame
	GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

And now we have to make the method that actually renders the model:

public void render(RawModel model){
	GL30.glBindVertexArray(model.getVaoID()); //bind the VAO, so we can use it
	GL20.glEnableVertexAttribArray(0); // Activate the attribute list in which our data is stored
	GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(), GL11.GL_UNSIGNED_INT, 0); // Render it, update 2
	GL20.glDisableVertexAttribArray(0); // Disable that attribute list because we're done with using it
	GL30.glBindVertexArray(0); // Unbind the VAO
}

Clone this wiki locally