コード例 #1
0
        public void TickRender()
        {
            if (Ready)
            {
                GL.Enable(EnableCap.Blend);
                GL.Disable(EnableCap.DepthTest);
                GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

                GL.BindVertexArray(VAO);
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);

                GUI.GetFontShader.Use();

                font.AtlasTexture.Use();

                GUI.GetFontShader.Setbool("HaveTexture", true);
                GUI.GetFontShader.SetColor("MainColor", colour);

                GUI.GetFontShader.SetMatrix4("projection", Matrix4.CreateOrthographicOffCenter(Window.Instance.ClientRectangle.Left, Window.Instance.ClientRectangle.Right, Window.Instance.ClientRectangle.Bottom, Window.Instance.ClientRectangle.Top, 0f, 5.0f));

                GL.DrawArrays(PrimitiveType.Triangles, 0, textMeshData.getVertexLength());

                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.BindVertexArray(0);

                GL.Enable(EnableCap.DepthTest);
                GL.Disable(EnableCap.Blend);
            }
        }
コード例 #2
0
        public void UpdateText(string text)
        {
            GenRectangle();

            textString = text;

            Ready        = false;
            textMeshData = null;

            textMeshData = createTextMesh();

            GL.BindVertexArray(VAO);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
            GL.BufferData(BufferTarget.ArrayBuffer, textMeshData.getVertexLength() * Vector2.SizeInBytes, textMeshData.getVertexPositions(), BufferUsageHint.DynamicDraw);
            GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(0);

            GL.BindBuffer(BufferTarget.ArrayBuffer, ubo);
            GL.BufferData(BufferTarget.ArrayBuffer, textMeshData.getTextureCoordsLength() * Vector2.SizeInBytes, textMeshData.getTextureCoords(), BufferUsageHint.DynamicDraw);
            GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 0, 0);
            GL.EnableVertexAttribArray(1);

            Ready = true;
        }