mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Remove vertex namespace
This commit is contained in:
@@ -35,7 +35,7 @@ namespace graphics
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
Buffer::Buffer(size_t size, const void *data, BufferTypeFlags typeflags, vertex::Usage usage, uint32 mapflags)
|
||||
Buffer::Buffer(size_t size, const void *data, BufferTypeFlags typeflags, BufferUsage usage, uint32 mapflags)
|
||||
: love::graphics::Buffer(size, typeflags, usage, mapflags)
|
||||
, vbo(0)
|
||||
, memoryMap(nullptr)
|
||||
@@ -141,13 +141,13 @@ void Buffer::unmap()
|
||||
{
|
||||
switch (getUsage())
|
||||
{
|
||||
case vertex::USAGE_STATIC:
|
||||
case BUFFERUSAGE_STATIC:
|
||||
unmapStatic(modifiedOffset, modifiedSize);
|
||||
break;
|
||||
case vertex::USAGE_STREAM:
|
||||
case BUFFERUSAGE_STREAM:
|
||||
unmapStream();
|
||||
break;
|
||||
case vertex::USAGE_DYNAMIC:
|
||||
case BUFFERUSAGE_DYNAMIC:
|
||||
default:
|
||||
// It's probably more efficient to treat it like a streaming buffer if
|
||||
// at least a third of its contents have been modified during the map().
|
||||
|
||||
@@ -39,7 +39,7 @@ class Buffer final : public love::graphics::Buffer, public Volatile
|
||||
{
|
||||
public:
|
||||
|
||||
Buffer(size_t size, const void *data, BufferTypeFlags typeflags, vertex::Usage usage, uint32 mapflags);
|
||||
Buffer(size_t size, const void *data, BufferTypeFlags typeflags, BufferUsage usage, uint32 mapflags);
|
||||
virtual ~Buffer();
|
||||
|
||||
void *map() override;
|
||||
|
||||
@@ -155,7 +155,7 @@ love::graphics::Shader *Graphics::newShaderInternal(love::graphics::ShaderStage
|
||||
return new Shader(vertex, pixel);
|
||||
}
|
||||
|
||||
love::graphics::Buffer *Graphics::newBuffer(size_t size, const void *data, BufferTypeFlags typeflags, vertex::Usage usage, uint32 mapflags)
|
||||
love::graphics::Buffer *Graphics::newBuffer(size_t size, const void *data, BufferTypeFlags typeflags, BufferUsage usage, uint32 mapflags)
|
||||
{
|
||||
return new Buffer(size, data, typeflags, usage, mapflags);
|
||||
}
|
||||
@@ -385,13 +385,13 @@ void Graphics::draw(const DrawIndexedCommand &cmd)
|
||||
++drawCalls;
|
||||
}
|
||||
|
||||
static inline void advanceVertexOffsets(const vertex::Attributes &attributes, vertex::BufferBindings &buffers, int vertexcount)
|
||||
static inline void advanceVertexOffsets(const Attributes &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 < vertex::Attributes::MAX; i++)
|
||||
for (unsigned int i = 0; i < Attributes::MAX; i++)
|
||||
{
|
||||
if (!attributes.isEnabled(i))
|
||||
continue;
|
||||
@@ -408,7 +408,7 @@ static inline void advanceVertexOffsets(const vertex::Attributes &attributes, ve
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings &buffers, love::graphics::Texture *texture)
|
||||
void Graphics::drawQuads(int start, int count, const Attributes &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;
|
||||
@@ -437,7 +437,7 @@ void Graphics::drawQuads(int start, int count, const vertex::Attributes &attribu
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex::BufferBindings bufferscopy = buffers;
|
||||
BufferBindings bufferscopy = buffers;
|
||||
if (start > 0)
|
||||
advanceVertexOffsets(attributes, bufferscopy, start * 4);
|
||||
|
||||
@@ -525,7 +525,7 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix
|
||||
endPass();
|
||||
|
||||
bool iswindow = rts.getFirstTarget().canvas == nullptr;
|
||||
vertex::Winding vertexwinding = state.winding;
|
||||
Winding vertexwinding = state.winding;
|
||||
|
||||
if (iswindow)
|
||||
{
|
||||
@@ -543,10 +543,10 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix
|
||||
|
||||
// Flip front face winding when rendering to a canvas, since our
|
||||
// projection matrix is flipped.
|
||||
vertexwinding = vertexwinding == vertex::WINDING_CW ? vertex::WINDING_CCW : vertex::WINDING_CW;
|
||||
vertexwinding = vertexwinding == WINDING_CW ? WINDING_CCW : WINDING_CW;
|
||||
}
|
||||
|
||||
glFrontFace(vertexwinding == vertex::WINDING_CW ? GL_CW : GL_CCW);
|
||||
glFrontFace(vertexwinding == WINDING_CW ? GL_CW : GL_CCW);
|
||||
|
||||
gl.setViewport({0, 0, pixelw, pixelh});
|
||||
|
||||
@@ -1241,7 +1241,7 @@ void Graphics::setDepthMode(CompareMode compare, bool write)
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::setFrontFaceWinding(vertex::Winding winding)
|
||||
void Graphics::setFrontFaceWinding(Winding winding)
|
||||
{
|
||||
DisplayState &state = states.back();
|
||||
|
||||
@@ -1251,9 +1251,9 @@ void Graphics::setFrontFaceWinding(vertex::Winding winding)
|
||||
state.winding = winding;
|
||||
|
||||
if (isCanvasActive())
|
||||
winding = winding == vertex::WINDING_CW ? vertex::WINDING_CCW : vertex::WINDING_CW;
|
||||
winding = winding == WINDING_CW ? WINDING_CCW : WINDING_CW;
|
||||
|
||||
glFrontFace(winding == vertex::WINDING_CW ? GL_CW : GL_CCW);
|
||||
glFrontFace(winding == WINDING_CW ? GL_CW : GL_CCW);
|
||||
}
|
||||
|
||||
void Graphics::setColor(Colorf c)
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
love::graphics::Image *newImage(const Image::Slices &data, const Image::Settings &settings) override;
|
||||
love::graphics::Image *newImage(TextureType textype, PixelFormat format, int width, int height, int slices, const Image::Settings &settings) override;
|
||||
love::graphics::Canvas *newCanvas(const Canvas::Settings &settings) override;
|
||||
love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferTypeFlags typeflags, vertex::Usage usage, uint32 mapflags) override;
|
||||
love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferTypeFlags typeflags, BufferUsage usage, uint32 mapflags) override;
|
||||
love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataMember> &format, size_t arraylength) override;
|
||||
|
||||
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
void draw(const DrawCommand &cmd) override;
|
||||
void draw(const DrawIndexedCommand &cmd) override;
|
||||
void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings &buffers, Texture *texture) override;
|
||||
void drawQuads(int start, int count, const Attributes &attributes, const BufferBindings &buffers, Texture *texture) override;
|
||||
|
||||
void clear(OptionalColorf color, OptionalInt stencil, OptionalDouble depth) override;
|
||||
void clear(const std::vector<OptionalColorf> &colors, OptionalInt stencil, OptionalDouble depth) override;
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
|
||||
void setDepthMode(CompareMode compare, bool write) override;
|
||||
|
||||
void setFrontFaceWinding(vertex::Winding winding) override;
|
||||
void setFrontFaceWinding(Winding winding) override;
|
||||
|
||||
void setColorMask(ColorChannelMask mask) override;
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ void OpenGL::setupContext()
|
||||
state.enabledAttribArrays = (uint32) ((1ull << uint32(maxvertexattribs)) - 1);
|
||||
state.instancedAttribArrays = 0;
|
||||
|
||||
setVertexAttributes(vertex::Attributes(), vertex::BufferBindings());
|
||||
setVertexAttributes(Attributes(), BufferBindings());
|
||||
|
||||
// Get the current viewport.
|
||||
glGetIntegerv(GL_VIEWPORT, (GLint *) &state.viewport.x);
|
||||
@@ -631,62 +631,62 @@ GLenum OpenGL::getGLIndexDataType(IndexDataType type)
|
||||
}
|
||||
}
|
||||
|
||||
GLenum OpenGL::getGLVertexDataType(vertex::DataType type, GLboolean &normalized, bool &intformat)
|
||||
GLenum OpenGL::getGLVertexDataType(DataType type, GLboolean &normalized, bool &intformat)
|
||||
{
|
||||
normalized = GL_FALSE;
|
||||
intformat = false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case vertex::DATA_SNORM8:
|
||||
case DATA_SNORM8:
|
||||
normalized = GL_TRUE;
|
||||
return GL_BYTE;
|
||||
case vertex::DATA_UNORM8:
|
||||
case DATA_UNORM8:
|
||||
normalized = GL_TRUE;
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case vertex::DATA_INT8:
|
||||
case DATA_INT8:
|
||||
intformat = true;
|
||||
return GL_BYTE;
|
||||
case vertex::DATA_UINT8:
|
||||
case DATA_UINT8:
|
||||
intformat = true;
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case vertex::DATA_SNORM16:
|
||||
case DATA_SNORM16:
|
||||
normalized = GL_TRUE;
|
||||
return GL_SHORT;
|
||||
case vertex::DATA_UNORM16:
|
||||
case DATA_UNORM16:
|
||||
normalized = GL_TRUE;
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case vertex::DATA_INT16:
|
||||
case DATA_INT16:
|
||||
intformat = true;
|
||||
return GL_SHORT;
|
||||
case vertex::DATA_UINT16:
|
||||
case DATA_UINT16:
|
||||
intformat = true;
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case vertex::DATA_INT32:
|
||||
case DATA_INT32:
|
||||
intformat = true;
|
||||
return GL_INT;
|
||||
case vertex::DATA_UINT32:
|
||||
case DATA_UINT32:
|
||||
intformat = true;
|
||||
return GL_UNSIGNED_INT;
|
||||
case vertex::DATA_FLOAT:
|
||||
case DATA_FLOAT:
|
||||
normalized = GL_FALSE;
|
||||
return GL_FLOAT;
|
||||
case vertex::DATA_MAX_ENUM:
|
||||
case DATA_MAX_ENUM:
|
||||
return GL_ZERO;
|
||||
}
|
||||
|
||||
return GL_ZERO;
|
||||
}
|
||||
|
||||
GLenum OpenGL::getGLBufferUsage(vertex::Usage usage)
|
||||
GLenum OpenGL::getGLBufferUsage(BufferUsage usage)
|
||||
{
|
||||
switch (usage)
|
||||
{
|
||||
case vertex::USAGE_STREAM:
|
||||
case BUFFERUSAGE_STREAM:
|
||||
return GL_STREAM_DRAW;
|
||||
case vertex::USAGE_DYNAMIC:
|
||||
case BUFFERUSAGE_DYNAMIC:
|
||||
return GL_DYNAMIC_DRAW;
|
||||
case vertex::USAGE_STATIC:
|
||||
case BUFFERUSAGE_STATIC:
|
||||
return GL_STATIC_DRAW;
|
||||
default:
|
||||
return 0;
|
||||
@@ -713,7 +713,7 @@ void OpenGL::deleteBuffer(GLuint buffer)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGL::setVertexAttributes(const vertex::Attributes &attributes, const vertex::BufferBindings &buffers)
|
||||
void OpenGL::setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers)
|
||||
{
|
||||
uint32 enablediff = attributes.enableBits ^ state.enabledAttribArrays;
|
||||
uint32 instanceattribbits = 0;
|
||||
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
/**
|
||||
* Set all vertex attribute state.
|
||||
**/
|
||||
void setVertexAttributes(const vertex::Attributes &attributes, const vertex::BufferBindings &buffers);
|
||||
void setVertexAttributes(const Attributes &attributes, const BufferBindings &buffers);
|
||||
|
||||
/**
|
||||
* Wrapper for glCullFace which eliminates redundant state setting.
|
||||
@@ -404,8 +404,8 @@ public:
|
||||
static GLenum getGLPrimitiveType(PrimitiveType type);
|
||||
static GLenum getGLBufferType(BufferType type);
|
||||
static GLenum getGLIndexDataType(IndexDataType type);
|
||||
static GLenum getGLVertexDataType(vertex::DataType type, GLboolean &normalized, bool &intformat);
|
||||
static GLenum getGLBufferUsage(vertex::Usage usage);
|
||||
static GLenum getGLVertexDataType(DataType type, GLboolean &normalized, bool &intformat);
|
||||
static GLenum getGLBufferUsage(BufferUsage usage);
|
||||
static GLenum getGLTextureType(TextureType type);
|
||||
static GLint getGLWrapMode(Texture::WrapMode wmode);
|
||||
static GLint getGLCompareMode(CompareMode mode);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "Shader.h"
|
||||
#include "Graphics.h"
|
||||
#include "graphics/vertex.h"
|
||||
|
||||
// C++
|
||||
#include <algorithm>
|
||||
@@ -322,7 +323,7 @@ bool Shader::loadVolatile()
|
||||
for (int i = 0; i < int(ATTRIB_MAX_ENUM); i++)
|
||||
{
|
||||
const char *name = nullptr;
|
||||
if (vertex::getConstant((BuiltinVertexAttribute) i, name))
|
||||
if (graphics::getConstant((BuiltinVertexAttribute) i, name))
|
||||
glBindAttribLocation(program, i, (const GLchar *) name);
|
||||
}
|
||||
|
||||
@@ -345,7 +346,7 @@ bool Shader::loadVolatile()
|
||||
for (int i = 0; i < int(ATTRIB_MAX_ENUM); i++)
|
||||
{
|
||||
const char *name = nullptr;
|
||||
if (vertex::getConstant(BuiltinVertexAttribute(i), name))
|
||||
if (graphics::getConstant(BuiltinVertexAttribute(i), name))
|
||||
builtinAttributes[i] = glGetAttribLocation(program, name);
|
||||
else
|
||||
builtinAttributes[i] = -1;
|
||||
|
||||
Reference in New Issue
Block a user