Hello everyone.
I am new to OpenGL and i require help…
I am trying to draw a triangle where every top is colored in a different color…
The current code that I have is :
int buf2;
Vector3[] vertices2 = new Vector3[3];
vertices2[1] = new Vector3(1f, -1f, 0f);
vertices2[2] = new Vector3(-1f, -1f, 0f);
vertices2[0] = new Vector3(0f, 1f, 0f);
GL.GenBuffers(1, out buf2);
GL.BindBuffer(BufferTarget.ArrayBuffer, buf2);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(vertices2.Length * Vector3.SizeInBytes),
vertices2, BufferUsageHint.StaticDraw);
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.EnableVertexAttribArray(0);
GL.BindBuffer(BufferTarget.ArrayBuffer, buf2);
GL.Color3(Color.Yellow);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
GL.DrawArrays(BeginMode.Triangles,0,3);
GL.DisableVertexAttribArray(0);
GL.SwapBuffers();
This gives me a yellow triangle. Now I wonder how to color each top differently with colors transitioning one from another as you get closer to some top…