Why not.
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")
#endif // SFML_STATIC
#include <SFML/Graphics.hpp>
#include <SFML\OpenGL.hpp>
#include "include/Defaults.hpp"
#include "include/Debug.hpp"
#include "include/FPS.h"
#include "include/Timer.hpp"
#include "include/Camera.hpp"
#include "include/Animation.hpp"
#include "include/Collision.hpp"
#include "include/Object.hpp"
#include "include/Player.hpp"
#include "include/Scene.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(Default::windowWidth, Default::widnowHeight),
Default::windowTitle, Default::windowStyle);
window.setFramerateLimit(60);
Scene test(sf::Vector2f(400,300));
sf::Texture * tex = new sf::Texture();
tex->loadFromFile("gfx/test.png");
Animation anim;
anim.setImage(tex, 64);
anim.setOrigin(32, 32);
Player hero(sf::Vector2f(64,64),anim);
test.add(&hero);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
hero.eventUpdate(event);
}
FPS::update();
window.resetGLStates();
hero.update(FPS::dt);
window.clear(sf::Color::Black);
test.draw(window);
window.display();
}
delete tex;
return 0;
}
Scene::Scene(sf::Vector2f Size)
{
previous = NULL; // previous scene pointer
next = NULL;
name = "";
this->Size = Size;
camera.setCenter(Default::windowWidth / 2, Default::widnowHeight / 2);
surface.create(Size.x,Size.y, true); // sf::RenderTexture
surfaceRenderer.setPosition(0, 0); // sprite for render sf::RenderTexture
surfaceRenderer.setTexture(surface.getTexture());
}
//...
void Scene::draw(sf::RenderWindow & window)
{
surface.clear(sf::Color::White);
surface.draw(objects.back()->getAnimation());
surface.display();
window.draw(surfaceRenderer);
}