
vertex coloring
Posted Wednesday, 8 August, 2012 - 17:48 by clayphd inHello, I am rather new to OpenTk/OpenGL. I've learned draw a square, add color to said square and then add lights to the scene... My problem is that when I add a light to the scene the vertex colors seem to disappear on me, is that suppose to happen? Am I doing something wrong? Here is my onRenderFrame method
base.OnRenderFrame(e); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview); float[] lightPose1 = { 4f, 0.0f, 0.0f, 1.0f }; float[] lightColor1 = { .5f, 0.5f, 0.5f, 0.0f }; GL.Light(LightName.Light0, LightParameter.Diffuse, lightColor1); GL.Light(LightName.Light0, LightParameter.Position, lightPose1); float[] lightColor2 = { 0.5f, .5f, .5f, 1.0f}; float[] lightPose2 = { -4f, 0.0f, 0.0f, 0f }; GL.Light(LightName.Light1, LightParameter.Diffuse, lightColor2); GL.Light(LightName.Light1, LightParameter.Position, lightPose2); GL.PushMatrix(); GL.Translate(0.0f, 0.0f, 6f); GL.Rotate(angle, 0.0f, 1.0f ,0.0f); GL.Begin(BeginMode.Quads); GL.Normal3(0.0f, 0.0f, -1.0f); GL.Color3(Color.Purple); GL.Vertex3(-1.0f, 0.0f, 0.0f); GL.Vertex3(0.0f, 1.0f, 0.0f); GL.Color3(Color.Green); GL.Vertex3(1.0f, 0.0f, 0.0f); GL.Vertex3(0.0f, -1.0f, 0.0f); GL.End(); GL.PopMatrix(); SwapBuffers();


Comments
Re: vertex coloring
Well... I figured out the problem... I didn't have GL.Enable(EnableCap.ColorMaterial);