public static void DrawStudConnector2(Matrix4 transform, LDDModder.LDD.Primitives.Connectors.Custom2DFieldConnector connector) { float offset = connector.SubType == 23 ? 0.0005f : -0.0005f; DrawTexturedQuad(transform, TextureManager.StudConnectionGrid, new Vector2(connector.StudWidth * 0.8f, connector.StudHeight * 0.8f), new Vector4(0, 0, connector.StudWidth, connector.StudHeight), offset); }
public static void DrawStudConnector(Matrix4 transform, LDDModder.LDD.Primitives.Connectors.Custom2DFieldConnector connector) { bool wasTexEnabled = GL.IsEnabled(EnableCap.Texture2D); GL.Enable(EnableCap.Texture2D); //GL.DepthMask(false); StudConnectionShader.Use(); StudConnectionShader.ModelMatrix.Set(transform); var cellSize = new Vector2(0.8f) * new Vector2(connector.StudWidth, connector.StudHeight); cellSize.X /= connector.ArrayWidth; cellSize.Y /= connector.ArrayHeight; StudConnectionShader.CellSize.Set(cellSize); StudConnectionShader.IsMale.Set(connector.SubType == 23); TextureManager.StudGridTexture.Bind(TextureUnit.Texture5); StudConnectionShader.Texture.Set(TextureUnit.Texture5); var items = new List <StudGridCell>(); for (int y = 0; y < connector.ArrayHeight; y++) { for (int x = 0; x < connector.ArrayWidth; x++) { var node = connector[x, y]; items.Add(new StudGridCell() { Position = new Vector3(x, y, 0), Values = new Vector3(node.Value1, node.Value2, node.Value3) }); } } var gridBuffer = new Buffer <StudGridCell>(); gridBuffer.Init(BufferTarget.ArrayBuffer, items.ToArray()); var vao = new VertexArray(); vao.Bind(); vao.BindAttribute(StudConnectionShader.Position, gridBuffer, 0); vao.BindAttribute(StudConnectionShader.Values, gridBuffer, 12); vao.DrawArrays(PrimitiveType.Points, 0, items.Count); vao.UnbindAttribute(StudConnectionShader.Position); vao.UnbindAttribute(StudConnectionShader.Values); gridBuffer.Dispose(); vao.Dispose(); StudConnectionShader.Texture.Set(TextureUnit.Texture0); TextureManager.StudGridTexture.Bind(TextureUnit.Texture0); //GL.DepthMask(true); if (!wasTexEnabled) { GL.Disable(EnableCap.Texture2D); } }