Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

View RSS Feed


LWJGL 3D Terrain: Modernizing the code

Rate this Entry
In my last post I was able to achieve fairly decent results by creating a static display list and off-loading the drawing code to GPU.

There's just one problem: This code utilizes features which are "deprecated" and can only be used when running under a backwards compatibility context. Most notably I'm utilizing the direct mode rendering. Starting with OpenGL 3 (I think it's actually 3.3), OpenGL moved to essentially a purely shader-based model.

So once again, I'm re-writing my code to compensate for the changes. This time the changes are much more significant because basically anything involved with actually drawing stuff has changed. There's no longer the default lighting, default modelview and projection matrices, and as stated before rendering is handled using shaders rather than a direct mode rendering.

So the first question is what is a shader? From what I understand a shader is a small program which runs on the GPU to describe how to render something. It's not as general purpose as CUDA or OpenCL, but it could be thought of as the pre-cursor to these languages (indeed, many early GPU-accelerated computations were implemented using shaders). OpenGL's shader language is known as GLSL which is a C-like programming language.

There are different types of shaders and I'm still trying to work my way through the two most basic ones, vertex shaders and fragment shaders.

Here's the latest screenshot of what I have:

Most of the original functionality is back. The most notable missing feature is lighting and shadows. I'm planning on implementing Phong Lighting to provide fairly decent results while still being simple and computationally fast. Once again the color mapping has changed.

Another point is I took a performance hit when porting over to shader-based rendering (1024x1024 height map being used again). I'm not too worried at this point because it's still decently fast and I haven't really spent any time optimizing my render code.

Updated October 5th, 2012 at 02:28 AM by helloworld922