S
Swyrl
Guest
Hey, so I've been grappling with something for a while now, and I can't quite seem to get it to function correctly-
My game has a resizable window, and essentially what I'm trying to do is detect when the window is resized (which I've done) and then resize the viewport to fill the window. I've tried several different techniques, but for the life of me I just can't get the viewport to change size. (the most recent thing I tried was calling it along with window_set_size(), but that didn't seem to do anything.)
One thing I tried before was resizing the application_surface, which sort of worked, but later on led to major issues with more complex cameras, and while I may be able to get it working with a lot of work, I'd rather not resort to something so hacky.
My current resizing code looks something like this-
and here's one of my other attempts-
Any tips? Is there something stupid I'm doing wrong?
My game has a resizable window, and essentially what I'm trying to do is detect when the window is resized (which I've done) and then resize the viewport to fill the window. I've tried several different techniques, but for the life of me I just can't get the viewport to change size. (the most recent thing I tried was calling it along with window_set_size(), but that didn't seem to do anything.)
One thing I tried before was resizing the application_surface, which sort of worked, but later on led to major issues with more complex cameras, and while I may be able to get it working with a lot of work, I'd rather not resort to something so hacky.
My current resizing code looks something like this-
Code:
win_wid=window_get_width();
win_hgt=window_get_height();
view_wport[0]=win_wid;
view_hport[0]=win_hgt;
aspect=room_width/room_height;
if aspect <= win_wid/win_hgt {
scale=win_wid/room_width;
//view_yport[0]=(win_hgt-(room_height*scale))/2;
camera_set_view_pos(simplecam,0,(win_hgt-(room_height*scale))/2);
} else {
scale=win_hgt/room_height;
//view_xport[0]=(win_wid-(room_width*scale))/2;
camera_set_view_pos(simplecam,(win_wid-(room_width*scale))/2,0);
}
camera_set_view_size(simplecam,room_width*scale,room_height*scale);
Code:
win_height=window_get_height();
win_width=window_get_width();
//camera_set_view_size(maincam,min(win_width,1920),win_height/win_width*min(win_width,1920));
//camera_set_view_size(maincam,min(win_width,1200),win_height/win_width*min(win_width,1200));
if win_height>0 and win_width>0{
scl=max(win_width,win_height)/640*zoom;
scl=min(scl,1.2);
if menu {
scl=max(win_width/room_width,win_height/room_height);
global.fscl=min(win_width/room_width,win_height/room_height);
if win_width/scl >= win_height/scl{
}
global.menu_xoff=((win_width-(global.fscl*room_width))/2);
global.menu_yoff=((win_height-(global.fscl*room_height))/2);
show_debug_message(global.fscl);
show_debug_message(scl);
}
v_wid=win_width/scl;
v_hgt=win_height/scl;
camera_set_view_size(maincam,v_wid,v_hgt);
surface_resize(application_surface,v_wid,v_hgt);
global.rsz=true;
}
Any tips? Is there something stupid I'm doing wrong?