Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-07-20 13:50:24 +0000
committerStijn Buys <ingar@osirion.org>2008-07-20 13:50:24 +0000
commitaaaae14884eefe5571b5c5d6ce1606085e0b9376 (patch)
tree1a35d43e22497dd233afbcb5a67456e914005b64 /src/model/vertexarray.cc
parentc3d90b226bdd83592d08704aa918f155f4c757e2 (diff)
handle vertexarray overflows more gracefull
Diffstat (limited to 'src/model/vertexarray.cc')
-rw-r--r--src/model/vertexarray.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc
index b0da6ab..27124fa 100644
--- a/src/model/vertexarray.cc
+++ b/src/model/vertexarray.cc
@@ -44,11 +44,12 @@ VertexArray::~VertexArray()
void VertexArray::clear()
{
vertex_index = 0;
+ vertex_overflow = false;
memset(vertex_vertex, 0, sizeof(vertex_vertex));
memset(vertex_color, 0, sizeof(vertex_color));
memset(vertex_normal, 0, sizeof(vertex_normal));
- memset(vertex_texture, 0, sizeof(vertex_normal));
+ memset(vertex_texture, 0, sizeof(vertex_texture));
add_sphere();
}
@@ -128,10 +129,11 @@ void VertexArray::add_sphere()
delete[] costable;
}
-void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color) {
+size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color) {
if (vertex_index + 3 >= vertex_size) {
con_warn << "VertexArray overflow!" << std::endl;
- return;
+ vertex_overflow = true;
+ return 0;
}
for (int i = 0; i < 3; i ++) {
@@ -144,12 +146,15 @@ void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, m
vertex_color[vertex_index+2] = color.b;
vertex_index += 3;
+
+ return 1;
}
-void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, math::Vector3f const &tex) {
+size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, math::Vector3f const &tex) {
if (vertex_index + 3 >= vertex_size) {
con_warn << "VertexArray overflow!" << std::endl;
- return;
+ vertex_overflow = true;
+ return 0;
}
for (int i = 0; i < 3; i ++) {
@@ -163,6 +168,7 @@ void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, m
vertex_color[vertex_index+2] = color.b;
vertex_index += 3;
+ return 1;
}
}