|
@@ -0,0 +1,106 @@
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+#include "MetaDeg.h"
|
|
|
+
|
|
|
+int main ( int argc, char** argv )
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ if ( SDL_Init( SDL_INIT_VIDEO ) < 0)
|
|
|
+ {
|
|
|
+ std::cout << "Impossible d'initialiser la SDL: " << SDL_GetError() << std::endl;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ atexit(SDL_Quit);
|
|
|
+
|
|
|
+
|
|
|
+ SDL_WM_SetCaption("Application SDL", 0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int sc_w(640) ;
|
|
|
+ int sc_h(480) ;
|
|
|
+ SDL_Surface* screen = SDL_SetVideoMode(sc_w, sc_h, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
|
|
|
+ if ( !screen )
|
|
|
+ {
|
|
|
+ std::cout << "Unable to set 640x480 video: " << SDL_GetError() << std::endl;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ MetaDeg mySpace;
|
|
|
+ if ( !mySpace.init(sc_w, sc_h) )
|
|
|
+ {
|
|
|
+ std::cout << "Problème initialisation du Metaspace." << std::endl ;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ SDL_Surface* meta_img(mySpace.getSurf());
|
|
|
+
|
|
|
+
|
|
|
+ Uint32 mx(sc_w / 2) ;
|
|
|
+ Uint32 my(sc_w / 2) ;
|
|
|
+
|
|
|
+
|
|
|
+ SDL_EnableKeyRepeat(10,10);
|
|
|
+ bool done = false;
|
|
|
+ while (!done)
|
|
|
+ {
|
|
|
+
|
|
|
+ SDL_Event event;
|
|
|
+ while (SDL_PollEvent(&event))
|
|
|
+ {
|
|
|
+ switch (event.type)
|
|
|
+ {
|
|
|
+ case SDL_QUIT:
|
|
|
+ done = true;
|
|
|
+ break;
|
|
|
+ case SDL_MOUSEMOTION:
|
|
|
+ mx = event.motion.x ;
|
|
|
+ my = event.motion.y ;
|
|
|
+ break;
|
|
|
+ case SDL_KEYDOWN:
|
|
|
+ switch (event.key.keysym.sym)
|
|
|
+ {
|
|
|
+ case SDLK_ESCAPE:
|
|
|
+ done = true;
|
|
|
+ break;
|
|
|
+ case SDLK_UP:
|
|
|
+
|
|
|
+ seuil += 1 ;
|
|
|
+ mySpace.setSeuil(seuil);*/
|
|
|
+ break;
|
|
|
+ case SDLK_DOWN:
|
|
|
+
|
|
|
+ seuil -= 1 ;
|
|
|
+ mySpace.setSeuil(seuil);*/
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ mySpace.clean();
|
|
|
+ mySpace.deform(my, mx);
|
|
|
+ mySpace.deform(180, 250);
|
|
|
+ mySpace.draw();
|
|
|
+
|
|
|
+
|
|
|
+ SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 255, 255));
|
|
|
+
|
|
|
+ SDL_BlitSurface(meta_img, 0, screen, 0);
|
|
|
+
|
|
|
+ SDL_Flip(screen);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SDL_FreeSurface(screen);
|
|
|
+
|
|
|
+
|
|
|
+ std::cout << "Aucune erreur détectée." << std::endl;
|
|
|
+ return 0;
|
|
|
+}
|