mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Make VertexBuffer::Usage a scoped enumeration
This commit is contained in:
parent
a019b5167b
commit
0d3c7f1c32
@ -99,7 +99,7 @@ int main()
|
||||
sf::Text statusText(font);
|
||||
sf::Shader terrainShader;
|
||||
const sf::RenderStates terrainStates(&terrainShader);
|
||||
sf::VertexBuffer terrain(sf::PrimitiveType::Triangles, sf::VertexBuffer::Static);
|
||||
sf::VertexBuffer terrain(sf::PrimitiveType::Triangles, sf::VertexBuffer::Usage::Static);
|
||||
|
||||
// Set up our text drawables
|
||||
statusText.setCharacterSize(28);
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
/// good compromise.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Usage
|
||||
enum class Usage
|
||||
{
|
||||
Stream, //!< Constantly changing data
|
||||
Dynamic, //!< Occasionally changing data
|
||||
@ -270,7 +270,7 @@ public:
|
||||
/// to be updated with new data for the usage specifier to
|
||||
/// take effect.
|
||||
///
|
||||
/// The default primitive type is sf::VertexBuffer::Stream.
|
||||
/// The default usage type is sf::VertexBuffer::Usage::Stream.
|
||||
///
|
||||
/// \param usage Usage specifier
|
||||
///
|
||||
@ -336,7 +336,7 @@ private:
|
||||
unsigned int m_buffer{}; //!< Internal buffer identifier
|
||||
std::size_t m_size{}; //!< Size in Vertices of the currently allocated buffer
|
||||
PrimitiveType m_primitiveType{PrimitiveType::Points}; //!< Type of primitives to draw
|
||||
Usage m_usage{Stream}; //!< How this vertex buffer is to be used
|
||||
Usage m_usage{Usage::Stream}; //!< How this vertex buffer is to be used
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -47,9 +47,9 @@ GLenum usageToGlEnum(sf::VertexBuffer::Usage usage)
|
||||
{
|
||||
switch (usage)
|
||||
{
|
||||
case sf::VertexBuffer::Static:
|
||||
case sf::VertexBuffer::Usage::Static:
|
||||
return GLEXT_GL_STATIC_DRAW;
|
||||
case sf::VertexBuffer::Dynamic:
|
||||
case sf::VertexBuffer::Usage::Dynamic:
|
||||
return GLEXT_GL_DYNAMIC_DRAW;
|
||||
default:
|
||||
return GLEXT_GL_STREAM_DRAW;
|
||||
|
@ -35,7 +35,7 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
CHECK(vertexBuffer.getVertexCount() == 0);
|
||||
CHECK(vertexBuffer.getNativeHandle() == 0);
|
||||
CHECK(vertexBuffer.getPrimitiveType() == sf::PrimitiveType::Points);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Stream);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Usage::Stream);
|
||||
}
|
||||
|
||||
SECTION("Primitive type constructor")
|
||||
@ -44,31 +44,31 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
CHECK(vertexBuffer.getVertexCount() == 0);
|
||||
CHECK(vertexBuffer.getNativeHandle() == 0);
|
||||
CHECK(vertexBuffer.getPrimitiveType() == sf::PrimitiveType::Triangles);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Stream);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Usage::Stream);
|
||||
}
|
||||
|
||||
SECTION("Usage constructor")
|
||||
{
|
||||
const sf::VertexBuffer vertexBuffer(sf::VertexBuffer::Static);
|
||||
const sf::VertexBuffer vertexBuffer(sf::VertexBuffer::Usage::Static);
|
||||
CHECK(vertexBuffer.getVertexCount() == 0);
|
||||
CHECK(vertexBuffer.getNativeHandle() == 0);
|
||||
CHECK(vertexBuffer.getPrimitiveType() == sf::PrimitiveType::Points);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Static);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Usage::Static);
|
||||
}
|
||||
|
||||
SECTION("Primitive type and usage constructor")
|
||||
{
|
||||
const sf::VertexBuffer vertexBuffer(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Dynamic);
|
||||
const sf::VertexBuffer vertexBuffer(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Usage::Dynamic);
|
||||
CHECK(vertexBuffer.getVertexCount() == 0);
|
||||
CHECK(vertexBuffer.getNativeHandle() == 0);
|
||||
CHECK(vertexBuffer.getPrimitiveType() == sf::PrimitiveType::LineStrip);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Dynamic);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Usage::Dynamic);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Copy semantics")
|
||||
{
|
||||
const sf::VertexBuffer vertexBuffer(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Dynamic);
|
||||
const sf::VertexBuffer vertexBuffer(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Usage::Dynamic);
|
||||
|
||||
SECTION("Construction")
|
||||
{
|
||||
@ -76,7 +76,7 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
CHECK(vertexBufferCopy.getVertexCount() == 0);
|
||||
CHECK(vertexBufferCopy.getNativeHandle() == 0);
|
||||
CHECK(vertexBufferCopy.getPrimitiveType() == sf::PrimitiveType::LineStrip);
|
||||
CHECK(vertexBufferCopy.getUsage() == sf::VertexBuffer::Dynamic);
|
||||
CHECK(vertexBufferCopy.getUsage() == sf::VertexBuffer::Usage::Dynamic);
|
||||
}
|
||||
|
||||
SECTION("Assignment")
|
||||
@ -86,7 +86,7 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
CHECK(vertexBufferCopy.getVertexCount() == 0);
|
||||
CHECK(vertexBufferCopy.getNativeHandle() == 0);
|
||||
CHECK(vertexBufferCopy.getPrimitiveType() == sf::PrimitiveType::LineStrip);
|
||||
CHECK(vertexBufferCopy.getUsage() == sf::VertexBuffer::Dynamic);
|
||||
CHECK(vertexBufferCopy.getUsage() == sf::VertexBuffer::Usage::Dynamic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,10 +146,10 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
|
||||
SECTION("swap()")
|
||||
{
|
||||
sf::VertexBuffer vertexBuffer1(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Dynamic);
|
||||
sf::VertexBuffer vertexBuffer1(sf::PrimitiveType::LineStrip, sf::VertexBuffer::Usage::Dynamic);
|
||||
CHECK(vertexBuffer1.create(50));
|
||||
|
||||
sf::VertexBuffer vertexBuffer2(sf::PrimitiveType::TriangleStrip, sf::VertexBuffer::Stream);
|
||||
sf::VertexBuffer vertexBuffer2(sf::PrimitiveType::TriangleStrip, sf::VertexBuffer::Usage::Stream);
|
||||
CHECK(vertexBuffer2.create(60));
|
||||
|
||||
sf::swap(vertexBuffer1, vertexBuffer2);
|
||||
@ -157,12 +157,12 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
CHECK(vertexBuffer1.getVertexCount() == 60);
|
||||
CHECK(vertexBuffer1.getNativeHandle() != 0);
|
||||
CHECK(vertexBuffer1.getPrimitiveType() == sf::PrimitiveType::TriangleStrip);
|
||||
CHECK(vertexBuffer1.getUsage() == sf::VertexBuffer::Stream);
|
||||
CHECK(vertexBuffer1.getUsage() == sf::VertexBuffer::Usage::Stream);
|
||||
|
||||
CHECK(vertexBuffer2.getVertexCount() == 50);
|
||||
CHECK(vertexBuffer2.getNativeHandle() != 0);
|
||||
CHECK(vertexBuffer2.getPrimitiveType() == sf::PrimitiveType::LineStrip);
|
||||
CHECK(vertexBuffer2.getUsage() == sf::VertexBuffer::Dynamic);
|
||||
CHECK(vertexBuffer2.getUsage() == sf::VertexBuffer::Usage::Dynamic);
|
||||
}
|
||||
|
||||
SECTION("Set/get primitive type")
|
||||
@ -175,7 +175,7 @@ TEST_CASE("[Graphics] sf::VertexBuffer", "[.display]")
|
||||
SECTION("Set/get usage")
|
||||
{
|
||||
sf::VertexBuffer vertexBuffer;
|
||||
vertexBuffer.setUsage(sf::VertexBuffer::Dynamic);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Dynamic);
|
||||
vertexBuffer.setUsage(sf::VertexBuffer::Usage::Dynamic);
|
||||
CHECK(vertexBuffer.getUsage() == sf::VertexBuffer::Usage::Dynamic);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user