129 lines
2.1 KiB
C++
129 lines
2.1 KiB
C++
#include <psemek/gfx/mesh.hpp>
|
|
|
|
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_;
|
|
|
|
other.array_ = 0;
|
|
other.buffer_ = 0;
|
|
other.count_ = 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_;
|
|
|
|
other.array_ = 0;
|
|
other.buffer_ = 0;
|
|
other.count_ = 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_;
|
|
|
|
other.array_ = 0;
|
|
other.buffer_ = 0;
|
|
other.index_buffer_ = 0;
|
|
other.count_ = 0;
|
|
other.index_type_ = 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_;
|
|
|
|
other.array_ = 0;
|
|
other.buffer_ = 0;
|
|
other.index_buffer_ = 0;
|
|
other.count_ = 0;
|
|
other.index_type_ = 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;
|
|
}
|
|
|
|
|
|
}
|