diff --git a/src/nebulae.c b/src/nebulae.c index 051da08..7ea9e4f 100644 --- a/src/nebulae.c +++ b/src/nebulae.c @@ -33,10 +33,11 @@ static double nebu_view = 0.; static double nebu_dt = 0.; static int nebu_checkCompat(const char* file); +static void nebu_generate(void); static void saveNebulae(float* map, const uint32_t w, const uint32_t h, const char* file); static SDL_Surface* loadNebulae(const char* file); -static void nebu_generate(void); +static SDL_Surface* nebu_surfaceFromNebulaeMap(float* map, const int w, const int h); /* Initialize the nebulae. */ void nebu_init(void) { @@ -345,7 +346,7 @@ static void saveNebulae(float* map, const uint32_t w, const uint32_t h, char file_path[PATH_MAX]; SDL_Surface* sur; - sur = noise_surfaceFromNebulaeMap(map, w, h); + sur = nebu_surfaceFromNebulaeMap(map, w, h); snprintf(file_path, PATH_MAX, "%s%s", lfile_basePath(), file); @@ -370,3 +371,24 @@ static SDL_Surface* loadNebulae(const char* file) { return sur; } +/* Generate an SDL_Surface from a 2d nebulae map. */ +SDL_Surface* nebu_surfaceFromNebulaeMap(float* map, const int w, const int h) { + int i; + SDL_Surface* sur; + uint32_t* pix; + double c; + + sur = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RGBAMASK); + pix = sur->pixels; + + /* Convert from mapping to actual colours. */ + SDL_LockSurface(sur); + for(i = 0; i < h*w; i++) { + c = map[i]; + pix[i] = RMASK + BMASK + GMASK + (AMASK & (uint32_t)((double)AMASK*c)); + } + SDL_UnlockSurface(sur); + + return sur; +} + diff --git a/src/perlin.c b/src/perlin.c index c20bf36..89cc255 100644 --- a/src/perlin.c +++ b/src/perlin.c @@ -239,24 +239,3 @@ float* noise_genNebulaeMap(const int w, const int h, const int n, float rug) { return nebulae; } -/* Generate an SDL_Surface from a 2d nebulae map. */ -SDL_Surface* noise_surfaceFromNebulaeMap(float* map, const int w, const int h) { - int i; - SDL_Surface* sur; - uint32_t* pix; - double c; - - sur = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RGBAMASK); - pix = sur->pixels; - - /* Convert from mapping to actual colours. */ - SDL_LockSurface(sur); - for(i = 0; i < h*w; i++) { - c = map[i]; - pix[i] = RMASK + BMASK + GMASK + (AMASK & (uint32_t)((double)AMASK*c)); - } - SDL_UnlockSurface(sur); - - return sur; -} - diff --git a/src/perlin.h b/src/perlin.h index 57c57b4..5db966d 100644 --- a/src/perlin.h +++ b/src/perlin.h @@ -3,5 +3,3 @@ float* noise_genNebulaeMap(const int w, const int h, const int n, float rug); -SDL_Surface* noise_surfaceFromNebulaeMap(float* map, const int w, const int h); -