summaryrefslogtreecommitdiffstats
path: root/src/graphics/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/core')
-rw-r--r--src/graphics/core/color.h10
-rw-r--r--src/graphics/core/device.h60
-rw-r--r--src/graphics/core/vertex.h20
3 files changed, 56 insertions, 34 deletions
diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h
index 7cbd175..5d059e5 100644
--- a/src/graphics/core/color.h
+++ b/src/graphics/core/color.h
@@ -76,6 +76,16 @@ struct Color
{
return ! this->operator==(other);
}
+
+ inline Color operator*(float scale) const
+ {
+ Color c = *this;
+ c.r *= scale;
+ c.g *= scale;
+ c.b *= scale;
+ c.a *= scale;
+ return c;
+ }
};
/**
diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h
index b6dd138..41d7796 100644
--- a/src/graphics/core/device.h
+++ b/src/graphics/core/device.h
@@ -104,8 +104,7 @@ enum RenderState
RENDER_STATE_DEPTH_TEST,
RENDER_STATE_DEPTH_WRITE,
RENDER_STATE_ALPHA_TEST,
- RENDER_STATE_CULLING,
- RENDER_STATE_DITHERING
+ RENDER_STATE_CULLING
};
/**
@@ -204,22 +203,22 @@ enum PrimitiveType
};
/**
- * \enum IntersectPlane
- * \brief Intersection plane of projection volume
+ * \enum FrustumPlane
+ * \brief Planes of frustum space
*
- * These flags can be OR'd together.
+ * Bitset of flags - can be OR'd together.
*/
-enum IntersectPlane
+enum FrustumPlane
{
- INTERSECT_PLANE_LEFT = 0x01,
- INTERSECT_PLANE_RIGHT = 0x02,
- INTERSECT_PLANE_TOP = 0x04,
- INTERSECT_PLANE_BOTTOM = 0x08,
- INTERSECT_PLANE_FRONT = 0x10,
- INTERSECT_PLANE_BACK = 0x20,
- INTERSECT_PLANE_ALL = INTERSECT_PLANE_LEFT | INTERSECT_PLANE_RIGHT |
- INTERSECT_PLANE_TOP | INTERSECT_PLANE_BOTTOM |
- INTERSECT_PLANE_FRONT | INTERSECT_PLANE_BACK
+ FRUSTUM_PLANE_LEFT = 0x01,
+ FRUSTUM_PLANE_RIGHT = 0x02,
+ FRUSTUM_PLANE_TOP = 0x04,
+ FRUSTUM_PLANE_BOTTOM = 0x08,
+ FRUSTUM_PLANE_FRONT = 0x10,
+ FRUSTUM_PLANE_BACK = 0x20,
+ FRUSTUM_PLANE_ALL = FRUSTUM_PLANE_LEFT | FRUSTUM_PLANE_RIGHT |
+ FRUSTUM_PLANE_TOP | FRUSTUM_PLANE_BOTTOM |
+ FRUSTUM_PLANE_FRONT | FRUSTUM_PLANE_BACK
};
/**
@@ -287,7 +286,7 @@ public:
virtual void DestroyAllTextures() = 0;
//! Returns the maximum number of multitexture stages
- virtual int GetMaxTextureCount() = 0;
+ virtual int GetMaxTextureStageCount() = 0;
//! Sets the texture at given texture stage
virtual void SetTexture(int index, const Texture &texture) = 0;
//! Sets the texture image by ID at given texture stage
@@ -313,10 +312,35 @@ public:
//! Renders primitive composed of vertices with multitexturing (2 textures)
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
- //! Renders primitive composed of vertices with color information
+ //! Renders primitive composed of vertices with solid color
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
- //! Tests whether a sphere intersects the 6 clipping planes of projection volume
+ //! Creates a static buffer composed of given primitives with single texture vertices
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
+
+ //! Creates a static buffer composed of given primitives with multitexturing
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
+
+ //! Creates a static buffer composed of given primitives with solid color
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with single texture vertices
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with multitexturing
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with solid color
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
+
+ //! Draws a static buffer
+ virtual void DrawStaticBuffer(unsigned int bufferId) = 0;
+
+ //! Deletes a static buffer
+ virtual void DestroyStaticBuffer(unsigned int bufferId) = 0;
+
+ //! Tests whether a sphere is (partially) within the frustum volume
+ //! Returns a mask of frustum planes for which the test is positive
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius) = 0;
//! Enables/disables the given render state
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index 2ee6be4..66e1503 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -44,23 +44,18 @@ 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), pad1(0.0f), normal(aNormal),
- pad2(0.0f),texCoord(aTexCoord), pad3(0.0f), pad4(0.0f) {}
+ : coord(aCoord), normal(aNormal),
+ texCoord(aTexCoord) {}
//! Returns a string "(c: [...], n: [...], tc: [...])"
@@ -81,18 +76,15 @@ 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())
- : coord(aCoord), pad(0.0f), color(aColor) {}
+ : coord(aCoord), color(aColor) {}
//! Returns a string "(c: [...], col: [...])"
inline std::string ToString() const
@@ -111,15 +103,11 @@ 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;
@@ -127,7 +115,7 @@ struct VertexTex2
Math::Vector aNormal = Math::Vector(),
Math::Point aTexCoord = Math::Point(),
Math::Point aTexCoord2 = Math::Point())
- : coord(aCoord), pad1(0.0f), normal(aNormal), pad2(0.0f),
+ : coord(aCoord), normal(aNormal),
texCoord(aTexCoord), texCoord2(aTexCoord2) {}
//! Sets the fields from Vertex with texCoord2 = (0,0)