private void ColorCodedRender(RenderEventArgs arg, IndexBufferPtr temporaryIndexBufferPtr = null) { UpdatePolygonMode(arg.PickingGeometryType); ShaderProgram program = this.Program; // 绑定shader program.Bind(); program.SetUniform("pickingBaseId", temporaryIndexBufferPtr == null ? (int)this.PickingBaseId : 0); UniformMat4 uniformmMVP4Picking = this.uniformmMVP4Picking; bool mvpUpdated = uniformmMVP4Picking.Updated; if (mvpUpdated) { uniformmMVP4Picking.SetUniform(program); } PickingSwitchesOn(); GLSwitch primitiveRestartIndexSwitch = null; var oneIndexBufferPtr = temporaryIndexBufferPtr as OneIndexBufferPtr; if (oneIndexBufferPtr != null) { primitiveRestartIndexSwitch = new PrimitiveRestartSwitch(oneIndexBufferPtr); primitiveRestartIndexSwitch.On(); } if (this.vertexArrayObject == null) { var vertexArrayObject = new VertexArrayObject( this.indexBufferPtr, this.positionBufferPtr); vertexArrayObject.Create(arg, program); this.vertexArrayObject = vertexArrayObject; } //else { this.vertexArrayObject.Render(arg, program, temporaryIndexBufferPtr); } if (oneIndexBufferPtr != null) { primitiveRestartIndexSwitch.Off(); } PickingSwitchesOff(); if (mvpUpdated) { uniformmMVP4Picking.ResetUniform(program); } // 解绑shader program.Unbind(); }
private void ColorCodedRender(RenderEventArgs arg, IndexBufferPtr temporaryIndexBufferPtr = null) { UpdatePolygonMode(arg.PickingGeometryType); ShaderProgram program = this.Program; // 绑定shader program.Bind(); program.SetUniform("pickingBaseId", temporaryIndexBufferPtr == null ? (int)this.PickingBaseId : 0); UniformMat4 uniformmMVP4Picking = this.uniformmMVP4Picking; { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); uniformmMVP4Picking.Value = projection * view * model; } uniformmMVP4Picking.SetUniform(program); PickingSwitchesOn(); GLSwitch primitiveRestartIndexSwitch = null; var oneIndexBufferPtr = temporaryIndexBufferPtr as OneIndexBufferPtr; if (oneIndexBufferPtr != null) { primitiveRestartIndexSwitch = new PrimitiveRestartSwitch(oneIndexBufferPtr); primitiveRestartIndexSwitch.On(); } { this.vertexArrayObject.Render(arg, program, temporaryIndexBufferPtr); } if (oneIndexBufferPtr != null) { primitiveRestartIndexSwitch.Off(); } PickingSwitchesOff(); //if (mvpUpdated) { uniformmMVP4Picking.ResetUniform(program); } // 解绑shader program.Unbind(); }
protected override void DoRender(RenderEventArgs arg) { UpdatePolygonMode(arg.PickingGeometryType); ShaderProgram program = this.shaderProgram; // 绑定shader program.Bind(); program.SetUniform("pickingBaseId", (int)this.PickingBaseId); UniformMat4 uniformmMVP4Picking = this.uniformmMVP4Picking; bool mvpUpdated = uniformmMVP4Picking.Updated; if (mvpUpdated) { uniformmMVP4Picking.SetUniform(program); } PickingSwitchesOn(); if (this.vertexArrayObject == null) { var vertexArrayObject4Picking = new VertexArrayObject( this.indexBufferPtr, this.positionBufferPtr); vertexArrayObject4Picking.Create(arg, program); this.vertexArrayObject = vertexArrayObject4Picking; } //else { this.vertexArrayObject.Render(arg, program); } PickingSwitchesOff(); if (mvpUpdated) { uniformmMVP4Picking.ResetUniform(program); } // 解绑shader program.Unbind(); }
/// <summary> /// render with specified index buffer. /// </summary> /// <param name="arg"></param> /// <param name="temporaryIndexBuffer"></param> private void Render4Picking(RenderEventArgs arg, IndexBuffer temporaryIndexBuffer) { UpdatePolygonMode(arg.PickingGeometryType); ShaderProgram program = this.Program; // 绑定shader program.Bind(); program.glUniform("pickingBaseId", 0); UniformMat4 uniformmMVP4Picking = this.uniformmMVP4Picking; { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = this.GetModelMatrix().Value; uniformmMVP4Picking.Value = projection * view * model; } uniformmMVP4Picking.SetUniform(program); PickingStateesOn(); var oneIndexBuffer = temporaryIndexBuffer as OneIndexBuffer; if (oneIndexBuffer != null) { PrimitiveRestartState glState = this.GetPrimitiveRestartState(oneIndexBuffer); glState.On(); this.vertexArrayObject.Render(arg, program, temporaryIndexBuffer); glState.Off(); } else { this.vertexArrayObject.Render(arg, program, temporaryIndexBuffer); } PickingStateesOff(); //if (mvpUpdated) { uniformmMVP4Picking.ResetUniform(program); } // 解绑shader program.Unbind(); }
/// <summary> /// /// </summary> /// <param name="arg"></param> public void Render4Picking(RenderEventArgs arg) { if (!this.IsInitialized) { this.Initialize(); } UpdatePolygonMode(arg.PickingGeometryType); ShaderProgram program = this.Program; // 绑定shader program.Bind(); program.glUniform("pickingBaseId", (int)this.PickingBaseId); UniformMat4 uniformmMVP4Picking = this.uniformmMVP4Picking; { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = this.GetModelMatrix().Value; uniformmMVP4Picking.Value = projection * view * model; } uniformmMVP4Picking.SetUniform(program); PickingStateesOn(); this.vertexArrayObject.Render(arg, program); PickingStateesOff(); //if (mvpUpdated) { uniformmMVP4Picking.ResetUniform(program); } // 解绑shader program.Unbind(); }