Пример #1
0
        public static void DrawLine(Color color, Position2D start, Dimension2D tSize)
        {
            OGLTools.glDisable(Gl.GL_TEXTURE_2D);
            OGLTools.glEnable(Gl.GL_ALPHA);
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 1f);

            Gl.glPushMatrix();
            Gl.glTranslated(start.X, start.Y, 0);

            float x1, y1;


            Gl.glBegin(Gl.GL_LINES);
            Gl.glColor3f(color.R / 255, color.G / 255, color.B / 255);
            Gl.glVertex2f(0f, 0f);
            Gl.glColor3f(color.R / 255, color.G / 255, color.B / 255);
            Gl.glVertex2f(tSize.Width, tSize.Height);
            Gl.glEnd();

            // disable blending
            glDisable(Gl.GL_BLEND);
            OGLTools.glDisable(Gl.GL_ALPHA);

            Gl.glPopMatrix(); // Need to optimize this like glPopMatrix(sessionID);
        }
Пример #2
0
        public static void DrawFilledRectangle(Color color, Position2D start, Dimension2D size)
        {
            OGLTools.glDisable(Gl.GL_TEXTURE_2D);
            OGLTools.glEnable(Gl.GL_ALPHA);
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 1f);

            Gl.glPushMatrix();
            Gl.glTranslated(start.X, start.Y, 0);

            float x1, y1;

            /*
             * Gl.glBegin(Gl.GL_QUADS);
             * Gl.glColor3f((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f);
             * Gl.glVertex2f(0f, 0f);
             * Gl.glVertex2f(0, size.Height);
             * Gl.glVertex2f(size.Width, size.Height);
             * Gl.glVertex2f(size.Width, 0);
             * Gl.glVertex2f(0f, 0f);
             * Gl.glEnd();
             */
            float[] Vertices = new float[] { 0, 0, 0, (float)size.Height, (float)size.Width, (float)size.Height, (float)size.Width, 0, 0, 0 };
            float[] Indices  = { 0, 1, 2, 3, 4 };



            //Load the arrays
            Gl.glColor3f((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f);
            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, Vertices);
            Gl.glDrawArrays(Gl.GL_QUADS, 0, Indices.Length);
            Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);

            // disable blending
            glDisable(Gl.GL_BLEND);
            OGLTools.glDisable(Gl.GL_ALPHA);



            Gl.glPopMatrix(); // Need to optimize this like glPopMatrix(sessionID);
        }