viewport - C++ SFML Drawing scrollable content within a defined rectangle -


i'm having trouble drawing scrollable content within defined rectangle. achieve ability freely scroll contents within rectangle, not within or partially in being cropped. @ present scroll number of items available make sure nothings being drawn outside of rectangle.

looking @ what's available in sfml seems should able achieve using sf::view attempts not working.

sf::view panelview;  panelview.reset(sf::floatrect(220,85,815,575)); panelview.setviewport(sf::floatrect(0, 0, 1.0f, 1.0f)); 

i'm setting viewpoint this, drawing items, going default view. seems draw entire screen though instead of desired rectangle i've set in reset method?

my understanding should create viewport @ 220 on x axis, 85 on y axis , 815 wide , 575 high, it's drawing outside of boundaries.

any ideas?

sorted out issue looking little bit further - seems need set position factor between 0.0f , 1.0f, position in sample code below want viewport positioned:

sf::floatrect panelrect(position.left / screenwidth, (position.top) / screenheight, (position.width) / screenwidth, (position.height) / screenheight);  panelview.reset(sf::floatrect(position.left,position.top,position.width,position.height)); panelview.setviewport(panelrect); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -