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; }
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; }