Exemplo n.º 1
0
        private static void InitWireframe()
        {
            wireframeShader = new WireframeShader();
            wireframeShader.Load();

            wireframeBoxMesh    = Mesh.CreateSimpleBoxMesh(Vector3.One, true);
            wireframeSphereMesh = Mesh.CreateSimpleSphereMesh(1.0f, 8, 6, true);
        }
Exemplo n.º 2
0
        public static void BeginDrawWireframe(IVertexBuffer vertexBuffer, Matrix4 transform, float thickness, Vector4 color)
        {
            WireframeShader.Use();
            WireframeShader.Color.Set(color);
            WireframeShader.ModelMatrix.Set(transform);

            GL.PushAttrib(AttribMask.LineBit);
            GL.LineWidth(thickness);

            vertexBuffer.Bind();
            vertexBuffer.BindAttribute(WireframeShader.Position, 0);
            vertexBuffer.BindAttribute(WireframeShader.Normal, 12);
        }
Exemplo n.º 3
0
        public static void ReleaseResources()
        {
            if (ColorShader != null)
            {
                ColorShader.Dispose();
                ColorShader = null;
            }

            if (WireframeShader != null)
            {
                WireframeShader.Dispose();
                WireframeShader = null;
            }

            if (WireframeShader2 != null)
            {
                WireframeShader2.Dispose();
                WireframeShader2 = null;
            }

            if (ModelShader != null)
            {
                ModelShader.Dispose();
                ModelShader = null;
            }

            if (BoundingBoxBufffer != null)
            {
                BoundingBoxBufffer.Dispose();
                BoundingBoxBufffer = null;
            }

            if (StudConnectionShader != null)
            {
                StudConnectionShader.Dispose();
                StudConnectionShader = null;
            }

            if (SimpleTextureShader != null)
            {
                SimpleTextureShader.Dispose();
                SimpleTextureShader = null;
            }
        }
Exemplo n.º 4
0
        public static void InitializeMatrices(Camera camera)
        {
            var viewMatrix = camera.GetViewMatrix();
            var projection = camera.GetProjectionMatrix();

            WireframeShader.Use();
            WireframeShader.ViewMatrix.Set(viewMatrix);
            WireframeShader.Projection.Set(projection);

            WireframeShader2.Use();
            WireframeShader2.ViewMatrix.Set(viewMatrix);
            WireframeShader2.Projection.Set(projection);

            ColorShader.Use();
            ColorShader.ViewMatrix.Set(viewMatrix);
            ColorShader.Projection.Set(projection);

            ModelShader.Use();
            ModelShader.ViewMatrix.Set(viewMatrix);
            ModelShader.Projection.Set(projection);
            ModelShader.ViewPosition.Set(camera.Position);

            StudConnectionShader.Use();
            StudConnectionShader.ViewMatrix.Set(viewMatrix);
            StudConnectionShader.Projection.Set(projection);

            SimpleTextureShader.Use();
            SimpleTextureShader.ViewMatrix.Set(viewMatrix);
            SimpleTextureShader.Projection.Set(projection);

            if (UIRenderHelper.Freetype6Loaded)
            {
                UIRenderHelper.TextRenderer.ProjectionMatrix = projection;
                UIRenderHelper.TextRenderer.DrawingPrimitives.Clear();
            }

            TextViewMatrix = viewMatrix;

            GL.UseProgram(0);
        }