public void PrepareHTVAO(OpenGL gl, HitTestProgram program) { var vertArrIds = new uint[1]; gl.GenVertexArrays(1, vertArrIds); VaoHT = vertArrIds[0]; gl.BindVertexArray(VaoHT); BindHTVBOs(gl, program); gl.EnableVertexAttribArray(0); gl.BindVertexArray(0); }
public void BindHTVBOs(OpenGL gl, HitTestProgram program) { var attribPos = program.Attribs["Position"]; gl.BindBuffer(_vboTarget, Position); gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero); gl.EnableVertexAttribArray(attribPos); attribPos = program.Attribs["HTColorId"]; gl.BindBuffer(_vboTarget, HTColorId); gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero); gl.VertexAttribDivisor(attribPos, 1); gl.EnableVertexAttribArray(attribPos); gl.BindBuffer(_iboTarget, Ibo); }
public void Init(object sender, OpenGLEventArgs args) { SceneControl = sender as OpenGLControlJOG; // Set up the view. MvpBuilder.FovRadians = (float)Math.PI / 2f; // Set FOV to 90° MvpBuilder.Far = 100f; MvpBuilder.Near = 0.01f; MvpBuilder.Width = (int)SceneControl.ActualWidth; MvpBuilder.Height = (int)SceneControl.ActualHeight; MvpBuilder.TranslationZ = -10; MvpBuilder.BuildPerspectiveProjection(); MvpBuilder.BuildTurntableModelview(); // Create a visible shader program. NmProgram = new NormalMaterialProgram(GL); NmProgram.LightPosition = new vec3(5, 10, 15); NormalMatrix = mat3.identity(); // Create the hit test shader program. HtProgram = new HitTestProgram(GL); ProjectionMatrix = MvpBuilder.ProjectionMatrix; ModelviewMatrix = MvpBuilder.ModelviewMatrix; AddData(GL); GL.Enable(OpenGL.GL_DEPTH_TEST); GL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); }
public void Init(object sender, OpenGLEventArgs args) { SceneControl = sender as OpenGLControlJOG; // Set up the view. MvpBuilder.FovRadians = (float)Math.PI / 2f; // Set FOV to 90° MvpBuilder.Far = 100f; MvpBuilder.Near = 0.01f; MvpBuilder.Width = (int)SceneControl.ActualWidth; MvpBuilder.Height = (int)SceneControl.ActualHeight; MvpBuilder.TranslationZ = -10; MvpBuilder.BuildPerspectiveProjection(); MvpBuilder.BuildTurntableModelview(); // Create a visible shader program. NmProgram = new NormalMaterialProgram(GL); NmProgram.LightPosition = new vec3(5, 10, 15); NormalMatrix = mat3.identity(); // Create the hit test shader program. HtProgram = new HitTestProgram(GL); ProjectionMatrix = MvpBuilder.ProjectionMatrix; ModelviewMatrix = MvpBuilder.ModelviewMatrix; AddData(GL); GL.Enable(OpenGL.GL_DEPTH_TEST); GL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); }
public void PrepareHTVAO(OpenGL gl, HitTestProgram program) { var vertArrIds = new uint[1]; gl.GenVertexArrays(1, vertArrIds); VaoHT = vertArrIds[0]; gl.BindVertexArray(VaoHT); BindHTVBOs(gl, program); gl.EnableVertexAttribArray(0); gl.BindVertexArray(0); }
public void BindHTVBOs(OpenGL gl, HitTestProgram program) { var attribPos = program.Attribs["Position"]; gl.BindBuffer(_vboTarget, Position); gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero); gl.EnableVertexAttribArray(attribPos); attribPos = program.Attribs["HTColorId"]; gl.BindBuffer(_vboTarget, HTColorId); gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero); gl.VertexAttribDivisor(attribPos, 1); gl.EnableVertexAttribArray(attribPos); gl.BindBuffer(_iboTarget, Ibo); }