6
6
#define FUNCTION
7
7
#endif
8
8
9
- FUNCTION unsigned int FNVHash (char * str , unsigned int length ) {
9
+ FUNCTION static unsigned int FNVHash (char * str , unsigned int length ) {
10
10
const unsigned int fnv_prime = 0x811C9DC5 ;
11
11
unsigned int hash = 0 ;
12
12
unsigned int i = 0 ;
@@ -20,13 +20,13 @@ FUNCTION unsigned int FNVHash(char* str, unsigned int length) {
20
20
return hash ;
21
21
}
22
22
23
- FUNCTION unsigned int nrand (unsigned int * rng ) {
23
+ FUNCTION static unsigned int nrand (unsigned int * rng ) {
24
24
unsigned int orand = * rng ;
25
25
* rng = FNVHash ((char * ) & orand , 4 );
26
26
return * rng ;
27
27
}
28
28
29
- FUNCTION Scalar drand48 (Ctx * ctx ) {
29
+ FUNCTION static Scalar drand48 (Ctx * ctx ) {
30
30
Scalar n = (nrand (& ctx -> rng ) / 65536.0f );
31
31
n = n - floorf (n );
32
32
return n ;
@@ -193,7 +193,7 @@ FUNCTION static void ambient_occlusion(Ctx* ctx, vec *col, const Isect *isect)
193
193
col -> z = occlusion ;
194
194
}
195
195
196
- FUNCTION unsigned char aobench_clamp (Scalar f )
196
+ FUNCTION static unsigned char aobench_clamp (Scalar f )
197
197
{
198
198
Scalar s = (f * 255.5f );
199
199
@@ -203,7 +203,13 @@ FUNCTION unsigned char aobench_clamp(Scalar f)
203
203
return (unsigned char ) s ;
204
204
}
205
205
206
- FUNCTION void render_pixel (Ctx * ctx , int x , int y , int w , int h , int nsubsamples , unsigned char * img ) {
206
+ FUNCTION EXTERNAL_FN Ctx get_init_context () {
207
+ return (Ctx ) {
208
+ .rng = 0xFEEFDEED ,
209
+ };
210
+ }
211
+
212
+ FUNCTION EXTERNAL_FN void render_pixel (Ctx * ctx , int x , int y , int w , int h , int nsubsamples , unsigned char * img ) {
207
213
Scalar pixel [3 ] = { 0 , 0 , 0 };
208
214
209
215
ctx -> rng = x * w + y ;
@@ -263,7 +269,7 @@ FUNCTION void render_pixel(Ctx* ctx, int x, int y, int w, int h, int nsubsamples
263
269
img [3 * (y * w + x ) + 2 ] = aobench_clamp (pixel [2 ]);
264
270
}
265
271
266
- FUNCTION void init_scene (Ctx * ctx )
272
+ FUNCTION EXTERNAL_FN void init_scene (Ctx * ctx )
267
273
{
268
274
ctx -> spheres [0 ].center .x = -2.0f ;
269
275
ctx -> spheres [0 ].center .y = 0.0f ;
@@ -288,10 +294,4 @@ FUNCTION void init_scene(Ctx* ctx)
288
294
ctx -> plane .n .y = 1.0f ;
289
295
ctx -> plane .n .z = 0.0f ;
290
296
291
- }
292
-
293
- FUNCTION Ctx get_init_context () {
294
- return (Ctx ) {
295
- .rng = 0xFEEFDEED ,
296
- };
297
297
}
0 commit comments