>>3154928if (cudaMalloc((void**)&matrix_CUDA, sizeof(unsigned char) * matrix_width *
matrix_height) == cudaErrorMemoryAllocation || matrix_CUDA == NULL){printf("CUDA: cudaMalloc() error: couldn't allocate %li bytes!\n",
matrix_width * matrix_height * sizeof(unsigned char));
return_code = -4;goto exit;}
if (cudaMalloc((void**)&next_CUDA, sizeof(unsigned char) * matrix_width * matrix_height) == cudaErrorMemoryAllocation || matrix_CUDA == NULL){
printf("CUDA: cudaMalloc() error: couldn't allocate %li bytes!\n",matrix_width * matrix_height * sizeof(unsigned char));
return_code = -4;goto exit;}GameOfLife_ClearGrid(matrix, matrix_width, matrix_height);
while (going) {
while (SDL_PollEvent(&event)) { switch (event.type) {
case SDL_QUIT:going = 0;break;
case SDL_KEYDOWN:switch (event.key.keysym.sym) {
case SDLK_SPACE:GameOfLife_RandomGrid(matrix, matrix_width, matrix_height);break;
case SDLK_BACKSPACE:GameOfLife_ClearGrid(matrix, matrix_width, matrix_height);break;
case SDLK_RETURN:GOL_going = !GOL_going;break;}break;
case SDL_MOUSEBUTTONDOWN:
switch (event.button.button) {case SDL_BUTTON_LEFT:
if (!mandelbrot_going) {SDL_GetMouseState(&mouse_x, &mouse_y);
if (mouse_x < DEFAULT_WINDOW_WIDTH && mouse_y < DEFAULT_WINDOW_HEIGHT) {mouse_left_down = 1;
mouse_down_cell_state = !(matrix[(mouse_x/CELL_SIZE) + (mouse_y/CELL_SIZE) * matrix_width]);}}
break;case SDL_BUTTON_RIGHT:0break;}break;
case SDL_MOUSEBUTTONUP:switch (event.button.button) {case SDL_BUTTON_LEFT:
mouse_left_down = 0;break;case SDL_BUTTON_RIGHT:
break;}break;}}