Remove code for drawing dynamic vertex formats

It's unused, and it's a bad idea - it's important for authoring tools
and for performance that vertex formats are well-defined instead of
dynamically created.
1008-fix
AbigailBuccaneer 2018-05-03 18:21:21 +01:00
parent 94b30c00a0
commit f8ebc6ec21
10 changed files with 0 additions and 478 deletions

View File

@ -416,14 +416,6 @@ public:
//! Sets only the texture wrap modes (for faster than thru stage params)
virtual void SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT) = 0;
//! Renders primitive composed of generic vertices
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount) = 0;
//! Renders multiple primitives composed of generic vertices
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount) = 0;
//! Renders primitive composed of vertices with single texture
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;

View File

@ -168,16 +168,6 @@ void CNullDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
{
}
void CNullDevice::DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount)
{
}
void CNullDevice::DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount)
{
}
void CNullDevice::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
int first[], int count[], int drawCount, Color color)
{

View File

@ -81,11 +81,6 @@ public:
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
void DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount) override;
void DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
void DrawPrimitive(PrimitiveType type, const Vertex* vertices, int vertexCount, Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
void DrawPrimitive(PrimitiveType type, const VertexTex2* vertices, int vertexCount, Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
void DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount) override;

View File

@ -39,59 +39,6 @@
namespace Gfx
{
/**
* \struct VertexAttribute
* \brief Vertex attribute
*
* This structure contains parameters for a vertex attribute.
*/
struct VertexAttribute
{
//! true enables vertex attribute
bool enabled = false;
//! true means normalized value (integer types only)
bool normalized = false;
//! Number of elements in the vertex attribute.
//! Valid values are 1, 2, 3, and 4. Depends on specific attribute.
unsigned char size = 0;
//! Type of values in vertex attribute
Type type = Type::UBYTE;
//! Offset to the vertex attribute
int offset = 0;
//! Stride of vertex attribute
int stride = 0;
//! Default values used when attribute is disabled
float values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
};
/**
* \struct VertexFormat
* \brief Vertex format
*
* This structure defines vertex formats for generic vertex arrays.
*
* It contains:
* - vertex coordinate specification
* - color specification
* - normal specification
* - texture coordinate 1 specification
* - texture coordinate 2 specification
*/
struct VertexFormat
{
//! Vertex coordinate
VertexAttribute vertex{};
//! Color
VertexAttribute color{};
//! Normal
VertexAttribute normal{};
//! Texture coordinate 1
VertexAttribute tex1{};
//! Texture coordinate 2
VertexAttribute tex2{};
};
enum VertexType
{
VERTEX_TYPE_NORMAL,

View File

@ -1371,168 +1371,6 @@ void CGL14Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
glDisableClientState(GL_COLOR_ARRAY);
}
void CGL14Device::DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount)
{
const char *ptr = reinterpret_cast<const char*>(vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(format.vertex.size,
TransformType(format.vertex.type),
format.vertex.stride,
ptr + format.vertex.offset);
if (format.color.enabled)
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(format.color.size,
TransformType(format.color.type),
format.color.stride,
ptr + format.color.offset);
}
else
glColor4fv(format.color.values);
if (format.normal.enabled)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(TransformType(format.normal.type),
format.normal.stride,
ptr + format.normal.offset);
}
else
glNormal3fv(format.normal.values);
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
if (format.tex1.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex1.size,
TransformType(format.tex1.type),
format.tex1.stride,
ptr + format.tex1.offset);
}
else
glTexCoord2fv(format.tex1.values);
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
if (format.tex2.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex2.size,
TransformType(format.tex2.type),
format.tex2.stride,
ptr + format.tex2.offset);
}
else
glTexCoord2fv(format.tex2.values);
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
glDisableClientState(GL_VERTEX_ARRAY);
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
if (format.tex1.enabled)
{
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (format.tex2.enabled)
{
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
void CGL14Device::DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount)
{
const char *ptr = reinterpret_cast<const char*>(vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(format.vertex.size,
TransformType(format.vertex.type),
format.vertex.stride,
ptr + format.vertex.offset);
if (format.color.enabled)
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(format.color.size,
TransformType(format.color.type),
format.color.stride,
ptr + format.color.offset);
}
else
glColor4fv(format.color.values);
if (format.normal.enabled)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(TransformType(format.normal.type),
format.normal.stride,
ptr + format.normal.offset);
}
else
glNormal3fv(format.normal.values);
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
if (format.tex1.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex1.size,
TransformType(format.tex1.type),
format.tex1.stride,
ptr + format.tex1.offset);
}
else
glTexCoord2fv(format.tex1.values);
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
if (format.tex2.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex2.size,
TransformType(format.tex2.type),
format.tex2.stride,
ptr + format.tex2.offset);
}
else
glTexCoord2fv(format.tex2.values);
GLenum t = TranslateGfxPrimitive(type);
if (m_multiDrawArrays)
{
glMultiDrawArrays(t, first, count, drawCount);
}
else
{
for (int i = 0; i < drawCount; i++)
glDrawArrays(t, first[i], count[i]);
}
glDisableClientState(GL_VERTEX_ARRAY);
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
if (format.tex1.enabled)
{
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (format.tex2.enabled)
{
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
void CGL14Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
int first[], int count[], int drawCount, Color color)
{

View File

@ -119,11 +119,6 @@ public:
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount) override;
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,

View File

@ -1199,166 +1199,6 @@ void CGL21Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
glDisableClientState(GL_COLOR_ARRAY);
}
void CGL21Device::DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount)
{
if (m_updateLights) UpdateLights();
BindVBO(0);
const char *ptr = reinterpret_cast<const char*>(vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(format.vertex.size,
TransformType(format.vertex.type),
format.vertex.stride,
ptr + format.vertex.offset);
if (format.color.enabled)
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(format.color.size,
TransformType(format.color.type),
format.color.stride,
ptr + format.color.offset);
}
else
glColor4fv(format.color.values);
if (format.normal.enabled)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(TransformType(format.normal.type),
format.normal.stride,
ptr + format.normal.offset);
}
else
glNormal3fv(format.normal.values);
glClientActiveTexture(GL_TEXTURE0);
if (format.tex1.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex1.size,
TransformType(format.tex1.type),
format.tex1.stride,
ptr + format.tex1.offset);
}
else
glTexCoord2fv(format.tex1.values);
glClientActiveTexture(GL_TEXTURE1);
if (format.tex2.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex2.size,
TransformType(format.tex2.type),
format.tex2.stride,
ptr + format.tex2.offset);
}
else
glTexCoord2fv(format.tex2.values);
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
glDisableClientState(GL_VERTEX_ARRAY);
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
if (format.tex1.enabled)
{
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (format.tex2.enabled)
{
glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
void CGL21Device::DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount)
{
if (m_updateLights) UpdateLights();
BindVBO(0);
const char *ptr = reinterpret_cast<const char*>(vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(format.vertex.size,
TransformType(format.vertex.type),
format.vertex.stride,
ptr + format.vertex.offset);
if (format.color.enabled)
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(format.color.size,
TransformType(format.color.type),
format.color.stride,
ptr + format.color.offset);
}
else
glColor4fv(format.color.values);
if (format.normal.enabled)
{
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(TransformType(format.normal.type),
format.normal.stride,
ptr + format.normal.offset);
}
else
glNormal3fv(format.normal.values);
glClientActiveTexture(GL_TEXTURE0);
if (format.tex1.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex1.size,
TransformType(format.tex1.type),
format.tex1.stride,
ptr + format.tex1.offset);
}
else
glTexCoord2fv(format.tex1.values);
glClientActiveTexture(GL_TEXTURE1);
if (format.tex2.enabled)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(format.tex2.size,
TransformType(format.tex2.type),
format.tex2.stride,
ptr + format.tex2.offset);
}
else
glTexCoord2fv(format.tex2.values);
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
glDisableClientState(GL_VERTEX_ARRAY);
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
if (format.tex1.enabled)
{
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (format.tex2.enabled)
{
glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
void CGL21Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
int first[], int count[], int drawCount, Color color)
{

View File

@ -100,11 +100,6 @@ public:
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount) override;
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,

View File

@ -1158,50 +1158,6 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
}
void CGL33Device::DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount)
{
if (m_updateLights) UpdateLights();
DynamicBuffer& buffer = m_dynamicBuffer;
BindVAO(buffer.vao);
BindVBO(buffer.vbo);
unsigned int offset = UploadVertexData(buffer, vertices, size);
// Update vertex attribute bindings
UpdateVertexAttribute(0, format.vertex, offset);
UpdateVertexAttribute(1, format.normal, offset);
UpdateVertexAttribute(2, format.color, offset);
UpdateVertexAttribute(3, format.tex1, offset);
UpdateVertexAttribute(4, format.tex2, offset);
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
}
void CGL33Device::DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount)
{
if (m_updateLights) UpdateLights();
DynamicBuffer& buffer = m_dynamicBuffer;
BindVAO(buffer.vao);
BindVBO(buffer.vbo);
unsigned int offset = UploadVertexData(buffer, vertices, size);
// Update vertex attribute bindings
UpdateVertexAttribute(0, format.vertex, offset);
UpdateVertexAttribute(1, format.normal, offset);
UpdateVertexAttribute(2, format.color, offset);
UpdateVertexAttribute(3, format.tex1, offset);
UpdateVertexAttribute(4, format.tex2, offset);
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
}
void CGL33Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
int first[], int count[], int drawCount, Color color)
{
@ -1924,25 +1880,6 @@ unsigned int CGL33Device::UploadVertexData(DynamicBuffer& buffer, const void* da
return currentOffset;
}
void CGL33Device::UpdateVertexAttribute(int index, const VertexAttribute &attribute, int offset)
{
if (attribute.enabled)
{
glEnableVertexAttribArray(index);
glVertexAttribPointer(index,
attribute.size,
TranslateType(attribute.type),
attribute.normalized ? GL_TRUE : GL_FALSE,
attribute.stride,
reinterpret_cast<void*>(offset + attribute.offset));
}
else
{
glDisableVertexAttribArray(index);
glVertexAttrib4fv(index, attribute.values);
}
}
bool CGL33Device::IsAnisotropySupported()
{
return m_capabilities.anisotropySupported;

View File

@ -115,11 +115,6 @@ public:
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int vertexCount) override;
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
@ -231,8 +226,6 @@ private:
//! Uploads data to dynamic buffer and returns offset to it
unsigned int UploadVertexData(DynamicBuffer& buffer, const void* data, unsigned int size);
inline void UpdateVertexAttribute(int index, const VertexAttribute &attribute, int offset);
template <typename Vertex>
unsigned int CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
template <typename Vertex>