From 813fefd59901ff07b0e010c98111357a71efaba8 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 18 Aug 2016 11:26:25 -0700 Subject: [PATCH] reimplement buffer get for (c)end --- libraries/gpu/src/gpu/Buffer.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/gpu/src/gpu/Buffer.h b/libraries/gpu/src/gpu/Buffer.h index da1a987bee..8160f648fc 100644 --- a/libraries/gpu/src/gpu/Buffer.h +++ b/libraries/gpu/src/gpu/Buffer.h @@ -293,10 +293,18 @@ public: template Iterator end() { return Iterator(&edit(getNum()), _stride); } #else template Iterator begin() const { return Iterator(&get(), _stride); } - template Iterator end() const { return Iterator(&get(getNum()), _stride); } + template Iterator end() const { + // reimplement get without bounds checking + Resource::Size elementOffset = getNum() * _stride + _offset; + return Iterator((reinterpret_cast (_buffer->getData() + elementOffset)), _stride); + } #endif template Iterator cbegin() const { return Iterator(&get(), _stride); } - template Iterator cend() const { return Iterator(&get(getNum()), _stride); } + template Iterator cend() const { + // reimplement get without bounds checking + Resource::Size elementOffset = getNum() * _stride + _offset; + return Iterator((reinterpret_cast (_buffer->getData() + elementOffset)), _stride); + } // the number of elements of the specified type fitting in the view size template Index getNum() const {