Skip to content

Commit

Permalink
Remove duplicate operator statements (#338)
Browse files Browse the repository at this point in the history
* Remove duplicate operator statements

* Make raylib not introduce the operators
  • Loading branch information
RobLoach authored Nov 14, 2024
1 parent 7b9fd03 commit 3a6e7bb
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 9b3d019
GIT_TAG 5e6cdf3
GIT_SHALLOW 1
)
FetchContent_GetProperties(raylib)
Expand Down
6 changes: 3 additions & 3 deletions include/AudioStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class AudioStream : public ::AudioStream {
* Unload audio stream and free memory
*/
void Unload() {
if (IsReady()) {
if (IsValid()) {
::UnloadAudioStream(*this);
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ class AudioStream : public ::AudioStream {
/**
* Retrieve whether or not the audio stream is ready.
*/
bool IsReady() const { return ::IsAudioStreamReady(*this); }
bool IsValid() const { return ::IsAudioStreamValid(*this); }

/**
* Load audio stream (to stream raw audio pcm data)
Expand All @@ -192,7 +192,7 @@ class AudioStream : public ::AudioStream {
void Load(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels = 2) {
Unload();
set(::LoadAudioStream(SampleRate, SampleSize, Channels));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load audio stream");
}
}
Expand Down
6 changes: 3 additions & 3 deletions include/AutomationEventList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AutomationEventList : public ::AutomationEventList {
void Load(const char* fileName) {
Unload();
set(::LoadAutomationEventList(fileName));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load automation event list");
}
}
Expand All @@ -80,7 +80,7 @@ class AutomationEventList : public ::AutomationEventList {
* Update audio stream buffers with data
*/
void Unload() {
if (!IsReady()) {
if (!IsValid()) {
return;
}

Expand All @@ -96,7 +96,7 @@ class AutomationEventList : public ::AutomationEventList {
#endif
}

bool IsReady() { return events != nullptr; }
bool IsValid() { return events != nullptr; }

bool Export(const char* fileName) { return ::ExportAutomationEventList(*this, fileName); }

Expand Down
10 changes: 5 additions & 5 deletions include/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Font : public ::Font {
*/
void Load(const std::string& fileName) {
set(::LoadFont(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Font with from file: " + fileName);
}
}
Expand All @@ -175,14 +175,14 @@ class Font : public ::Font {
*/
void Load(const std::string& fileName, int fontSize, int* fontChars, int charCount) {
set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Font with from file with font size: " + fileName);
}
}

void Load(const ::Image& image, ::Color key, int firstChar) {
set(::LoadFontFromImage(image, key, firstChar));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Font with from image");
}
}
Expand All @@ -195,15 +195,15 @@ class Font : public ::Font {
int* fontChars,
int charsCount) {
set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, fontChars, charsCount));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Font " + fileType + " with from file data");
}
}

/**
* Returns if the font is ready to be used.
*/
bool IsReady() const { return ::IsFontReady(*this); }
bool IsValid() const { return ::IsFontValid(*this); }

/**
* Draw text using font and additional parameters.
Expand Down
12 changes: 6 additions & 6 deletions include/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Image : public ::Image {
*/
void Load(const std::string& fileName) {
set(::LoadImage(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Image from file: " + fileName);
}
}
Expand All @@ -222,7 +222,7 @@ class Image : public ::Image {
*/
void Load(const std::string& fileName, int width, int height, int format, int headerSize) {
set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Image from file: " + fileName);
}
}
Expand All @@ -236,7 +236,7 @@ class Image : public ::Image {
*/
void Load(const std::string& fileName, int* frames) {
set(::LoadImageAnim(fileName.c_str(), frames));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Image from file: " + fileName);
}
}
Expand All @@ -250,7 +250,7 @@ class Image : public ::Image {
*/
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Image data with file type: " + fileType);
}
}
Expand All @@ -264,7 +264,7 @@ class Image : public ::Image {
*/
void Load(const ::Texture2D& texture) {
set(::LoadImageFromTexture(texture));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Image from texture.");
}
}
Expand Down Expand Up @@ -728,7 +728,7 @@ class Image : public ::Image {
*
* @return True or false depending on whether the Image has been loaded.
*/
bool IsReady() const { return ::IsImageReady(*this); }
bool IsValid() const { return ::IsImageValid(*this); }
protected:
void set(const ::Image& image) {
data = image.data;
Expand Down
2 changes: 1 addition & 1 deletion include/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Material : public ::Material {
/**
* Check if material is ready
*/
bool IsReady() const { return ::IsMaterialReady(*this); }
bool IsValid() const { return ::IsMaterialValid(*this); }
protected:
void set(const ::Material& material) {
shader = material.shader;
Expand Down
6 changes: 6 additions & 0 deletions include/MeshUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ class MeshUnmanaged : public ::Mesh {
* Load model from generated mesh
*/
operator raylib::Model() { return ::LoadModelFromMesh(*this); }

/**
* Returns whether or not the Mesh is valid.
*/
bool IsValid() { return ::IsModelValid(*this); }

protected:
void set(const ::Mesh& mesh) {
vertexCount = mesh.vertexCount;
Expand Down
6 changes: 3 additions & 3 deletions include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Model : public ::Model {
/**
* Determines whether or not the Model has data in it.
*/
bool IsReady() const { return ::IsModelReady(*this); }
bool IsValid() const { return ::IsModelValid(*this); }

/**
* Loads a Model from the given file.
Expand All @@ -192,7 +192,7 @@ class Model : public ::Model {
*/
void Load(const std::string& fileName) {
set(::LoadModel(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Model from " + fileName);
}
}
Expand All @@ -204,7 +204,7 @@ class Model : public ::Model {
*/
void Load(const ::Mesh& mesh) {
set(::LoadModelFromMesh(mesh));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Model from Mesh");
}
}
Expand Down
6 changes: 3 additions & 3 deletions include/Music.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Music : public ::Music {
*/
void Load(const std::string& fileName) {
set(::LoadMusicStream(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException(TextFormat("Failed to load Music from file: %s", fileName.c_str()));
}
}
Expand All @@ -195,7 +195,7 @@ class Music : public ::Music {
*/
void Load(const std::string& fileType, unsigned char* data, int dataSize) {
set(::LoadMusicStreamFromMemory(fileType.c_str(), data, dataSize));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException(TextFormat("Failed to load Music from %s file dat", fileType.c_str()));
}
}
Expand All @@ -205,7 +205,7 @@ class Music : public ::Music {
*
* @return True or false depending on whether the Music has been loaded.
*/
bool IsReady() const { return ::IsMusicReady(*this); }
bool IsValid() const { return ::IsMusicValid(*this); }
protected:
void set(const ::Music& music) {
stream = music.stream;
Expand Down
2 changes: 1 addition & 1 deletion include/RenderTexture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class RenderTexture : public ::RenderTexture {
/**
* Retrieves whether or not the render texture is ready.
*/
bool IsReady() const { return ::IsRenderTextureReady(*this); }
bool IsValid() const { return ::IsRenderTextureValid(*this); }
protected:
void set(const ::RenderTexture& renderTexture) {
id = renderTexture.id;
Expand Down
2 changes: 1 addition & 1 deletion include/ShaderUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ShaderUnmanaged : public ::Shader {
/**
* Retrieves whether or not the shader is ready.
*/
bool IsReady() const { return id != 0 && locs != nullptr; }
bool IsValid() const { return ::IsShaderValid(*this); }
protected:
void set(const ::Shader& shader) {
id = shader.id;
Expand Down
6 changes: 3 additions & 3 deletions include/Sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Sound : public ::Sound {
*/
void Load(const std::string& fileName) {
set(::LoadSound(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Sound from file");
}
}
Expand All @@ -176,7 +176,7 @@ class Sound : public ::Sound {
*/
void Load(const ::Wave& wave) {
set(::LoadSoundFromWave(wave));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Wave");
}
}
Expand All @@ -186,7 +186,7 @@ class Sound : public ::Sound {
*
* @return True or false depending on whether the Sound buffer is loaded.
*/
bool IsReady() const { return ::IsSoundReady(*this); }
bool IsValid() const { return ::IsSoundValid(*this); }
protected:
void set(const ::Sound& sound) {
frameCount = sound.frameCount;
Expand Down
8 changes: 4 additions & 4 deletions include/TextureUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TextureUnmanaged : public ::Texture {
*/
void Load(const ::Image& image) {
set(::LoadTextureFromImage(image));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Texture from Image");
}
}
Expand All @@ -106,7 +106,7 @@ class TextureUnmanaged : public ::Texture {
*/
void Load(const ::Image& image, int layoutType) {
set(::LoadTextureCubemap(image, layoutType));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Texture from Cubemap");
}
}
Expand All @@ -116,7 +116,7 @@ class TextureUnmanaged : public ::Texture {
*/
void Load(const std::string& fileName) {
set(::LoadTexture(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Texture from file: " + fileName);
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ class TextureUnmanaged : public ::Texture {
*
* @return True or false depending on whether the Texture has data.
*/
bool IsReady() const { return id != 0; }
bool IsValid() const { return IsTextureValid(*this); }
protected:
void set(const ::Texture& texture) {
id = texture.id;
Expand Down
1 change: 1 addition & 0 deletions include/Vector2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Vector2 : public ::Vector2 {
*/
Vector2 Divide(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); }


/**
* Divide vector by vector
*/
Expand Down
6 changes: 3 additions & 3 deletions include/Wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Wave : public ::Wave {
*/
void Load(const std::string& fileName) {
set(::LoadWave(fileName.c_str()));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Wave from file: " + fileName);
}
}
Expand All @@ -184,7 +184,7 @@ class Wave : public ::Wave {
*/
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
if (!IsReady()) {
if (!IsValid()) {
throw RaylibException("Failed to load Wave from file data of type: " + fileType);
}
}
Expand All @@ -194,7 +194,7 @@ class Wave : public ::Wave {
*
* @return True or false depending on whether the wave data has been loaded.
*/
bool IsReady() const { return ::IsWaveReady(*this); }
bool IsValid() const { return ::IsWaveValid(*this); }
protected:
void set(const ::Wave& wave) {
frameCount = wave.frameCount;
Expand Down
1 change: 1 addition & 0 deletions include/raymath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
#pragma GCC diagnostic push // These throw a warnings on visual studio, need to check if __GNUC__ is defined to use it.
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#define RAYMATH_DISABLE_CPP_OPERATORS
#include "raymath.h" // NOLINT
#ifdef __GNUC__
#pragma GCC diagnostic pop
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raylib-cpp",
"version": "5.0.2",
"version": "5.5.0",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"main": "index.js",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions projects/CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 9b3d019
GIT_TAG 5e6cdf3
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(raylib)
Expand All @@ -18,7 +18,7 @@ endif()
find_package(raylib_cpp QUIET)
if (NOT raylib_cpp_FOUND)
if (NOT DEFINED RAYLIB_CPP_VERSION)
set(RAYLIB_CPP_VERSION v5.0.2)
set(RAYLIB_CPP_VERSION next)
endif()
include(FetchContent)
FetchContent_Declare(
Expand Down
Loading

0 comments on commit 3a6e7bb

Please sign in to comment.