Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kimkulling/add light radius #171

Merged
merged 9 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/osre/App/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class OSRE_EXPORT Component {
/// @brief The default class destructor.
virtual ~Component() = default;


/// @brief The update callback
/// @param[in] timeSlice The time slice
virtual void update(Time timeSlice);
Expand Down
1 change: 1 addition & 0 deletions include/osre/RenderBackend/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace OSRE {
namespace RenderBackend {

// Forward declarations ---------------------------------------------------------------------------
class Material;

//-------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion include/osre/RenderBackend/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace OSRE {
namespace RenderBackend {

// Forward declarations
// Forward declarations ---------------------------------------------------------------------------
class Shader;
class RenderBackendService;

Expand Down
165 changes: 86 additions & 79 deletions include/osre/RenderBackend/RenderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Mesh;
class Shader;
class Pipeline;

/// @brief An array to stoer meshes.
/// @brief An array to store meshes.
using MeshArray = cppcore::TArray<RenderBackend::Mesh*>;

/// Describes an unset id.
Expand Down Expand Up @@ -100,7 +100,6 @@ enum class TextureTargetType {
Texture2D, ///< 2D-textures, used for images and render targets.
Texture3D, ///< 3D-textures, used for volume rendering.
NumTextureTargetTypes ///< Number of enums.

};

/// @brief This enum describes the supported texture stages. A texture stage describes one layer of
Expand All @@ -126,52 +125,49 @@ enum class TextureParameterName {

/// @brief This enum describes the parameters which are related the the parameter names ( @see TextureParameterName ).
enum class TextureParameterType {
TexturePTNearest = 0, ///< Use nearest filter mode.
TexturePTLinear, ///< Use linear interpolation mode.
TexturePTClamp, ///< Use clamp mode, texture data will be clamped.
TexturePTMirroredRepeat, ///< Use mirror repeat mode, texture will be repeated mirrored.
TexturePTRepeat, ///< Use repeat mode, texture will be repeated mirrored.
NumTextureParameterTypes, ///< Number of enums.

InvalidTextureParameterType, ///< Enum for invalid enum.
InvalidTextureParameterType = -1, ///< Enum for invalid enum.
TexturePTNearest = 0, ///< Use nearest filter mode.
TexturePTLinear, ///< Use linear interpolation mode.
TexturePTClamp, ///< Use clamp mode, texture data will be clamped.
TexturePTMirroredRepeat, ///< Use mirror repeat mode, texture will be repeated mirrored.
TexturePTRepeat, ///< Use repeat mode, texture will be repeated mirrored.
NumTextureParameterTypes ///< Number of enums.
};

/// @brief This enum describes the index data type.
enum class IndexType {
UnsignedByte = 0, ///< Bytes are used for the index data.
UnsignedShort, ///< Unsigned short for the index data.
UnsignedInt, ///< Unsigned int for the index data.
NumIndexTypes, ///< Number of enums.

InvalidIndexType, ///< Enum for invalid enum.
InvalidIndexType = -1, ///< Enum for invalid enum.
UnsignedByte = 0, ///< Bytes are used for the index data.
UnsignedShort, ///< Unsigned short for the index data.
UnsignedInt, ///< Unsigned int for the index data.
NumIndexTypes ///< Number of enums.
};

/// @brief This enum describes the primitive types for rendering vertex information.
enum class PrimitiveType {
PointList = 0, ///< A list of points, one index per point.
LineList, ///< A list of separate lines, 2 indices per line.
LineStrip, ///< A line strip, Start and end-index and all indices between.
TriangleList, ///< A list of triangles, 3 indices per triangle.
TriangelStrip, ///< A strip of triangles
TriangleFan, ///< A triangle fan.
NumPrimitiveTypes, ///< Number of enums.

InvalidPrimitiveType, ///< Enum for invalid enum.
InvalidPrimitiveType = -1, ///< Enum for invalid enum.
PointList = 0, ///< A list of points, one index per point.
LineList, ///< A list of separate lines, 2 indices per line.
LineStrip, ///< A line strip, Start and end-index and all indices between.
TriangleList, ///< A list of triangles, 3 indices per triangle.
TriangelStrip, ///< A strip of triangles
TriangleFan, ///< A triangle fan.
NumPrimitiveTypes ///< Number of enums.
};

/// @brief This enum is used to describe the type of build-in matrices.
enum class MatrixType {
Model = 0, ///<
View, ///<
Projection, ///<
Normal, ///<
NumMatrixTypes, ///< Number of matrix types-

InvalidMatrixType ///< Enum for invalid values.
InvalidMatrixType = -1, ///< Enum for invalid values.
Model = 0, ///<
View, ///<
Projection, ///<
Normal, ///<
NumMatrixTypes, ///< Number of matrix types-
};

/// @brief This enum is used to describe the data-type of a parameter.
enum class ParameterType {
InvalidParameterType = -1, ///<
PT_None,
PT_Int,
PT_IntArray,
Expand All @@ -183,14 +179,14 @@ enum class ParameterType {
PT_Float3Array,
PT_Mat4,
PT_Mat4Array,

InvalidParameterType
NumParameterTypes
};

/// @brief This enum to describes the type of the vertex attribute.
enum class VertexAttribute : int {
Position = 0, ///< "position"
Normal, ///< "normal"
InvalidVertexAttr = 1, ///< Enum for invalid enum.
Position = 0, ///< "position"
Normal, ///< "normal"
TexCoord0, ///< "texcoord0"
TexCoord1, ///< "texcoord1"
TexCoord2, ///< "texcoord2"
Expand All @@ -205,34 +201,30 @@ enum class VertexAttribute : int {
Instance1, ///< "instance1"
Instance2, ///< "instance2"
Instance3, ///< "instance3"
NumVertexAttrs, ///< Number of enums.

InvalidVertexAttr ///< Enum for invalid enum.
NumVertexAttrs ///< Number of enums.
};

/// @brief This enum describes the vertex data format.
enum class VertexFormat : int {
Float, ///< single component float, expanded to (x, 0, 0, 1)
Float2, ///< 2-component float, expanded to (x, y, 0, 1)
Float3, ///< 3-component float, expanded to (x, y, z, 1)
Float4, ///< 4-component float
Byte4, ///< 4-component float (-128.0f..+127.0f) mapped to byte (-128..+127)
UByte4, ///< 4-component float (0.0f..255.0f) mapped to byte (0..255)
Short2, ///< 2-component float (-32768.0f..+32767.0f) mapped to short (-32768..+32768)
Short4, ///< 4-component float (-32768.0f..+32767.0f) mapped to short (-32768..+32768)
NumVertexFormats, ///< Number of enums.

InvalidVertexFormat, ///< Enum for invalid enum.
InvalidVertexFormat = -1, ///< Enum for invalid enum.
Float, ///< single component float, expanded to (x, 0, 0, 1)
Float2, ///< 2-component float, expanded to (x, y, 0, 1)
Float3, ///< 3-component float, expanded to (x, y, z, 1)
Float4, ///< 4-component float
Byte4, ///< 4-component float (-128.0f..+127.0f) mapped to byte (-128..+127)
UByte4, ///< 4-component float (0.0f..255.0f) mapped to byte (0..255)
Short2, ///< 2-component float (-32768.0f..+32767.0f) mapped to short (-32768..+32768)
Short4, ///< 4-component float (-32768.0f..+32767.0f) mapped to short (-32768..+32768)
NumVertexFormats ///< Number of enums.
};

/// @brief This enum describes the light type.
enum class LightType {
InvalidLightType = -1, ///< Enum for invalid enum.
Directional = 0,
Point,
Spot,
NumLightTypes,

InvalidLightType ///< Enum for invalid enum.
NumLightTypes
};

/// @brief This struct declares a render vertex for textured geometry.
Expand All @@ -242,6 +234,7 @@ struct OSRE_EXPORT ColorVert {
glm::vec3 color0; ///< The diffuse color ( r|g|b )

ColorVert();
~ColorVert() = default;

/// @brief Returns the number of attributes.
static size_t getNumAttributes();
Expand All @@ -252,12 +245,12 @@ struct OSRE_EXPORT ColorVert {
/// @brief This struct declares a render vertex for textured geometry.
struct OSRE_EXPORT RenderVert {
glm::vec3 position; ///< The position ( x|y|z )
glm::vec3 normal; ///< The normal vector ( x|y|z )
glm::vec3 color0; ///< The diffuse color ( r|g|b )
glm::vec2 tex0; ///< The texture color ( r|g|b )
glm::vec3 normal; ///< The normal vector ( x|y|z )
glm::vec3 color0; ///< The diffuse color ( r|g|b )
glm::vec2 tex0; ///< The texture color ( r|g|b )

RenderVert();
~RenderVert();
~RenderVert() = default;
bool operator==(const RenderVert &rhs) const;
bool operator!=(const RenderVert &rhs) const;

Expand Down Expand Up @@ -328,10 +321,11 @@ struct ExtensionProperty {
c8 m_extensionName[MaxEntNameLen];
ui32 m_version;

ExtensionProperty() {
ExtensionProperty() : m_version(0) {
::memset(m_extensionName, '\0', sizeof(c8) * MaxEntNameLen);
m_version = 0;
}

~ExtensionProperty() = default;
};

/// @brief
Expand All @@ -341,7 +335,7 @@ struct OSRE_EXPORT VertComponent {

VertComponent();
VertComponent(VertexAttribute attrib, VertexFormat format);
~VertComponent();
~VertComponent() = default;

OSRE_NON_COPYABLE(VertComponent)
};
Expand Down Expand Up @@ -388,7 +382,7 @@ struct OSRE_EXPORT BufferData {

private:
BufferData();
~BufferData();
~BufferData() = default;

OSRE_NON_COPYABLE(BufferData)
};
Expand Down Expand Up @@ -437,8 +431,8 @@ struct OSRE_EXPORT Texture {
/// @brief
class OSRE_EXPORT TextureLoader {
public:
TextureLoader();
~TextureLoader();
TextureLoader() = default;
~TextureLoader() = default;
size_t load(const IO::Uri &uri, Texture *tex);
bool unload(Texture *tex);
static RenderBackend::Texture *getDefaultTexture();
Expand Down Expand Up @@ -657,17 +651,21 @@ struct TIndexCache {
}
};

/// @brief
/// @brief This struct is used to desribe a light source.
struct OSRE_EXPORT Light {
glm::vec4 m_position;
glm::vec3 m_specular;
glm::vec3 m_diffuse;
glm::vec3 m_ambient;
glm::vec4 m_direction;
f32 m_specularExp;
LightType m_type;

glm::vec4 m_position; ///< The position of the light
glm::vec3 m_specular; ///< The specular colot.
glm::vec3 m_diffuse; ///< The diffuse color.
glm::vec3 m_ambient; ///< The ambient color.
glm::vec4 m_direction; ///< The direction vector.
f32 m_specularExp; ///< The specular exponent.
f32 mRadius; ///< The light radius.
LightType m_type; ///< The light type.

/// @brief The class constructor.
Light();

/// @brief The class destructor.
~Light();
};

Expand All @@ -685,12 +683,16 @@ struct MatrixBuffer {
m_proj(1.0f) {
// empty
}
~MatrixBuffer() = default;
};

struct MeshEntry {
ui32 numInstances;
bool m_isDirty;
cppcore::TArray<Mesh*> mMeshArray;

MeshEntry() = default;
~MeshEntry() = default;
};

struct RenderBatchData {
Expand Down Expand Up @@ -718,7 +720,10 @@ struct RenderBatchData {
osre_assert(id != nullptr);
}

~RenderBatchData() = default;

MeshEntry *getMeshEntryByName(const c8 *name);

UniformVar *getVarByName(const c8 *name);
};

Expand All @@ -740,9 +745,7 @@ struct PassData {
// empty
}

~PassData() {
// empty
}
~PassData() = default;

RenderBatchData *getBatchById(const c8 *id) const;
};
Expand Down Expand Up @@ -774,7 +777,7 @@ struct OSRE_EXPORT UniformVar {

private:
UniformVar();
~UniformVar();
~UniformVar() = default;
};

struct FrameSubmitCmd {
Expand Down Expand Up @@ -805,6 +808,8 @@ struct FrameSubmitCmd {
m_newMeshes() {
// empty
}

~FrameSubmitCmd() = default;
};

using FrameSubmitCmdAllocator = ::cppcore::TPoolAllocator<FrameSubmitCmd>;
Expand All @@ -817,6 +822,8 @@ struct UniformBuffer {
// empty
}

~UniformBuffer() = default;

size_t getSize() const {
return m_buffer.size();
}
Expand Down Expand Up @@ -892,6 +899,7 @@ struct UniformBuffer {
MemoryBuffer m_buffer;
};

/// @brief This struct is used to desribe a new frame to render.
struct Frame {
cppcore::TArray<PassData *> m_newPasses;
cppcore::TArray<FrameSubmitCmd*> m_submitCmds;
Expand All @@ -909,6 +917,7 @@ struct Frame {
Frame &operator=(const Frame &) = delete;
};

/// @brief This struct is used to descripe a frame buffer data structure.
struct FrameBuffer {
i32 m_width;
i32 m_height;
Expand All @@ -919,9 +928,7 @@ struct FrameBuffer {
// empty
}

~FrameBuffer() {
// empty
}
~FrameBuffer() = default;

FrameBuffer(const FrameBuffer &) = delete;
FrameBuffer(FrameBuffer &&) = delete;
Expand Down
Loading
Loading