General queries about LWJGL

Hey guys. I’m quite new to working with lwjgl (and game dev in 3d in general) and I was wondering if anyone could help me out with a few problems I’m having. Below is the project I’m working on to try and get some of the core concepts of lwjgl and 3d collisions and stuff so it will be a bit buggy but it will work for what I’m asking (I think).

Here’s a list of questions that I would like answered.

  1. How do I do 2d graphics for the player to act as a HUD. I’ve tried a few things I’ve seen online but it just blacks out my screen.
  2. How do I get rid of the lines appearing on my skybox. Again I’ve tried a few things but it only made it marginally better instead of getting rid of it.
  3. Is this the best way to do the skybox. It seems a little inefficient to me.
  4. Is there anything that would be recommended for me to know that would come in handy?

Thanks in advance :slight_smile:

You need to give more details and code, and not in RAR format. Just paste the relevant bits that are causing problems. We have no way of knowing how to fix your problem when all you say is “it just blacks out my screen.” :stuck_out_tongue:

To render HUD, you typically use two triangles in orthographic projection to make up a textured quad. Each quad may represent an icon (such as a button background) or even individual font glyphs. Ideally you should batch these into a single VBO (or vertex array) to reduce bandwidth.

For skyboxes, a common issue with seams appearing has to do with texture clamping. Use a different clamp mode, or use something like texture arrays. Better yet, you could use cube maps or another technique to texture your skybox. Another popular solution is to texture a sphere with an equirectangular sky map:
http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html

GL_QUADS is deprecated.

Like Jeremy said, GL_QUADS is deprecated.

If you think batching is a lot of work, you shouldn’t be working with pure OpenGL. :stuck_out_tongue: Instead, use a library like LibGDX, jME, or whatever.

A single UI element might be made up of many quads. Imagine a typical checkbox: a nine-patch for the background, a quad for the checkbox icon, and N quads for each character in the text. That’s already well over a dozen quads just for one UI element. You’re looking at potentially hundreds of quads that need to be rendered.

And if you aren’t using sprite sheets, then not only are you calling GL for every quad, but you are also incurring texture switches.

Besides; you don’t have immediate mode in modern OpenGL, so you’re going to be writing VBOs anyways…

On desktop it probably won’t be too bad, but on mobile those things can definitely add up and slow down your game.

Ok thanks a lot for the help guys.

Sorry for the vagueness of the code but I had a few questions and thought it would be easier to see the mistakes with the whole project.

I’m going to be working on some of the other problems I have but for now its more of a curiosity.
Here’s everything in my game loop. http://pastebin.com/1WVN7NBr
The 2d stuff in there is just temporary to get used to it.

I can’t figure out why the box being drawn in 2d is all in black even though I have glColor3f(1,1,1); just before it.

Thanks