Commit e501b8b1 by Alexis Hetu Committed by Alexis Hétu

VertexArray Object implementation

Added VertexArray.cpp with a few trivial function implementations. Change-Id: I9ea0bf47b2c6a1f76392c5fc84837f1778946855 Reviewed-on: https://swiftshader-review.googlesource.com/2984Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 8e32f7bf
......@@ -24,6 +24,7 @@ LOCAL_SRC_FILES += \
Texture.cpp \
TransformFeedback.cpp \
utilities.cpp \
VertexArray.cpp \
VertexDataManager.cpp \
LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv2_swiftshader\"
......
// SwiftShader Software Renderer
//
// Copyright(c) 2015 Google Inc.
//
// All rights reserved. No part of this software may be copied, distributed, transmitted,
// transcribed, stored in a retrieval system, translated into any human or computer
// language by any means, or disclosed to third parties without the explicit written
// agreement of Google Inc. Without such an agreement, no rights or licenses, express
// or implied, including but not limited to any patent rights, are granted to you.
//
#include "VertexArray.h"
namespace es2
{
VertexArray::VertexArray(GLuint name) : gl::NamedObject(name)
{
}
VertexArray::~VertexArray()
{
for(size_t i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
mVertexAttributes[i].mBoundBuffer = NULL;
}
mElementArrayBuffer = NULL;
}
void VertexArray::detachBuffer(GLuint bufferName)
{
for(size_t attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
{
if(mVertexAttributes[attribute].mBoundBuffer.name() == bufferName)
{
mVertexAttributes[attribute].mBoundBuffer = NULL;
}
}
if (mElementArrayBuffer.name() == bufferName)
{
mElementArrayBuffer = NULL;
}
}
const VertexAttribute& VertexArray::getVertexAttribute(size_t attributeIndex) const
{
ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS);
return mVertexAttributes[attributeIndex];
}
void VertexArray::setVertexAttribDivisor(GLuint index, GLuint divisor)
{
ASSERT(index < MAX_VERTEX_ATTRIBS);
mVertexAttributes[index].mDivisor = divisor;
}
void VertexArray::enableAttribute(unsigned int attributeIndex, bool enabledState)
{
ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS);
mVertexAttributes[attributeIndex].mArrayEnabled = enabledState;
}
void VertexArray::setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, GLsizei stride, const void *pointer)
{
ASSERT(attributeIndex < MAX_VERTEX_ATTRIBS);
mVertexAttributes[attributeIndex].mBoundBuffer = boundBuffer;
mVertexAttributes[attributeIndex].mSize = size;
mVertexAttributes[attributeIndex].mType = type;
mVertexAttributes[attributeIndex].mNormalized = normalized;
mVertexAttributes[attributeIndex].mStride = stride;
mVertexAttributes[attributeIndex].mPointer = pointer;
}
void VertexArray::setElementArrayBuffer(Buffer *buffer)
{
mElementArrayBuffer = buffer;
}
}
......@@ -14,17 +14,33 @@
#ifndef LIBGLESV2_VERTEX_ARRAY_H_
#define LIBGLESV2_VERTEX_ARRAY_H_
#include "common/Object.hpp"
#include "Renderer/Renderer.hpp"
#define GL_APICALL
#include <GLES2/gl2.h>
#include "Buffer.h"
#include "Context.h"
namespace es2
{
class VertexArray : public gl::Object
class VertexArray : public gl::NamedObject
{
public:
VertexArray(GLuint name);
~VertexArray();
const VertexAttribute& getVertexAttribute(size_t attributeIndex) const;
VertexAttributeArray& getVertexAttributes() { return mVertexAttributes; }
void detachBuffer(GLuint bufferName);
void setVertexAttribDivisor(GLuint index, GLuint divisor);
void enableAttribute(unsigned int attributeIndex, bool enabledState);
void setAttributeState(unsigned int attributeIndex, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, GLsizei stride, const void *pointer);
Buffer *getElementArrayBuffer() const { return mElementArrayBuffer; }
void setElementArrayBuffer(Buffer *buffer);
private:
VertexAttributeArray mVertexAttributes;
gl::BindingPointer<Buffer> mElementArrayBuffer;
};
}
......
......@@ -368,6 +368,7 @@
<Unit filename="Texture.h" />
<Unit filename="TransformFeedback.cpp" />
<Unit filename="TransformFeedback.h" />
<Unit filename="VertexArray.cpp" />
<Unit filename="VertexArray.h" />
<Unit filename="VertexDataManager.cpp" />
<Unit filename="VertexDataManager.h" />
......
......@@ -339,6 +339,7 @@ copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)_$(Plat
<ClCompile Include="Texture.cpp" />
<ClCompile Include="TransformFeedback.cpp" />
<ClCompile Include="utilities.cpp" />
<ClCompile Include="VertexArray.cpp" />
<ClCompile Include="VertexDataManager.cpp" />
</ItemGroup>
<ItemGroup>
......
......@@ -77,6 +77,9 @@
<ClCompile Include="TransformFeedback.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VertexArray.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment