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