• 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!

GameMaker [SOLVED] Drawing on surface will make wrong text.

Flaick

Member
Hi guys, i'm trying to optimize my code in draw events. I've start to use surfaces. But i have a strange issue, the text will appear bad when drawing onto surface. But if i copy from applicaiton_surface is perfect. So i presume there is some setting into application_surface that i have to propagate to my custom surface. Here the code:

Create:
Code:
txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris gravida nunc sed justo malesuada molestie.";
surf = -1;
Draw:
Code:
if !surface_exists(surf){
    surf = surface_create(surface_get_width(application_surface),surface_get_height(application_surface));
    
    //Uncomment this it works!
    //surface_copy(surf,0,0,application_surface);
    
    surface_set_target(surf);
    draw_set_font(-1);
    draw_text_ext(10,10,txt,12,400);
    surface_reset_target();
}
//Text on surface
draw_surface(surf,0,0);

//Original text
draw_text_ext(10,400,txt,12,400);
And here the screen:
 
I'm pretty sure this problem can be resolved in one of two ways.

If your surface has a background (such as the color black), then disable writing to the alpha channel while drawing your text to the surface.

If your surface has a transparent background, then you will need to use pre-multiplied alpha.
 

Flaick

Member
Thanks! Adding this code it works:

Code:
//Text on surface
gpu_set_blendenable(false);
draw_surface(surf,0,0);
gpu_set_blendenable(true);
 
Top