[FIXED] : I wasn't familiar with the concept of depth-testing, all is fine now!
Ey All!
I have a question; the answer might be obvious since I'm new at OpenGL. I made a simple 3-d game in which a flyer is controlled by two ultrasonic sensors. The problem is in the code that adds the indexes to the mesh I use to create a mountain landscape. http://i60.tinypic.com/2coitxf.png (the problem shows on the right top side of the flyer).
If I use .drawWireframe to draw the mesh, everything is connected correctly ( http://i61.tinypic.com/58cac.png ), but if I use drawfaces, non 3-d shapes are present parralel with the x-axis. So the vertexes& vertices all seem to be correct, but the faces are not perceived correctly. I'm suspecting I have to make a seperate mesh with trianglestrips for each row, and connect the meshes into a whole somehow? I know the problem is in the winding, but I thought the Mesh would take care of this. By now have no clue at what I'm doing haha Image may be NSFW.
Clik here to view. So any pointers would be appreciated!
The code that creates the landscape is as follows:
void LandScapeC::setup(){
landScape.setMode(OF_PRIMITIVE_TRIANGLES);
landScape.enableColors();
landScape.enableIndices();
landScape.enableNormals();
for(int z=0; z<sizeY; z++){
for(int x=0; x<sizeX; x++){
float AltitudeY=ofRandom(0,heightM);
ofVec3f point(x*stretch, AltitudeY,- z*stretch);
landScape.addVertex(point);
if(AltitudeY>=snowLine){
landScape.addColor(ofFloatColor(1.0,1.0,1.0));
}else if(AltitudeY<10){
landScape.addColor(ofFloatColor(0,0.6,0));
}else{
landScape.addColor(ofFloatColor(0.0,0.8,0.0));
}
}
}
//triangles
// for(int i=0;i<(sizeX-1)*(sizeY-1);i++){
//if(i<(((sizeX-1)*(sizeY-1))*2)){
int i=0;
for(int y=0;y<sizeY-1;y++){
i=y*sizeX;
for(int x=0;x<sizeX-1;x++){
landScape.addIndex(i);
landScape.addIndex(i+sizeX);
landScape.addIndex(i+sizeX+1);
landScape.addIndex(i);
landScape.addIndex(i+1);
landScape.addIndex(i+sizeX+1);
i++;
}
}
}
}