1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include "odfaeg/Graphics/renderWindow.h"
#include "glCheck.h"
#include "odfaeg/Graphics/window.h"
#include <fstream>
#include "odfaeg/Core/archive.h"
#include "odfaeg/Graphics/2D/tile.h"
#include <functional>
int main(int argc, char* args[])
{
sf::VideoMode mode(800, 600);
sf::ContextSettings settings(0, 0, 4, 3, 0);
odfaeg::RenderWindow window(mode, "test", sf::Style::Default, settings);
odfaeg::Texture tex;
tex.loadFromFile("tilesets/herbe.png");
std::ostringstream oss;
std::string text = "Ceci est un texte.";
std::ofstream ofss("FichierDeSerialization.tex");
{
odfaeg::OTextArchive oa(ofss);
oa(tex);
// oa<<ofss;
}
ofss.close();
std::istringstream iss;
std::ifstream ifss("FichierDeSerialization.tex");
{
odfaeg::ITextArchive ia(ifss);
ia(tex);
//ia>>ifss;
}
ifss.close();
odfaeg::g2d::Entity* tile = new odfaeg::g2d::Tile (&tex, odfaeg::Vec3f(0, 0, 0), odfaeg::Vec3f(100, 50, 0), sf::IntRect(0, 0, 100, 50));
std::cout<<tile->getCollisionVolume()<<std::endl;
while (window.isOpen()) {
sf::Event event;
while(window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(*tile);
window.display();
}
delete tile;
odfaeg::BoundingVolume* b1 = new odfaeg::BoundingSphere(odfaeg::Vec3f(0, 0, 0), 100);
odfaeg::BoundingVolume* b2;
std::ofstream ofs("FichierDeSerialisation");
{
odfaeg::OTextArchive oa(ofs);
oa(b1);
}
ofs.close();
std::ifstream ifs("FichierDeSerialisation");
{
odfaeg::ITextArchive ia(ifs);
ia(&b2);
}
std::cout<<static_cast<odfaeg::BoundingSphere*>(b2)->getCenter()<<" "<<static_cast<odfaeg::BoundingSphere*>(b2)->getRadius()<<std::endl;
ifs.close();
return 0; |
Partager