From dbfe063aee4eadeb70d6c5dcfa0ea0f5c8f35920 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 19 Nov 2008 18:00:28 +0000 Subject: [PATCH] Prevent LoadGlyph from thrashing the PixelStore attribute. --- Source/Utilities/Fonts/TextureFont.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/Utilities/Fonts/TextureFont.cs b/Source/Utilities/Fonts/TextureFont.cs index 0e695320..6d30ce9f 100644 --- a/Source/Utilities/Fonts/TextureFont.cs +++ b/Source/Utilities/Fonts/TextureFont.cs @@ -418,12 +418,22 @@ using System.Text.RegularExpressions; BitmapData bitmap_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1.0f); - GL.PixelStore(PixelStoreParameter.UnpackRowLength, bmp.Width); - GL.TexSubImage2D(TextureTarget.Texture2D, 0, (int)rect.Left, (int)rect.Top, - rect.Width, rect.Height, - OpenTK.Graphics.PixelFormat.Rgba, - PixelType.UnsignedByte, bitmap_data.Scan0); + + GL.PushClientAttrib(ClientAttribMask.ClientPixelStoreBit); + try + { + GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1.0f); + GL.PixelStore(PixelStoreParameter.UnpackRowLength, bmp.Width); + GL.TexSubImage2D(TextureTarget.Texture2D, 0, (int)rect.Left, (int)rect.Top, + rect.Width, rect.Height, + OpenTK.Graphics.PixelFormat.Rgba, + PixelType.UnsignedByte, bitmap_data.Scan0); + } + finally + { + GL.PopClientAttrib(); + } + bmp.UnlockBits(bitmap_data); rectangle = RectangleF.FromLTRB(