Cube  Diff

Differences From Artifact [e10c3367c9]:

To Artifact [072d71a9b6]:


323
324
325
326
327
328
329

330
331


332
333
334
335
336
337



338
339
340
341
342
343
344
323
324
325
326
327
328
329
330


331
332
333
334
335
336
337

338
339
340
341
342
343
344
345
346
347







+
-
-
+
+





-
+
+
+








	struct strip s = { .tex = tex, .start = start, .num = n };
	[strips addItem: &s];
}

#undef gamma

static int gamma = 100;
VARFP(gamma, 30, 100, 300, {
	float f = gamma / 100.0f;
VARBP(gamma, 30, 300, ^ { return gamma; }, ^ (int value) {
	float f = value / 100.0f;
	Uint16 ramp[256];

	SDL_CalculateGammaRamp(f, ramp);

	if (SDL_SetWindowGammaRamp(Cube.sharedInstance.window,
	    ramp, ramp, ramp) == -1) {
	    ramp, ramp, ramp) != -1)
		gamma = value;
	else {
		conoutf(
		    @"Could not set gamma (card/driver doesn't support it?)");
		conoutf(@"sdl: %s", SDL_GetError());
	}
})

void
358
359
360
361
362
363
364


365





















366
367
368
369
370
371
372
361
362
363
364
365
366
367
368
369

370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397







+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







}

VARP(fov, 10, 105, 120);

int xtraverts;

VAR(fog, 64, 180, 1024);

static OFColor *fogColor;
VAR(fogcolour, 0, 0x8099B3, 0xFFFFFF);
VARB(fogcolour, 0, 0xFFFFFF, (^ {
	float red, green, blue;

	if (fogColor == nil)
		return 0x8099B3;

	[fogColor getRed: &red green: &green blue: &blue alpha: NULL];

	return ((unsigned char)(red * 255.0f) << 16) |
	    ((unsigned char)(green * 255.0f) << 8) |
	    (unsigned char)(blue * 255.0f);
}), ^ (int value) {
	unsigned char red = (value >> 16) & 0xFF;
	unsigned char green = (value >> 8) & 0xFF;
	unsigned char blue = value & 0xFF;

	fogColor = [OFColor colorWithRed: red / 255.0f
				   green: green / 255.0f
				    blue: blue / 255.0f
				   alpha: 1.f];
})

VARP(hudgun, 0, 1, 1);

OFString *hudgunnames[] = { @"hudguns/fist", @"hudguns/shotg",
	@"hudguns/chaing", @"hudguns/rocket", @"hudguns/rifle" };

void
418
419
420
421
422
423
424
425
426
427
428
429


430
431
432
433
434
435
436
443
444
445
446
447
448
449





450
451
452
453
454
455
456
457
458







-
-
-
-
-
+
+







	float hf = hdr.waterlevel - 0.3f;
	float fovy = (float)fov * h / w;
	float aspect = w / (float)h;
	bool underwater = (player1.origin.z < hf);

	glFogi(GL_FOG_START, (fog + 64) / 8);
	glFogi(GL_FOG_END, fog);
	float fogc[4] = { (fogcolour >> 16) / 256.0f,
		((fogcolour >> 8) & 255) / 256.0f, (fogcolour & 255) / 256.0f,
		1.0f };
	glFogfv(GL_FOG_COLOR, fogc);
	glClearColor(fogc[0], fogc[1], fogc[2], 1.0f);
	[fogColor cube_setAsGLFogColor];
	[fogColor cube_setAsGLClearColor];

	if (underwater) {
		fovy += (float)sin(lastmillis / 1000.0) * 2.0f;
		aspect += (float)sin(lastmillis / 1000.0 + PI) * 0.1f;
		glFogi(GL_FOG_START, 0);
		glFogi(GL_FOG_END, (fog + 96) / 8);
	}