548{
549 BOOL OK = YES;
550 unsigned i, j, vertexCount;
551 GLfloat *pos;
552 GLfloat *tc;
553 GLfloat *col;
555 size_t posSize, tcSize, colSize;
557 int skyColorCorrection = [[NSUserDefaults standardUserDefaults] oo_integerForKey:@"sky-color-correction" defaultValue:0];
558
559
560
561#define SKYCOLOR_TONEMAP_COMPONENT(skyColorComponent) \
562do { \
563 x = MAX(0.0, skyColorComponent - 0.004); \
564 *col++ = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); \
565} while (0)
566
567 self = [super init];
568 if (
self ==
nil) OK = NO;
569
570 if (OK)
571 {
572
573 for (i = 0; i != totalCount; ++i)
574 {
576 }
578 }
579
580 if (OK)
581 {
582
587
591
593
597 }
598
599 if (OK)
600 {
601
602 for (i = 0; i != totalCount; ++i)
603 {
605 {
606 r = [array[i].color redComponent];
607 g = [array[i].color greenComponent];
608 b = [array[i].color blueComponent];
609
610
611 for (j = 0; j != 4; ++j)
612 {
613 *pos++ = array[i].corners[j].
x;
614 *pos++ = array[i].corners[j].
y;
615 *pos++ = array[i].corners[j].z;
616
617
618 if (skyColorCorrection == 0)
619 {
620 *col++ = r;
621 *col++ = g;
622 *col++ = b;
623 }
624 else if (skyColorCorrection == 1)
625 {
626 *col++ = pow(r, 1.0/2.2);
627 *col++ = pow(g, 1.0/2.2);
628 *col++ = pow(b, 1.0/2.2);
629 }
630 else
631 {
635 }
636 *col++ = 1.0f;
637 }
638
639
642
645
648
651
653 }
654 }
655
657 OOLog(
@"sky.setup",
@"Generated quadset with %u quads for texture %@",
count,
_texture);
658 }
659
660 if (!OK)
661 {
662 [self release];
664 }
665
666 return self;
667}
#define OOLog(class, format,...)
static float sMaxTexCoord
static float sMinTexCoord
#define SKYCOLOR_TONEMAP_COMPONENT(skyColorComponent)
@ kSkyQuadSetTexCoordEntriesPerVertex
@ kSkyQuadSetPositionEntriesPerVertex
@ kSkyQuadSetColorEntriesPerVertex