summaryrefslogtreecommitdiffstats
path: root/src/graphics/core/vertex.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-29 10:40:11 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-29 10:40:11 +0200
commit677ce3960cd13cbf994311c76d75b343b22fd480 (patch)
treeee2bab43ec29cdf94d8c1173ee022fe95c2a0222 /src/graphics/core/vertex.h
parent77952a85e63ca13dd9cfc93c7b6a271d7c91e59a (diff)
downloadcolobot-677ce3960cd13cbf994311c76d75b343b22fd480.tar.gz
colobot-677ce3960cd13cbf994311c76d75b343b22fd480.tar.bz2
colobot-677ce3960cd13cbf994311c76d75b343b22fd480.zip
Some fixes and optimizations
- fixed 2nd texture setting - added padding to some structs for faster access - changed rendering primitives to glDrawArrays() - optimized texture modesetting calls - fixed some valgrind errors
Diffstat (limited to 'src/graphics/core/vertex.h')
-rw-r--r--src/graphics/core/vertex.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index e2c35c3..fa6120f 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -33,6 +33,7 @@
// Graphics module namespace
namespace Gfx {
+
/**
* \struct Vertex
* \brief Vertex of a primitive
@@ -43,17 +44,23 @@ namespace Gfx {
* - vertex coordinates (x,y,z) as Math::Vector,
* - normal coordinates (nx,ny,nz) as Math::Vector
* - texture coordinates (u,v) as Math::Point.
+ *
+ * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct Vertex
{
Math::Vector coord;
+ float pad1;
Math::Vector normal;
+ float pad2;
Math::Point texCoord;
+ float pad3, pad4;
explicit Vertex(Math::Vector aCoord = Math::Vector(),
Math::Vector aNormal = Math::Vector(),
Math::Point aTexCoord = Math::Point())
- : coord(aCoord), normal(aNormal), texCoord(aTexCoord) {}
+ : coord(aCoord), pad1(0.0f), normal(aNormal),
+ pad2(0.0f),texCoord(aTexCoord), pad3(0.0f), pad4(0.0f) {}
//! Returns a string "(c: [...], n: [...], tc: [...])"
@@ -74,16 +81,19 @@ struct Vertex
* It contains:
* - vertex coordinates (x,y,z) as Math::Vector,
* - RGBA color as Color
+ *
+ * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct VertexCol
{
Math::Vector coord;
+ float pad;
Color color;
explicit VertexCol(Math::Vector aCoord = Math::Vector(),
Color aColor = Color(),
Math::Point aTexCoord = Math::Point())
- : coord(aCoord), color(aColor) {}
+ : coord(aCoord), pad(0.0f), color(aColor) {}
//! Returns a string "(c: [...], col: [...])"
inline std::string ToString() const
@@ -102,11 +112,15 @@ struct VertexCol
*
* In addition to fields from Vector, it contains
* secondary texture coordinates (u2, v2) as Math::Point
+ *
+ * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct VertexTex2
{
Math::Vector coord;
+ float pad1;
Math::Vector normal;
+ float pad2;
Math::Point texCoord;
Math::Point texCoord2;
@@ -114,7 +128,8 @@ struct VertexTex2
Math::Vector aNormal = Math::Vector(),
Math::Point aTexCoord = Math::Point(),
Math::Point aTexCoord2 = Math::Point())
- : coord(aCoord), normal(aNormal), texCoord(aTexCoord), texCoord2(aTexCoord2) {}
+ : coord(aCoord), pad1(0.0f), normal(aNormal), pad2(0.0f),
+ texCoord(aTexCoord), texCoord2(aTexCoord2) {}
//! Sets the fields from Vertex with texCoord2 = (0,0)
void FromVertex(const Vertex &v)