public void Draw(Matrix4 fov, Matrix4 cameraView) { //Logging.Debug("Entering background draw."); if (!HasBackground) { return; } //Logging.Debug("We have a background."); _backgroundProgram.Use(); //Logging.Debug("Set background program."); GL.ActiveTexture(TextureUnit.Texture0); //Logging.Debug("Set active texture."); GlUtility.BindTexture(_backgroundTexture); //Logging.Debug("Bound background texture."); _backgroundProgram["projection_matrix"].SetValue(fov); _backgroundProgram["view_matrix"].SetValue(cameraView); //Logging.Debug("Bound background uniforms."); GlUtility.BindBuffer(_points); //Logging.Debug("Bound background points."); //vertexPosition GL.VertexAttribPointer(ShaderProgram.VertexPosition, 3, _points.PointerType, false, 5 * Marshal.SizeOf(typeof(float)), IntPtr.Zero); GL.EnableVertexAttribArray(ShaderProgram.VertexPosition); //Logging.Debug("Bound background positions to array."); GL.DisableVertexAttribArray(ShaderProgram.VertexColor); //Logging.Debug("Disabled VertexColor array."); GL.DisableVertexAttribArray(ShaderProgram.VertexSize); //textureCoords GL.VertexAttribPointer(ShaderProgram.TextureCoords, 2, _points.PointerType, false, 5 * Marshal.SizeOf(typeof(float)), Vector3.SizeInBytes); GL.EnableVertexAttribArray(ShaderProgram.TextureCoords); //Logging.Debug("Bound background texture coords to array."); GlUtility.BindBuffer(_backgroundElements); GL.DrawElements(PrimitiveType.Triangles, 6, DrawElementsType.UnsignedInt, IntPtr.Zero); //Logging.Debug("Exit background draw."); }
public void Draw(ShaderProgram program) { //Logging.Debug("Entering Draw."); if (_points.Count == 0) { //Logging.Debug("Exiting Draw."); return; } //program["pointSize"].SetValue((float)PixelSize); VBO <float> points = new VBO <float>(_points.ToArray()); //Logging.Debug("Created VBO."); GlUtility.BindBuffer(points); //Logging.Debug("Buffer Bound."); GL.VertexAttribPointer(ShaderProgram.VertexPosition, 3, VertexAttribPointerType.Float, false, EightFloatDataSize, IntPtr.Zero); GL.EnableVertexAttribArray(ShaderProgram.VertexPosition); //Logging.Debug("Point pointer set."); GL.VertexAttribPointer(ShaderProgram.VertexColor, 4, VertexAttribPointerType.Float, false, EightFloatDataSize, Vector3.SizeInBytes); GL.EnableVertexAttribArray(ShaderProgram.VertexColor); GL.VertexAttribPointer(ShaderProgram.VertexSize, 1, VertexAttribPointerType.Float, false, EightFloatDataSize, Vector3.SizeInBytes + Vector4.SizeInBytes); GL.EnableVertexAttribArray(ShaderProgram.VertexSize); GL.DisableVertexAttribArray(ShaderProgram.TextureCoords); //Logging.Debug("Color pointer set."); //Logging.Debug("Beginning draw."); // draw the points GL.DrawArrays(PrimitiveType.Points, 0, points.Count / 8); //Logging.Debug("Draw completed for shape."); points.Dispose(); //Logging.Debug("VBO Disposed."); //Logging.Debug("Exiting Draw."); }