LWJGL - Immediate rendering alternative

I want to render points and lines on screen for debugging purposes.

What methods are there?

not many. for debugging GL_LINES and GL_POINTS are sufficient … usually.

the hassle of setting up a VBO and whatnot is not worth it, especially when you debug moving things.

Yeah that’s what I figured. However,

GL11.glBegin(GL11.GL_LINE);
...
...
GL11.glEnd();

Does nothing.

nothing ? O_o

Use GL_LINES instead of GL_LINE.

In addition, if you need to display A LOT of lines/points/anything else and you don’t want to change rendering data often, you can use display lists for significant performance boost.

Yes, nothing renders at all. I have no experience with the deprecated immediate mode. So I might not be setting up properly?

And thanks Mac70. I just need them to debug frustum and ray casting. It is not going to be a part of my game. I just need a visual for that sort of thing.

I’m testing by using this:


GL11.glColor3f(1f, 1f, 1f);
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex3d(10, 5, 10);
GL11.glVertex3d(10, 15, 10);
GL11.glEnd();

If you want a continuous line you should use GL_LINE_STRIP.
If you want it to loop back at the end you should use GL_LINE_LOOP.

Okay. I had to clear depth buffer before using the immediate calls.

But now it renders the immediate stuff with the center at the middle of the screen. How do I update those transforms?

Remember I’m not 100% familiar with the deprecated code.

Here for reference:

Well in fixed function pipeline (which you are probably using with calls like glVertex3f()) there are a couple of matrices defining transformations. GL_PROJECTION_MATRIX and GL_MODELVIEW_MATRIX. The matrix you are currently working on is defined with glMatrixMode(). Modifying these matrices is done with glLoadMatrix(), glLoadIdentity(), glTranslatef(), glRotatef, glScalef(), glOrtho(), glFrustum() and similar calls.

But tbh I would try to stick with deferred rendering. You can use the variant of the glVertexAttribPointer() command which takes a buffer directly to achieve what is essentially immediate mode rendering without changing any of your rendering setup and without the hassle of messing around with VBOs.

I figured it was something like that. Thanks for the glVertexAttribPointer() tip I’ll look into that.