LWJGL using modern OpenGL examples or Open Source

Hi

I’m trying to develop a game using LWJGL.
Everywhere I look, everybody says that you should use Modern OpenGL (not glBegin() and glEnd() I guess).

And I followed the tutorials on the LWJGL homepage.
But every time I try to make a moving Quad with textures i get som sort of ghosting or studdering.
Most likely I’ve done something wrong.

I’m using a delta for the movement and I’m using VBO’s and VAO.

Every project or example code I find is using glBegin() and glEnd().

Could anybody show me or give me a link to some code that uses VBO’s and VAO’s to move a quad (textured)?

Do you clear screen buffers each frame using glClear?

Yes. I’ve tried both

GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

and

GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

But it’s not that.

Could you post the code?

I have it split into several classes, mostly Game and GameObject.

I’m linked my github: https://github.com/Khazrak/ManaEngine.git

I see that you don’t have any matrixes - movement in modern OpenGL is all about shaders and matrixes, so you should add them.

I was actually wondering about that since I’m going to do SNES-style 2D. Is it necessary? Will it change anything “right now”?

I am usign matrices even though I am making 2D game - this has lots of benefits: the game look the same on every computer, everything is displayed correctly, you an easily manipulate everything.

The problem with forcing a 3.2+ context is that only a subset of users will be able to play your game. For example, only ~38% of Minecraft users support GL 3.2+.

My tutorials focus on “modern GL” (i.e. programmable pipeline) using code and techniques that will be compatible with GL 2.0+ and GL ES. Check out the API to see how things are done, like custom vertex attributes, shader compilation, and so forth. You can add your own VBO/VAO stuff on top relatively easily by implementing VertexData. (Although, for most purposes, simple vertex arrays will suffice.)

Tutorials
API

Briefly looking at your code, I have a couple suggestions:

  • Decouple GL boilerplate/rendering from your game and entity structure (rather than putting VAO/VBO stuff inside of Player)
  • You should re-use float arrays (i.e. in your Vertex class) instead of creating new ones every frame, to minimize garbage. This is especially important if you ever plan to do mobile/ES programming.