Thanks, I get the part about drawing onto the default viewport, but when I try to draw it into the the small view, the mapview if you will I do this:
#include "app.h"
void App::Loop(){
// Clear previous view first.
gameScreen.clear(sf::Color(24, 24, 24));
// Set map view
gameScreen.setView(mapView);
playerChar.setPosition(x, y);
gameScreen.draw(playerChar);
// Set interface view
gameScreen.setView(fullView);
}
Nothing seems to print at all?
And even if I switch the order of view's, it doesn't work?
#include "app.h"
void App::Loop(){
// Clear previous view first.
gameScreen.clear(sf::Color(24, 24, 24));
// Set interface view
gameScreen.setView(fullView);
// Set map view
gameScreen.setView(mapView);
playerChar.setPosition(x, y);
gameScreen.draw(playerChar);
}
I don't know what you have in app.h but here's simple viewport example:
#include <SFML/Graphics.hpp>
int main()
{
const float a=0.f;
sf::RenderWindow app(sf::VideoMode(600,480),"Viewports");
app.setFramerateLimit(60);
sf::View first=app.getDefaultView();
sf::View second=app.getDefaultView();
second.setViewport(sf::FloatRect(a,a,a+0.1f,a+0.1f));
sf::RectangleShape shape(sf::Vector2f(200.f,200.f));
shape.setPosition(sf::Vector2f(200.f,200.f));
sf::Event eve;
while(app.isOpen())
{
while(app.pollEvent(eve))if(eve.type==sf::Event::Closed) app.close();
app.clear();
app.setView(first);
shape.setFillColor(sf::Color::Red);
app.draw(shape);//now we draw 0,0,600,480 over entire window(0,0,1,1)
app.setView(second);
shape.setFillColor(sf::Color::Blue);
app.draw(shape);//now we treat entire 0,0,600,480 area as a place which will get
//drawn over the 0,0,0.1,0.1 portion of the window
app.display();
}
}
View basically has it's source rectangle and it's viewport normalized rectangle and the viewport says to which portion of the window to draw and source says where to look for things to draw.
Basically what has to be done is : clear, set view, draw, set view, draw, etc. , display, repeat everything.
Read the wiki tutorial, it's very extensive, has example code and pictures.. ;D