Game performance based on Java OpenGL block
I'm using lwjgl and Java to build a block - based 3D game, just like minecraft I currently have a block class, which contains the functions void update() and void draw(). I call them in the order of update() and draw() in each loop of the game loop The function drawing contains a texture Bind(), which applies a texture to the block and then checks under conditions whether six edges need to be rendered separately
if(rendertop) GL11.glVertex3f(position.x,position.y,position.z); .....
At present, it works very well. Unless I draw a lot of these blocks, it slows down FPS, so the game can't play After some searching on Google, I found a better way to draw 3D objects on the screen, and then send graphics cards to each vertex again and again in each drawing I tried to use the list, but it only seemed to need more memory I create a new list for each side of the block, and call it if I need to make the side the same as the above example, which means there are 6 lists for each block That's how I make these lists:
GL11.glNewList(displayListId,GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); ...... (Calling GL11.glVertex3f to draw the side) GL11.glEnd(); GL11.glEndList();
I call like this:
if(rendertop) GL11.glCallList(displayListId);
But as I said before, it only makes the game very slow, and I know it may have something to do with the way I implement it Another problem with this method is that you break the block required to delete the displaylist. I don't know what to do
Can anyone suggest a way to use displays or other methods to improve performance?
Solution
Batch rendering using vertex arrays or vertex buffer objects
Each VA or VBO shall contain, for example, 16x16x16 cubes