Hash :
17732823
Author :
Date :
2013-08-29T13:46:49
Moved the compiler source files into directories based on their project and added a compiler.gypi to generate the compiler projects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/InitializeGLPosition.h"
#include "compiler/translator/compilerdebug.h"
bool InitializeGLPosition::visitAggregate(Visit visit, TIntermAggregate* node)
{
bool visitChildren = !mCodeInserted;
switch (node->getOp())
{
case EOpSequence: break;
case EOpFunction:
{
// Function definition.
ASSERT(visit == PreVisit);
if (node->getName() == "main(")
{
TIntermSequence &sequence = node->getSequence();
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
TIntermAggregate *body = NULL;
if (sequence.size() == 1)
{
body = new TIntermAggregate(EOpSequence);
sequence.push_back(body);
}
else
{
body = sequence[1]->getAsAggregate();
}
ASSERT(body);
insertCode(body->getSequence());
mCodeInserted = true;
}
break;
}
default: visitChildren = false; break;
}
return visitChildren;
}
void InitializeGLPosition::insertCode(TIntermSequence& sequence)
{
TIntermBinary *binary = new TIntermBinary(EOpAssign);
sequence.insert(sequence.begin(), binary);
TIntermSymbol *left = new TIntermSymbol(
0, "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
binary->setLeft(left);
ConstantUnion *u = new ConstantUnion[4];
for (int ii = 0; ii < 3; ++ii)
u[ii].setFConst(0.0f);
u[3].setFConst(1.0f);
TIntermConstantUnion *right = new TIntermConstantUnion(
u, TType(EbtFloat, EbpUndefined, EvqConst, 4));
binary->setRight(right);
}