flopoloco's picture

Help Needed - VBO Terrain

Hi there fellow OpenTK developers, I would like some one experienced developer in OpenGL to finish this project. I try to create a terrain using Vertex Buffer Objects and Vertex Arrays and Texturing and I am stuck, I did something wrong and I can't find the problem.

Here's the solution file here (about 1 MB)

Also in any case here's some tips about the project here (the code is not a straight port, I used it as a guide though and it might help you to understand what I am trying to do)

If you succeed, please let me know. Thank you for time and effort in advance. :D


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
migueltk's picture

I made ​​some modifications that allow you to see something.

                Vector3 eyePosition = new Vector3(0.0f, 100.0f, 100.0f); // 4 change
		protected override void OnUpdateFrame(FrameEventArgs e)
				eyePosition.Z += 0.5f;
				eyePosition.Z -= 0.5f;
				eyePosition.X += 0.5f;
				eyePosition.X -= 0.5f;
				eyePosition.Y += 0.5f;
				eyePosition.Y -= 0.5f;
		protected override void OnRenderFrame(FrameEventArgs e)
			GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // 3 change
			GL.MatrixMode(MatrixMode.Modelview); // 1 change
			GL.LoadIdentity();					 // 2 change
			Matrix4 modelview = Matrix4.LookAt(eyePosition, eyeTarget, Vector3.UnitY);
			GL.LoadMatrix(ref modelview);
			GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-4.6f, -4.4f); // 5 change
                        GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(4.6f, -4.4f); // 6 change
                        GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(4.6f, 4.4f); // 7 change
                        GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-4.6f, 4.4f); // 8 change

Basically the method that represents the terrain "RenderTerrain ()" does the right thing.

I recommend you progress step by step, first get to represent the terrain mesh in wireframe and when this happens the way you textured.
First using the OpenGL fixed functionality and when everything finally works using VBO.


31337's picture

Would be amazing if someone could provide a working example.