Example #1
0
        public void RenderEx(int index, int x, int y, byte r, byte g, byte b, byte a, Palette pal, bool flip, int xoffs)
        {
            if (index < 0 || index >= Frames.Count)
            {
                throw new FormatException("Frame index out of bounds.");
            }

            if (VBO == null)
            {
                VBO = new Rendering.VertexBuffer();
            }
            bool op = MainWindow.RenderPaletted;

            MainWindow.RenderPaletted = true;

            VBO.FixedReset();
            VBO.FixedColor4ub(r, g, b, a);
            float left  = flip ? 1f : 0f;
            float right = flip ? 0f : 1f;

            VBO.FixedTexCoord2f(left, 0f);
            VBO.FixedVertex2f(x + xoffs, y);
            VBO.FixedTexCoord2f(right, 0f);
            VBO.FixedVertex2f(x + xoffs + Frames[index].Width, y);
            VBO.FixedTexCoord2f(right, 1f);
            VBO.FixedVertex2f(x + Frames[index].Width, y + Frames[index].Height);
            VBO.FixedTexCoord2f(left, 1f);
            VBO.FixedVertex2f(x, y + Frames[index].Height);
            VBO.Update();

            GL.PushAttrib(AttribMask.TextureBit);
            try
            {
                GL.ActiveTexture(TextureUnit.Texture0);
                GL.BindTexture(TextureTarget.Texture2D, Frames[index].TextureID);
                GL.ActiveTexture(TextureUnit.Texture1);
                GL.BindTexture(TextureTarget.Texture2D, pal.TextureID);
                VBO.Draw(PrimitiveType.Quads);
            }
            finally
            {
                GL.PopAttrib();
            }

            MainWindow.RenderPaletted = op;
        }
Example #2
0
        public override void RenderColored(int index, int x, int y, byte r, byte g, byte b, byte a)
        {
            if (index < 0 || index >= Frames.Count)
            {
                throw new FormatException("Frame index out of bounds.");
            }

            if (VBO == null)
            {
                VBO = new Rendering.VertexBuffer();
            }
            bool op = MainWindow.RenderPaletted;

            MainWindow.RenderPaletted = false;

            VBO.FixedReset();
            VBO.FixedColor4ub(r, g, b, a);
            VBO.FixedTexCoord2f(0f, 0f);
            VBO.FixedVertex2f(x, y);
            VBO.FixedTexCoord2f(1f, 0f);
            VBO.FixedVertex2f(x + Frames[index].Width, y);
            VBO.FixedTexCoord2f(1f, 1f);
            VBO.FixedVertex2f(x + Frames[index].Width, y + Frames[index].Height);
            VBO.FixedTexCoord2f(0f, 1f);
            VBO.FixedVertex2f(x, y + Frames[index].Height);
            VBO.Update();

            GL.PushAttrib(AttribMask.TextureBit);
            try
            {
                GL.ActiveTexture(TextureUnit.Texture0);
                GL.BindTexture(TextureTarget.Texture2D, Frames[index].TextureID);
                GL.ActiveTexture(TextureUnit.Texture1);
                GL.BindTexture(TextureTarget.Texture2D, 0);
                VBO.Draw(PrimitiveType.Quads);
            }
            finally
            {
                GL.PopAttrib();
            }

            MainWindow.RenderPaletted = op;
        }
Example #3
0
        public void RenderEx(int x, int y, int inx, int iny, int inw, int inh, byte r, byte g, byte b, byte a)
        {
            if (VBO == null)
            {
                VBO = new Rendering.VertexBuffer();
            }
            bool op = MainWindow.RenderPaletted;

            MainWindow.RenderPaletted = false;

            float fStepX = 1f / Width;
            float fStepY = 1f / Height;

            VBO.FixedReset();
            VBO.FixedColor4ub(r, g, b, a);
            VBO.FixedTexCoord2f(fStepX * inx, fStepY * iny);
            VBO.FixedVertex2i(x, y);
            VBO.FixedTexCoord2f(fStepX * (inx + inw), fStepY * iny);
            VBO.FixedVertex2i(x + inw, y);
            VBO.FixedTexCoord2f(fStepX * (inx + inw), fStepY * (iny + inh));
            VBO.FixedVertex2i(x + inw, y + inh);
            VBO.FixedTexCoord2f(fStepX * inx, fStepY * (iny + inh));
            VBO.FixedVertex2i(x, y + inh);
            VBO.Update();

            GL.PushAttrib(AttribMask.TextureBit);
            try
            {
                GL.BindTexture(TextureTarget.Texture2D, TextureID);
                VBO.Draw(PrimitiveType.Quads);
            }
            finally
            {
                GL.PopAttrib();
            }

            MainWindow.RenderPaletted = op;
        }