mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Rename Attributes struct to VertexAttributes
This commit is contained in:
@@ -1133,7 +1133,7 @@ void Graphics::flushStreamDraws()
|
|||||||
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
|
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Attributes attributes;
|
VertexAttributes attributes;
|
||||||
BufferBindings buffers;
|
BufferBindings buffers;
|
||||||
|
|
||||||
size_t usedsizes[3] = {0, 0, 0};
|
size_t usedsizes[3] = {0, 0, 0};
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
{
|
{
|
||||||
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
|
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
|
||||||
|
|
||||||
const Attributes *attributes;
|
const VertexAttributes *attributes;
|
||||||
const BufferBindings *buffers;
|
const BufferBindings *buffers;
|
||||||
|
|
||||||
int vertexStart = 0;
|
int vertexStart = 0;
|
||||||
@@ -224,7 +224,7 @@ public:
|
|||||||
// TODO: This should be moved out to a state transition API?
|
// TODO: This should be moved out to a state transition API?
|
||||||
CullMode cullMode = CULL_NONE;
|
CullMode cullMode = CULL_NONE;
|
||||||
|
|
||||||
DrawCommand(const Attributes *attribs, const BufferBindings *buffers)
|
DrawCommand(const VertexAttributes *attribs, const BufferBindings *buffers)
|
||||||
: attributes(attribs)
|
: attributes(attribs)
|
||||||
, buffers(buffers)
|
, buffers(buffers)
|
||||||
{}
|
{}
|
||||||
@@ -234,7 +234,7 @@ public:
|
|||||||
{
|
{
|
||||||
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
|
PrimitiveType primitiveType = PRIMITIVE_TRIANGLES;
|
||||||
|
|
||||||
const Attributes *attributes;
|
const VertexAttributes *attributes;
|
||||||
const BufferBindings *buffers;
|
const BufferBindings *buffers;
|
||||||
|
|
||||||
int indexCount = 0;
|
int indexCount = 0;
|
||||||
@@ -249,7 +249,7 @@ public:
|
|||||||
// TODO: This should be moved out to a state transition API?
|
// TODO: This should be moved out to a state transition API?
|
||||||
CullMode cullMode = CULL_NONE;
|
CullMode cullMode = CULL_NONE;
|
||||||
|
|
||||||
DrawIndexedCommand(const Attributes *attribs, const BufferBindings *buffers, Resource *indexbuffer)
|
DrawIndexedCommand(const VertexAttributes *attribs, const BufferBindings *buffers, Resource *indexbuffer)
|
||||||
: attributes(attribs)
|
: attributes(attribs)
|
||||||
, buffers(buffers)
|
, buffers(buffers)
|
||||||
, indexBuffer(indexbuffer)
|
, indexBuffer(indexbuffer)
|
||||||
@@ -833,7 +833,7 @@ public:
|
|||||||
|
|
||||||
virtual void draw(const DrawCommand &cmd) = 0;
|
virtual void draw(const DrawCommand &cmd) = 0;
|
||||||
virtual void draw(const DrawIndexedCommand &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();
|
void flushStreamDraws();
|
||||||
StreamVertexData requestStreamDraw(const StreamDrawCommand &command);
|
StreamVertexData requestStreamDraw(const StreamDrawCommand &command);
|
||||||
|
|||||||
@@ -328,8 +328,8 @@ void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::strin
|
|||||||
auto it = attachedAttributes.find(name);
|
auto it = attachedAttributes.find(name);
|
||||||
if (it != attachedAttributes.end())
|
if (it != attachedAttributes.end())
|
||||||
oldattrib = it->second;
|
oldattrib = it->second;
|
||||||
else if (attachedAttributes.size() + 1 > Attributes::MAX)
|
else if (attachedAttributes.size() + 1 > VertexAttributes::MAX)
|
||||||
throw love::Exception("A maximum of %d attributes can be attached at once.", Attributes::MAX);
|
throw love::Exception("A maximum of %d attributes can be attached at once.", VertexAttributes::MAX);
|
||||||
|
|
||||||
newattrib.mesh = mesh;
|
newattrib.mesh = mesh;
|
||||||
newattrib.enabled = oldattrib.mesh ? oldattrib.enabled : true;
|
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())
|
if (Shader::current && texture.get())
|
||||||
Shader::current->checkMainTexture(texture);
|
Shader::current->checkMainTexture(texture);
|
||||||
|
|
||||||
Attributes attributes;
|
VertexAttributes attributes;
|
||||||
BufferBindings buffers;
|
BufferBindings buffers;
|
||||||
|
|
||||||
int activebuffers = 0;
|
int activebuffers = 0;
|
||||||
|
|||||||
@@ -744,7 +744,7 @@ private:
|
|||||||
|
|
||||||
bool relativeRotation;
|
bool relativeRotation;
|
||||||
|
|
||||||
const Attributes vertexAttributes;
|
const VertexAttributes vertexAttributes;
|
||||||
Buffer *buffer;
|
Buffer *buffer;
|
||||||
|
|
||||||
static StringMap<AreaSpreadDistribution, DISTRIBUTION_MAX_ENUM>::Entry distributionsEntries[];
|
static StringMap<AreaSpreadDistribution, DISTRIBUTION_MAX_ENUM>::Entry distributionsEntries[];
|
||||||
|
|||||||
@@ -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.)
|
// Make sure the buffer isn't mapped when we draw (sends data to GPU if needed.)
|
||||||
array_buf->unmap();
|
array_buf->unmap();
|
||||||
|
|
||||||
Attributes attributes;
|
VertexAttributes attributes;
|
||||||
BufferBindings buffers;
|
BufferBindings buffers;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ private:
|
|||||||
|
|
||||||
StrongRef<Font> font;
|
StrongRef<Font> font;
|
||||||
|
|
||||||
Attributes vertexAttributes;
|
VertexAttributes vertexAttributes;
|
||||||
BufferBindings vertexBuffers;
|
BufferBindings vertexBuffers;
|
||||||
|
|
||||||
Buffer *vertex_buffer;
|
Buffer *vertex_buffer;
|
||||||
|
|||||||
@@ -385,13 +385,13 @@ void Graphics::draw(const DrawIndexedCommand &cmd)
|
|||||||
++drawCalls;
|
++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
|
// TODO: Figure out a better way to avoid touching the same buffer multiple
|
||||||
// times, if multiple attributes share the buffer.
|
// times, if multiple attributes share the buffer.
|
||||||
uint32 touchedbuffers = 0;
|
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))
|
if (!attributes.isEnabled(i))
|
||||||
continue;
|
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_VERTICES_PER_DRAW = LOVE_UINT16_MAX;
|
||||||
const int MAX_QUADS_PER_DRAW = MAX_VERTICES_PER_DRAW / 4;
|
const int MAX_QUADS_PER_DRAW = MAX_VERTICES_PER_DRAW / 4;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
void draw(const DrawCommand &cmd) override;
|
void draw(const DrawCommand &cmd) override;
|
||||||
void draw(const DrawIndexedCommand &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(OptionalColorf color, OptionalInt stencil, OptionalDouble depth) override;
|
||||||
void clear(const std::vector<OptionalColorf> &colors, OptionalInt stencil, OptionalDouble depth) override;
|
void clear(const std::vector<OptionalColorf> &colors, OptionalInt stencil, OptionalDouble depth) override;
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void OpenGL::setupContext()
|
|||||||
state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1);
|
state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1);
|
||||||
state.instancedAttribArrays = 0;
|
state.instancedAttribArrays = 0;
|
||||||
|
|
||||||
setVertexAttributes(Attributes(), BufferBindings());
|
setVertexAttributes(VertexAttributes(), BufferBindings());
|
||||||
|
|
||||||
// Get the current viewport.
|
// Get the current viewport.
|
||||||
glGetIntegerv(GL_VIEWPORT, (GLint *) &state.viewport.x);
|
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 enablediff = attributes.enableBits ^ state.enabledAttribArrays;
|
||||||
uint32 instanceattribbits = 0;
|
uint32 instanceattribbits = 0;
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Set all vertex attribute state.
|
* 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.
|
* Wrapper for glCullFace which eliminates redundant state setting.
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ void fillIndices(TriangleIndexMode mode, uint32 vertexStart, uint32 vertexCount,
|
|||||||
fillIndicesT(mode, vertexStart, vertexCount, indices);
|
fillIndicesT(mode, vertexStart, vertexCount, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
|
void VertexAttributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
|
||||||
{
|
{
|
||||||
setBufferLayout(bufferindex, (uint16) getFormatStride(format));
|
setBufferLayout(bufferindex, (uint16) getFormatStride(format));
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ struct BufferBindings
|
|||||||
void clear() { useBits = 0; }
|
void clear() { useBits = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AttributeInfo
|
struct VertexAttributeInfo
|
||||||
{
|
{
|
||||||
uint8 bufferIndex;
|
uint8 bufferIndex;
|
||||||
DataType type : 4;
|
DataType type : 4;
|
||||||
@@ -238,23 +238,23 @@ struct AttributeInfo
|
|||||||
uint16 offsetFromVertex;
|
uint16 offsetFromVertex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BufferLayout
|
struct VertexBufferLayout
|
||||||
{
|
{
|
||||||
uint16 stride;
|
uint16 stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Attributes
|
struct VertexAttributes
|
||||||
{
|
{
|
||||||
static const uint32 MAX = 32;
|
static const uint32 MAX = 32;
|
||||||
|
|
||||||
uint32 enableBits = 0; // indexed by attribute
|
uint32 enableBits = 0; // indexed by attribute
|
||||||
uint32 instanceBits = 0; // indexed by buffer
|
uint32 instanceBits = 0; // indexed by buffer
|
||||||
|
|
||||||
AttributeInfo attribs[MAX];
|
VertexAttributeInfo attribs[MAX];
|
||||||
BufferLayout bufferLayouts[BufferBindings::MAX];
|
VertexBufferLayout bufferLayouts[BufferBindings::MAX];
|
||||||
|
|
||||||
Attributes() {}
|
VertexAttributes() {}
|
||||||
Attributes(CommonFormat format, uint8 bufferindex)
|
VertexAttributes(CommonFormat format, uint8 bufferindex)
|
||||||
{
|
{
|
||||||
setCommonFormat(format, bufferindex);
|
setCommonFormat(format, bufferindex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user