LWJGL Tutorial Series - Display Lists
This tutorial continues over the understanding you've got in previous tutorials. Please don't skip them. For instance, think that you are making a game where you draw an object several times and one time rendering of that object requires a lot of OpenGL calls, the performance can get down since several reasons of them one being JNI calls has some overhead. What if you can replace a lot of calls with a very few though retaining what you need exactly to render to the screen? You can achieve that with Display Lists.
What is a Display List?
A Display List is a compiled set of commands that needs to be executed every time. When it's compiled, OpenGL need not compute the vertices again and again since they are calculated way before. It would then suffice to call one list with one OpenGL function and automatically others get executed reducing a lot of overhead on JNI calls. so, we're here to learn Display Lists.
Creating a Display List
Like textures and other stuff, you have to generate handle to a Display List you would like to call. So let's start by generating a handle.
public void init()
quad = glGenLists(1);
Now that we have generated a handle, we can create a list. Each list starts with
function and gets compiled into memory with
glColor3f(1, 0, 0);
glColor3f(0, 1, 0);
glColor3f(0, 0, 1);
glColor3f(1, 1, 1);
Now, we've made a list, we can call it in render method.
Calling a DisplayList
You can simply call a display list with
function. Now let's write that in the render method.
public void render()
And when you run it, you can have some thing like this on your screen.
That completes this tutorial. In the next part, I'm going to show "Vertex Arrays" which are more faster than the DisplayLists. If there are any errors or improvements, please notify me with comments.