Kristupas A.
Kristupas A.

Reputation: 344

How to increase performance in LWJGL?

I'm new to LWJGL. When I try to make a level comprised of 100*100 cubes (I use QUADS to create it) I get about 8 fps on my laptop. When I delete 5 sides of the cube and leave only to render the top, I get 10fps. How can this be? When I was deleting the 5 sides of the cube I was expecting to get 5 or 6 times more performance. What I came to was that the amount of vertex doesn't affect performance ass bad as the amount of objects. I also create new instance of BLOCK class to store some random colors for all 6 sides of the cubes. Can anybody help me with this? How to drastically increase performance? (Just asking in general. Not step by step). The only thing I can think of right is now take a bunch of blocks that are at nearby and if they are the same block (dirt for example) render them as huge single block but changing the texture of it to make it look like a lot of blocks.

Upvotes: 1

Views: 1157

Answers (1)

Slicedpan
Slicedpan

Reputation: 5015

Hmm, in general, to increase performance, don't use glBegin/glEnd. (I am guessing this is what you are using, if not then disregard this answer). This is what is known as immediate mode, and is substantially slower than creating vertex/index buffers and then rendering from those. If your geometry is static then you should have no problem rendering 10000 cubes at 60 fps on a modern enough GPU. There is a tutorial on the lwjgl site here, and some more information on the opengl wiki here.

Upvotes: 3

Related Questions