diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 27bb1108a..dd5396912 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -1133,7 +1133,7 @@ void Graphics::flushStreamDraws() if (sbstate.vertexCount == 0 && sbstate.indexCount == 0) return; - Attributes attributes; + VertexAttributes attributes; BufferBindings buffers; size_t usedsizes[3] = {0, 0, 0}; diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index dd915624c..1ea9607c7 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -212,7 +212,7 @@ public: { PrimitiveType primitiveType = PRIMITIVE_TRIANGLES; - const Attributes *attributes; + const VertexAttributes *attributes; const BufferBindings *buffers; int vertexStart = 0; @@ -224,7 +224,7 @@ public: // TODO: This should be moved out to a state transition API? CullMode cullMode = CULL_NONE; - DrawCommand(const Attributes *attribs, const BufferBindings *buffers) + DrawCommand(const VertexAttributes *attribs, const BufferBindings *buffers) : attributes(attribs) , buffers(buffers) {} @@ -234,7 +234,7 @@ public: { PrimitiveType primitiveType = PRIMITIVE_TRIANGLES; - const Attributes *attributes; + const VertexAttributes *attributes; const BufferBindings *buffers; int indexCount = 0; @@ -249,7 +249,7 @@ public: // TODO: This should be moved out to a state transition API? CullMode cullMode = CULL_NONE; - DrawIndexedCommand(const Attributes *attribs, const BufferBindings *buffers, Resource *indexbuffer) + DrawIndexedCommand(const VertexAttributes *attribs, const BufferBindings *buffers, Resource *indexbuffer) : attributes(attribs) , buffers(buffers) , indexBuffer(indexbuffer) @@ -833,7 +833,7 @@ public: virtual void draw(const DrawCommand &cmd) = 0; virtual void draw(const DrawIndexedCommand &cmd) = 0; - virtual void drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, Texture *texture) = 0; + virtual void drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, Texture *texture) = 0; void flushStreamDraws(); StreamVertexData requestStreamDraw(const StreamDrawCommand &command); diff --git a/src/modules/graphics/Mesh.cpp b/src/modules/graphics/Mesh.cpp index 24f90d435..913941461 100644 --- a/src/modules/graphics/Mesh.cpp +++ b/src/modules/graphics/Mesh.cpp @@ -328,8 +328,8 @@ void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::strin auto it = attachedAttributes.find(name); if (it != attachedAttributes.end()) oldattrib = it->second; - else if (attachedAttributes.size() + 1 > Attributes::MAX) - throw love::Exception("A maximum of %d attributes can be attached at once.", Attributes::MAX); + else if (attachedAttributes.size() + 1 > VertexAttributes::MAX) + throw love::Exception("A maximum of %d attributes can be attached at once.", VertexAttributes::MAX); newattrib.mesh = mesh; newattrib.enabled = oldattrib.mesh ? oldattrib.enabled : true; @@ -580,7 +580,7 @@ void Mesh::drawInstanced(Graphics *gfx, const Matrix4 &m, int instancecount) if (Shader::current && texture.get()) Shader::current->checkMainTexture(texture); - Attributes attributes; + VertexAttributes attributes; BufferBindings buffers; int activebuffers = 0; diff --git a/src/modules/graphics/ParticleSystem.h b/src/modules/graphics/ParticleSystem.h index 1a24266b3..07740a3bd 100644 --- a/src/modules/graphics/ParticleSystem.h +++ b/src/modules/graphics/ParticleSystem.h @@ -744,7 +744,7 @@ private: bool relativeRotation; - const Attributes vertexAttributes; + const VertexAttributes vertexAttributes; Buffer *buffer; static StringMap::Entry distributionsEntries[]; diff --git a/src/modules/graphics/SpriteBatch.cpp b/src/modules/graphics/SpriteBatch.cpp index aaaf1e7ea..41da30043 100644 --- a/src/modules/graphics/SpriteBatch.cpp +++ b/src/modules/graphics/SpriteBatch.cpp @@ -315,7 +315,7 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m) // Make sure the buffer isn't mapped when we draw (sends data to GPU if needed.) array_buf->unmap(); - Attributes attributes; + VertexAttributes attributes; BufferBindings buffers; { diff --git a/src/modules/graphics/Text.h b/src/modules/graphics/Text.h index 3199b0074..0e3259919 100644 --- a/src/modules/graphics/Text.h +++ b/src/modules/graphics/Text.h @@ -85,7 +85,7 @@ private: StrongRef font; - Attributes vertexAttributes; + VertexAttributes vertexAttributes; BufferBindings vertexBuffers; Buffer *vertex_buffer; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index b2fcba39d..e17028d46 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -385,13 +385,13 @@ void Graphics::draw(const DrawIndexedCommand &cmd) ++drawCalls; } -static inline void advanceVertexOffsets(const Attributes &attributes, BufferBindings &buffers, int vertexcount) +static inline void advanceVertexOffsets(const VertexAttributes &attributes, BufferBindings &buffers, int vertexcount) { // TODO: Figure out a better way to avoid touching the same buffer multiple // times, if multiple attributes share the buffer. uint32 touchedbuffers = 0; - for (unsigned int i = 0; i < Attributes::MAX; i++) + for (unsigned int i = 0; i < VertexAttributes::MAX; i++) { if (!attributes.isEnabled(i)) continue; @@ -408,7 +408,7 @@ static inline void advanceVertexOffsets(const Attributes &attributes, BufferBind } } -void Graphics::drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, love::graphics::Texture *texture) +void Graphics::drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, love::graphics::Texture *texture) { const int MAX_VERTICES_PER_DRAW = LOVE_UINT16_MAX; const int MAX_QUADS_PER_DRAW = MAX_VERTICES_PER_DRAW / 4; diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 8f2f69a88..36c63d64c 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -74,7 +74,7 @@ public: void draw(const DrawCommand &cmd) override; void draw(const DrawIndexedCommand &cmd) override; - void drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, Texture *texture) override; + void drawQuads(int start, int count, const VertexAttributes &attributes, const BufferBindings &buffers, Texture *texture) override; void clear(OptionalColorf color, OptionalInt stencil, OptionalDouble depth) override; void clear(const std::vector &colors, OptionalInt stencil, OptionalDouble depth) override; diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 601808254..a2c36d192 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -186,7 +186,7 @@ void OpenGL::setupContext() state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1); state.instancedAttribArrays = 0; - setVertexAttributes(Attributes(), BufferBindings()); + setVertexAttributes(VertexAttributes(), BufferBindings()); // Get the current viewport. glGetIntegerv(GL_VIEWPORT, (GLint *) &state.viewport.x); @@ -713,7 +713,7 @@ void OpenGL::deleteBuffer(GLuint buffer) } } -void OpenGL::setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers) +void OpenGL::setVertexAttributes(const VertexAttributes &attributes, const BufferBindings &buffers) { uint32 enablediff = attributes.enableBits ^ state.enabledAttribArrays; uint32 instanceattribbits = 0; diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index f174a0b22..264a9fe3b 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -238,7 +238,7 @@ public: /** * Set all vertex attribute state. **/ - void setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers); + void setVertexAttributes(const VertexAttributes &attributes, const BufferBindings &buffers); /** * Wrapper for glCullFace which eliminates redundant state setting. diff --git a/src/modules/graphics/vertex.cpp b/src/modules/graphics/vertex.cpp index 8366515ce..3e3549c64 100644 --- a/src/modules/graphics/vertex.cpp +++ b/src/modules/graphics/vertex.cpp @@ -236,7 +236,7 @@ void fillIndices(TriangleIndexMode mode, uint32 vertexStart, uint32 vertexCount, fillIndicesT(mode, vertexStart, vertexCount, indices); } -void Attributes::setCommonFormat(CommonFormat format, uint8 bufferindex) +void VertexAttributes::setCommonFormat(CommonFormat format, uint8 bufferindex) { setBufferLayout(bufferindex, (uint16) getFormatStride(format)); diff --git a/src/modules/graphics/vertex.h b/src/modules/graphics/vertex.h index 8c8a6aa80..219193489 100644 --- a/src/modules/graphics/vertex.h +++ b/src/modules/graphics/vertex.h @@ -230,7 +230,7 @@ struct BufferBindings void clear() { useBits = 0; } }; -struct AttributeInfo +struct VertexAttributeInfo { uint8 bufferIndex; DataType type : 4; @@ -238,23 +238,23 @@ struct AttributeInfo uint16 offsetFromVertex; }; -struct BufferLayout +struct VertexBufferLayout { uint16 stride; }; -struct Attributes +struct VertexAttributes { static const uint32 MAX = 32; uint32 enableBits = 0; // indexed by attribute uint32 instanceBits = 0; // indexed by buffer - AttributeInfo attribs[MAX]; - BufferLayout bufferLayouts[BufferBindings::MAX]; + VertexAttributeInfo attribs[MAX]; + VertexBufferLayout bufferLayouts[BufferBindings::MAX]; - Attributes() {} - Attributes(CommonFormat format, uint8 bufferindex) + VertexAttributes() {} + VertexAttributes(CommonFormat format, uint8 bufferindex) { setCommonFormat(format, bufferindex); }