By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Flickering.

P: 20
Hi guys, im using DrawString to write some text over a game's screen. The problem is because im having to run it on a timer, realtime (to keep the text on the game screen or will will dissapear) its causing the written text to flicker. iv done some googling about something for forms called backbuffer, but iv enabled that for my forms but it seems to be only for Forms. Also one of my text boxes gets updated and that flickers too.

Wondering if someone knows a simple solution. Maybe a way to freeze the text on the screen and only change it when the value updates?

Thanks

Here's my Drawstring code

Expand|Select|Wrap|Line Numbers
  1.         private void timer2_Tick(object sender, EventArgs e)
  2.         {
  3.             string kills = txtBoxkills.Text
  4.             IntPtr hWnd = WinApi.FindWindowA("WindowName", null);
  5.             IntPtr hDC = WinApi.GetDC(hWnd);
  6.             Graphics memDC = Graphics.FromHdc(hDC);
  7.             memDC.DrawString(kills, new Font("Arial", 15, FontStyle.Bold), Brushes.Blue, new PointF(10, 100));
  8.             WinApi.ReleaseDC(hWnd, hDC);
  9.         }
Mar 5 '09 #1
Share this Question
Share on Google+
2 Replies


tlhintoq
Expert 2.5K+
P: 3,525
I think the problem is the overall design. For a game putting standard controls like textboxes on top of the graphics is always going to do this.

Might want to look at DirectX for this.

Or look at the design of this. I have no idea how you are producing the "game screen". Is it a picture box with a bunch of text boxes on top for example?

Maybe the solution is to build the game screen in memory, draw all the text data on the image, then draw that entire composited image to the screen for the user - doing it all in rapid succession.
Mar 5 '09 #2

P: 20
the game is Call of duty "directx game" but i figured this might have an issue with it due to the framerate or whatever. i did think directx was the answer, guess il have to learn directX then! :D

Thanks
Mar 5 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.