diff --git a/cs677/final/Makefile b/cs677/final/Makefile new file mode 100644 index 0000000..1a3df29 --- /dev/null +++ b/cs677/final/Makefile @@ -0,0 +1,17 @@ + +CXX := mpiCC +CXXFLAGS := `sdl-config --cflags` +LDFLAGS := `sdl-config --libs` +TARGET := mpi-fractals +OBJS := mpi-fractals.o + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CXX) -o $@ $^ $(LDFLAGS) + +%.o: %.cc + $(CXX) -o $@ -c $< $(CXXFLAGS) + +clean: + -rm -f *.o *~ $(TARGET) diff --git a/cs677/final/mpi-fractals.cc b/cs677/final/mpi-fractals.cc new file mode 100644 index 0000000..34bf713 --- /dev/null +++ b/cs677/final/mpi-fractals.cc @@ -0,0 +1,54 @@ +/* + * Josh Holtrop + * 2008-12-11 + * barebones SDL program + */ + +#include +#include +#include +using namespace std; + +int main(int argc, char * argv[]) +{ + int width = 800; + int height = 600; + + SDL_Surface * screen; + SDL_Event event; + + if (SDL_Init(SDL_INIT_VIDEO)) + { + cerr << "Failed to initialize SDL!" << endl; + return 1; + } + + atexit(SDL_Quit); + + if (!(screen = SDL_SetVideoMode(width, height, 32, 0))) + { + cerr << "Failed to set video mode!" << endl; + return 2; + } + + Uint32 * pixels = (Uint32 *) screen->pixels; + Uint32 c; + for (c = 0; c < width * height; c++) + *pixels++ = c; + SDL_UpdateRect(screen, 0, 0, 0, 0); + + bool going = true; + while (going && SDL_WaitEvent(&event) != 0) + { + switch (event.type) + { + case SDL_QUIT: + going = false; + break; + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_q) + going = false; + break; + } + } +}