#include namespace psemek::gfx { mesh mesh::null() { return mesh(0); } mesh::mesh() { gl::GenVertexArrays(1, &array_); gl::GenBuffers(1, &buffer_); } mesh::mesh(mesh && other) { array_ = other.array_; buffer_ = other.buffer_; count_ = other.count_; stride_ = other.stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.count_ = 0; other.stride_ = 0; } mesh & mesh::operator =(mesh && other) { if (this == &other) return *this; if (array_) { gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); } array_ = other.array_; buffer_ = other.buffer_; count_ = other.count_; stride_ = other.stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.count_ = 0; other.stride_ = 0; return *this; } mesh::~mesh() { gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); } mesh::mesh(int) { array_ = 0; buffer_ = 0; } indexed_mesh indexed_mesh::null() { return indexed_mesh(0); } indexed_mesh::indexed_mesh() { gl::GenVertexArrays(1, &array_); gl::GenBuffers(1, &buffer_); gl::GenBuffers(1, &index_buffer_); } indexed_mesh::indexed_mesh(indexed_mesh && other) { array_ = other.array_; buffer_ = other.buffer_; index_buffer_ = other.index_buffer_; count_ = other.count_; index_type_ = other.index_type_; stride_ = other.stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.index_buffer_ = 0; other.count_ = 0; other.index_type_ = 0; other.stride_ = 0; } indexed_mesh & indexed_mesh::operator =(indexed_mesh && other) { if (this == &other) return *this; if (array_) { gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); gl::DeleteBuffers(1, &index_buffer_); } array_ = other.array_; buffer_ = other.buffer_; index_buffer_ = other.index_buffer_; count_ = other.count_; index_type_ = other.index_type_; stride_ = other.stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.index_buffer_ = 0; other.count_ = 0; other.index_type_ = 0; other.stride_ = 0; return *this; } indexed_mesh::~indexed_mesh() { gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); gl::DeleteBuffers(1, &index_buffer_); } indexed_mesh::indexed_mesh(int) { array_ = 0; buffer_ = 0; index_buffer_ = 0; } instanced_mesh instanced_mesh::null() { return instanced_mesh(0); } instanced_mesh::instanced_mesh() { gl::GenVertexArrays(1, &array_); gl::GenBuffers(1, &buffer_); gl::GenBuffers(1, &instance_buffer_); } instanced_mesh::instanced_mesh(instanced_mesh && other) { array_ = other.array_; buffer_ = other.buffer_; instance_buffer_ = other.instance_buffer_; count_ = other.count_; instance_count_ = other.instance_count_; stride_ = other.stride_; instance_stride_ = other.instance_stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.instance_buffer_ = 0; other.count_ = 0; other.instance_count_ = 0; other.stride_ = 0; other.instance_stride_ = 0; } instanced_mesh & instanced_mesh::operator = (instanced_mesh && other) { if (this == &other) return *this; gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); gl::DeleteBuffers(1, &instance_buffer_); array_ = other.array_; buffer_ = other.buffer_; instance_buffer_ = other.instance_buffer_; count_ = other.count_; instance_count_ = other.instance_count_; stride_ = other.stride_; instance_stride_ = other.instance_stride_; primitive_type_ = other.primitive_type_; other.array_ = 0; other.buffer_ = 0; other.instance_buffer_ = 0; other.count_ = 0; other.instance_count_ = 0; other.stride_ = 0; other.instance_stride_ = 0; return *this; } instanced_mesh::~instanced_mesh() { gl::DeleteVertexArrays(1, &array_); gl::DeleteBuffers(1, &buffer_); gl::DeleteBuffers(1, &instance_buffer_); } instanced_mesh::instanced_mesh(int) { array_ = 0; buffer_ = 0; instance_buffer_ = 0; } }