En tous cas chez moi ça alourdit vraiment vraiment (notamment du côté du drawFillRect par exemple):
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// Variables locales
int ordre = 1, taille = 240;
int positionX = 0, positionY = 0;
char lecture;
wingraph::Font verdana("Tahoma", 13, true);
// Initialisation de la librairie
wingraph::initLib();
wingraph::initWindow("Fractales de Koch", 640, 480, true);
turtle::init();
while (!wingraph::closed)
{
const int vitesseDeplacement = 20;
// Fonctions de la librairie pour la saisie (à faire à chaque frame)
wingraph::keyboard.readInput();
// Lit les caractères au clavier tant qu'il y en a
while (wingraph::keyboard.availableChar())
{
lecture = wingraph::keyboard.readChar();
if (lecture >= '1' && lecture <= '9')
ordre = lecture - '0';
else if (lecture == '0')
ordre = 10;
}
// Teste les touches de direction
if (wingraph::keyboard.held(VK_UP))
positionY -= vitesseDeplacement;
if (wingraph::keyboard.held(VK_DOWN))
positionY += vitesseDeplacement;
if (wingraph::keyboard.held(VK_LEFT))
positionX -= vitesseDeplacement;
if (wingraph::keyboard.held(VK_RIGHT))
positionX += vitesseDeplacement;
// Et celles de zoom
if (wingraph::keyboard.held('A'))
// Si la taille devient trop petite, on ne peut plus la récupérer...
taille = max(taille * 9 / 10, 10);
if (wingraph::keyboard.held('S'))
taille = taille * 11 / 10;
// Et le milieu
if (wingraph::keyboard.held('M'))
positionX = positionY = 0;
if (!wingraph::skipFrame)
{
wingraph::beginDrawing();
// Un petit dégradé de fond
wingraph::drawFillRect(
wingraph::Vertex(0, 0, wingraph::Color(128, 128, 255)),
wingraph::Vertex(wingraph::screenWidth, 0, wingraph::Color(128, 128, 255)),
wingraph::Vertex(0, wingraph::screenHeight, wingraph::Color(255, 255, 255)),
wingraph::Vertex(wingraph::screenWidth, wingraph::screenHeight, wingraph::Color(255, 255, 255))
);
// Dessin de la fractale
curColor = wingraph::Color(0, 0, 0);
turtle::setPosition(taille / 2 - positionX, taille / 3 - positionY);
koch(taille, ordre);
// Affiche l'ordre par-dessus
std:: ostringstream titre;
titre << "Ordre: " << ordre;
wingraph::setColor(wingraph::Color(0, 0, 0));
verdana.drawText(0, 0, titre.str().c_str());
// Ainsi que des informations supplémentaires
verdana.drawText(0, 13, "0-9: définir l'ordre");
verdana.drawText(0, 26, "a/s: modifier la taille");
verdana.drawText(0, 39, "m: revenir au milieu");
wingraph::endDrawing();
}
// On fait tourner à 10 fps pour ne pas trop surcharger le GPU =)
wingraph::syncFrame(10, 8);
}
}
En plus ça doit être moi mais ça me fait bizarre de faire image.draw() quand tout ce que tu fais avant est du genre wingraph::qqch(). En fait je dessine une image mais je ne sais pas que je le fais avec wingraph au coup d'oeil, ça me paraît illogique.