gave window a title, generated pixels differently
git-svn-id: svn://anubis/gvsu@314 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
ec3ac34994
commit
b99939912c
@ -11,30 +11,22 @@ using namespace std;
|
||||
|
||||
#define PROGNAME "Josh's CS677 Final : MPI Fractal Generator"
|
||||
|
||||
bool createWindow(int width, int height,
|
||||
SDL_Surface ** screen, Uint32 ** pixels);
|
||||
void getSizes(int * rank, int * size);
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
int my_rank;
|
||||
int world_size;
|
||||
|
||||
SDL_Surface * screen;
|
||||
SDL_Event event;
|
||||
Uint32 * pixels;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO))
|
||||
{
|
||||
cerr << "Failed to initialize SDL!" << endl;
|
||||
return 1;
|
||||
}
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
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++)
|
||||
@ -46,6 +38,7 @@ int main(int argc, char * argv[])
|
||||
SDL_UpdateRect(screen, 0, 0, 0, 0);
|
||||
|
||||
bool going = true;
|
||||
SDL_Event event;
|
||||
while (going && SDL_WaitEvent(&event) != 0)
|
||||
{
|
||||
switch (event.type)
|
||||
@ -59,4 +52,36 @@ int main(int argc, char * argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool createWindow(int width, int height,
|
||||
SDL_Surface ** screen, Uint32 ** pixels)
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO))
|
||||
{
|
||||
cerr << "Failed to initialize SDL!" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
atexit(SDL_Quit);
|
||||
|
||||
if (!(*screen = SDL_SetVideoMode(width, height, 32, 0)))
|
||||
{
|
||||
cerr << "Failed to set video mode!" << endl;
|
||||
return false;
|
||||
}
|
||||
SDL_WM_SetCaption(PROGNAME, PROGNAME);
|
||||
|
||||
*pixels = (Uint32 *) screen->pixels;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void getSizes(int * rank, int * size)
|
||||
{
|
||||
MPI_Comm_rank(rank);
|
||||
MPI_Comm_size(size, MPI_COMM_WORLD);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user