PDA

View Full Version : Landscape



eskimo
03-01-2004, 04:58 AM
I am very new to OpenGL programing and was wondering. If I have a set of 3d-coordinates (x,y,z, is it possible to input that data in the form of an array and generating a 3d map of an area?

If so - where would be a good place to start?

Nychold
03-01-2004, 06:32 AM
There are a lot of ways to send data to OpenGL. Other than glVertex3f or its siblings, you can use glDrawArrays. First, you have to enable it:

glEnableClientState(GL_VERTEX_ARRAY);

Then, you set OpenGL to use the array:

glVertexPointer(3,GL_FLOAT,0,vertexArrayPointer);

Modify the above to fit your needs...the 3 represents the number elements per vertex, GL_FLOAT is obviously the type of data for each element in the vertex, and 0 is the stride (the number of bytes between each vertex).

Finally, in your rendering code use:

glDrawArrays(GL_POINTS,0,numOfVertices);

replacing GL_POINTS with whatever primitives you're trying to draw for the array. When you get that to work, look up:

glTexCoordPointer
glNormalPointer
glDrawElements

for some advanced options and ideas.