Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim Kulling committed Sep 14, 2023
1 parent 575bbc8 commit 6ca457b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 52 deletions.
43 changes: 21 additions & 22 deletions include/osre/RenderBackend/RenderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ enum class TextureStageType {
NumTextureStageTypes ///< Number of enums.
};

/// @brief This enum describes different texture parameter names.
/// @brief This enum describes different texture parameter names.
enum class TextureParameterName {
InvalidTextureParameterName = -1, ///< Enum for invalid enum.
TextureParamMinFilter = 0, ///< The min filter name.
Expand All @@ -124,7 +124,7 @@ enum class TextureParameterName {
NumTextureParameterNames ///< Number of enums.
};

/// @brief This enum describes the parameters which are related the the parameter names ( @see 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.
Expand All @@ -136,7 +136,7 @@ enum class TextureParameterType {
InvalidTextureParameterType, ///< Enum for invalid enum.
};

/// @brief This enum describes the index data type.
/// @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.
Expand All @@ -146,7 +146,7 @@ enum class IndexType {
InvalidIndexType, ///< Enum for invalid enum.
};

/// @brief This enum describes the primitive types for rendering vertex information.
/// @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.
Expand Down Expand Up @@ -187,7 +187,7 @@ enum class ParameterType {
InvalidParameterType
};

/// @brief This enum to describes the type of the vertex attribute.
/// @brief This enum to describes the type of the vertex attribute.
enum class VertexAttribute : int {
Position = 0, ///< "position"
Normal, ///< "normal"
Expand All @@ -210,22 +210,22 @@ enum class VertexAttribute : int {
InvalidVertexAttr ///< Enum for invalid enum.
};

/// @brief This enum describes the vertex data format.
/// @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)
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.
};

/// @brief
/// @brief This enum describes the light type.
enum class LightType {
Directional = 0,
Point,
Expand All @@ -238,8 +238,8 @@ enum class LightType {
/// @brief This struct declares a render vertex for textured geometry.
struct OSRE_EXPORT ColorVert {
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::vec3 normal; ///< The normal vector ( x|y|z )
glm::vec3 color0; ///< The diffuse color ( r|g|b )

ColorVert();

Expand All @@ -249,7 +249,7 @@ struct OSRE_EXPORT ColorVert {
static const String *getAttributes();
};

/// @brief This struct declares a render vertex for textured geometry.
/// @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 )
Expand Down Expand Up @@ -334,7 +334,7 @@ struct ExtensionProperty {
}
};

/// @brief
/// @brief
struct OSRE_EXPORT VertComponent {
VertexAttribute m_attrib;
VertexFormat m_format;
Expand All @@ -346,7 +346,7 @@ struct OSRE_EXPORT VertComponent {
OSRE_NON_COPYABLE(VertComponent)
};

/// @brief
/// @brief
struct OSRE_EXPORT VertexLayout {
static VertComponent ErrorComp;
String *m_attributes;
Expand All @@ -367,7 +367,7 @@ struct OSRE_EXPORT VertexLayout {
OSRE_NON_COPYABLE(VertexLayout)
};

/// @brief This struct is used to describe data for a GPU buffer.
/// @brief This struct is used to describe data for a GPU buffer.
struct OSRE_EXPORT BufferData {
using BufferDataAllocator = ::cppcore::TPoolAllocator<BufferData>;
friend BufferDataAllocator;
Expand All @@ -379,7 +379,6 @@ struct OSRE_EXPORT BufferData {
BufferAccessType m_access; ///< Access token ( @see BufferAccessType )

static BufferData *alloc(BufferType type, size_t sizeInBytes, BufferAccessType access);
static void free(BufferData *data);
void copyFrom(void *data, size_t size);
void attach(const void *data, size_t size);
BufferType getBufferType() const;
Expand Down
14 changes: 3 additions & 11 deletions src/Engine/RenderBackend/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <osre/Debugging/osre_debugging.h>
#include <osre/RenderBackend/Material.h>


namespace OSRE {
namespace RenderBackend {

Expand Down Expand Up @@ -56,14 +55,6 @@ Mesh::Mesh(const String &name, VertexType vertexType, IndexType indextype) :
}

Mesh::~Mesh() {
mMaterial = nullptr;

BufferData::free(mVertexBuffer);
mVertexBuffer = nullptr;

BufferData::free(mIndexBuffer);
mIndexBuffer = nullptr;

s_Ids.releaseId(mId);
}

Expand Down Expand Up @@ -161,5 +152,6 @@ void Mesh::addPrimitiveGroup( PrimitiveGroup *group ) {
mPrimGroups.add(group);
}

} // Namespace RenderBackend
} // Namespace OSRE
} // namespace RenderBackend
} // namespace OSRE

11 changes: 2 additions & 9 deletions src/Engine/RenderBackend/RenderCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static const String
static const String ErrorCmpName = "Error";

// List of attributes for color vertices
static const ui32 NumColorVertAttributes = 3;
static constexpr ui32 NumColorVertAttributes = 3;
static const String ColorVertAttributes[NumColorVertAttributes] = {
"position", "normal", "color0"
};
Expand All @@ -88,7 +88,7 @@ const String *ColorVert::getAttributes() {
}

// List of attributes for render vertices
static const ui32 NumRenderVertAttributes = 4;
static constexpr ui32 NumRenderVertAttributes = 4;

static const String RenderVertAttributes[NumRenderVertAttributes] = {
"position",
Expand Down Expand Up @@ -266,12 +266,6 @@ BufferData *BufferData::alloc(BufferType type, size_t sizeInBytes, BufferAccessT
return buffer;
}

void BufferData::free(BufferData *data) {
if (nullptr == data) {
return;
}
}

void BufferData::copyFrom(void *data, size_t size) {
if (nullptr == data) {
return;
Expand Down Expand Up @@ -487,7 +481,6 @@ GeoInstanceData::GeoInstanceData() :
}

GeoInstanceData::~GeoInstanceData() {
BufferData::free(m_data);
m_data = nullptr;
}

Expand Down
2 changes: 0 additions & 2 deletions test/RenderTests/src/AbstractRenderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ namespace RenderTest {

using namespace ::OSRE::RenderBackend;

static const c8 *Tag = "AbstractRenderTest";

AbstractRenderTest::AbstractRenderTest(const String &renderTestName) :
mRenderTestName(renderTestName),
mWindow(nullptr) {
Expand Down
3 changes: 1 addition & 2 deletions test/RenderTests/src/Textures/Texture3DRenderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ namespace RenderTest {

using namespace ::OSRE::RenderBackend;

static const c8 *Tag = "Texture3DRenderTest";

class Texture3DRenderTest : public AbstractRenderTest {
f32 m_angle;
TransformMatrixBlock m_transformMatrix;
Expand Down Expand Up @@ -90,3 +88,4 @@ ATTACH_RENDERTEST(Texture3DRenderTest)

} // namespace RenderTest
} // namespace OSRE

9 changes: 3 additions & 6 deletions test/UnitTests/src/RenderBackend/RenderCommonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,16 @@ TEST_F( RenderCommonTest, allocBufferDataTest ) {
EXPECT_EQ(data->m_access, BufferAccessType::ReadWrite);
EXPECT_EQ(data->getSize(), 100u);
EXPECT_EQ(data->m_type, BufferType::VertexBuffer);

BufferData::free(data);
}

TEST_F( RenderCommonTest, copyBufferDataTest ) {
BufferData *data = BufferData::alloc(BufferType::VertexBuffer, 100, BufferAccessType::ReadWrite);

static const ui32 size = 100;
static const unsigned char Value = 9;
void *buffer = new unsigned char[size];
static constexpr ui32 size = 100;
static constexpr unsigned char Value = 9;
unsigned char *buffer = new unsigned char[size];
::memset(buffer, Value, size);
data->copyFrom(buffer, size);
BufferData::free(data);

delete[] buffer;
}
Expand Down

0 comments on commit 6ca457b

Please sign in to comment.