gvsu/cs677/final/mpi-fractals.cc
josh ec3ac34994 gave window a title, generated pixels differently
git-svn-id: svn://anubis/gvsu@313 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-12-06 19:10:59 +00:00

63 lines
1.3 KiB
C++

/*
* Josh Holtrop
* 2008-12-11
* barebones SDL program
*/
#include <SDL/SDL.h>
#include <mpi.h>
#include <iostream>
using namespace std;
#define PROGNAME "Josh's CS677 Final : MPI Fractal Generator"
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;
}
SDL_WM_SetCaption(PROGNAME, PROGNAME);
Uint32 * pixels = (Uint32 *) screen->pixels;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
*pixels++ = (((x * 255 / width) & 0xFF) << 8)
+ ((y * 255 / height) & 0xFF);
}
}
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;
}
}
}