structures for convinient loading data to GPU

This commit is contained in:
Roman Sorokin 2014-07-31 14:21:14 +03:00 committed by Alex Zolotarev
parent 19a96b7321
commit 5eade0f859
2 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#include "common_structures.hpp"
namespace glsl_types
{
vec2 const & vec2::operator = (vec2 const & p)
{
x = p.x;
y = p.y;
return *this;
}
vec2 const & vec2::operator = (m2::PointF const & p)
{
x = p.x;
y = p.y;
return *this;
}
}

View file

@ -0,0 +1,89 @@
#pragma once
#include "../geometry/point2d.hpp"
namespace glsl_types
{
struct vec2
{
vec2() {}
vec2(m2::PointF const & p)
: x(p.x), y(p.y) {}
vec2(float X, float Y = 0.0f)
: x(X), y(Y) {}
vec2 const & operator = (vec2 const & p);
vec2 const & operator = (m2::PointF const & p);
float x;
float y;
};
struct vec3
{
vec3() {}
vec3(m2::PointF const & p, float Z)
: x(p.x), y(p.y), z(Z) {}
vec3(float X, m2::PointF const & p)
: x(X), y(p.x), z(p.y) {}
vec3(vec2 const & p, float Z)
: x(p.x), y(p.y), z(Z) {}
vec3(float X, vec2 const & p)
: x(X), y(p.x), z(p.y) {}
vec3(float X, float Y = 0.0f, float Z = 0.0f)
: x(X), y(Y), z(Z) {}
float x;
float y;
float z;
};
struct vec4
{
vec4() {}
vec4(m2::PointF const & p, m2::PointF const & t)
: x(p.x), y(p.y), z(t.x), w(t.y) {}
vec4(m2::PointF const & p, float Z, float W)
: x(p.x), y(p.y), z(Z), w(W) {}
vec4(float X, m2::PointF const & p, float W)
: x(X), y(p.x), z(p.y), w(W) {}
vec4(float X, float Y, m2::PointF const & p)
: x(X), y(Y), z(p.x), w(p.y) {}
vec4(vec2 const & p, vec2 const & t)
: x(p.x), y(p.y), z(t.x), w(t.y) {}
vec4(vec2 const & p, float Z, float W)
: x(p.x), y(p.y), z(Z), w(W) {}
vec4(float X, vec2 const & p, float W)
: x(X), y(p.x), z(p.y), w(W) {}
vec4(float X, float Y, vec2 const & p)
: x(X), y(Y), z(p.x), w(p.y) {}
vec4(float X, vec3 const & p)
: x(X), y(p.x), z(p.y), w(p.z) {}
vec4(vec3 const & p, float W)
: x(p.x), y(p.y), z(p.z), w(W) {}
vec4(float X, float Y = 0.0f, float Z = 0.0f, float W = 0.0f)
: x(X), y(Y), z(Z), w(W) {}
float x;
float y;
float z;
float w;
};
}