Testing textures and events

This commit is contained in:
2022-10-20 15:49:25 -07:00
parent 375b25ff59
commit 80d6cba854
27 changed files with 513 additions and 26 deletions

View File

@ -0,0 +1,11 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
TriangleMesh.cpp
QuadMesh.cpp
)

View File

@ -0,0 +1,38 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "QuadMesh.hpp"
using namespace Dawn;
void QuadMesh::bufferQuadMeshWithZ(
Mesh &mesh,
glm::vec2 xy0, glm::vec2 uv0,
glm::vec2 xy1, glm::vec2 uv1,
float_t z, int32_t verticeStart, int32_t indiceStart
) {
mesh.bufferPositions(
verticeStart, std::array<glm::vec3, QUAD_VERTICE_COUNT>{{
glm::vec3(xy0, z),
glm::vec3(xy1.x, xy0.y, z),
glm::vec3(xy0.x, xy1.y, z),
glm::vec3(xy1, z)
}}
);
mesh.bufferCoordinates(
verticeStart, std::array<glm::vec2, QUAD_VERTICE_COUNT>{{
uv0, glm::vec2(uv1.x, uv0.y),
glm::vec2(uv0.x, uv1.y), uv1
}}
);
mesh.bufferIndices(
indiceStart, std::array<meshindice_t, QUAD_INDICE_COUNT>{{
verticeStart, verticeStart + 1, verticeStart + 2,
verticeStart + 1, verticeStart + 2, verticeStart + 3
}}
);
}

View File

@ -0,0 +1,53 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "display/mesh/Mesh.hpp"
#define QUAD_VERTICE_COUNT 4
#define QUAD_INDICE_COUNT 6
#define QUAD_INDICE_PER_QUAD 2
namespace Dawn {
class QuadMesh {
public:
/**
* Buffers the vertices of a quad onto a primitive.
*
* @param primitive The primitive to buffer to.
* @param xy0 The lower X and Y coordinate.
* @param uv0 The lower Xand Y texture coordinate.
* @param xy1 The higher X and Y coordinate.
* @param uv1 The higher X and Y texture coordinate.
* @param z The Z position of the coordinates.
* @param verticeStart Start vertice to buffer to.
* @param indiceStart Start indice to buffer to.
*/
static void bufferQuadMeshWithZ(
Mesh &mesh,
glm::vec2 xy0, glm::vec2 uv0,
glm::vec2 xy1, glm::vec2 uv1,
float_t z, int32_t verticeStart, int32_t indiceStart
);
/**
* Buffers the vertices of a quad onto a primitive.
*
* @param primitive The primitive to buffer to.
* @param xy0 The lower X and Y coordinate.
* @param uv0 The lower Xand Y texture coordinate.
* @param xy1 The higher X and Y coordinate.
* @param uv1 The higher X and Y texture coordinate.
* @param verticeStart Start vertice to buffer to.
* @param indiceStart Start indice to buffer to.
*/
static void bufferQuadMesh(
Mesh &mesh,
glm::vec2 xy0, glm::vec2 uv0,
glm::vec2 xy1, glm::vec2 uv1,
int32_t verticeStart, int32_t indiceStart
);
};
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "display/mesh/TriangleMesh.hpp"
using namespace Dawn;
void TriangleMesh::createTriangleMesh(Mesh &mesh) {
mesh.createBuffers(3, 3);
mesh.bufferPositions(0, std::array<glm::vec3, 3>{{
glm::vec3(-0.5f, -0.5f, 0),
glm::vec3(0.5f, -0.5f, 0),
glm::vec3(0, 0.5f, 0)
}});
mesh.bufferCoordinates(0, std::array<glm::vec2, 3>{{
glm::vec2(0, 0),
glm::vec2(0, 1),
glm::vec2(1, 0)
}});
mesh.bufferIndices(0, std::array<meshindice_t,3>{{
0, 1, 2
}});
}