public:
void Update(const Buffer &) noexcept;
- void Draw() const noexcept;
+ bool Empty() const noexcept {
+ return vao.Empty();
+ }
+
+ void Draw() const noexcept {
+ vao.DrawTriangleElements();
+ }
private:
VAO vao;
public:
void Update(const Buffer &) noexcept;
- void Draw() const noexcept;
+ bool Empty() const noexcept {
+ return vao.Empty();
+ }
+
+ void Draw() const noexcept {
+ vao.DrawTriangleElements();
+ }
private:
VAO vao;
public:
void Update(const Buffer &) noexcept;
- void DrawLines() noexcept;
- void DrawTriangles() noexcept;
+ bool Empty() const noexcept {
+ return vao.Empty();
+ }
+
+ void DrawLines() const noexcept;
+ void DrawTriangles() const noexcept {
+ vao.DrawTriangleElements();
+ }
private:
VAO vao;
void LoadUnitBox();
void Update(const Buffer &) noexcept;
- void Draw() const noexcept;
+ bool Empty() const noexcept {
+ return vao.Empty();
+ }
+
+ void Draw() const noexcept {
+ vao.DrawTriangleElements();
+ }
private:
VAO vao;
public:
void Update(const Buffer &) noexcept;
- void Draw() noexcept;
+ bool Empty() const noexcept {
+ return vao.Empty();
+ }
+
+ void Draw() const noexcept {
+ vao.DrawTriangleElements();
+ }
private:
VAO vao;
VertexArray<N> &operator =(VertexArray<N> &&) noexcept;
public:
+ bool Empty() const noexcept { return idx_count == 0; }
+
void Bind() const noexcept;
template <class T>
std::cerr << "EntityMesh: not enough tex coords!" << std::endl;
}
if (buf.hsl_mods.size() < buf.vertices.size()) {
- std::cerr << "BlockMesh: not enough HSL modifiers!" << std::endl;
+ std::cerr << "EntityMesh: not enough HSL modifiers!" << std::endl;
}
if (buf.rgb_mods.size() < buf.vertices.size()) {
- std::cerr << "BlockMesh: not enough RGB modifiers!" << std::endl;
+ std::cerr << "EntityMesh: not enough RGB modifiers!" << std::endl;
}
if (buf.normals.size() < buf.vertices.size()) {
std::cerr << "EntityMesh: not enough normals!" << std::endl;
}
-void EntityMesh::Draw() const noexcept {
- vao.DrawTriangleElements();
-}
-
-
void BlockMesh::Update(const Buffer &buf) noexcept {
#ifndef NDEBUG
if (buf.tex_coords.size() < buf.vertices.size()) {
}
-void BlockMesh::Draw() const noexcept {
- vao.DrawTriangleElements();
-}
-
-
void PrimitiveMesh::Buffer::FillRect(
float w, float h,
const Color &color,
}
-void PrimitiveMesh::DrawLines() noexcept {
+void PrimitiveMesh::DrawLines() const noexcept {
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.0f);
vao.DrawLineElements();
}
-void PrimitiveMesh::DrawTriangles() noexcept {
- vao.DrawTriangleElements();
-}
-
void SkyBoxMesh::LoadUnitBox() {
Buffer buffer;
vao.PushIndices(ATTRIB_INDEX, buf.indices);
}
-void SkyBoxMesh::Draw() const noexcept {
- vao.DrawTriangleElements();
-}
-
void SpriteMesh::Buffer::LoadRect(
float w, float h,
vao.PushIndices(ATTRIB_INDEX, buf.indices);
}
-
-void SpriteMesh::Draw() noexcept {
- vao.DrawTriangleElements();
-}
-
}
Frustum frustum(transpose(chunk_prog.GetVP()));
AABB box;
- //std::cout << "V = " << chunk_prog.View() << std::endl;
- //std::cout << "P = " << chunk_prog.Projection() << std::endl;
- //std::cout << "VP = " << chunk_prog.GetVP() << std::endl;
- //std::cout << "frustum = " << frustum << std::endl;
-
for (int i = 0; i < index.TotalChunks(); ++i) {
if (!index[i]) continue;
box.min = (index[i]->Position() - index.Base()) * ExactLocation::Extent();
box.max = box.min + ExactLocation::FExtent();
if (!CullTest(box, frustum)) {
-
- //glm::mat4 m(index[i]->Transform(index.Base()));
- //if (CullTest(Chunk::Bounds(), chunk_prog.GetVP() * m)) {
- // std::cout << "M = " << m << std::endl;
- // std::cout << "box = " << box.min << ", " << box.max << std::endl;
- // std::cout << "should've been culled" << std::endl;
- //}
-
if (index[i]->ShouldUpdateMesh()) {
index[i]->Update(models[i]);
}
- chunk_prog.SetM(index[i]->Transform(index.Base()));
- models[i].Draw();
+ if (!models[i].Empty()) {
+ chunk_prog.SetM(index[i]->Transform(index.Base()));
+ models[i].Draw();
+ }
}
}
- //std::cout << std::endl;
}