Commit ad60e8ee by Jamie Madill

Move more sample_util sources to util.

These sample utils can also be useful for writing perf tests. BUG=angleproject:1164 Change-Id: I44b5d63b57bfce7a541442fd02cd729a1bab17f0 Reviewed-on: https://chromium-review.googlesource.com/301468Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent db3dd083
......@@ -161,7 +161,7 @@ class MultiWindowSample : public SampleApplication
glUseProgram(mProgram);
// Load the vertex data
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices[0].data);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertices[0].data());
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, 3);
......
......@@ -146,14 +146,14 @@ class ParticleSystemSample : public SampleApplication
Vector3 centerPos(RandomBetween(-0.5f, 0.5f),
RandomBetween(-0.5f, 0.5f),
RandomBetween(-0.5f, 0.5f));
glUniform3fv(mCenterPositionLoc, 1, centerPos.data);
glUniform3fv(mCenterPositionLoc, 1, centerPos.data());
// Random color
Vector4 color(RandomBetween(0.0f, 1.0f),
RandomBetween(0.0f, 1.0f),
RandomBetween(0.0f, 1.0f),
0.5f);
glUniform4fv(mColorLoc, 1, color.data);
glUniform4fv(mColorLoc, 1, color.data());
}
// Load uniform time variable
......
//
// Copyright (c) 2014 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 "geometry_utils.h"
#define _USE_MATH_DEFINES
#include <math.h>
void CreateSphereGeometry(size_t sliceCount, float radius, SphereGeometry *result)
{
size_t parellelCount = sliceCount / 2;
size_t vertexCount = (parellelCount + 1) * (sliceCount + 1);
size_t indexCount = parellelCount * sliceCount * 6;
float angleStep = static_cast<float>(2.0f * M_PI) / sliceCount;
result->positions.resize(vertexCount);
result->normals.resize(vertexCount);
for (size_t i = 0; i < parellelCount + 1; i++)
{
for (size_t j = 0; j < sliceCount + 1; j++)
{
Vector3 direction(sinf(angleStep * i) * sinf(angleStep * j),
cosf(angleStep * i),
sinf(angleStep * i) * cosf(angleStep * j));
size_t vertexIdx = i * (sliceCount + 1) + j;
result->positions[vertexIdx] = direction * radius;
result->normals[vertexIdx] = direction;
}
}
result->indices.clear();
result->indices.reserve(indexCount);
for (size_t i = 0; i < parellelCount; i++)
{
for (size_t j = 0; j < sliceCount; j++)
{
result->indices.push_back(static_cast<unsigned short>( i * (sliceCount + 1) + j ));
result->indices.push_back(static_cast<unsigned short>((i + 1) * (sliceCount + 1) + j ));
result->indices.push_back(static_cast<unsigned short>((i + 1) * (sliceCount + 1) + (j + 1)));
result->indices.push_back(static_cast<unsigned short>( i * (sliceCount + 1) + j ));
result->indices.push_back(static_cast<unsigned short>((i + 1) * (sliceCount + 1) + (j + 1)));
result->indices.push_back(static_cast<unsigned short>( i * (sliceCount + 1) + (j + 1)));
}
}
}
void GenerateCubeGeometry(float radius, CubeGeometry *result)
{
result->positions.resize(24);
result->positions[ 0] = Vector3(-radius, -radius, -radius);
result->positions[ 1] = Vector3(-radius, -radius, radius);
result->positions[ 2] = Vector3( radius, -radius, radius);
result->positions[ 3] = Vector3( radius, -radius, -radius);
result->positions[ 4] = Vector3(-radius, radius, -radius);
result->positions[ 5] = Vector3(-radius, radius, radius);
result->positions[ 6] = Vector3( radius, radius, radius);
result->positions[ 7] = Vector3( radius, radius, -radius);
result->positions[ 8] = Vector3(-radius, -radius, -radius);
result->positions[ 9] = Vector3(-radius, radius, -radius);
result->positions[10] = Vector3( radius, radius, -radius);
result->positions[11] = Vector3( radius, -radius, -radius);
result->positions[12] = Vector3(-radius, -radius, radius);
result->positions[13] = Vector3(-radius, radius, radius);
result->positions[14] = Vector3( radius, radius, radius);
result->positions[15] = Vector3( radius, -radius, radius);
result->positions[16] = Vector3(-radius, -radius, -radius);
result->positions[17] = Vector3(-radius, -radius, radius);
result->positions[18] = Vector3(-radius, radius, radius);
result->positions[19] = Vector3(-radius, radius, -radius);
result->positions[20] = Vector3( radius, -radius, -radius);
result->positions[21] = Vector3( radius, -radius, radius);
result->positions[22] = Vector3( radius, radius, radius);
result->positions[23] = Vector3( radius, radius, -radius);
result->normals.resize(24);
result->normals[ 0] = Vector3( 0.0f, -1.0f, 0.0f);
result->normals[ 1] = Vector3( 0.0f, -1.0f, 0.0f);
result->normals[ 2] = Vector3( 0.0f, -1.0f, 0.0f);
result->normals[ 3] = Vector3( 0.0f, -1.0f, 0.0f);
result->normals[ 4] = Vector3( 0.0f, 1.0f, 0.0f);
result->normals[ 5] = Vector3( 0.0f, 1.0f, 0.0f);
result->normals[ 6] = Vector3( 0.0f, 1.0f, 0.0f);
result->normals[ 7] = Vector3( 0.0f, 1.0f, 0.0f);
result->normals[ 8] = Vector3( 0.0f, 0.0f, -1.0f);
result->normals[ 9] = Vector3( 0.0f, 0.0f, -1.0f);
result->normals[10] = Vector3( 0.0f, 0.0f, -1.0f);
result->normals[11] = Vector3( 0.0f, 0.0f, -1.0f);
result->normals[12] = Vector3( 0.0f, 0.0f, 1.0f);
result->normals[13] = Vector3( 0.0f, 0.0f, 1.0f);
result->normals[14] = Vector3( 0.0f, 0.0f, 1.0f);
result->normals[15] = Vector3( 0.0f, 0.0f, 1.0f);
result->normals[16] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[17] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[18] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[19] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[20] = Vector3( 1.0f, 0.0f, 0.0f);
result->normals[21] = Vector3( 1.0f, 0.0f, 0.0f);
result->normals[22] = Vector3( 1.0f, 0.0f, 0.0f);
result->normals[23] = Vector3( 1.0f, 0.0f, 0.0f);
result->texcoords.resize(24);
result->texcoords[ 0] = Vector2(0.0f, 0.0f);
result->texcoords[ 1] = Vector2(0.0f, 1.0f);
result->texcoords[ 2] = Vector2(1.0f, 1.0f);
result->texcoords[ 3] = Vector2(1.0f, 0.0f);
result->texcoords[ 4] = Vector2(1.0f, 0.0f);
result->texcoords[ 5] = Vector2(1.0f, 1.0f);
result->texcoords[ 6] = Vector2(0.0f, 1.0f);
result->texcoords[ 7] = Vector2(0.0f, 0.0f);
result->texcoords[ 8] = Vector2(0.0f, 0.0f);
result->texcoords[ 9] = Vector2(0.0f, 1.0f);
result->texcoords[10] = Vector2(1.0f, 1.0f);
result->texcoords[11] = Vector2(1.0f, 0.0f);
result->texcoords[12] = Vector2(0.0f, 0.0f);
result->texcoords[13] = Vector2(0.0f, 1.0f);
result->texcoords[14] = Vector2(1.0f, 1.0f);
result->texcoords[15] = Vector2(1.0f, 0.0f);
result->texcoords[16] = Vector2(0.0f, 0.0f);
result->texcoords[17] = Vector2(0.0f, 1.0f);
result->texcoords[18] = Vector2(1.0f, 1.0f);
result->texcoords[19] = Vector2(1.0f, 0.0f);
result->texcoords[20] = Vector2(0.0f, 0.0f);
result->texcoords[21] = Vector2(0.0f, 1.0f);
result->texcoords[22] = Vector2(1.0f, 1.0f);
result->texcoords[23] = Vector2(1.0f, 0.0f);
result->indices.resize(36);
result->indices[ 0] = 0; result->indices[ 1] = 2; result->indices[ 2] = 1;
result->indices[ 3] = 0; result->indices[ 4] = 3; result->indices[ 5] = 2;
result->indices[ 6] = 4; result->indices[ 7] = 5; result->indices[ 8] = 6;
result->indices[ 9] = 4; result->indices[10] = 6; result->indices[11] = 7;
result->indices[12] = 8; result->indices[13] = 9; result->indices[14] = 10;
result->indices[15] = 8; result->indices[16] = 10; result->indices[17] = 11;
result->indices[18] = 12; result->indices[19] = 15; result->indices[20] = 14;
result->indices[21] = 12; result->indices[22] = 14; result->indices[23] = 13;
result->indices[24] = 16; result->indices[25] = 17; result->indices[26] = 18;
result->indices[27] = 16; result->indices[28] = 18; result->indices[29] = 19;
result->indices[30] = 20; result->indices[31] = 23; result->indices[32] = 22;
result->indices[33] = 20; result->indices[34] = 22; result->indices[35] = 21;
}
......@@ -34,14 +34,8 @@
],
'sources':
[
'sample_util/Matrix.cpp',
'sample_util/Matrix.h',
'sample_util/SampleApplication.cpp',
'sample_util/SampleApplication.h',
'sample_util/Vector.cpp',
'sample_util/Vector.h',
'sample_util/geometry_utils.cpp',
'sample_util/geometry_utils.h',
'sample_util/texture_utils.cpp',
'sample_util/texture_utils.h',
'sample_util/tga_utils.cpp',
......
This diff is collapsed. Click to expand it.
......@@ -3,9 +3,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Matrix:
// Helper class for doing matrix math.
//
#ifndef SAMPLE_UTIL_MATRIX_H
#define SAMPLE_UTIL_MATRIX_H
#ifndef UTIL_MATRIX_H
#define UTIL_MATRIX_H
#include "Vector.h"
......@@ -14,10 +17,22 @@ struct Matrix4
float data[16];
Matrix4();
Matrix4(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33);
Matrix4(float m00,
float m01,
float m02,
float m03,
float m10,
float m11,
float m12,
float m13,
float m20,
float m21,
float m22,
float m23,
float m30,
float m31,
float m32,
float m33);
static Matrix4 identity();
static Matrix4 rotate(float angle, const Vector3 &p);
......@@ -43,4 +58,4 @@ Vector4 operator*(const Matrix4 &a, const Vector4 &b);
bool operator==(const Matrix4 &a, const Matrix4 &b);
bool operator!=(const Matrix4 &a, const Matrix4 &b);
#endif // SAMPLE_UTIL_MATRIX_H
#endif // UTIL_MATRIX_H
......@@ -3,20 +3,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Vector:
// Vector class for linear math.
//
#include "Vector.h"
#include <math.h>
Vector2::Vector2()
: x(0.0),
y(0.0)
Vector2::Vector2() : x(0.0), y(0.0)
{
}
Vector2::Vector2(float x, float y)
: x(x),
y(y)
Vector2::Vector2(float x, float y) : x(x), y(y)
{
}
......@@ -28,8 +27,7 @@ float Vector2::length(const Vector2 &vec)
float Vector2::lengthSquared(const Vector2 &vec)
{
return vec.x * vec.x +
vec.y * vec.y;
return vec.x * vec.x + vec.y * vec.y;
}
Vector2 Vector2::normalize(const Vector2 &vec)
......@@ -39,23 +37,17 @@ Vector2 Vector2::normalize(const Vector2 &vec)
if (len != 0.0f)
{
float invLen = 1.0f / len;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
}
return ret;
}
Vector3::Vector3()
: x(0.0),
y(0.0),
z(0.0)
Vector3::Vector3() : x(0.0), y(0.0), z(0.0)
{
}
Vector3::Vector3(float x, float y, float z)
: x(x),
y(y),
z(z)
Vector3::Vector3(float x, float y, float z) : x(x), y(y), z(z)
{
}
......@@ -67,9 +59,7 @@ float Vector3::length(const Vector3 &vec)
float Vector3::lengthSquared(const Vector3 &vec)
{
return vec.x * vec.x +
vec.y * vec.y +
vec.z * vec.z;
return vec.x * vec.x + vec.y * vec.y + vec.z * vec.z;
}
Vector3 Vector3::normalize(const Vector3 &vec)
......@@ -79,82 +69,58 @@ Vector3 Vector3::normalize(const Vector3 &vec)
if (len != 0.0f)
{
float invLen = 1.0f / len;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
ret.z = vec.z * invLen;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
ret.z = vec.z * invLen;
}
return ret;
}
float Vector3::dot(const Vector3 &a, const Vector3 &b)
{
return a.x * b.x +
a.y * b.y +
a.z * b.z;
return a.x * b.x + a.y * b.y + a.z * b.z;
}
Vector3 Vector3::cross(const Vector3 &a, const Vector3 &b)
{
return Vector3(a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x);
return Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
}
Vector3 operator*(const Vector3 &a, const Vector3 &b)
{
return Vector3(a.x * b.x,
a.y * b.y,
a.z * b.z);
return Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
}
Vector3 operator*(const Vector3 &a, const float& b)
Vector3 operator*(const Vector3 &a, const float &b)
{
return Vector3(a.x * b,
a.y * b,
a.z * b);
return Vector3(a.x * b, a.y * b, a.z * b);
}
Vector3 operator/(const Vector3 &a, const Vector3 &b)
{
return Vector3(a.x / b.x,
a.y / b.y,
a.z / b.z);
return Vector3(a.x / b.x, a.y / b.y, a.z / b.z);
}
Vector3 operator/(const Vector3 &a, const float& b)
Vector3 operator/(const Vector3 &a, const float &b)
{
return Vector3(a.x / b,
a.y / b,
a.z / b);
return Vector3(a.x / b, a.y / b, a.z / b);
}
Vector3 operator+(const Vector3 &a, const Vector3 &b)
{
return Vector3(a.x + b.x,
a.y + b.y,
a.z + b.z);
return Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
}
Vector3 operator-(const Vector3 &a, const Vector3 &b)
{
return Vector3(a.x - b.x,
a.y - b.y,
a.z - b.z);
return Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
}
Vector4::Vector4()
: x(0.0f),
y(0.0f),
z(0.0f),
w(0.0f)
Vector4::Vector4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f)
{
}
Vector4::Vector4(float x, float y, float z, float w)
: x(x),
y(y),
z(z),
w(w)
Vector4::Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w)
{
}
......@@ -166,10 +132,7 @@ float Vector4::length(const Vector4 &vec)
float Vector4::lengthSquared(const Vector4 &vec)
{
return vec.x * vec.x +
vec.y * vec.y +
vec.z * vec.z +
vec.w * vec.w;
return vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + vec.w * vec.w;
}
Vector4 Vector4::normalize(const Vector4 &vec)
......@@ -178,17 +141,14 @@ Vector4 Vector4::normalize(const Vector4 &vec)
if (vec.w != 0.0f)
{
float invLen = 1.0f / vec.w;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
ret.z = vec.z * invLen;
ret.x = vec.x * invLen;
ret.y = vec.y * invLen;
ret.z = vec.z * invLen;
}
return ret;
}
float Vector4::dot(const Vector4 &a, const Vector4 &b)
{
return a.x * b.x +
a.y * b.y +
a.z * b.z +
a.w * b.w;
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}
......@@ -3,21 +3,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Vector:
// Vector class for linear math.
//
#ifndef SAMPLE_UTIL_VECTOR_H
#define SAMPLE_UTIL_VECTOR_H
#ifndef UTIL_VECTOR_H
#define UTIL_VECTOR_H
struct Vector2
{
union
{
struct
{
float x, y;
};
float data[2];
};
Vector2();
Vector2(float x, float y);
......@@ -25,19 +19,15 @@ struct Vector2
static float lengthSquared(const Vector2 &vec);
static Vector2 normalize(const Vector2 &vec);
float *data() { return &x; }
const float *data() const { return &x; }
float x, y;
};
struct Vector3
{
union
{
struct
{
float x, y, z;
};
float data[3];
};
Vector3();
Vector3(float x, float y, float z);
......@@ -48,26 +38,22 @@ struct Vector3
static float dot(const Vector3 &a, const Vector3 &b);
static Vector3 cross(const Vector3 &a, const Vector3 &b);
float *data() { return &x; }
const float *data() const { return &x; }
float x, y, z;
};
Vector3 operator*(const Vector3 &a, const Vector3 &b);
Vector3 operator*(const Vector3 &a, const float& b);
Vector3 operator*(const Vector3 &a, const float &b);
Vector3 operator/(const Vector3 &a, const Vector3 &b);
Vector3 operator/(const Vector3 &a, const float& b);
Vector3 operator/(const Vector3 &a, const float &b);
Vector3 operator+(const Vector3 &a, const Vector3 &b);
Vector3 operator-(const Vector3 &a, const Vector3 &b);
struct Vector4
{
union
{
struct
{
float x, y, z, w;
};
float data[4];
};
Vector4();
Vector4(float x, float y, float z, float w);
......@@ -77,6 +63,11 @@ struct Vector4
static Vector4 normalize(const Vector4 &vec);
static float dot(const Vector4 &a, const Vector4 &b);
float *data() { return &x; }
const float *data() const { return &x; }
float x, y, z, w;
};
#endif // SAMPLE_UTIL_VECTOR_H
#endif // UTIL_VECTOR_H
//
// Copyright (c) 2014 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.
//
// geometry_utils:
// Helper library for generating certain sets of geometry.
//
#include "geometry_utils.h"
#define _USE_MATH_DEFINES
#include <math.h>
void CreateSphereGeometry(size_t sliceCount, float radius, SphereGeometry *result)
{
size_t parellelCount = sliceCount / 2;
size_t vertexCount = (parellelCount + 1) * (sliceCount + 1);
size_t indexCount = parellelCount * sliceCount * 6;
float angleStep = static_cast<float>(2.0f * M_PI) / sliceCount;
result->positions.resize(vertexCount);
result->normals.resize(vertexCount);
for (size_t i = 0; i < parellelCount + 1; i++)
{
for (size_t j = 0; j < sliceCount + 1; j++)
{
Vector3 direction(sinf(angleStep * i) * sinf(angleStep * j), cosf(angleStep * i),
sinf(angleStep * i) * cosf(angleStep * j));
size_t vertexIdx = i * (sliceCount + 1) + j;
result->positions[vertexIdx] = direction * radius;
result->normals[vertexIdx] = direction;
}
}
result->indices.clear();
result->indices.reserve(indexCount);
for (size_t i = 0; i < parellelCount; i++)
{
for (size_t j = 0; j < sliceCount; j++)
{
result->indices.push_back(static_cast<unsigned short>(i * (sliceCount + 1) + j));
result->indices.push_back(static_cast<unsigned short>((i + 1) * (sliceCount + 1) + j));
result->indices.push_back(
static_cast<unsigned short>((i + 1) * (sliceCount + 1) + (j + 1)));
result->indices.push_back(static_cast<unsigned short>(i * (sliceCount + 1) + j));
result->indices.push_back(
static_cast<unsigned short>((i + 1) * (sliceCount + 1) + (j + 1)));
result->indices.push_back(static_cast<unsigned short>(i * (sliceCount + 1) + (j + 1)));
}
}
}
void GenerateCubeGeometry(float radius, CubeGeometry *result)
{
result->positions.resize(24);
result->positions[0] = Vector3(-radius, -radius, -radius);
result->positions[1] = Vector3(-radius, -radius, radius);
result->positions[2] = Vector3(radius, -radius, radius);
result->positions[3] = Vector3(radius, -radius, -radius);
result->positions[4] = Vector3(-radius, radius, -radius);
result->positions[5] = Vector3(-radius, radius, radius);
result->positions[6] = Vector3(radius, radius, radius);
result->positions[7] = Vector3(radius, radius, -radius);
result->positions[8] = Vector3(-radius, -radius, -radius);
result->positions[9] = Vector3(-radius, radius, -radius);
result->positions[10] = Vector3(radius, radius, -radius);
result->positions[11] = Vector3(radius, -radius, -radius);
result->positions[12] = Vector3(-radius, -radius, radius);
result->positions[13] = Vector3(-radius, radius, radius);
result->positions[14] = Vector3(radius, radius, radius);
result->positions[15] = Vector3(radius, -radius, radius);
result->positions[16] = Vector3(-radius, -radius, -radius);
result->positions[17] = Vector3(-radius, -radius, radius);
result->positions[18] = Vector3(-radius, radius, radius);
result->positions[19] = Vector3(-radius, radius, -radius);
result->positions[20] = Vector3(radius, -radius, -radius);
result->positions[21] = Vector3(radius, -radius, radius);
result->positions[22] = Vector3(radius, radius, radius);
result->positions[23] = Vector3(radius, radius, -radius);
result->normals.resize(24);
result->normals[0] = Vector3(0.0f, -1.0f, 0.0f);
result->normals[1] = Vector3(0.0f, -1.0f, 0.0f);
result->normals[2] = Vector3(0.0f, -1.0f, 0.0f);
result->normals[3] = Vector3(0.0f, -1.0f, 0.0f);
result->normals[4] = Vector3(0.0f, 1.0f, 0.0f);
result->normals[5] = Vector3(0.0f, 1.0f, 0.0f);
result->normals[6] = Vector3(0.0f, 1.0f, 0.0f);
result->normals[7] = Vector3(0.0f, 1.0f, 0.0f);
result->normals[8] = Vector3(0.0f, 0.0f, -1.0f);
result->normals[9] = Vector3(0.0f, 0.0f, -1.0f);
result->normals[10] = Vector3(0.0f, 0.0f, -1.0f);
result->normals[11] = Vector3(0.0f, 0.0f, -1.0f);
result->normals[12] = Vector3(0.0f, 0.0f, 1.0f);
result->normals[13] = Vector3(0.0f, 0.0f, 1.0f);
result->normals[14] = Vector3(0.0f, 0.0f, 1.0f);
result->normals[15] = Vector3(0.0f, 0.0f, 1.0f);
result->normals[16] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[17] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[18] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[19] = Vector3(-1.0f, 0.0f, 0.0f);
result->normals[20] = Vector3(1.0f, 0.0f, 0.0f);
result->normals[21] = Vector3(1.0f, 0.0f, 0.0f);
result->normals[22] = Vector3(1.0f, 0.0f, 0.0f);
result->normals[23] = Vector3(1.0f, 0.0f, 0.0f);
result->texcoords.resize(24);
result->texcoords[0] = Vector2(0.0f, 0.0f);
result->texcoords[1] = Vector2(0.0f, 1.0f);
result->texcoords[2] = Vector2(1.0f, 1.0f);
result->texcoords[3] = Vector2(1.0f, 0.0f);
result->texcoords[4] = Vector2(1.0f, 0.0f);
result->texcoords[5] = Vector2(1.0f, 1.0f);
result->texcoords[6] = Vector2(0.0f, 1.0f);
result->texcoords[7] = Vector2(0.0f, 0.0f);
result->texcoords[8] = Vector2(0.0f, 0.0f);
result->texcoords[9] = Vector2(0.0f, 1.0f);
result->texcoords[10] = Vector2(1.0f, 1.0f);
result->texcoords[11] = Vector2(1.0f, 0.0f);
result->texcoords[12] = Vector2(0.0f, 0.0f);
result->texcoords[13] = Vector2(0.0f, 1.0f);
result->texcoords[14] = Vector2(1.0f, 1.0f);
result->texcoords[15] = Vector2(1.0f, 0.0f);
result->texcoords[16] = Vector2(0.0f, 0.0f);
result->texcoords[17] = Vector2(0.0f, 1.0f);
result->texcoords[18] = Vector2(1.0f, 1.0f);
result->texcoords[19] = Vector2(1.0f, 0.0f);
result->texcoords[20] = Vector2(0.0f, 0.0f);
result->texcoords[21] = Vector2(0.0f, 1.0f);
result->texcoords[22] = Vector2(1.0f, 1.0f);
result->texcoords[23] = Vector2(1.0f, 0.0f);
result->indices.resize(36);
result->indices[0] = 0;
result->indices[1] = 2;
result->indices[2] = 1;
result->indices[3] = 0;
result->indices[4] = 3;
result->indices[5] = 2;
result->indices[6] = 4;
result->indices[7] = 5;
result->indices[8] = 6;
result->indices[9] = 4;
result->indices[10] = 6;
result->indices[11] = 7;
result->indices[12] = 8;
result->indices[13] = 9;
result->indices[14] = 10;
result->indices[15] = 8;
result->indices[16] = 10;
result->indices[17] = 11;
result->indices[18] = 12;
result->indices[19] = 15;
result->indices[20] = 14;
result->indices[21] = 12;
result->indices[22] = 14;
result->indices[23] = 13;
result->indices[24] = 16;
result->indices[25] = 17;
result->indices[26] = 18;
result->indices[27] = 16;
result->indices[28] = 18;
result->indices[29] = 19;
result->indices[30] = 20;
result->indices[31] = 23;
result->indices[32] = 22;
result->indices[33] = 20;
result->indices[34] = 22;
result->indices[35] = 21;
}
......@@ -3,9 +3,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// geometry_utils:
// Helper library for generating certain sets of geometry.
//
#ifndef SAMPLE_UTIL_GEOMETRY_UTILS_H
#define SAMPLE_UTIL_GEOMETRY_UTILS_H
#ifndef UTIL_GEOMETRY_UTILS_H
#define UTIL_GEOMETRY_UTILS_H
#include <cstddef>
#include <vector>
......@@ -32,4 +35,4 @@ struct CubeGeometry
void GenerateCubeGeometry(float radius, CubeGeometry *result);
#endif // SAMPLE_UTIL_GEOMETRY_UTILS_H
#endif // UTIL_GEOMETRY_UTILS_H
......@@ -11,6 +11,8 @@
[
'com_utils.h',
'keyboard.h',
'geometry_utils.cpp',
'geometry_utils.h',
'mouse.h',
'random_utils.cpp',
'random_utils.h',
......@@ -20,10 +22,14 @@
'Event.h',
'EGLWindow.cpp',
'EGLWindow.h',
'Matrix.cpp',
'Matrix.h',
'OSPixmap.h',
'OSWindow.cpp',
'OSWindow.h',
'Timer.h',
'Vector.cpp',
'Vector.h',
],
'util_win32_sources':
[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment