From 99b656a7c44859a038156b82365122a5e336b1e8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 May 2008 14:42:17 +0000 Subject: [PATCH] Add Mesh::use_vertex_buffer Change VertexArray::use_vertex_buffer semantics to allow disabling vertex buffer Initialize ObjectPass:use_textures in constructor --- source/mesh.cpp | 12 ++++++++---- source/mesh.h | 2 ++ source/objectpass.cpp | 3 ++- source/vertexarray.cpp | 10 +++++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/source/mesh.cpp b/source/mesh.cpp index cba1bf57..44005514 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -14,14 +14,18 @@ namespace GL { Mesh::Mesh(): vertices(NODATA) -{ - vertices.use_vertex_buffer(); -} +{ } Mesh::Mesh(VertexFormat f): vertices(f) +{ } + +void Mesh::use_vertex_buffer(bool b) { - vertices.use_vertex_buffer(); + if(b) + vertices.use_vertex_buffer(); + else + vertices.use_vertex_buffer(0); } RefPtr Mesh::modify() diff --git a/source/mesh.h b/source/mesh.h index 2a5ce474..8e1f906c 100644 --- a/source/mesh.h +++ b/source/mesh.h @@ -39,6 +39,8 @@ private: public: Mesh(); Mesh(VertexFormat f); + + void use_vertex_buffer(bool); RefPtr modify(); const VertexArray &get_vertices() const { return vertices; } void add_batch(const Batch &b); diff --git a/source/objectpass.cpp b/source/objectpass.cpp index 92864b45..afb9f45d 100644 --- a/source/objectpass.cpp +++ b/source/objectpass.cpp @@ -16,7 +16,8 @@ namespace GL { ObjectPass::ObjectPass(): shprog(0), - shdata(0) + shdata(0), + use_textures(true) { } ObjectPass::~ObjectPass() diff --git a/source/vertexarray.cpp b/source/vertexarray.cpp index c0ca8dca..0d4fd919 100644 --- a/source/vertexarray.cpp +++ b/source/vertexarray.cpp @@ -33,18 +33,22 @@ VertexArray::~VertexArray() void VertexArray::use_vertex_buffer() { - if(vbuf) return; + if(vbuf && own_vbuf) + return; vbuf=new VertexBuffer(); own_vbuf=true; + update_data(); } void VertexArray::use_vertex_buffer(VertexBuffer *b) { - if(vbuf) return; - + if(own_vbuf) + delete vbuf; vbuf=b; + own_vbuf=false; + update_data(); } -- 2.45.2