internal override void Draw(Matrix4 worldTransform) { Material.ApplyMaterial(); //place button in right corner var trans = Node.GetTransform.GlobalTransform; trans.M41 += trans.M11 - BoxSize; trans.M11 = trans.M22 = BoxSize; shaderUniform.SetValue(trans * worldTransform); colorMask.SetValue(color); //draw box Texture?.BindTexture(); base.Draw(worldTransform); //draw mark if (IsOn) { colorMask.SetValue(Vector4.One); chekMarkDefault?.BindTexture(); base.Draw(worldTransform); } }
internal override void Draw(Matrix4 worldTransform) { Material.ApplyMaterial(); //draw bg var trans = Node.GetTransform.GlobalTransform; trans.M42 += (trans.M22 - SliderBoxSize) * 0.5f; trans.M22 = SliderBoxSize; bgTexture?.BindTexture(); colorMask.SetValue(new Vector4(Vector3.Zero, 1)); shaderUniform.SetValue(trans * worldTransform); base.Draw(worldTransform); //draw fill gauge trans.M11 *= Value; trans.M42 += (trans.M22 - SliderFillSize) * 0.5f; trans.M22 = SliderFillSize; fillTexture?.BindTexture(); colorMask.SetValue(Vector4.One); shaderUniform.SetValue(trans * worldTransform); base.Draw(worldTransform); //draw slider button trans = Node.GetTransform.GlobalTransform; trans.M41 += trans.M11 * Value - ButtonSize * 0.5f; trans.M11 = trans.M22 = ButtonSize; bgTexture?.BindTexture(); colorMask.SetValue(color); shaderUniform.SetValue(trans * worldTransform); base.Draw(worldTransform); }
public void RenderInstanced() { shaderProgram.ApplyShader(); //color.SetValue(new Vector4(1)); //worldS.SetValue(Matrix4.Identity); GL.EnableVertexAttribArray(0); foreach (PrimitiveData shapeData in shapes.Values) { //break; // Normal buffer // Vertex buffer GL.BindBuffer(BufferTarget.ArrayBuffer, shapeData.VertexBufferID); GL.VertexAttribPointer(vertexPositionLocation, 3, VertexAttribPointerType.Float, false, BulletSharp.Math.Vector3.SizeInBytes, IntPtr.Zero); Matrix4 worldMatrix; // Index (element) buffer if (shapeData.ElementCount != 0) { GL.BindBuffer(BufferTarget.ElementArrayBuffer, shapeData.ElementBufferID); foreach (InstanceData instance in shapeData.Instances) { worldMatrix = instance.WorldTransform; color.SetValue(ColorToVec3(instance.Color)); worldS.SetValue(worldMatrix); //GL.UniformMatrix4(worldMatrixLocation, false, ref worldMatrix); //GL.Uniform4(vertexColorLocation, instance.Color); GL.DrawElements(shapeData.PrimitiveType, shapeData.ElementCount, shapeData.ElementsType, IntPtr.Zero); } GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); } else { foreach (InstanceData instance in shapeData.Instances) { worldMatrix = instance.WorldTransform; color.SetValue(ColorToVec3(instance.Color)); worldS.SetValue(worldMatrix); //GL.UniformMatrix4(worldMatrixLocation, false, ref worldMatrix); //GL.Uniform4(vertexColorLocation, instance.Color); GL.DrawArrays(shapeData.PrimitiveType, 0, shapeData.VertexCount); } } } GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.DisableVertexAttribArray(vertexPositionLocation); }
internal override void Draw(Matrix4 worldTransform) { Material.ApplyMaterial(); colorMask.SetValue(color); shaderUniform.SetValue(Node.GetTransform.GlobalTransform * worldTransform); Texture?.BindTexture(); base.Draw(worldTransform); }
public RawImage() : base(typeof(RawImage)) { //Material = defaultMaterial; shaderUniform = Material.UniformManager.GetUniform("model"); colorMask = Material.UniformManager.GetUniform("color_mask"); color = Vector4.One; Material.ApplyMaterial(); colorMask.SetValue(color); }
internal override void Draw(Matrix4 worldTransform) { Material.ApplyMaterial(); var trans = Node.GetTransform.GlobalTransform; shaderUniform.SetValue(trans * worldTransform); colorMask.SetValue(color); //draw box Texture?.BindTexture(); base.Draw(worldTransform); //draw caret if (IsFocused) { trans.M41 += Text.textCanvas.Width + caretPadding; trans.M11 = CaretSize.X; trans.M22 = CaretSize.Y; shaderUniform.SetValue(trans * worldTransform); colorMask.SetValue(new Vector4(Vector3.Zero, 0.5f)); base.Draw(worldTransform); } }
internal override void Draw(Matrix4 worldTransform) { if (!ScrollBox) { return; } Material.ApplyMaterial(); //draw bg var trans = Node.GetTransform.GlobalTransform; trans.M41 += trans.M11 - ScrollBarSize; trans.M11 = ScrollBarSize; bgTexture?.BindTexture(); colorMask.SetValue(new Vector4(Vector3.Zero, 1)); shaderUniform.SetValue(trans); base.Draw(worldTransform * worldTransform); //knob size var scrollSize = ScrollBox.Node.GetTransform.GlobalTransform.M22; var trackSize = Node.GetTransform.GlobalTransform.M22; var buttonSize = (float)(trackSize / scrollSize); buttonSize = (buttonSize > 1) ? 1 : buttonSize; buttonSize *= trackSize; ButtonSize = buttonSize; //draw slider button //trans = Node.GetTransform.GlobalTransform; trans.M42 += (trans.M22 - ButtonSize) * Value; trans.M22 = ButtonSize; bgTexture?.BindTexture(); colorMask.SetValue(color); shaderUniform.SetValue(trans * worldTransform); base.Draw(worldTransform); }
internal override void Draw(Matrix4 worldTransform) { Material.ApplyMaterial(); colorMask.SetValue(color); shaderUniform.SetValue(Node.GetTransform.GlobalTransform * worldTransform); /* * Console.WriteLine(1111); * Console.WriteLine(Node.GetTransform.GlobalTransform); * Console.WriteLine(Node.GetTransform.GlobalTransform * worldTransform); * Console.WriteLine(new Vector4(1,1,0,1) * Node.GetTransform.GlobalTransform * worldTransform); * Console.ReadLine(); */ if (Texture) { Texture.BindTexture(); } base.Draw(worldTransform); }
internal void Render(TextBox text, Matrix4 worldTransform) { //GL.StencilFunc(StencilFunction.Always, 0, 0xFF); shdr.ApplyShader(); //stencil masking if (text.Node.MaskCheck == 0) { GL.StencilFunc(StencilFunction.Always, 0, 0xFF); } else { GL.StencilFunc(StencilFunction.Equal, text.Node.MaskCheck, 0xFF); } colorUniform.SetValue(text.textCanvas.colour); var translation = Matrix4.CreateScale(text.textCanvas.Scale) * CalculatePosition(text.textCanvas, text.Node.GetTransform); projUniform.SetValue(translation * worldTransform); GL.ActiveTexture(TextureUnit.Texture0); charmap.BindTexture(); GL.BindVertexArray(text.textCanvas.VAO); GL.DrawArrays(PrimitiveType.Triangles, 0, 6 * text.textCanvas.StringLength); }