delphi - Drawing over Directdraw window -


ive been working on project fix old game , came accross new ideas it, adding cool information game world , real-time tracking of important information game hides user (for no actual reason) , came across problem:

when try draw on game, show information wanted to, game updates own windows , draws over.

my first approach use window hwnd_topmost on top of game's window, doesnt work expected, window wont on game window , wont show information.

the second approach use gdi functions such textout, text there flicker lot , forcing draw in short ammount of time use memory.

i wanted ideas on how without hooking dx functions nor (since know few of dx). there way draw on window show information without flickering?

you can use undelphix delphi package directx.
can download package here: http://www.micrel.cz/dx/

it date , makes directx work standard gdi.

drawing without flicker
trick eliminating flicker draw off-screen surface , "flip" offscreen surface in view when you're done.
flip can synchronized verticalsync, there's no tearing well.

demo
there's demo displays current time in milliseconds without blinking.

unit main;  interface  uses   windows, messages, sysutils, classes, graphics, controls, forms, dialogs,   stdctrls, extctrls, menus, dxclass, dxdraws;  type   tmainform = class(tdxform)     dxdraw: tdxdraw;     dxtimer: tdxtimer;  //precision timer.      procedure dxdrawfinalize(sender: tobject);     procedure dxdrawinitialize(sender: tobject);     procedure dxtimertimer(sender: tobject; lagcount: integer);   end;  var   mainform: tmainform;  implementation  uses mmsystem;  {$r *.dfm}  procedure tmainform.dxdrawinitialize(sender: tobject); begin   dxtimer.enabled := true; end;  procedure tmainform.dxdrawfinalize(sender: tobject); begin   dxtimer.enabled := false; end;  procedure tmainform.dxtimertimer(sender: tobject; lagcount: integer); var   formatteddatetime: string; begin   if not dxdraw.candraw exit;    dxdraw.surface.fill(0);    dxdraw.surface.canvas  //draw offscreen surface.   begin     brush.style := bsclear;     font.color := clwhite;     font.size := 30;     datetimetostring(formatteddatetime, 'hh:nn:ss.zzz', now);     textout(30, 30, formatteddatetime);      release; {  indispensability  }   end;    dxdraw.flip;  //flip offscreen surface screen, no flicker :=) end;  end. 

installing undelphix in xe2
in order package installed in delphi xe2 had add designide requires clause of dpk. so:

enter image description here

this fix designintf.dcu not found error.

displaying full screen
if want fullscreen enable in settings of dxdraw, note:

enter image description here

if enable dofullscreen without enabling doselectdriver you'll interface not supported error. enable them both , fine.
see: http://www.micrel.cz/dx/history.rtf

don't forget listen keypresses , exit app on esc or something, or you'll stuck in full screen mode.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -