Hi, I first started Java game programming with simple built in Java2D classes. I remember having to create a game loop that updates that game that re-draws the screen. It was a lot of code (relatively).

I'm starting to learn LWJGL and is this following code all I really need to do in terms of worrying about re-drawing/updating the screen?

1 2 3 4 5 6 7 8 9

//I've created the Display in earlier lines of codewhile (!Display.isCloseRequested()){//Render

No, it's not really that simple. For most games you'll probably want a variable or "semi-fixed" timestep; and use the delta-time variable to ensure smooth animation and movement across systems.

However, unlike Java2D, you won't need to worry about buffer strategies, or repainting, or Thread.wait/sleep, or what have you. At the end of each frame, you simply call Display.update to "swap the buffers" (i.e. show what has been rendered), then Display.sync if you want to cap the frame rate.

publicvoidinitGL(){GL11.glMatrixMode(GL11.GL_PROJECTION);GL11.glLoadIdentity();// Coordinate Placement, use glOrtho(0, Display.getWidth(), 0, Display.getHeight, 1, -1); for Cartesian Coordinates (better for mouse input and what I consider to be the standard :P)GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);GL11.glMatrixMode(GL11.GL_MODELVIEW);// Enabling Textures to be drawn on the screenGL11.glEnable(GL11.GL_TEXTURE_2D);

// Used for TransparencyGL11.glEnable(GL11.GL_BLEND);GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }

You could put it in the constructor if you really wanted to, but if you ever need to access your main class variable, you will have to do it through inheritance. I would personally just make it an initGL() method that is called in your main init() method. Saves a lot of confusion.

About your code, it is fine to not have the GL11. before everything. You just need to statically import GL11.

About the glOrtho though, I would still use the Display.width(), and Display.height() just so that it you don't have to worry about it later on if you want to change the size of the display.The way you have it set up right now (glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1)), the coordinates are like they are in Java2D and such (with (0, 0) starting the the upper left hand corner). Unfortunately though, the mouse input doesn't change depending on your coordinate system. You can easily fix this by having a mouseY = Display.getHeight() - Mouse.getY();

I personally use glOrtho the way you are doing it just because I am used to it. You can use whatever you like though.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org