PDA

View Full Version : Textout without text background



Diaboli
30-12-2006, 03:07 PM
I'm trying to make a text input (for username and password) in my game, and used TextOut to draw the text in a variable to the screen, over the area where the "input" is. The problem is that the text has a background, and isnt transparent. is there any way of removing the background from TextOut? like when you set transparent to true on labels?

JSoftware
30-12-2006, 03:23 PM
I think you need to set the brush to clNone or something like that. In gdi i think there is a brush called HBR_TRANSPARENT

Diaboli
30-12-2006, 03:50 PM
thx! it was the brush style. had to set it to bsClear.

WILL
30-12-2006, 09:17 PM
My answer would have also been just to set Brush.Color to bsClear. :thumbup:

Funny thing is that this is the same for the VCL's TCanvas it's self and rather a reuse of the functionality existing there rather than being specific to DelphiX's usage.

Now if only I could remember if it was the original TCanvas they use or a completely remade one... :think:

Diaboli
01-01-2007, 01:30 PM
only problem is that i have to do the TDirectDraw.FLip BEFORE the TextOut... if i dont draw the text to a image, and the load that image into a TDirectDrawSurface and the draw that surface onto the TdirectDraw.Surface...

any suggestions on how to do this better? a font-engine or something?

WILL
01-01-2007, 07:31 PM
Actually as I recall, DelphiX requires you to Release your surface after using the canvas to continue drawing to it. If you don't release it it will not draw anything else beyond what you whee just previously doing with the canvas. his includes TextOut();.

There should only every be 1 Flip();

Diaboli
01-01-2007, 10:59 PM
yeah, i know, but somehow, the text doesent show up even though i use "TheDraw.Surface.Canvas.Release" after the textout...


procedure DoLogin;
begin
fMain.TheDraw.Surface.Draw(0,0,LoginBG.ClientRect, LoginBG,False);
fMain.TheDraw.Surface.Draw(434,338,LoginFields.Cli entRect,LoginFields,True);
fMain.TheDraw.Surface.Canvas.Brush.Style:= bsClear;
fMain.TheDraw.Surface.Canvas.Font.Size:= 12;
fMain.TheDraw.Surface.Canvas.Font.Color:= clBlack;
fMain.TheDraw.Surface.Canvas.TextOut(440,361,Login Name);
fMain.TheDraw.Surface.Canvas.TextOut(440,406,Login Pass);
fMain.TheDraw.Surface.Canvas.Release;
end;

(i know i should use "with fmain.Thedraw do", but i just want it to work first :P)
the flip comes after this on the end of the Processgamestate procedure...

czar
02-01-2007, 12:49 AM
Try a release just before - maybe you are using a lineto or some other command that locks the surface.

Diaboli
02-01-2007, 01:42 AM
i have tried both releasing the canvas and unlocking the surface...

EDIT: Found a solution: setting Do3D to False!