Refresh text continuously

This commit is contained in:
Stefanos A 2013-12-23 22:00:10 +01:00 committed by thefiddler
parent dd648a8362
commit ea3c9ffe85

View file

@ -25,9 +25,8 @@ namespace Examples.Tests
int texture; int texture;
bool mouse_in_window = false; bool mouse_in_window = false;
bool viewport_changed = true; bool viewport_changed = true;
bool refresh_text = true; MouseState mouse;
MouseState mouse, mouse_old; KeyboardState keyboard;
KeyboardState keyboard, keyboard_old;
public GameWindowStates() public GameWindowStates()
: base(800, 600, GraphicsMode.Default) : base(800, 600, GraphicsMode.Default)
@ -197,22 +196,11 @@ namespace Examples.Tests
} }
protected override void OnUpdateFrame(FrameEventArgs e) protected override void OnUpdateFrame(FrameEventArgs e)
{; {
InputDriver.Poll(); InputDriver.Poll();
mouse = OpenTK.Input.Mouse.GetState(); mouse = OpenTK.Input.Mouse.GetState();
if (mouse != mouse_old)
refresh_text = true;
mouse_old = mouse;
keyboard = OpenTK.Input.Keyboard.GetState(); keyboard = OpenTK.Input.Keyboard.GetState();
if (keyboard != keyboard_old)
refresh_text = true;
keyboard_old = keyboard;
if (refresh_text)
{
refresh_text = false;
using (Graphics gfx = Graphics.FromImage(TextBitmap)) using (Graphics gfx = Graphics.FromImage(TextBitmap))
{ {
@ -243,7 +231,6 @@ namespace Examples.Tests
line = DrawJoysticks(gfx, Joysticks, line++); line = DrawJoysticks(gfx, Joysticks, line++);
line = DrawGamePads(gfx, line++); line = DrawGamePads(gfx, line++);
} }
}
System.Drawing.Imaging.BitmapData data = TextBitmap.LockBits( System.Drawing.Imaging.BitmapData data = TextBitmap.LockBits(
new System.Drawing.Rectangle(0, 0, TextBitmap.Width, TextBitmap.Height), new System.Drawing.Rectangle(0, 0, TextBitmap.Width, TextBitmap.Height),