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

Application Surface

T2008

Member
I am using Dynamic Lighting System from Grizzlius Maxiums' tutorial. In the Post Draw Event, I have to draw the application surface. The problem is that it creates black bars at the top and bottom of the screen. Is there anyway of fixing this? I can increase the size to 1.78,1.78, (instead of 1.6,1.6 see below) in the below code to eliminate the bars, but then part of my view is off the screen. This is a huge problem because I don't want to have to redo all of my rooms. My room size is 1920x1080; and view is 960x540. I've been working on my game for over 5 years now and this is causing a big headache. Any help would be greatly appreciated!!!

Code:
draw_surface_ext(application_surface,0,0,1.6,1.6,0,c_white,1);
 

NightFrost

Member
Something sounds a bit wonky. I assume your application_surface_draw_enable() is set to false so you're not competing with the system on what gets drawn. When you draw in Post Draw, the default target is the back buffer, and the 0,0 position is the top left corner of window if in windowed mode, of display if in fullscreen mode. If the draw isn't hitting the corner, I can only think of port size being adjusted, which usually isn't necessary. You also mention your room size but that bears no relevance here, and you do not mention the size of your target, which is essential here. You use a scaling of 1.6 there which means you've set your goal to be 960*540 times 1.6 or 1536*864. Does this match what you're seeing?
 

T2008

Member
Thanks for the responses! Yes, I have application surface draw enable set to false. In the draw event I have the below code; shad surf is 1920x1080. Vx and Vy are 0,0.
I'll try your idea sp202, but I prefer not having a stretched look. This is a very frustrating problem. Does the below code help? (i've included short version and longer version)

Edit: I watched Pixelated Pope's tutorial and added his code and now all I get is a black screen. I've added the pixelated pope code below. Also forgot to mention that I have the game in fullscreen mode.

Code:
draw_surface_ext(shad_surf,vx,vy,1,1,0,c_white,0.95);
The full code in Draw Event :
Code:
//Local variables setup
var _u_pos = u_pos;
var _u_zz = u_zz;
var _u_str = u_str;
var _u_pos2 = u_pos2;
var _vb = vb;
var _vx = vx;
var _vy = vy;

//Shadow surface setup
if (!surface_exists(shad_surf)){
    //shad_surf = surface_create(320,180); //tutorial
    shad_surf = surface_create(1920,1080);
}

matrix_set(matrix_world,matrix_build(-vx,-vy,0,0,0,0,1,1,1));
surface_set_target(shad_surf);
draw_clear_alpha(c_black,0);
//Light Lantern
with(obj_light_lantern) {
    //Draw the shadows (AKA light blockers)
    gpu_set_blendmode_ext_sepalpha(bm_zero,bm_one,bm_one,bm_zero);
    shader_set(shd_shadow);
    shader_set_uniform_f(_u_pos2,x,y);
    vertex_submit(_vb,pr_trianglelist,-1);
    //Draw the Light
    gpu_set_blendmode_ext_sepalpha(bm_inv_dest_alpha,bm_one,bm_zero,bm_zero);
    shader_set(shd_light);
    shader_set_uniform_f(_u_pos,x,y);
    shader_set_uniform_f(_u_zz,size);
    shader_set_uniform_f(_u_str,str);
    //draw_rectangle_color(_vx,_vy,_vx+320,_vy+180,color,color,color,color,0); //canvas for drawing the light
    draw_rectangle_color(_vx,_vy,_vx+1920,_vy+1080,color,color,color,color,0); //canvas for drawing the light
}
//Light
with(obj_light){
    //Draw the shadows (AKA light blockers)
    gpu_set_blendmode_ext_sepalpha(bm_zero,bm_one,bm_one,bm_zero);
    shader_set(shd_shadow);
    shader_set_uniform_f(_u_pos2,x,y);
    vertex_submit(_vb,pr_trianglelist,-1);
    //Draw the Light
    gpu_set_blendmode_ext_sepalpha(bm_inv_dest_alpha,bm_one,bm_zero,bm_zero);
    shader_set(shd_light);
    shader_set_uniform_f(_u_pos,x,y);
    shader_set_uniform_f(_u_zz,size);
    shader_set_uniform_f(_u_str,str);
    //draw_rectangle_color(_vx,_vy,_vx+320,_vy+180,color,color,color,color,0); //canvas for drawing the light
    draw_rectangle_color(_vx,_vy,_vx+1920,_vy+1080,color,color,color,color,0); //canvas for drawing the light
}

//Light Small flicker
with(obj_light_sm_flkcr){
  
    //Draw the shadows (AKA light blockers)
    gpu_set_blendmode_ext_sepalpha(bm_zero,bm_one,bm_one,bm_zero);
    shader_set(shd_shadow);
    shader_set_uniform_f(_u_pos2,x,y);
    vertex_submit(_vb,pr_trianglelist,-1);
  
    //Draw the Light
    gpu_set_blendmode_ext_sepalpha(bm_inv_dest_alpha,bm_one,bm_zero,bm_zero);
    shader_set(shd_light);
    shader_set_uniform_f(_u_pos,x,y);
    shader_set_uniform_f(_u_zz,size);
    shader_set_uniform_f(_u_str,str);
    //draw_rectangle_color(_vx,_vy,_vx+320,_vy+180,color,color,color,color,0); //canvas for drawing the light
    draw_rectangle_color(_vx,_vy,_vx+1920,_vy+1080,color,color,color,color,0); //canvas for drawing the light
}

//Light Small NS (No Shadow, White)
with(obj_light_sm_ns){
    //Draw the Light
    gpu_set_blendmode_ext_sepalpha(bm_inv_dest_alpha,bm_one,bm_zero,bm_zero);
    shader_set(shd_light);
    shader_set_uniform_f(_u_pos,x,y);
    shader_set_uniform_f(_u_zz,size);
    shader_set_uniform_f(_u_str,str);
    //draw_rectangle_color(_vx,_vy,_vx+320,_vy+180,color,color,color,color,0); //canvas for drawing the light
    draw_rectangle_color(_vx,_vy,_vx+1920,_vy+1080,color,color,color,color,0); //canvas for drawing the light
}

surface_reset_target();
matrix_set(matrix_world,matrix_build(0,0,0,0,0,0,1,1,1));


//Draw and blend the shadow surface to the application surface
gpu_set_blendmode_ext(bm_zero,bm_src_color);
shader_set(shd_shadsurf);
if (room = rm_room_test3) || (room = rm_room_test_light)
//VIS1
|| (room = rm_vis1_rm2)
//LAB1
|| (room = rm_lab1_rm1) || (room = rm_lab1_rm2) || (room = rm_lab1_rm3) || (room = rm_lab1_rm4)
//LAB3
|| (room = rm_lab3_rm4) || (room = rm_lab3_rm5)
{
draw_surface_ext(shad_surf,vx,vy,1,1,0,c_white,0.95);//.8
} else {
draw_surface_ext(shad_surf,vx,vy,1,1,0,c_white,0.05);//.8
}

//reset shader and blendmode
shader_reset();
gpu_set_blendmode(bm_normal);
CREATE EVENT PIXEALTED POPE CODE:
Code:
//Pixelated Pope's Aspect Ratio Tutorial
//Display Properties
ideal_width = 0;
ideal_height = 1080;
//zoom = 1;
//max_zoom = 1;
aspect_ratio = display_get_width()/display_get_height();
ideal_width = round(ideal_height*aspect_ratio);
//ideal_height = round(ideal_width/aspect_ratio); //if want to scale height

//Perfect Pixel Scaling
if (display_get_width() mod ideal_width !=0) {
    var d = round(display_get_width()/ideal_width);   
    ideal_width = display_get_width()/d;
}
if (display_get_height() mod ideal_height !=0) {
    var d = round(display_get_height()/ideal_width);   
    ideal_width = display_get_height()/d;
}

//Check For Odd Numbers
if (ideal_width & 1)
    ideal_width++;
if (ideal_height & 1) //when add perfect pixel scaling
    ideal_height++;
   
//Calculate Max Zoom
//max_zoom = floor(display_get_width()/ideal_width);

for(var i=0; i<=room_last; i++) { //started with 1 and not 0 because tutorial had very small display room with view object in it
    if room_exists(i)
        //room_set_view(i,0,true,0,0,ideal_width,ideal_height,0,0,ideal_width,ideal_height,0,0,0,0,-1);
        room_set_viewport(i,0,true,ideal_width,ideal_height,ideal_width,ideal_height);
        room_set_view_enabled(i,true);

}

surface_resize(application_surface,ideal_width,ideal_height);
display_set_gui_size(ideal_width,ideal_height);
//window_set_size(ideal_width,ideal_height);

room_goto(room_next(room));

//Center Window Alarm
alarm[0] = 1;
END STEP EVENT:
Code:
#macro view view_camera[0]

camera_set_view_size(view,view_width,view_height);

if (instance_exists(obj_player)) {
    var _x = clamp(obj_player.x - view_width/2,0,room_width-view_width);
    var _y = clamp(obj_player.y - view_height/2,0,room_height-view_height);
   
    var _cur_x = camera_get_view_x(view);
    var _cur_y = camera_get_view_y(view);
   
    var _spd = .05; //higher means faster following
   
    camera_set_view_pos(view,
                        lerp(_cur_x,_x,_spd),
                        lerp(_cur_y,_y,_spd));
   
}
 
Last edited:

T2008

Member
Anyone have any ideas? It seems that the resized surface in the create event is about 100 pixels off from the application surface in the post draw event.
When I use below in the post draw event, it works, but the graphics look stretched which really bothers me. This is so frustrating. I don't want to have to either stretch or try to redo all my numerous rooms.

Code:
draw_surface_stretched_ext(application_surface,0,0,display_get_width(),display_get_height(),c_white,1);
 

T2008

Member
So, I figured out that my computer screen has an aspect ratio of 16:10. After tinkering around, I got it to a halfway decent look. However, my textbox now looks distorted. Any ideas as to how I can change my textbox code to look right when aspect ratio is fixed. The relevant code is below. My textbox was originally designed for 1920x1080. When I change the ideal height to be 1600 in setup, textbox gets distorted. Any ideas as to how to fix this?

Textbox code:
CREATE EVENT:
Code:
//Sprite Variables
box = spr_text_box;
portrait = spr_portraits_other;
//Get Sprite Dimensions for Coordinates
box_width = sprite_get_width(box);
box_height = sprite_get_height(box);
port_width = sprite_get_width(portrait);
port_height = sprite_get_height(portrait);
//Coordinates for Portrait and Textbox
port_x = 287;   
port_y = 422;     
box_x = 273; 
box_y = 408; 
//Buffer Coordinates
x_buffer = 78;  
y_buffer = 13;  
text_x = box_x + x_buffer;  
text_y = box_y + y_buffer;  
//Textbox Control
counter = 0;
pause = false;
//Color and Type of Font
text_col = c_white;
font = fn_mordred_11;
//Set Font 
draw_set_font(font)
//Define Text Dimensions
text_height = string_height("M");
text_max_width = 322;  
//Scroll Text/Pages
interact_key = vk_space;
DRAW GUI EVENT:
Code:
//Draw Box
draw_sprite(box, 0, box_x, box_y);
//Draw Portrait
draw_sprite(portrait, portrait_index, port_x, port_y);
//Set Font
draw_set_font(font);
//Draw Text 
if(!pause and counter < str_len){
    //Text Speed
    counter++; //can change to do more than one letter at a time
    //Play NPC Similsh Every 10 Frames
    if((counter mod 10 == 0) and (!audio_is_playing(simlish1))  
    and (!audio_is_playing(simlish2)) and (!audio_is_playing(simlish3))
    and (!audio_is_playing(simlish4)) and (!audio_is_playing(simlish5)))
    {
        audio_play_sound(choose(simlish1,simlish2,simlish3,simlish4,simlish5), 10, false);
    }
    //Play Text Voice Every 4 Frames
    if(counter mod 4 == 0) {
        audio_play_sound(text_voice, 10, false);
    }
    //Set Up Pause for Certain Characters 
    switch(string_char_at(text_wrapped, counter)){
        case ",": pause = true;  alarm[1] = 15; break;
        case ".":
        case "?":
        case "!": pause = true; alarm[1] = 25; break; //. ? ! all same so don't need break 
    }    
}
var substr = string_copy(text_wrapped, 1, counter);

c = text_col;
draw_text_color(text_x, text_y, substr, c,c,c,c, 1);
 
Top