Hash :
004a6f9f
Author :
Date :
2013-07-10T15:13:38
Move VAO buffer clearing code to the destructor, instead of the constructor. This fixes assertion failures during the VertexArray destructor in Debug mode. TRAC #23390 Signed-off-by: Shannon Woods Signed-off-by: Geoff Lang Authored-by: Jamie Madill
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#include "precompiled.h"
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Implementation of the state class for mananging GLES 3 Vertex Array Objects.
//
#include "libGLESv2/VertexArray.h"
#include "libGLESv2/Buffer.h"
namespace gl
{
VertexArray::VertexArray(rx::Renderer *renderer, GLuint id)
: RefCountObject(id)
{
}
VertexArray::~VertexArray()
{
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
mVertexAttributes[i].mBoundBuffer.set(NULL);
}
mElementArrayBuffer.set(NULL);
}
void VertexArray::detachBuffer(GLuint bufferName)
{
for (int attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
{
if (mVertexAttributes[attribute].mBoundBuffer.id() == bufferName)
{
mVertexAttributes[attribute].mBoundBuffer.set(NULL);
}
}
if (mElementArrayBuffer.id() == bufferName)
{
mElementArrayBuffer.set(NULL);
}
}
const VertexAttribute& VertexArray::getVertexAttribute(unsigned int attributeIndex) const
{
ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS);
return mVertexAttributes[attributeIndex];
}
void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor)
{
ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
mVertexAttributes[index].mDivisor = divisor;
}
void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState)
{
ASSERT(attributeIndex < gl::MAX_VERTEX_ATTRIBS);
mVertexAttributes[attributeIndex].mArrayEnabled = enabledState;
}
void VertexArray::setAttributeState(unsigned int attributeIndex, gl::Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer)
{
ASSERT(attributeIndex < gl::MAX_VERTEX_ATTRIBS);
mVertexAttributes[attributeIndex].setState(boundBuffer, size, type, normalized, pureInteger, stride, pointer);
}
}