[colobot] 03/100: Added types and vertex format specification
Didier Raboud
odyx at moszumanska.debian.org
Thu Jun 1 18:10:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit ae3b2b8572b4ff0eac49f3a99aa38d9df855f7ac
Author: Tomasz Kapuściński <tomaszkax86 at gmail.com>
Date: Fri Nov 4 11:59:57 2016 +0100
Added types and vertex format specification
---
src/CMakeLists.txt | 1 +
src/graphics/core/type.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++
src/graphics/core/vertex.h | 54 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dd54926..78a1221 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -165,6 +165,7 @@ set(BASE_SOURCES
graphics/core/nulldevice.cpp
graphics/core/nulldevice.h
graphics/core/texture.h
+ graphics/core/type.h
graphics/core/vertex.h
graphics/engine/camera.cpp
graphics/engine/camera.h
diff --git a/src/graphics/core/type.h b/src/graphics/core/type.h
new file mode 100644
index 0000000..0c04747
--- /dev/null
+++ b/src/graphics/core/type.h
@@ -0,0 +1,59 @@
+/*
+* This file is part of the Colobot: Gold Edition source code
+* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
+* http://epsitec.ch; http://colobot.info; http://github.com/colobot
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see http://gnu.org/licenses
+*/
+
+/**
+* \file graphics/core/type.h
+* \brief Type support and conversion
+*/
+
+#pragma once
+
+// Graphics module namespace
+namespace Gfx
+{
+
+/**
+* \enum class Type
+* \brief Value types for vertex attributes
+*/
+enum class Type : unsigned char
+{
+ //! Unsigned byte (8-bit)
+ UBYTE = 0,
+ //! Signed byte (8-bit)
+ BYTE,
+ //! Unsigned short (16-bit)
+ USHORT,
+ //! Signed short (16-bit)
+ SHORT,
+ //! Unsigned int (32-bit)
+ UINT,
+ //! Signed int (32-bit)
+ INT,
+ //! Half precision floating-point (16-bit)
+ HALF,
+ //! Single precision floating-point (32-bit)
+ FLOAT,
+ //! Double precision floating-point (64-bit)
+ DOUBLE,
+};
+
+// TODO: functions for conversion between types
+
+} // namespace Gfx
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index 8357cc8..11f1ea4 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -26,11 +26,13 @@
#include "graphics/core/color.h"
+#include "graphics/core/type.h"
#include "math/point.h"
#include "math/vector.h"
#include <sstream>
+#include <cstdint>
// Graphics module namespace
@@ -39,6 +41,58 @@ namespace Gfx
/**
+* \struct VertexAttribute
+* \brief Vertex attribute
+*
+* This structure contains parameters for a vertex attribute.
+*/
+struct VertexAttribute
+{
+ //! true enables vertex attribute
+ bool enabled;
+ //! true means normalized value (integer types only)
+ bool normalized;
+ //! Number of elements in the vertex attribute.
+ //! Valid values are 1, 2, 3, and 4. Depends on specific attribute.
+ unsigned char size;
+ //! Type of values in vertex attribute
+ Type type;
+ //! Offset to the vertex attribute
+ int offset;
+ //! Stride of vertex attribute
+ int stride;
+ //! Default values used when attribute is disabled
+ float values[4];
+};
+
+/**
+* \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;
+};
+
+/**
* \struct Vertex
* \brief Vertex of a primitive
*
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list