removed index type unsigned_byte

This commit is contained in:
andrey.zhirnov
2019-08-05 12:32:51 +03:00
parent 3fcf6e053a
commit cff16a5cfa
9 changed files with 6 additions and 28 deletions

View File

@@ -102,7 +102,6 @@ namespace e2d
class index_declaration final {
public:
enum class index_type : u8 {
unsigned_byte,
unsigned_short,
unsigned_int
};

View File

@@ -64,7 +64,7 @@ namespace
}
};
std::array<u8,6> generate_quad_indices() noexcept {
std::array<u16,6> generate_quad_indices() noexcept {
return {0, 1, 2, 2, 1, 3};
}
@@ -111,7 +111,7 @@ namespace
const auto indices = generate_quad_indices();
index_buffer_ = the<render>().create_index_buffer(
indices,
index_declaration::index_type::unsigned_byte,
index_declaration::index_type::unsigned_short,
index_buffer::usage::static_draw);
const auto vertices1 = generate_quad_vertices(texture1_->size());

View File

@@ -56,7 +56,7 @@ namespace
}
};
std::array<u8,36> generate_cube_indices() noexcept {
std::array<u16,36> generate_cube_indices() noexcept {
return {
0, 1, 2,
2, 3, 0,
@@ -170,7 +170,7 @@ namespace
const auto indices = generate_cube_indices();
index_buffer_ = the<render>().create_index_buffer(
indices,
index_declaration::index_type::unsigned_byte,
index_declaration::index_type::unsigned_short,
index_buffer::usage::static_draw);
const auto vertices1 = generate_cube_vertices(make_vec3(1.f));

View File

@@ -44,7 +44,7 @@ namespace
}
};
std::array<u8,36> generate_cube_indices() noexcept {
std::array<u16,36> generate_cube_indices() noexcept {
return {
0, 1, 2,
2, 3, 0,
@@ -125,7 +125,7 @@ namespace
const auto indices = generate_cube_indices();
index_buffer_ = the<render>().create_index_buffer(
indices,
index_declaration::index_type::unsigned_byte,
index_declaration::index_type::unsigned_short,
index_buffer::usage::static_draw);
const auto vertices = generate_cube_vertices(make_vec3(1.f));

View File

@@ -59,7 +59,6 @@ namespace
const char* index_element_cstr(index_declaration::index_type it) noexcept {
#define DEFINE_CASE(x) case index_declaration::index_type::x: return #x;
switch ( it ) {
DEFINE_CASE(unsigned_byte);
DEFINE_CASE(unsigned_short);
DEFINE_CASE(unsigned_int);
default:
@@ -72,7 +71,6 @@ namespace
std::size_t index_element_size(index_declaration::index_type it) noexcept {
#define DEFINE_CASE(x,y) case index_declaration::index_type::x: return y;
switch ( it ) {
DEFINE_CASE(unsigned_byte, sizeof(u8));
DEFINE_CASE(unsigned_short, sizeof(u16));
DEFINE_CASE(unsigned_int, sizeof(u32));
default:

View File

@@ -1194,7 +1194,6 @@ namespace e2d
E2D_ASSERT(is_in_main_thread());
const device_caps& caps = device_capabilities();
switch ( decl.type() ) {
case index_declaration::index_type::unsigned_byte:
case index_declaration::index_type::unsigned_short:
return true;
case index_declaration::index_type::unsigned_int:

View File

@@ -885,7 +885,6 @@ namespace e2d::opengl
GLenum convert_index_type(index_declaration::index_type it) noexcept {
#define DEFINE_CASE(x,y) case index_declaration::index_type::x: return y;
switch ( it ) {
DEFINE_CASE(unsigned_byte, GL_UNSIGNED_BYTE);
DEFINE_CASE(unsigned_short, GL_UNSIGNED_SHORT);
DEFINE_CASE(unsigned_int, GL_UNSIGNED_INT);
default:

View File

@@ -10,13 +10,6 @@
namespace e2d::render_system_impl
{
struct index_u8 {
using type = u8;
static index_declaration decl() noexcept {
return index_declaration::index_type::unsigned_byte;
}
};
struct index_u16 {
using type = u16;
static index_declaration decl() noexcept {

View File

@@ -114,21 +114,11 @@ TEST_CASE("render"){
REQUIRE(id2.type() == index_declaration::index_type::unsigned_short);
REQUIRE(id2.bytes_per_index() == 2);
index_declaration id3(index_declaration::index_type::unsigned_byte);
REQUIRE(id3.type() == index_declaration::index_type::unsigned_byte);
REQUIRE(id3.bytes_per_index() == 1);
REQUIRE(id == id2);
REQUIRE_FALSE(id == id3);
REQUIRE_FALSE(id != id2);
REQUIRE(id != id3);
index_declaration id4 = id;
REQUIRE(id4 == id2);
id4 = id3;
REQUIRE(id4 != id2);
REQUIRE(id4 == id3);
}
SECTION("vertex_declaration"){
vertex_declaration vd;