From bcfbb3215f84aaf34bac3d62072b55b29f0977a3 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 2 Dec 2020 13:52:01 -0500 Subject: [PATCH] Update raylib to 2020-12-02 --- include/Color.hpp | 16 +++---------- include/Image.hpp | 4 ---- include/Model.hpp | 22 +++++++++++++++++ include/Rectangle.hpp | 11 ++++----- include/Texture.hpp | 35 ++++++++++++++++++++++++++- include/Window.hpp | 56 +++++++++++++++++++++++++++++++------------ vendor/raylib | 2 +- 7 files changed, 106 insertions(+), 40 deletions(-) diff --git a/include/Color.hpp b/include/Color.hpp index e7cfdbd..fe43c51 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -34,13 +34,6 @@ namespace raylib { class Color : public ::Color { public: - Color() { - r = 0; - g = 0; - b = 0; - a = 255; - } - Color(::Color color) { r = color.r; g = color.g; @@ -48,12 +41,9 @@ class Color : public ::Color { a = color.a; } - Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255) { - r = red; - g = green; - b = blue; - a = alpha; - } + Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) : ::Color{red, green, blue, alpha} {}; + Color(unsigned char red, unsigned char green, unsigned char blue) : ::Color{red, green, blue, 255} {}; + Color() {}; Color(::Vector3 hsv) { set(::ColorFromHSV(hsv.x, hsv.y, hsv.z)); diff --git a/include/Image.hpp b/include/Image.hpp index dbbed69..d1ec6f1 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -365,10 +365,6 @@ class Image : public ::Image { return ::GetImageData(*this); } - inline ::Vector4* GetImageDataNormalized() { - return ::GetImageDataNormalized(*this); - } - ::Texture2D LoadTexture() { return ::LoadTextureFromImage(*this); } diff --git a/include/Model.hpp b/include/Model.hpp index d8c8f9d..210afb2 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -65,24 +65,46 @@ class Model : public ::Model { return *this; } + /** + * Unload model (including meshes) from memory (RAM and/or VRAM) + */ inline void Unload() { ::UnloadModel(*this); } + /** + * Unload model (but not meshes) from memory (RAM and/or VRAM) + */ + inline void UnloadKeepMeshes() { + ::UnloadModelKeepMeshes(*this); + } + + /** + * Set material for a mesh + */ inline Model& SetMeshMaterial(int meshId, int materialId) { ::SetModelMeshMaterial(this, meshId, materialId); return *this; } + /** + * Get collision info between ray and model + */ inline RayHitInfo GetCollision(::Ray ray) const { return ::GetCollisionRayModel(ray, *this); } + /** + * Update model animation pose + */ inline Model& UpdateModelAnimation(::ModelAnimation anim, int frame) { ::UpdateModelAnimation(*this, anim, frame); return *this; } + /** + * Check model animation skeleton match + */ inline bool IsModelAnimationValid(::ModelAnimation anim) const { return ::IsModelAnimationValid(*this, anim); } diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index a736c4b..27178fd 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -36,12 +36,11 @@ class Rectangle : public ::Rectangle { set(vec); } - Rectangle(float X = 0, float Y = 0, float Width = 0, float Height = 0) { - x = X; - y = Y; - width = Width; - height = Height; - } + Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {}; + Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, height} {}; + Rectangle(float x, float y) : ::Rectangle{x, y, 0, 0} {}; + Rectangle(float x) : ::Rectangle{x, 0, 0, 0} {}; + Rectangle() {}; GETTERSETTER(float, X, x) GETTERSETTER(float, Y, y) diff --git a/include/Texture.hpp b/include/Texture.hpp index 58dae02..19e5ad4 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -67,50 +67,83 @@ class Texture : public ::Texture { return *this; } + /** + * Load texture from image data + */ void LoadFromImage(const ::Image& image) { set(::LoadTextureFromImage(image)); } + /** + * Load cubemap from image, multiple image cubemap layouts supported + */ void LoadTextureCubemap(const ::Image& image, int layoutType) { set(::LoadTextureCubemap(image, layoutType)); } + /** + * Load texture from file into GPU memory (VRAM) + */ void Load(const std::string& fileName) { set(::LoadTexture(fileName.c_str())); } + /** + * Unload texture from GPU memory (VRAM) + */ inline void Unload() { ::UnloadTexture(*this); } + /** + * Update GPU texture with new data + */ inline Texture& Update(const void *pixels) { ::UpdateTexture(*this, pixels); return *this; } + /** + * Update GPU texture rectangle with new data + */ inline Texture& UpdateRec(::Rectangle rec, const void *pixels) { UpdateTextureRec(*this, rec, pixels); return *this; } + /** + * Get pixel data from GPU texture and return an Image + */ inline Image GetTextureData() const { return ::GetTextureData(*this); } + /** + * Get pixel data from GPU texture and return an Image + */ inline operator raylib::Image() { return GetTextureData(); } + /** + * Generate GPU mipmaps for a texture + */ inline Texture& GenMipmaps() { ::GenTextureMipmaps(this); return *this; } + /** + * Set texture scaling filter mode + */ inline Texture& SetFilter(int filterMode) { ::SetTextureFilter(*this, filterMode); return *this; } + /** + * Set texture wrapping mode + */ inline Texture& SetWrap(int wrapMode) { ::SetTextureWrap(*this, wrapMode); return *this; @@ -161,7 +194,7 @@ class Texture : public ::Texture { return *this; } - inline Texture& DrawTiled(Rectangle sourceRec, Rectangle destRec, Vector2 origin, + inline Texture& DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin, float rotation, float scale, Color tint = WHITE) { ::DrawTextureTiled(*this, sourceRec, destRec, origin, rotation, scale, tint); return *this; diff --git a/include/Window.hpp b/include/Window.hpp index d593114..7a8b96f 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -89,6 +89,20 @@ class Window { return ::IsWindowReady(); } + /** + * Check if window is currently fullscreen + */ + inline bool IsFullscreen() const { + return ::IsWindowFullscreen(); + } + + /** + * Check if window is currently hidden + */ + inline bool IsHidden() const { + return ::IsWindowHidden(); + } + /** * Check if window is currently minimized */ @@ -96,6 +110,13 @@ class Window { return ::IsWindowMinimized(); } + /** + * Check if window is currently minimized + */ + inline bool IsMaximized() const { + return ::IsWindowMaximized(); + } + /** * Check if window is currently focused */ @@ -110,18 +131,18 @@ class Window { return ::IsWindowResized(); } - /** - * Check if window is currently hidden - */ - inline bool IsHidden() const { - return ::IsWindowHidden(); + inline bool IsState(unsigned int flag) { + return ::IsWindowState(flag); } - /** - * Check if window is currently fullscreen - */ - inline bool IsFullscreen() const { - return ::IsWindowFullscreen(); + inline Window& SetState(unsigned int flag) { + ::SetWindowState(flag); + return *this; + } + + inline Window& ClearState(unsigned int flag) { + ::ClearWindowState(flag); + return *this; } /** @@ -132,20 +153,25 @@ class Window { return *this; } - inline Window& Unhide() { - ::UnhideWindow(); + inline Window& Maximize() { + ::MaximizeWindow(); return *this; } - inline Window& Hide() { - ::HideWindow(); + inline Window& Minimize() { + ::MinimizeWindow(); + return *this; + } + + inline Window& Restore() { + ::RestoreWindow(); return *this; } /** * Set icon for window */ - inline Window& SetIcon(Image image) { + inline Window& SetIcon(::Image image) { ::SetWindowIcon(image); return *this; } diff --git a/vendor/raylib b/vendor/raylib index fc1fc25..84ab00d 160000 --- a/vendor/raylib +++ b/vendor/raylib @@ -1 +1 @@ -Subproject commit fc1fc250e7ae39af7aadb1d00a7e098ea01aa8cd +Subproject commit 84ab00d52e66d7a9cec7d05c8dbede5e6a3f31eb