• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Text Defects when preDrawn to a Surface

G

Getron

Guest
Hi All,

Just a question regarding Surfaces and Text.

I have notice that when I have drawn text to a Surface, it begins to distort and not present as crisp as when you draw text directly to screen. You will notice, in the example picture below, with the text: "Barter" that the edges are green and unclean. Also when I display my Mouse-over on text: "Commit", you can clearly see very unclean / blocky.

Code Used:
box = surface_create(boxWidth, boxHeight);

surface_set_target(box);
draw_clear_alpha(0, 0);
draw_set_alpha(1);
draw_set_halign(fa_center);
draw_set_valign(fa_top);
draw_set_colour(c_black);
draw_rectangle( 0, 0, boxWidth, boxHeight, false);
draw_set_colour( c_gray);
draw_rectangle( 2, 2, boxWidth-3, boxHeight-3, false);
draw_set_colour( c_black);
draw_line(0, topLineY , boxWidth, topLineY);
draw_line(boxWHalf, topLineY, boxWHalf, botLineY1);
draw_line(0, topLineY * 2, boxWidth, topLineY * 2);
draw_line(0, botLineY1, boxWidth, botLineY1);
draw_line(0, botLineY2, boxWidth, botLineY2);
draw_text(boxWHalf+2, titleY+2, Title);
draw_text(boxWQurt+2, comtCanlY+2, canTxt);
draw_text(boxW3Qurt+2, comtCanlY+2, comTxt);
draw_set_colour( c_white);
draw_text(boxWHalf, titleY, Title);
draw_text(boxWQurt, comtCanlY, canTxt);
draw_text(boxW3Qurt, comtCanlY, comTxt);
surface_reset_target();
break;

Any words of wisdom would very appreciated.


Thanks

Garth


eg.png
 
I

icuurd12b42

Guest
turn off interpolation before drawing the text with texture_set_interpolation or draw the final text multiple times. or possible an easier solution simply draw your black and yellow text with bm_add.

the fuzz is from the outline of the text, the antialiasing when you created the font. that has transparent pixels on the edges. that transparently is transferred to the surface, punching tiny transparent holes in it. so when you draw the surface you get the gray from the background mixed with the surface image.

if you draw your text with bm_add the text outline will not mix with the surface.
 
G

Getron

Guest
Hey icuurd12b42,

Thanks for the reply and the explanation on a few things..

I played a bit with the bm_add and it didn't fix the issue i was having although when I used it on "Black" shadow text and White Text, it makes all text white.

I did try the turning off interpolation and that cleaned the white edges up.

To explain a little further, when the mouse was over "Commit", i was then displaying another Surface(Just yellow "COMMIT") on top of the Barter window..

I messed around with the draw_blend_mode_ext to explore the function some.. in the end i just ended up using 1 surface and redrawing it when mouse went over Commit or Cancel.. actually ran faster doing it that way than using 2 extra surfaces for Commit and Cancel.


Any thoughts on the above would be appreciated.

Thanks again


Garth
 
I

icuurd12b42

Guest
the bm add should have worked... bm add on black always results in the color you specified and always results in the alpha channel being added to and not mixed with the surface alpha channel. the result should have been identical as though you would have draw with bm normal on the screen. you did reset the blend mode to normal before drawing the surface right?

If you found another faster solution then it's all good right?
 
G

Getron

Guest
yeah right.. well no matter how many different times I tried it, didn't result change a thing except the above mentioned.. and yes i did reset blend mode to normal..
would the fact i am drawing to a "transparent" surface have anything to do with it or the Colour I clear the surface with?

I would like to understand what is happening with all this, as i have another instance where i use a surface to draw text on screen and it just doesn't look great at all.. even using your suggestion with bm_add..

I have even draw black text first at the same x/y position as where the yellow will be to no success..

In regards to font setup... are there any preferred recommended setting's you'd suggest, as I have currently no anti-aliasing, high quality on, bold on using just Ariel font pack.

here is the code i am using:
------------------------------------------------------------------------------------------------------------
shtSurf = surface_create(string_width(shout)+3, string_height(shout)+3);
surface_set_target(shtSurf);
draw_clear_alpha(c_black, 0);
draw_set_colour(c_black);
draw_set_alpha(1);
draw_set_blend_mode(bm_add);
draw_text(0, 0, shout);
draw_text(1, 1, shout);
draw_text(3, 3, shout);
draw_set_colour(c_yellow);
draw_text(1, 1, shout);
surface_reset_target();
draw_set_blend_mode(bm_normal);

------------------------------------------------------------------------------------------


The example below shows:
TopLine = straight draw_text
BottomLine = draw_surface using above code

eg.png
 
I

icuurd12b42

Guest
It makes no sense to me... I send the like to the topic to a guy I know. maybe he can shed some light
 

xot

GMLscripter
GMC Elder
This is probably a result of the way alpha works on surfaces. I don't have time to look into it any further today but you might glean some insight from the topic linked below. Problems like this can be solved with a two-pass surface rendering technique, a shader, or possibly a pre-multiplied sprite font.

http://gmc.yoyogames.com/index.php?showtopic=474273
 
Top