Hi, I have a program that loads in a heightmap data from a text file. The problem i have is i don’t really have a clue what do do with it.
I have to call glTexImage2D to set up the text, how would i use that? Oh and the data from the heightmap text file is stored in a floating point array.
Any tutorials or help os very welcome and much appreciate.
My OpenGL isn’t very good to be honest.
Thanks in advanced.
First step: load the heightmap data into an array (how you do this depends on your programming language). Once you have that, create an OpenGL texture and upload this data (see here: http://www.opengl.org/wiki/Texture).
Afterwards, create a vertex buffer object with a uniform square grid with the same size as your texture.
Finally, create a vertex shader that samples your heightmap texture and offsets the grid according to it (each ‘texel’ of the texture provides the elevation of a specific point on the grid).
There are a lot of concepts and the learning curve is rather steep, but everything will start making sense soon - trust me!
Thanks a lot for the reply.
I am using c++ for this project. Is there any change you could show me some code on how to create the texture? I’ve been trying for a few days now and i think im missing something on the concept but im not sure what it is.
Is this how i would create an openGL Texture:
glTexImage2D(GL_TEXTURE_2D, 0, 1, w, h, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, ifile);
Thanks again man.