Mercurial > hg > dmlib
comparison tests/blittest.c @ 896:90a879277ca2
Fix perling noise usage.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 23 Feb 2015 15:44:33 +0200 |
parents | daebbf28953d |
children | 985225a93aeb |
comparison
equal
deleted
inserted
replaced
895:eb4ebbd5c171 | 896:90a879277ca2 |
---|---|
1 #include "dmlib.h" | 1 #include "dmlib.h" |
2 #include "dmargs.h" | 2 #include "dmargs.h" |
3 #include "dmvecmat.h" | 3 #include "dmvecmat.h" |
4 #include "dmtext.h" | 4 #include "dmtext.h" |
5 #include "dmperlin.h" | |
5 #include <math.h> | 6 #include <math.h> |
6 | 7 |
7 #define DM_COLORS (256) | 8 #define DM_COLORS (256) |
8 | 9 |
9 char *optFontFile = "font.ttf"; | 10 char *optFontFile = "font.ttf"; |
10 BOOL optBenchmark = FALSE; | 11 BOOL optBenchmark = FALSE; |
11 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; | 12 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; |
12 int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32; | 13 int optScrWidth = 640, optScrHeight = 480, optFontSize = 20, optScrDepth = 32; |
13 int optBenchmarkLen = 20; | 14 int optBenchmarkLen = 20; |
15 DMPerlinContext perlinCtx; | |
14 | 16 |
15 static const DMOptArg optList[] = { | 17 static const DMOptArg optList[] = { |
16 { 0, '?', "help", "Show this help", OPT_NONE }, | 18 { 0, '?', "help", "Show this help", OPT_NONE }, |
17 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, | 19 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, |
18 { 3, 'f', "full", "Fullscreen", OPT_NONE }, | 20 { 3, 'f', "full", "Fullscreen", OPT_NONE }, |
164 { | 166 { |
165 int x, y; | 167 int x, y; |
166 for (y = 0; y < QHEIGHT; y++) | 168 for (y = 0; y < QHEIGHT; y++) |
167 for (x = 0; x < QWIDTH; x++) | 169 for (x = 0; x < QWIDTH; x++) |
168 { | 170 { |
169 DMFloat f = 0.40f + dmPerlinNoise2D(x, y, 1.1f, q, 2); | 171 DMFloat f = 0.40f + dmPerlinNoise2D(&perlinCtx, x, y, 1.1f, q, 2); |
170 map[y][x] = (int) (dmClip(f) * m); | 172 map[y][x] = (int) (dmClip(f) * m); |
171 } | 173 } |
172 } | 174 } |
173 | 175 |
174 | 176 |
332 goto error_exit; | 334 goto error_exit; |
333 | 335 |
334 SDL_WM_SetCaption("Halleluja", "DMT"); | 336 SDL_WM_SetCaption("Halleluja", "DMT"); |
335 } | 337 } |
336 | 338 |
337 dmPerlinInit(); | 339 dmPerlinInit(&perlinCtx, 1234); |
338 | 340 |
339 bmap = SDL_CreateRGBSurface(SDL_SWSURFACE, QWIDTH, QHEIGHT, 8, 0, 0, 0, 0); | 341 bmap = SDL_CreateRGBSurface(SDL_SWSURFACE, QWIDTH, QHEIGHT, 8, 0, 0, 0, 0); |
340 DM_MakePalette(bmap); | 342 DM_MakePalette(bmap); |
341 DM_Random(bmap, 15); | 343 DM_Random(bmap, 15); |
342 | 344 |