Update fin séance 12/05/2014

* Commencement des travaux sur l'analyse des arguments
* Ajout d'un Makefile pour Windows fonctionnel
On verra pour la correction du code plus tard.
This commit is contained in:
Geoffrey Frogeye 2014-05-12 12:01:56 +02:00
parent 9bbdb6b3ee
commit 425af05430
4 changed files with 101 additions and 27 deletions

37
Makefile.win Normal file
View File

@ -0,0 +1,37 @@
# Variables
## Pour make
.PHONY: clean, mrproper
## Compilation
CXX = g++
CXXFLAGS = -lmingw32 -lSDLmain -lSDL -static-libgcc -static-libstdc++
CXXFLAGSDEBUG = -lmingw32 -lSDLmain -lSDL -static-libgcc -static-libstdc++ -DDEBUG
## Chemins
EXEPATH = bin/
OBJPATH = obj/
SRCPATH = src/
# Programmes possibles
main: $(EXEPATH)main
testing: $(EXEPATH)testing
# Éxecutables
$(EXEPATH)main: $(OBJPATH)main.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGS)
$(EXEPATH)testing: $(OBJPATH)testing.o $(OBJPATH)image.o
$(CXX) $^ -o $@ $(CXXFLAGSDEBU2)
# Dépendances
## Fichiers executables
$(OBJPATH)main.o: $(SRCPATH)main.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS)
$(OBJPATH)testing.o: $(SRCPATH)testing.cpp $(SRCPATH)affichageFenetre.cpp $(SRCPATH)image.cpp $(SRCPATH)traitementImage.cpp $(SRCPATH)analyserCommande.cpp
$(CXX) -c $< -o $@ $(CXXFLAGSDEBUG)
## Bibliothèques
$(OBJPATH)image.o: $(SRCPATH)image.cpp
$(CXX) -c $< -o $@
# Meta
clean:
rm -rf $(OBJPATH)*.o

View File

@ -26,7 +26,7 @@ Téléchargement : ```git clone https://github.com/GeoffreyFrogeye/PILG.git```
2. Inclure **MinGW** dans la variable d'environnement ```%PATH%``` : ```set path=%path%;C:\MinGW\bin```
3. Télécharger la [bibliothèque de développement SDL 1.2.15](http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz), copier le contenu des dossier *lib* et *include* de l'archive téléchargée dans le dossier de **MinGW**
4. Télécharger la [bibliothèque dexécution de SDL 1.2.15](http://www.libsdl.org/release/SDL-1.2.15-win32.zip) et placer *SDL.dll* dans le dossier *bin*
5. Compiler : ```mingw32-make```
5. Compiler : ```mingw32-make -f Makefile.win```
Lexécutable se trouvera dans le dossier *bin*

View File

@ -2,8 +2,9 @@
#include <string>
#include <iostream>
int chaineVersEntier(string chaine) {
return (int) chaine[0];
int chaineVersEntier(string chaine, int &entier) {
entier = chaine[0];
return 0;
}
void afficherImage(Image image) {
@ -117,14 +118,52 @@ int analyserDecoupe(Commande &commande, vector< string > decoupe, Image const &i
// for (int i = 0; i < decoupe.size(); i++) { // DEBUG
// cout << "Argument " << i << " = " << decoupe[i] << endl;
// }
commande.couleur = image.g_pixelVide();
commande.fonction = decoupe[0];
// Analyse des arguments
// for (int i = 1; i < decoupe.size(); i++) {
// ...
// }
// // Analyse des arguments
for (int i = 1; i < decoupe.size(); i++) {
if (decoupe[i].at(0) == '-') {
if (decoupe[i] == "-x1" || decoupe[i] == "-x0" || decoupe[i] == "-x") {
commande.argumentsPresents.push_back("x1");
if (chaineVersEntier(decoupe[i+1], commande.x1)) {
return 3;
}
i++;
} else if (decoupe[i] == "-y1" || decoupe[i] == "-y0" || decoupe[i] == "-y") {
commande.argumentsPresents.push_back("y1");
if (chaineVersEntier(decoupe[i+1], commande.y1)) {
return 3;
}
i++;
} else if (decoupe[i] == "-x2") {
commande.argumentsPresents.push_back("x2");
if (chaineVersEntier(decoupe[i+1], commande.x2)) {
return 3;
}
i++;
} else if (decoupe[i] == "-y2") {
commande.argumentsPresents.push_back("y2");
if (chaineVersEntier(decoupe[i+1], commande.y2)) {
return 3;
}
i++;
} else if (decoupe[i] == "-couleur" || decoupe[i] == "-c") {
commande.argumentsPresents.push_back("couleur");
commande.couleur = image.g_pixelVide();
// Analyser deuxième partie
i++;
} else {
return 2;
}
} else {
return 1;
}
}
for (int i = 0; i < commande.argumentsPresents.size(); i++) { // DEBUG
cout << "Argument présent " << i << " = " << commande.argumentsPresents[i] << endl;
}
return 0;
}
@ -140,12 +179,10 @@ bool argumentPresent(Commande commande, string argumentVoulu) {
int executerCommande(Commande commande, Image &image) {
if (commande.fonction == "rectangle") {
commande.couleur.v = image.g_maxComposante(); // DEBUG
rectangle(image, image, 5, 5, 10, 10, commande.couleur); // DEBUG
if (argumentPresent(commande, "x1") && argumentPresent(commande, "x2")
&& argumentPresent(commande, "y1") && argumentPresent(commande, "y2")
&& argumentPresent(commande, "couleur")) {
// TODO
rectangle(image, image, commande.x1, commande.y1, commande.x2, commande.y2, commande.couleur);
} else {
return 2;
}
@ -172,8 +209,17 @@ void procederCommande(vector< string > decoupe, Image &image) {
messageErreur("Impossible d'éxecuter la fonction");
}
break;
case 1:
messageErreur("Argument inconnu");
break;
case 2:
messageErreur("Argument inconnu");
break;
case 3:
messageErreur("Impossible de comprendre un argument");
break;
default:
messageErreur("Impossible d'analyse de la commande");
messageErreur("Impossible d'analyser la commande");
break;
}
}

View File

@ -106,27 +106,18 @@ int main(int argc, char *args[]) {
cout << "PILG - Test" << endl; // Message d'entrée et de test
// // Analyse de commandes
// if (argc > 1) {
// vector< string > decoupe;
// for (int i = 1; i < argc; i++) {
// decoupe.push_back(args[i]);
// }
// analyserDecoupe(decoupe);
// } else {
// boucleDeCommandes();
// }
Image image = genererRoue(256, 128, 255);
#define DIMENSIONS 256
Image imageOriginale = genererRoue(DIMENSIONS, DIMENSIONS, 255);
Image image = imageOriginale.g_vide();
while(1) {
for (float i = 0; i < 2 * PI; i += 0.1) {
pivoter(imageOriginale, image, DIMENSIONS/2, DIMENSIONS/2, i);
afficherImage(image);
}
// while(1) {
for (float i = 0; i < 2 * PI; i += 0.1) {
pivoter(imageOriginale, image, DIMENSIONS/2, DIMENSIONS/2, i);
afficherImage(image);
}
// }
// // Neige en dégradé