M
mdbussen
Guest
I am experiencing a kind of strange issue on my current project. Whenever I switch to fullscreen mode (using the 'window_set_fullscreen' function), I experiencing consistent screen tearing. This only happens in fullscreen mode; in windowed mode everything works fine with no tearing, regardless of the size of the window. I suspect this is some kind of aliasing problem, because I am still up over 1000+ FPS in the debug overlay. Also, checking the "use synchronization to avoid tearing" checkbox does not fix the screen tearing I am seeing in fullscreen mode.
My game doesn't do any upscaling or downscaling of the graphics so it should be fairly simple. Whatever the window resolution is, the view port and camera resolution ends up set to the same thing. My laptop monitor is 1600 x 900.
All of the code pertaining to the display window and camera lives in an "obj_camera" object.
obj_camera CREATE event:
obj_camera STEP event:
obj_camera END STEP event:
window_fullscreen_update script:
window_size_update script:
camera_reset script:
I suspect the problem *might* be with this last script. I had run into problems when switching between rooms with my camera not updating the room viewport correctly which is where this 'camera_reset' script came from; I'm probably doing some overkill stuff in here but I was kind of pounding on it for a while until I figured out I had to resize the application surface.
Thanks in advance for any help you can give!
My game doesn't do any upscaling or downscaling of the graphics so it should be fairly simple. Whatever the window resolution is, the view port and camera resolution ends up set to the same thing. My laptop monitor is 1600 x 900.
All of the code pertaining to the display window and camera lives in an "obj_camera" object.
obj_camera CREATE event:
Code:
/// @description Initializes the camera system
// NOTE: This code will break if the display is less than 720p resolution.
//--------------------------------//
// CONSTANTS
//--------------------------------//
#macro WINDOW_MINIMUM_WIDTH 1280
#macro WINDOW_MINIMUM_HEIGHT 720
#macro WINDOW_CAPTION "Child of Darkness"
//--------------------------------//
// MEMBER VARIABLES
//--------------------------------//
// window width and height is tracked to detect when a
// window is resized and respond appropriately.
// These are global because the GUI needs to reference them
global.window_width = WINDOW_MINIMUM_WIDTH;
global.window_height = WINDOW_MINIMUM_HEIGHT;
// camera x and y position tells where the camera is focused
camera_x = 0;
camera_y = 0;
// set to an object ID to track that object with the camera
camera_object = NULL;
//--------------------------------//
// CODE
//--------------------------------//
//=== First, define the window size and position
// set to default size
window_set_size(global.window_width, global.window_height);
// center the window
var width = display_get_width();
var height = display_get_height();
var x_pos = (width - WINDOW_MINIMUM_WIDTH) div 2;
var y_pos = (height - WINDOW_MINIMUM_HEIGHT) div 2;
window_set_position(x_pos, y_pos);
// set the window caption appropriately
window_set_caption(WINDOW_CAPTION);
//=== Next, define the camera view
view_camera[0] = camera_create_view(camera_x, camera_y, global.window_width, global.window_height, 0, NULL, 0, 0, 0, 0);
camera_set_view_size(view_camera[0], global.window_width, global.window_height);
view_set_camera(0, view_camera[0]);
Code:
/// @description Should be called in the step event to update the camera
// Check if the user wants to switch to fullscreen mode
window_fullscreen_update();
// update the window if the window has been resized
window_size_update();
Code:
// track the camera object if the camera is in tracking mode
if (camera_object != NULL)
camera_set_position(camera_object.x, camera_object.y);
// update the camera view
camera_set_view_pos(view_camera[0], camera_x - global.window_width div 2, camera_y - global.window_height div 2);
Code:
/// @description Checks if the user wants to toggle fullscreen mode
if (global.ctl_fullscreen){
var current_fullscreen_mode = window_get_fullscreen();
window_set_fullscreen(!current_fullscreen_mode);
// we will update the window dimensions and resolution in a later call so we can exit from the script now
}
Code:
/// @description Should be called in the step function to watch for window resizing
if (window_get_width() != global.window_width) or (window_get_height() != global.window_height){
// don't let the window get smaller than the minimum size
if (window_get_width() < WINDOW_MINIMUM_WIDTH){
global.window_height = window_get_height();
window_set_size(WINDOW_MINIMUM_WIDTH, global.window_height);
alarm[0] = 1; // set to center window on next frame
}
if (window_get_height() < WINDOW_MINIMUM_HEIGHT){
global.window_width = window_get_width();
window_set_size(global.window_height, WINDOW_MINIMUM_HEIGHT);
alarm[0] = 1; // set to center window on next frame
}
// update the stored window sizes
global.window_width = window_get_width();
global.window_height = window_get_height();
// update the camera settings
camera_reset();
// dump the new window settings
camera_debug();
}
Code:
/// @description Call this to reset the camera for a new room or window size
view_visible[0] = true;
view_enabled = true;
view_wport[0] = global.window_width;
view_hport[0] = global.window_height;
view_set_camera(0, view_camera[0]);
camera_set_view_size(view_camera[0], global.window_width, global.window_height);
surface_resize(application_surface,global.window_width,global.window_height);
Thanks in advance for any help you can give!