Beispiel #1
0
        private static void DrawPolygonUv(NUD.Polygon p, int windowWidth, int windowHeight)
        {
            Shader shader = OpenTKSharedResources.shaders["UV"];

            shader.UseProgram();
            shader.EnableVertexAttributes();
            uvPositionVbo.Bind();

            // Draw over everything
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            GL.Clear(ClearBufferMask.DepthBufferBit);

            // Scale to 0 to 1 UV space and flip vertically.
            Matrix4 matrix = Matrix4.CreateOrthographicOffCenter(0, 1, 1, 0, -1, 1);

            shader.SetMatrix4x4("mvpMatrix", ref matrix);

            SetVertexAttributes(shader);

            // Draw the uvs.
            GL.LineWidth(1.5f);
            GL.Enable(EnableCap.LineSmooth);

            uvElementsIbo.Bind();
            GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);

            shader.DisableVertexAttributes();
        }
Beispiel #2
0
        public void Draw(Matrix4 mvpMatrix)
        {
            Shader shader = OpenTKSharedResources.shaders["SolidColor3D"];

            if (!shader.ProgramCreatedSuccessfully)
            {
                return;
            }

            // Set up.
            shader.UseProgram();
            shader.EnableVertexAttributes();
            positionBuffer.Bind();

            // Set shader values.
            Matrix4 matrix = mvpMatrix;

            shader.SetMatrix4x4("mvpMatrix", ref matrix);

            // Draw.
            int rectangularPrismVertCount = 24;

            GL.DrawArrays(PrimitiveType.TriangleFan, 0, rectangularPrismVertCount);

            shader.DisableVertexAttributes();
        }
Beispiel #3
0
        public static void DrawRectangularPrism(Matrix4 mvpMatrix, float scaleX = 1, float scaleY = 1, float scaleZ = 1,
                                                float centerX = 0, float centerY = 0, float centerZ = 0)
        {
            Shader shader = OpenTKSharedResources.shaders["SolidColor3D"];

            if (!shader.ProgramCreatedSuccessfully)
            {
                return;
            }

            // Set up.
            shader.UseProgram();
            shader.EnableVertexAttributes();
            rectangularPrismPositionBuffer.Bind();

            // Set shader values.
            SetVertexAttributes(shader);
            SetShaderUniforms(mvpMatrix, scaleX, scaleY, scaleZ, centerX, centerY, centerZ, shader);

            // Draw.
            int rectangularPrismVertCount = 24;

            GL.DrawArrays(PrimitiveType.TriangleFan, 0, rectangularPrismVertCount);

            shader.DisableVertexAttributes();
        }
        public static void DrawScreenTriangle(Shader shader, BufferObject vbo)
        {
            shader.EnableVertexAttributes();
            vbo.Bind();

            // Set everytime because multiple shaders use this for drawing.
            GL.VertexAttribPointer(shader.GetVertexAttributeUniformLocation("position"), 3, VertexAttribPointerType.Float, false, sizeof(float) * 3, 0);

            GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
            shader.DisableVertexAttributes();
        }