Why aren't my viewports working?

S

Smooth Operator

Guest
First of all, this is my first post here, so I apologize if I've posted in the wrong board or in the wrong way.

I'm pretty new to GML, though I've got some experience in C++, and I'm finding it frustrating trying to find where I'm going wrong.

If I start with views enabled, and have all my settings for the room where I want them, the window stretches to the appropriate proportions, uses all the correct settings, and is somewhat manipulable when it comes to the view_xview or view_yview settings, but no matter what I try, if I attempt to use code to configure the settings instead, the view in the room is scaled from the proportions of the room's actual size, rather than the settings I put for the view. So in this case, I've got a room that's 1024 x 768, and ALL of my view settings, within the room editor or not, are multiples of 320, but the window still scales to 1024 x 768 proportions. I've scoured pretty much every setting I can find and can't figure it out. I have a single object governing my camera, named objCamera. At some point I just started trying to control everything in its Create (and even Step) Events, but nothing seems to work.



Code:
if (instance_exists(objPlayer))
    view_object[view_current]=objPlayer;

view_hborder[view_current]=320;
view_vborder[view_current]=320;
view_hspeed[view_current]=-1;
view_vspeed[view_current]=-1;

view_wview[view_current]=320;
view_hview[view_current]=320;

view_wport[view_current]=view_wview[view_current]*2;
view_hport[view_current]=view_hview[view_current]*2;

view_xport[view_current]=0;
view_yport[view_current]=0;

view_enabled=true;
view_visible[view_current]=true;

window_set_size(view_wport[view_current],view_hport[view_current]);



What's worse, I can see a brief moment just after the screen loads where the proportions are correctly 640 x 640, but then it snaps back to these proportions.

Any help would be much appreciated, thanks.
 

TehCupcakes

Member
You've overlooked one really simple but important option... At the top of the view tab is a checkbox, "Enable the use of Views". That needs to be on. :) You don't need a script to manage the view unless you intend to change it mid-game.
 
S

Smooth Operator

Guest
I used scripts to enable views near the end of the code after all the settings were in place. I believe the screen would just be totally dark if there wasn't a view enabled, as I've tested before. I've tried it both ways, and neither one fixes this particular issue.
 
S

Squidel

Guest
interesting, do you have your target platform global game settings on keep aspect ratio?. i believe that could cause it.
 
Last edited by a moderator:
S

Smooth Operator

Guest
Ahh, thanks, that did it. After turning it off it's back to normal. I might not keep it this way, but for now, it's useful for future reference.

Thanks a lot!
 
Top