Merge pull request #148 from RobLoach/update-2021-10-17

Update to raylib 4.0.0
This commit is contained in:
Rob Loach
2021-11-04 21:52:04 -04:00
committed by GitHub
35 changed files with 236 additions and 214 deletions

View File

@@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [x.x.x] - xxxx-xx-xx
## [4.0.0] - 2021-11-04
### Changes
- Update to [raylib 4.0.0](https://github.com/raysan5/raylib/releases/tag/4.0.0)
- For tests, replaced catch.hpp with `assert()` calls
- Added assignment operators for objects ([#142](https://github.com/RobLoach/raylib-cpp/pull/142) by [@marciejewiczow](https://github.com/maciejewiczow))
- Replaced `NULL` with `nullptr`

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project (raylib-cpp
VERSION 3.7.0
VERSION 4.0.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX)

View File

@@ -47,7 +47,7 @@ int main() {
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON);
DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY);
DrawText(TextFormat("%i", randValue), 360, 180, 80, LIGHTGRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------

View File

@@ -30,7 +30,7 @@ int main(void)
// NOTE: By default each cube is mapped to one part of texture atlas
raylib::Texture texture("resources/cubicmap_atlas.png"); // Load map texture
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
// Get map image data to be used for collision detection
Color *mapPixels = imMap.LoadColors();

View File

@@ -89,7 +89,7 @@ int main(void)
DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK);
// Draw collision area
DrawText(FormatText("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
}
DrawFPS(10, 10);

View File

@@ -103,8 +103,8 @@ int main(void)
}
DrawRectangle(0, 0, screenWidth, 40, BLACK);
DrawText(FormatText("bunnies: %i", bunnies.size()), 120, 10, 20, GREEN);
DrawText(FormatText("batched draw calls: %i", 1 + bunnies.size()/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON);
DrawText(TextFormat("bunnies: %i", bunnies.size()), 120, 10, 20, GREEN);
DrawText(TextFormat("batched draw calls: %i", 1 + bunnies.size()/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON);
DrawFPS(10, 10);
}

View File

@@ -18,7 +18,7 @@ class AudioStream : public ::AudioStream {
* Init audio stream (to stream raw audio pcm data)
*/
AudioStream(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels = 2) {
set(InitAudioStream(SampleRate, SampleSize, Channels));
set(LoadAudioStream(SampleRate, SampleSize, Channels));
}
AudioStream(const AudioStream&) = delete;
@@ -33,7 +33,7 @@ class AudioStream : public ::AudioStream {
}
~AudioStream() {
Close();
Unload();
}
GETTERSETTER(rAudioBuffer *, Buffer, buffer)
@@ -53,7 +53,7 @@ class AudioStream : public ::AudioStream {
return *this;
}
Close();
Unload();
set(other);
other.buffer = nullptr;
@@ -73,10 +73,10 @@ class AudioStream : public ::AudioStream {
}
/**
* Close audio stream and free memory
* Unload audio stream and free memory
*/
inline void Close() {
::CloseAudioStream(*this);
inline void Unload() {
::UnloadAudioStream(*this);
}
/**

View File

@@ -18,7 +18,7 @@ class BoundingBox : public ::BoundingBox {
* Compute mesh bounding box limits
*/
BoundingBox(const ::Mesh& mesh) {
set(::MeshBoundingBox(mesh));
set(::GetMeshBoundingBox(mesh));
}
BoundingBox(::Vector3 minMax) : ::BoundingBox{minMax, minMax} {}
@@ -58,7 +58,14 @@ class BoundingBox : public ::BoundingBox {
* Detect collision between ray and bounding box
*/
inline bool CheckCollision(const ::Ray& ray) const {
return CheckCollisionRayBox(ray, *this);
return GetRayCollisionBox(ray, *this).hit;
}
/**
* Get collision information between ray and bounding box
*/
inline RayCollision GetCollision(const ::Ray& ray) const {
return GetRayCollisionBox(ray, *this);
}
private:

View File

@@ -25,7 +25,7 @@ install(FILES
physac.hpp
Physics.hpp
Ray.hpp
RayHitInfo.hpp
RayCollision.hpp
raylib-cpp-utils.hpp
raylib-cpp.hpp
raylib.hpp

View File

@@ -143,7 +143,7 @@ class Camera3D : public ::Camera3D {
const ::Texture2D& texture,
::Rectangle sourceRec,
::Vector3 center,
float size,
::Vector2 size,
::Color tint = {255, 255, 255, 255}) {
::DrawBillboardRec(*this, texture, sourceRec, center, size, tint);
return *this;

View File

@@ -46,7 +46,7 @@ class Color : public ::Color {
/**
* Get Color structure from hexadecimal value
*/
Color(int hexValue) {
Color(unsigned int hexValue) {
set(::GetColor(hexValue));
}
@@ -163,13 +163,14 @@ class Color : public ::Color {
}
inline Color& DrawText(
const ::Font& font,
const ::Font font,
const std::string& text,
::Rectangle rec,
::Vector2 position,
::Vector2 origin,
float rotation,
float fontSize,
float spacing,
bool wordWrap = false) {
::DrawTextRec(font, text.c_str(), rec, fontSize, spacing, wordWrap, *this);
float spacing) {
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, *this);
return *this;
}
@@ -198,7 +199,7 @@ class Color : public ::Color {
return *this;
}
inline Color& DrawRectangleLines(::Rectangle rec, int lineThick) {
inline Color& DrawRectangleLines(::Rectangle rec, float lineThick) {
::DrawRectangleLinesEx(rec, lineThick, *this);
return *this;
}

View File

@@ -44,11 +44,11 @@ class Font : public ::Font {
set(other);
other.baseSize = 0;
other.charsCount = 0;
other.charsPadding = 0;
other.texture = { 0 };
other.glyphCount = 0;
other.glyphPadding = 0;
other.texture = {};
other.recs = nullptr;
other.chars = nullptr;
other.glyphs = nullptr;
}
~Font() {
@@ -60,11 +60,11 @@ class Font : public ::Font {
}
GETTERSETTER(int, BaseSize, baseSize)
GETTERSETTER(int, CharsCount, charsCount)
GETTERSETTER(int, CharsPadding, charsPadding)
GETTERSETTER(int, GlyphCount, glyphCount)
GETTERSETTER(int, GlyphPadding, glyphPadding)
GETTERSETTER(::Texture2D, Texture, texture)
GETTERSETTER(::Rectangle*, Recs, recs)
GETTERSETTER(::CharInfo*, Chars, chars)
GETTERSETTER(::GlyphInfo*, Glyphs, glyphs)
Font& operator=(const ::Font& font) {
set(font);
@@ -82,11 +82,11 @@ class Font : public ::Font {
set(other);
other.baseSize = 0;
other.charsCount = 0;
other.charsPadding = 0;
other.texture = { 0 };
other.glyphCount = 0;
other.glyphPadding = 0;
other.texture = {};
other.recs = nullptr;
other.chars = nullptr;
other.glyphs = nullptr;
return *this;
}
@@ -100,20 +100,15 @@ class Font : public ::Font {
return *this;
}
inline Font& DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing,
bool wordWrap = false, ::Color tint = WHITE) {
::DrawTextRec(*this, text.c_str(), rec, fontSize, spacing, wordWrap, tint);
return *this;
}
/**
* Draw text using font inside rectangle limits with support for text selection.
*/
inline Font& DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing,
bool wordWrap, ::Color tint, int selectStart, int selectLength, ::Color selectText,
::Color selectBack) {
::DrawTextRecEx(*this, text.c_str(), rec, fontSize, spacing, wordWrap, tint,
selectStart, selectLength, selectText, selectBack);
inline Font& DrawText(
const std::string& text,
::Vector2 position,
::Vector2 origin,
float rotation,
float fontSize,
float spacing,
::Color tint = WHITE) {
::DrawTextPro(*this, text.c_str(), position, origin, rotation, fontSize, spacing, tint);
return *this;
}
@@ -153,11 +148,11 @@ class Font : public ::Font {
private:
void set(const ::Font& font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
charsPadding = font.charsPadding;
glyphCount = font.glyphCount;
glyphPadding = font.glyphPadding;
texture = font.texture;
recs = font.recs;
chars = font.chars;
glyphs = font.glyphs;
}
};
} // namespace raylib

View File

@@ -67,7 +67,7 @@ RLCPPAPI inline void TakeScreenshot(const std::string& fileName) {
RLCPPAPI std::string LoadFileText(const std::string& fileName) {
char* text = ::LoadFileText(fileName.c_str());
std::string output(text);
::UnloadFileText((unsigned char*)text);
::UnloadFileText(text);
return output;
}
@@ -189,13 +189,6 @@ RLCPPAPI inline void OpenURL(const std::string& url) {
return ::OpenURL(url.c_str());
}
/**
* Check gamepad name (if available)
*/
RLCPPAPI inline bool IsGamepadName(int gamepad, const std::string& name) {
return ::IsGamepadName(gamepad, name.c_str());
}
/**
* Update camera depending on selected mode
*/

View File

@@ -45,13 +45,6 @@ class Gamepad {
return ::IsGamepadAvailable(number);
}
/**
* Check gamepad name (if available)
*/
inline bool IsName(const std::string& name) const {
return ::IsGamepadName(number, name.c_str());
}
/**
* Return gamepad internal name id
*/

View File

@@ -35,13 +35,17 @@ class Image : public ::Image {
}
Image(const ::Texture2D& texture) {
set(::GetTextureData(texture));
set(::LoadImageFromTexture(texture));
}
Image(int width, int height, ::Color color = {255, 255, 255, 255}) {
set(::GenImageColor(width, height, color));
}
Image(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) {
set(::ImageText(text.c_str(), fontSize, color));
}
Image(const ::Font& font, const std::string& text, float fontSize, float spacing,
::Color tint = {255, 255, 255, 255}) {
set(::ImageTextEx(font, text.c_str(), fontSize, spacing, tint));
@@ -74,8 +78,8 @@ class Image : public ::Image {
/**
* Get pixel data from screen buffer and return an Image (screenshot)
*/
static ::Image GetScreenData() {
return ::GetScreenData();
static ::Image LoadFromScreen() {
return ::LoadImageFromScreen();
}
/**
@@ -122,14 +126,6 @@ class Image : public ::Image {
return ::GenImageWhiteNoise(width, height, factor);
}
/**
* Generate image: perlin noise
*/
static ::Image PerlinNoise(int width, int height, int offsetX, int offsetY,
float scale = 1.0f) {
return ::GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
}
/**
* Generate image: cellular algorithm. Bigger tileSize means bigger cells
*/
@@ -271,14 +267,6 @@ class Image : public ::Image {
return *this;
}
/**
* Apply alpha mask to image
*/
inline Image& AlphaMask(const ::Image& alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}
/**
* Crop image depending on alpha value
*/
@@ -287,6 +275,22 @@ class Image : public ::Image {
return *this;
}
/**
* Clear alpha channel to desired color
*/
inline Image& AlphaClear(::Color color, float threshold) {
::ImageAlphaClear(this, color, threshold);
return *this;
}
/**
* Apply alpha mask to image
*/
inline Image& AlphaMask(const ::Image& alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}
/**
* Premultiply alpha channel
*/

View File

@@ -30,7 +30,7 @@ class Material : public ::Material {
set(other);
other.maps = nullptr;
other.shader = { 0 };
other.shader = {};
}
~Material() {
@@ -68,7 +68,7 @@ class Material : public ::Material {
set(other);
other.maps = nullptr;
other.shader = { 0 };
other.shader = {};
return *this;
}

View File

@@ -19,7 +19,23 @@ class Mesh : public ::Mesh {
set(mesh);
}
Mesh(int vertexCount, int triangleCount) : ::Mesh{vertexCount, triangleCount} {}
Mesh(int vertexCount, int triangleCount) : ::Mesh{
vertexCount,
triangleCount,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
0,
nullptr
} {}
/**
* Load meshes from model file
@@ -133,7 +149,7 @@ class Mesh : public ::Mesh {
GETTERSETTER(unsigned short *, Indices, indices) // NOLINT
GETTERSETTER(float *, AnimVertices, animVertices)
GETTERSETTER(float *, AnimNormals, animNormals)
GETTERSETTER(int *, BoneIds, boneIds)
GETTERSETTER(unsigned char *, BoneIds, boneIds)
GETTERSETTER(float *, BoneWeights, boneWeights)
GETTERSETTER(unsigned int, VaoId, vaoId)
GETTERSETTER(unsigned int *, VboId, vboId)
@@ -220,7 +236,7 @@ class Mesh : public ::Mesh {
* Compute mesh bounding box limits
*/
inline raylib::BoundingBox BoundingBox() const {
return ::MeshBoundingBox(*this);
return ::GetMeshBoundingBox(*this);
}
/**
@@ -234,7 +250,7 @@ class Mesh : public ::Mesh {
* Compute mesh tangents
*/
inline Mesh& Tangents() {
::MeshTangents(this);
::GenMeshTangents(this);
return *this;
}
@@ -242,7 +258,7 @@ class Mesh : public ::Mesh {
* Compute mesh binormals (aka bitangent)
*/
inline Mesh& Binormals() {
::MeshBinormals(this);
::GenMeshBinormals(this);
return *this;
}

View File

@@ -109,8 +109,8 @@ class Model : public ::Model {
/**
* Get collision info between ray and model
*/
inline RayHitInfo GetCollision(const ::Ray& ray) const {
return ::GetCollisionRayModel(ray, *this);
inline RayCollision GetCollision(const ::Ray& ray) const {
return ::GetRayCollisionModel(ray, *this);
}
/**

View File

@@ -37,7 +37,7 @@ class ModelAnimation : public ::ModelAnimation {
* Load model animations from file
*/
static std::vector<ModelAnimation> Load(const std::string& fileName) {
int count = 0;
unsigned int count = 0;
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);

View File

@@ -38,8 +38,8 @@ class Music : public ::Music {
other.ctxType = 0;
other.ctxData = nullptr;
other.looping = false;
other.sampleCount = 0;
other.stream = { 0 };
other.frameCount = 0;
other.stream = {};
}
/**
@@ -50,7 +50,7 @@ class Music : public ::Music {
}
GETTERSETTER(::AudioStream, Stream, stream)
GETTERSETTER(unsigned int, SampleCount, sampleCount)
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(bool, Looping, looping)
GETTERSETTER(int, CtxType, ctxType)
GETTERSETTER(void*, CtxData, ctxData)
@@ -73,8 +73,8 @@ class Music : public ::Music {
other.ctxType = 0;
other.ctxData = nullptr;
other.looping = false;
other.sampleCount = 0;
other.stream = { 0 };
other.frameCount = 0;
other.stream = {};
return *this;
}
@@ -126,11 +126,19 @@ class Music : public ::Music {
return *this;
}
/**
* Seek music to a position (in seconds)
*/
inline Music& Seek(float position) {
SeekMusicStream(*this, position);
return *this;
}
/**
* Check if music is playing
*/
inline bool IsPlaying() const {
return ::IsMusicPlaying(*this);
return ::IsMusicStreamPlaying(*this);
}
/**
@@ -168,7 +176,7 @@ class Music : public ::Music {
ctxType = music.ctxType;
ctxData = music.ctxData;
looping = music.looping;
sampleCount = music.sampleCount;
frameCount = music.frameCount;
stream = music.stream;
}
};

View File

@@ -3,7 +3,7 @@
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./RayHitInfo.hpp"
#include "./RayCollision.hpp"
namespace raylib {
/**
@@ -41,43 +41,42 @@ class Ray : public ::Ray {
* Detect collision between ray and sphere
*/
inline bool CheckCollisionSphere(::Vector3 center, float radius) const {
return CheckCollisionRaySphere(*this, center, radius);
return GetRayCollisionSphere(*this, center, radius).hit;
}
/**
* Detect collision between ray and sphere, returns collision point
* Get collision information between ray and sphere
*/
inline bool CheckCollisionSphere(::Vector3 center, float radius,
::Vector3 *collisionPoint) const {
return CheckCollisionRaySphereEx(*this, center, radius, collisionPoint);
inline RayCollision GetCollisionSphere(::Vector3 center, float radius) const {
return GetRayCollisionSphere(*this, center, radius);
}
/**
* Detect collision between ray and box
*/
inline bool CheckCollision(const ::BoundingBox& box) const {
return CheckCollisionRayBox(*this, box);
return GetRayCollisionBox(*this, box).hit;
}
/**
* Get collision information between ray and box
*/
inline RayCollision GetCollision(const ::BoundingBox& box) const {
return GetRayCollisionBox(*this, box);
}
/**
* Get collision info between ray and model
*/
inline RayHitInfo GetCollision(const ::Model& model) const {
return GetCollisionRayModel(*this, model);
inline RayCollision GetCollision(const ::Model& model) const {
return GetRayCollisionModel(*this, model);
}
/**
* Get collision info between ray and triangle
*/
inline RayHitInfo GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
return GetCollisionRayTriangle(*this, p1, p2, p3);
}
/**
* Get collision info between ray and ground plane (Y-normal plane)
*/
inline RayHitInfo GetCollisionGround(float groundHeight) const {
return GetCollisionRayGround(*this, groundHeight);
inline RayCollision GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
return GetRayCollisionTriangle(*this, p1, p2, p3);
}
private:

60
include/RayCollision.hpp Normal file
View File

@@ -0,0 +1,60 @@
#ifndef RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
#define RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
namespace raylib {
/**
* Raycast hit information
*/
class RayCollision : public ::RayCollision {
public:
RayCollision(const ::RayCollision& ray) {
set(ray);
}
RayCollision(bool hit, float distance, ::Vector3 point, ::Vector3 normal) : ::RayCollision{hit, distance, point, normal} {}
/**
* Get collision info between ray and mesh
*/
RayCollision(const ::Ray& ray, const ::Mesh& mesh, const ::Matrix& transform) {
set(::GetRayCollisionMesh(ray, mesh, transform));
}
/**
* Get collision info between ray and model
*/
RayCollision(const ::Ray& ray, const ::Model& model) {
set(::GetRayCollisionModel(ray, model));
}
/**
* Get collision info between ray and triangle
*/
RayCollision(const ::Ray& ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
set(::GetRayCollisionTriangle(ray, p1, p2, p3));
}
RayCollision& operator=(const ::RayCollision& ray) {
set(ray);
return *this;
}
GETTERSETTER(bool, Hit, hit)
GETTERSETTER(float, Distance, distance)
GETTERSETTER(::Vector3, Position, point)
GETTERSETTER(::Vector3, Normal, normal)
private:
inline void set(const ::RayCollision& ray) {
hit = ray.hit;
distance = ray.distance;
point = ray.point;
normal = ray.normal;
}
};
} // namespace raylib
#endif // RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_

View File

@@ -1,67 +0,0 @@
#ifndef RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
#define RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
namespace raylib {
/**
* Raycast hit information
*/
class RayHitInfo : public ::RayHitInfo {
public:
RayHitInfo(const ::RayHitInfo& ray) {
set(ray);
}
RayHitInfo(bool hit, float distance, ::Vector3 position, ::Vector3 normal) : ::RayHitInfo{hit, distance, position, normal} {}
/**
* Get collision info between ray and mesh
*/
RayHitInfo(const ::Ray& ray, const ::Mesh& mesh, const ::Matrix& transform) {
set(::GetCollisionRayMesh(ray, mesh, transform));
}
/**
* Get collision info between ray and model
*/
RayHitInfo(const ::Ray& ray, const ::Model& model) {
set(::GetCollisionRayModel(ray, model));
}
/**
* Get collision info between ray and triangle
*/
RayHitInfo(const ::Ray& ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
set(::GetCollisionRayTriangle(ray, p1, p2, p3));
}
/**
* Get collision info between ray and ground plane (Y-normal plane)
*/
RayHitInfo(const ::Ray& ray, float groundHeight) {
set(::GetCollisionRayGround(ray, groundHeight));
}
RayHitInfo& operator=(const ::RayHitInfo& ray) {
set(ray);
return *this;
}
GETTERSETTER(bool, Hit, hit)
GETTERSETTER(float, Distance, distance)
GETTERSETTER(::Vector3, Position, position)
GETTERSETTER(::Vector3, Normal, normal)
private:
inline void set(const ::RayHitInfo& ray) {
hit = ray.hit;
distance = ray.distance;
position = ray.position;
normal = ray.normal;
}
};
} // namespace raylib
#endif // RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_

View File

@@ -81,7 +81,7 @@ class Rectangle : public ::Rectangle {
return *this;
}
inline Rectangle& DrawLines(::Color color, int lineThick) {
inline Rectangle& DrawLines(::Color color, float lineThick) {
::DrawRectangleLinesEx(*this, lineThick, color);
return *this;
}
@@ -91,8 +91,8 @@ class Rectangle : public ::Rectangle {
return *this;
}
inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick,
::Color color) {
inline Rectangle& DrawRoundedLines(float roundness, int segments,
float lineThick, ::Color color) {
::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
return *this;
}

View File

@@ -26,8 +26,8 @@ class RenderTexture : public ::RenderTexture {
set(other);
other.id = 0;
other.texture = { 0 };
other.depth = { 0 };
other.texture = {};
other.depth = {};
}
GETTERSETTER(unsigned int, Id, id)
@@ -50,8 +50,8 @@ class RenderTexture : public ::RenderTexture {
set(other);
other.id = 0;
other.texture = { 0 };
other.depth = { 0 };
other.texture = {};
other.depth = {};
return *this;
}

View File

@@ -23,7 +23,7 @@ class Sound : public ::Sound {
Sound(Sound&& other) {
set(other);
other.sampleCount = 0;
other.frameCount = 0;
other.stream = { 0, 0, 0, 0 };
};
@@ -39,7 +39,7 @@ class Sound : public ::Sound {
Unload();
}
GETTERSETTER(unsigned int, SampleCount, sampleCount)
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(::AudioStream, Stream, stream)
Sound& operator=(Sound&& other) {
@@ -49,7 +49,7 @@ class Sound : public ::Sound {
Unload();
set(other);
other.sampleCount = 0;
other.frameCount = 0;
other.stream = { 0, 0, 0, 0 };
return *this;
@@ -67,7 +67,7 @@ class Sound : public ::Sound {
* Update sound buffer with new data, assuming it's the same sample count.
*/
inline Sound& Update(const void *data) {
::UpdateSound(*this, data, static_cast<int>(sampleCount));
::UpdateSound(*this, data, static_cast<int>(frameCount));
return *this;
}
@@ -151,7 +151,7 @@ class Sound : public ::Sound {
private:
inline void set(const ::Sound& sound) {
sampleCount = sound.sampleCount;
frameCount = sound.frameCount;
stream = sound.stream;
}
};

View File

@@ -139,7 +139,7 @@ class Texture : public ::Texture {
* Get pixel data from GPU texture and return an Image
*/
inline ::Image GetData() const {
return ::GetTextureData(*this);
return ::LoadImageFromTexture(*this);
}
/**
@@ -255,6 +255,14 @@ class Texture : public ::Texture {
return *this;
}
/**
* Set texture and rectangle to be used on shapes drawing.
*/
inline Texture& SetShapes(const ::Rectangle& source) {
::SetShapesTexture(*this, source);
return *this;
}
private:
inline void set(const ::Texture& texture) {
id = texture.id;

View File

@@ -17,12 +17,12 @@ class Wave : public ::Wave {
}
Wave(
unsigned int sampleCount = 0,
unsigned int frameCount = 0,
unsigned int sampleRate = 0,
unsigned int sampleSize = 0,
unsigned int channels = 0,
void *data = nullptr
) : ::Wave{sampleCount, sampleRate, sampleSize, channels, data} { }
) : ::Wave{frameCount, sampleRate, sampleSize, channels, data} { }
/**
* Load wave data from file
@@ -45,7 +45,7 @@ class Wave : public ::Wave {
Wave(Wave&& other) {
set(other);
other.sampleCount = 0;
other.frameCount = 0;
other.sampleRate = 0;
other.sampleSize = 0;
other.channels = 0;
@@ -59,7 +59,7 @@ class Wave : public ::Wave {
Unload();
}
GETTERSETTER(unsigned int, SampleCount, sampleCount)
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
GETTERSETTER(unsigned int, Channels, channels)
@@ -89,7 +89,7 @@ class Wave : public ::Wave {
Unload();
set(other);
other.sampleCount = 0;
other.frameCount = 0;
other.sampleRate = 0;
other.sampleSize = 0;
other.channels = 0;
@@ -177,7 +177,7 @@ class Wave : public ::Wave {
private:
inline void set(const ::Wave& wave) {
sampleCount = wave.sampleCount;
frameCount = wave.frameCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;
channels = wave.channels;

View File

@@ -7,7 +7,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "physac.h" // NOLINT
#include "extras/physac.h" // NOLINT
#ifdef __cplusplus
}
#endif

View File

@@ -49,7 +49,7 @@
#include "./Mouse.hpp"
#include "./Music.hpp"
#include "./Ray.hpp"
#include "./RayHitInfo.hpp"
#include "./RayCollision.hpp"
#include "./Rectangle.hpp"
#include "./RenderTexture.hpp"
#include "./Shader.hpp"

View File

@@ -1,6 +1,6 @@
{
"name": "raylib-cpp",
"version": "3.7.0",
"version": "4.0.0",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"homepage": "https://github.com/robloach/raylib-cpp",
"bugs": {

View File

@@ -8,7 +8,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG b6c8d343dca2ef19c23c50975328a028124cf3cb
GIT_TAG 0851960397f02a477d80eda2239f90fae14dec64
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?

View File

@@ -14,3 +14,6 @@ target_link_libraries(raylib_test raylib-cpp raylib)
# Test
add_test(NAME raylib_test COMMAND raylib_test)
# Copy all the resources
file(COPY resources/ DESTINATION "resources/")

View File

@@ -26,7 +26,8 @@ int main() {
// Math
raylib::Vector2 direction(50, 50);
raylib::Vector2 newDirection = direction.Rotate(30);
assert((int)newDirection.x == 18);
std::cout << "Out: " << newDirection.x << std::endl;
assert((int)newDirection.x == 57);
// raylib::GetDirectoryFiles()
std::vector<std::string> files = raylib::GetDirectoryFiles(::GetWorkingDirectory());

2
vendor/raylib vendored