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

Update to raylib v4.5.0 #235

Merged
merged 1 commit into from
Mar 18, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project (raylib_cpp
VERSION 4.2.8
VERSION 4.5.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX
Expand Down
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 4.2.0
GIT_TAG 4.5.0
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
Expand Down
88 changes: 0 additions & 88 deletions examples/core/core_3d_camera_first_person.cpp

This file was deleted.

4 changes: 1 addition & 3 deletions examples/core/core_world_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ int main() {
Vector3 cubePosition;
Vector2 cubeScreenPosition;

camera.SetMode(CAMERA_FREE); // Set a free camera mode

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
camera.Update(); // Update camera
camera.Update(CAMERA_THIRD_PERSON); // Update camera

// Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen(Vector3{cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);
Expand Down
4 changes: 1 addition & 3 deletions examples/models/models_billboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ int main() {
raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard
raylib::Vector3 billPosition(0.0f, 2.0f, 0.0f); // Position where draw billboard

camera.SetMode(CAMERA_ORBITAL); // Set an orbital camera mode

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
camera.Update(); // Update camera
camera.Update(CAMERA_ORBITAL); // Update camera
//----------------------------------------------------------------------------------

// Draw
Expand Down
4 changes: 1 addition & 3 deletions examples/models/models_first_person_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ int main(void)
raylib::Vector3 mapPosition(-16.0f, 0.0f, -8.0f); // Set model position
raylib::Vector3 playerPosition(camera.position); // Set player position

camera.SetMode(CAMERA_FIRST_PERSON); // Set camera mode

SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

Expand All @@ -51,7 +49,7 @@ int main(void)
//----------------------------------------------------------------------------------
raylib::Vector3 oldCamPos(camera.position); // Store old camera position

camera.Update(); // Update camera
camera.Update(CAMERA_FIRST_PERSON); // Update camera

// Check player collision (we simplify to 2D collision detection)
raylib::Vector2 playerPos(camera.position.x, camera.position.z);
Expand Down
2 changes: 1 addition & 1 deletion include/AudioStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class AudioStream : public ::AudioStream {
* Retrieve whether or not the audio stream is ready.
*/
bool IsReady() {
return channels > 0;
return ::IsAudioStreamReady(*this);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions include/Camera2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ class Camera2D : public ::Camera2D {
}

/**
* Returns the screen space position for a 3d world space position
* Returns the world space position for a 2d camera screen space position
*/
inline Vector2 GetWorldToScreen(::Vector2 position) const {
return ::GetWorldToScreen2D(position, *this);
inline Vector2 GetScreenToWorld(::Vector2 position) const {
return ::GetScreenToWorld2D(position, *this);
}

/**
* Returns the world space position for a 2d camera screen space position
* Returns the screen space position for a 3d world space position
*/
inline Vector2 GetScreenToWorld(::Vector2 position) const {
return ::GetScreenToWorld2D(position, *this);
inline Vector2 GetWorldToScreen(::Vector2 position) const {
return ::GetWorldToScreen2D(position, *this);
}

private:
Expand Down
39 changes: 6 additions & 33 deletions include/Camera3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,45 +67,18 @@ class Camera3D : public ::Camera3D {
}

/**
* Set camera mode (multiple camera modes available)
*/
inline Camera3D& SetMode(int mode) {
::SetCameraMode(*this, mode);
return *this;
}

/**
* Set camera alt key to combine with mouse movement (free camera)
*/
inline Camera3D& SetAltControl(int altKey) {
::SetCameraAltControl(altKey);
return *this;
}

/**
* Set camera smooth zoom key to combine with mouse (free camera)
*/
inline Camera3D& SetSmoothZoomControl(int szKey) {
::SetCameraSmoothZoomControl(szKey);
return *this;
}

/**
* Set camera move controls (1st person and 3rd person cameras)
* Update camera position for selected mode
*/
inline Camera3D& SetMoveControls(
int frontKey, int backKey,
int rightKey, int leftKey,
int upKey, int downKey) {
::SetCameraMoveControls(frontKey, backKey, rightKey, leftKey, upKey, downKey);
inline Camera3D& Update(int mode) {
::UpdateCamera(this, mode);
return *this;
}

/**
* Update camera position for selected mode
* Update camera movement/rotation
*/
inline Camera3D& Update() {
::UpdateCamera(this);
inline Camera3D& Update(::Vector3 movement, ::Vector3 rotation, float zoom = 1.0f) {
::UpdateCameraPro(this, movement, rotation, zoom);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion include/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Font : public ::Font {
* Returns if the font is ready to be used.
*/
bool IsReady() {
return baseSize > 0;
return ::IsFontReady(*this);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions include/Functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ RLCPPAPI inline void OpenURL(const std::string& url) {
return ::OpenURL(url.c_str());
}

/**
* Update camera depending on selected mode
*/
RLCPPAPI inline void UpdateCamera(const ::Camera& camera) {
::Camera* cameraPointer = (::Camera*)&camera;
::UpdateCamera(cameraPointer);
}

/**
* Load an image.
*/
Expand Down
4 changes: 2 additions & 2 deletions include/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ class Image : public ::Image {
*
* @return The pixel data size of the image.
*/
int GetPixelDataSize() const {
inline int GetPixelDataSize() const {
return ::GetPixelDataSize(width, height, format);
}

Expand All @@ -723,7 +723,7 @@ class Image : public ::Image {
* @return True or false depending on whether the Image has been loaded.
*/
inline bool IsReady() const {
return data != nullptr;
return ::IsImageReady(*this);
}

private:
Expand Down
7 changes: 7 additions & 0 deletions include/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ class Material : public ::Material {
::DrawMeshInstanced(mesh, *this, transforms, instances);
}

/**
* Check if material is ready
*/
inline bool IsReady() {
return ::IsMaterialReady(*this);
}

private:
void set(const ::Material& material) {
shader = material.shader;
Expand Down
10 changes: 1 addition & 9 deletions include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ class Model : public ::Model {
}
}

/**
* Unload model (but not meshes) from memory (RAM and/or VRAM)
*/
inline Model& UnloadKeepMeshes() {
::UnloadModelKeepMeshes(*this);
return *this;
}

/**
* Set material for a mesh
*/
Expand Down Expand Up @@ -201,7 +193,7 @@ class Model : public ::Model {
* Determines whether or not the Model has data in it.
*/
bool IsReady() const {
return meshCount > 0 || materialCount > 0 || boneCount > 0;
return ::IsModelReady(*this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/Music.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Music : public ::Music {
* @return True or false depending on whether the Music has been loaded.
*/
inline bool IsReady() const {
return stream.buffer != nullptr;
return ::IsMusicReady(*this);
}

private:
Expand Down
4 changes: 2 additions & 2 deletions include/RenderTexture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class RenderTexture : public ::RenderTexture {
/**
* Retrieves whether or not the render texture is ready.
*/
bool IsReady() const {
return id != 0;
inline bool IsReady() const {
return ::IsRenderTextureReady(*this);
}

private:
Expand Down
25 changes: 1 addition & 24 deletions include/Sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ class Sound : public ::Sound {
return *this;
}

/**
* Play a sound (using multichannel buffer pool)
*/
inline Sound& PlayMulti() {
::PlaySoundMulti(*this);
return *this;
}

/**
* Stop any sound playing (using multichannel buffer pool)
*/
inline Sound& StopMulti() {
::StopSoundMulti();
return *this;
}

/**
* Check if a sound is currently playing
*/
Expand Down Expand Up @@ -211,14 +195,7 @@ class Sound : public ::Sound {
* @return True or false depending on whether the Sound buffer is loaded.
*/
bool IsReady() const {
return stream.buffer != nullptr;
}

/**
* Get number of sounds playing in the multichannel
*/
int GetPlaying() {
return ::GetSoundsPlaying();
return ::IsSoundReady(*this);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion include/Wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Wave : public ::Wave {
* @return True or false depending on whether the wave data has been loaded.
*/
inline bool IsReady() const {
return data != nullptr;
return ::IsWaveReady(*this);
}

private:
Expand Down
Loading