Jump to content
Sign in to follow this  
Dest

Turning a partial solution into a complete one

Recommended Posts

Dest

So someone asked how to draw text in games. Larry posted something which I have modified here:

$x = 100
$y = 100
$text = "Testing this Shiite"

Global Const $TRANSPARENT         = 1
Global Const $OPAQUE              = 2

While 1
TextOut($x,$y,$text)
WEnd

Func TextOut($x,$y,$text)
    $hdc = DllCall("user32.dll","int","GetDC","hwnd",0)
    $hdc = $hdc[0]
    _SetBkMode( $hdc, $TRANSPARENT )
    DllCall("gdi32.dll","int","TextOut","int",$hdc,"int",$x,"int",$y,"str",$text,"int",StringLen($text))
    DllCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$hdc)
EndFunc



Func _SetBkMode( $hdc, $mode, $dll_h = "Gdi32.dll")
;~     http://msdn.microsoft.com/library/en-us/gdi/pantdraw_47hh.asp
    Local $return = DllCall( $dll_h, "int", "SetBkMode", "ptr", $hdc, "int", $mode)
    Return $return[0]
EndFunc

This partially works as it does draw text on top of the game (fullscreen, uses direct3d)

However, the text blinks rapidly making it very annoying. Is there any way to fix this?

Share this post


Link to post
Share on other sites
Dest

That works in a non-game environment such as the desktop. However I am trying to draw to a game and if I call it once, it goes away in about 1/2 a second due to the game's direct3d updating.

So is there any way to prevent the text from flickering or being interfered with by the game's direct3d updating?

Edited by Dest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.