Skip to content

Commit

Permalink
Add NewFloat2.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Aug 1, 2016
1 parent 282ebbc commit f4c6bce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/nuanceur/builder/Float2Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Nuanceur
{
private:
friend CSwizzleSelector4;
friend CFloat2Rvalue NewFloat2(const CFloatValue& x, float y);

CFloat2Rvalue(const CFloat2Rvalue&) = default;

Expand Down
3 changes: 3 additions & 0 deletions include/nuanceur/builder/Operations.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "ShaderBuilder.h"
#include "FloatValue.h"
#include "Float2Value.h"
#include "Float3Value.h"
#include "Float4Value.h"
Expand All @@ -18,6 +19,8 @@ namespace Nuanceur

CFloat4Rvalue operator *(const CMatrix44Value& lhs, const CFloat4Value& rhs);

CFloat2Rvalue NewFloat2(const CFloatValue& x, float y);

CFloat4Rvalue NewFloat4(CShaderBuilder& owner, float x, float y, float z, float w);
CFloat4Rvalue NewFloat4(const CFloat3Value& xyz, float w);

Expand Down
11 changes: 11 additions & 0 deletions src/builder/Operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ void CFloat4Lvalue::operator =(const CFloat4Rvalue& rhs)
);
}

CFloat2Rvalue Nuanceur::NewFloat2(const CFloatValue& x, float y)
{
auto owner = x.symbol.owner;
auto literal = CFloat2Rvalue(owner->CreateConstant(y, 0, 0, 0), SWIZZLE_X);
auto temp = CFloat2Rvalue(owner->CreateTemporary());
owner->InsertStatement(
CShaderBuilder::STATEMENT(CShaderBuilder::STATEMENT_OP_NEWVECTOR2, temp, x, literal)
);
return temp;
}

CFloat4Rvalue Nuanceur::NewFloat4(CShaderBuilder& owner, float x, float y, float z, float w)
{
auto literal = owner.CreateConstant(x, y, z, w);
Expand Down

0 comments on commit f4c6bce

Please sign in to comment.