Trouble with 2D and setViewport

25 views
Skip to first unread message

Joshua Fraser

unread,
May 2, 2016, 11:38:25 PM5/2/16
to turbulenz-engine-users
Hey guys so sorry to trouble you with such a trivial question but I'm super stuck on trying to set up a 2D camera and I'm also having trouble with setViewport.

I'm trying to do 
gd.setViewport(100, 100, (gd.width - 100), (gd.height - 100));
in the onload but I'm having no success.

also trying to figure out a way to set up a 2d camera sort of thing but I see no clear way in the documentation, sorry if I'm asking silly questions.

Duncan Tebbs

unread,
May 3, 2016, 9:46:20 PM5/3/16
to turbulenz-engine-users
It's difficult to know what's going wrong.  What effect are you seeing from that call, and what would you expect to see?

The viewport defines the area of the screen that maps to screen space quad with x,y in [-1,1].  It's essentially just a scaling and doesn't prevent rendering outside of that area.
If you want to prevent all rendering to the 100 pixel border, you should probably use scissor as well.  You'll need to do this after every call to gd.beginFrame().

You might find it useful to read up about viewport and scissor on the webgl / opengl reference pages.  The GraphicsDevice calls correspond exactly to these.


Thanks.
Reply all
Reply to author
Forward
0 new messages