Hello there,
first of all, I'm completly new to openGL, so I'm suspecting the following problem is probably pretty stupid but I just don't seem to find the result.
I followed a lot of tutorials over at NeHe, got them all working just fine and I believe I understand as good as everything that is explained there.
Seeing how I am especialy curious about terrain rendering, I picked up this tutorial here:
http://home.planet.nl/~monstrous/terrain.html and started off trying to write my own little "terrain engine": I'm only up to the 2nd algorythm explained on that page, and I'm already stuck;
When I draw my terrain, my display just gives me a black window. Now, I'm thinking it has something to do with perspective and the coordinates system, which I probably don't understand as well I should at the moment. (at least, until now I thought I did
)
So here's my code for the initialisation of openGl and the actual rendering method:
/**
* Initialise openGL
**/
private void initGL()
{
GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
GL11.glClearDepth(1.0f); // Depth Buffer Setup
GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(
45.0f,
(float) Display.getDisplayMode().getWidth() / (float) Display.getDisplayMode().getHeight(),
0.1f,
1000.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}
/**
* render()
*
* render our scene
*/
public void render()
{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0f, 0.0f, -5.0f);
GL11.glColor3f(0.0f, 0.5f, 0.1f); // set color
// start rendering
GL11.glBegin(GL11.GL_QUADS);
for(float x = 0.0f; x < AREA_SIZE-1; x++)
{
for(float z = 0.0f; z < AREA_SIZE-1; z++)
{
GL11.glVertex3f(F * (x+1), F * height_map[(int)x+1][(int)z], F*z);
GL11.glVertex3f(F * x, F * height_map[(int)x][(int)z], F*z);
GL11.glVertex3f(F * x, F * height_map[(int)x][(int)z+1], F*(z+1));
GL11.glVertex3f(F * (x+1), F * height_map[(int)x+1][(int)z+1], F*(z+1));
}
}
GL11.glEnd();
}
The height_map array is filled with this method (as taken from the tutorial above):
/**
* generateMap()
*
* create a random height map
*/
private void generateMap()
{
float h;
int x, y;
for(x = 0; x < AREA_SIZE; x++)
{
for(y = 0; y < AREA_SIZE; y++)
{
h = (float) (10.0 * Math.sin(x/24.0) + 7.0 * Math.cos((y-50.0)/18.0));
height_map[x][y] = h;
}
}
}
So, could any of you see what I'm doing wrong here?
Thanks in advance for any tips!