Fix more references

This commit is contained in:
Rob Loach
2021-01-02 12:10:48 -05:00
parent 667615abcb
commit c144c71f27
23 changed files with 123 additions and 60 deletions

View File

@@ -14,10 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- `Mouse::SetX()` and `Mouse::SetY()`
- Most objects are now passed by reference
- Error correction when unloading images, materials, models and meshes
### Changed
- `Mouse` functions are now `static`. Use `Mouse::SetX()` instead of instantiating a `Mouse` object.
- `Mouse` functions are now `static`. Use `Mouse::SetX()` instead of using `Mouse mouse`.
- `Camera*::BeginMode()` and `Camera*::EndMode()` no longer have 2D/3D in the name
## [v3.5.0-alpha1] - 2020-12-26

View File

@@ -66,7 +66,7 @@ class BoundingBox : public ::BoundingBox {
/**
* Draw a bounding box with wires
*/
inline BoundingBox& Draw(::Color color = WHITE) {
inline BoundingBox& Draw(::Color color = {255, 255, 255, 255}) {
DrawBoundingBox(*this, color);
return *this;
}

View File

@@ -32,6 +32,11 @@
namespace raylib {
class Camera2D : public ::Camera2D {
public:
Camera2D() {}
Camera2D(const ::Camera2D& camera) {
set(camera);
}
Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue = 0,
float zoomValue = 1) {
offset = offsetValue;

View File

@@ -32,6 +32,10 @@
namespace raylib {
class Camera3D : public ::Camera3D {
public:
Camera3D(const ::Camera3D& camera) {
set(camera);
}
Camera3D(::Vector3 positionValue, ::Vector3 targetValue, ::Vector3 upValue,
float fovyValue = 0, int typeValue = 0) {
position = positionValue;

View File

@@ -34,11 +34,8 @@
namespace raylib {
class Color : public ::Color {
public:
Color(::Color color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
Color(const ::Color& color) {
set(color);
}
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) :
@@ -245,6 +242,33 @@ class Color : public ::Color {
return ::ColorAlphaBlend(dst, *this, tint);
}
inline static Color LightGray() { return LIGHTGRAY; }
inline static Color Gray() { return GRAY; }
inline static Color DarkGray() { return DARKGRAY; }
inline static Color Yellow() { return YELLOW; }
inline static Color Gold() { return GOLD; }
inline static Color Orange() { return ORANGE; }
inline static Color Pink() { return PINK; }
inline static Color Red() { return RED; }
inline static Color Maroon() { return MAROON; }
inline static Color Green() { return GREEN; }
inline static Color Lime() { return LIME; }
inline static Color DarkGreen() { return DARKGREEN; }
inline static Color SkyBlue() { return SKYBLUE; }
inline static Color Blue() { return BLUE; }
inline static Color DarkBlue() { return DARKBLUE; }
inline static Color Purple() { return PURPLE; }
inline static Color Violet() { return VIOLET; }
inline static Color DarkPurple() { return DARKPURPLE; }
inline static Color Beige() { return BEIGE; }
inline static Color Brown() { return BROWN; }
inline static Color DarkBrown() { return DARKBROWN; }
inline static Color White() { return WHITE; }
inline static Color Black() { return BLACK; }
inline static Color Blank() { return BLANK; }
inline static Color Magenta() { return MAGENTA; }
inline static Color RayWhite() { return RAYWHITE; }
protected:
inline void set(const ::Color& color) {
r = color.r;

View File

@@ -203,6 +203,13 @@ class Image : public ::Image {
GETTERSETTER(int, Mipmaps, mipmaps)
GETTERSETTER(int, Format, format)
/**
* Retrieve the width and height of the image.
*/
inline ::Vector2 GetSize() {
return {static_cast<float>(width), static_cast<float>(height)};
}
/**
* Create an image duplicate (useful for transformations)
*/
@@ -236,7 +243,7 @@ class Image : public ::Image {
/**
* Apply alpha mask to image
*/
inline Image& AlphaMask(::Image alphaMask) {
inline Image& AlphaMask(const ::Image& alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}

View File

@@ -34,7 +34,7 @@
namespace raylib {
class Material : public ::Material {
public:
Material(::Material material) {
Material(const ::Material& material) {
set(material);
}
@@ -91,7 +91,7 @@ class Material : public ::Material {
}
protected:
inline void set(::Material material) {
inline void set(const ::Material& material) {
shader = material.shader;
maps = material.maps;
params = material.params;

View File

@@ -45,7 +45,7 @@ extern "C" {
namespace raylib {
class Matrix : public ::Matrix {
public:
Matrix(::Matrix mat) {
Matrix(const ::Matrix& mat) {
set(mat);
}
@@ -186,19 +186,19 @@ class Matrix : public ::Matrix {
return ::MatrixIdentity();
}
Matrix Add(::Matrix right) {
Matrix Add(const ::Matrix& right) {
return ::MatrixAdd(*this, right);
}
Matrix operator+(const Matrix& matrix) {
Matrix operator+(const ::Matrix& matrix) {
return ::MatrixAdd(*this, matrix);
}
Matrix Subtract(::Matrix right) {
Matrix Subtract(const ::Matrix& right) {
return ::MatrixSubtract(*this, right);
}
Matrix operator-(const Matrix& matrix) {
Matrix operator-(const ::Matrix& matrix) {
return ::MatrixSubtract(*this, matrix);
}
@@ -230,11 +230,11 @@ class Matrix : public ::Matrix {
return ::MatrixScale(x, y, z);
}
Matrix Multiply(Matrix right) const {
Matrix Multiply(const ::Matrix& right) const {
return ::MatrixMultiply(*this, right);
}
Matrix operator*(const Matrix& matrix) {
Matrix operator*(const ::Matrix& matrix) {
return ::MatrixMultiply(*this, matrix);
}
@@ -275,7 +275,7 @@ class Matrix : public ::Matrix {
#endif
protected:
inline void set(::Matrix mat) {
inline void set(const ::Matrix& mat) {
m0 = mat.m0;
m1 = mat.m1;
m2 = mat.m2;

View File

@@ -36,7 +36,7 @@
namespace raylib {
class Mesh : public ::Mesh {
public:
Mesh(::Mesh mesh) {
Mesh(const ::Mesh& mesh) {
set(mesh);
}
@@ -216,7 +216,7 @@ class Mesh : public ::Mesh {
}
protected:
inline void set(::Mesh mesh) {
inline void set(const ::Mesh& mesh) {
vertexCount = mesh.vertexCount;
triangleCount = mesh.triangleCount;
vertices = mesh.vertices;

View File

@@ -34,7 +34,7 @@
namespace raylib {
class Model : public ::Model {
public:
Model(::Model model) {
Model(const ::Model& model) {
set(model);
}
@@ -42,7 +42,7 @@ class Model : public ::Model {
set(::LoadModel(fileName.c_str()));
}
Model(::Mesh mesh) {
Model(const ::Mesh& mesh) {
set(::LoadModelFromMesh(mesh));
}
@@ -122,7 +122,9 @@ class Model : public ::Model {
/**
* Draw a model (with texture if set)
*/
inline Model& Draw(::Vector3 position, float scale = 1.0f, ::Color tint = WHITE) {
inline Model& Draw(::Vector3 position,
float scale = 1.0f,
::Color tint = {255, 255, 255, 255}) {
::DrawModel(*this, position, scale, tint);
return *this;
}
@@ -135,7 +137,7 @@ class Model : public ::Model {
::Vector3 rotationAxis,
float rotationAngle = 0.0f,
::Vector3 scale = {1.0f, 1.0f, 1.0f},
::Color tint = WHITE) {
::Color tint = {255, 255, 255, 255}) {
::DrawModelEx(*this, position, rotationAxis, rotationAngle, scale, tint);
return *this;
}
@@ -143,7 +145,9 @@ class Model : public ::Model {
/**
* Draw a model wires (with texture if set)
*/
inline Model& DrawWires(::Vector3 position, float scale = 1.0f, ::Color tint = WHITE) {
inline Model& DrawWires(::Vector3 position,
float scale = 1.0f,
::Color tint = {255, 255, 255, 255}) {
::DrawModelWires(*this, position, scale, tint);
return *this;
}
@@ -156,13 +160,13 @@ class Model : public ::Model {
::Vector3 rotationAxis,
float rotationAngle = 0.0f,
::Vector3 scale = {1.0f, 1.0f, 1.0f},
::Color tint = WHITE) {
::Color tint = {255, 255, 255, 255}) {
::DrawModelWiresEx(*this, position, rotationAxis, rotationAngle, scale, tint);
return *this;
}
protected:
inline void set(::Model model) {
inline void set(const ::Model& model) {
transform = model.transform;
meshCount = model.meshCount;

View File

@@ -38,7 +38,7 @@ namespace raylib {
*/
class ModelAnimation : public ::ModelAnimation {
public:
ModelAnimation(::ModelAnimation model) {
ModelAnimation(const ::ModelAnimation& model) {
set(model);
}
@@ -93,7 +93,7 @@ class ModelAnimation : public ::ModelAnimation {
}
protected:
inline void set(::ModelAnimation model) {
inline void set(const ::ModelAnimation& model) {
boneCount = model.boneCount;
bones = model.bones;
frameCount = model.frameCount;

View File

@@ -33,7 +33,7 @@
namespace raylib {
class Music : public ::Music {
public:
Music(::Music music) {
Music(const ::Music& music) {
set(music);
}
@@ -152,7 +152,7 @@ class Music : public ::Music {
}
protected:
inline void set(::Music music) {
inline void set(const ::Music& music) {
ctxType = music.ctxType;
ctxData = music.ctxData;
looping = music.looping;

View File

@@ -37,7 +37,7 @@ namespace raylib {
*/
class Ray : public ::Ray {
public:
Ray(::Ray ray) {
Ray(const ::Ray& ray) {
set(ray);
}
@@ -115,7 +115,7 @@ class Ray : public ::Ray {
}
protected:
inline void set(::Ray ray) {
inline void set(const ::Ray& ray) {
position = ray.position;
direction = ray.direction;
}

View File

@@ -34,7 +34,7 @@ namespace raylib {
*/
class RayHitInfo : public ::RayHitInfo {
public:
RayHitInfo(::RayHitInfo ray) {
RayHitInfo(const ::RayHitInfo& ray) {
set(ray);
}
@@ -82,7 +82,7 @@ class RayHitInfo : public ::RayHitInfo {
GETTERSETTER(::Vector3, Normal, normal)
protected:
inline void set(::RayHitInfo ray) {
inline void set(const ::RayHitInfo& ray) {
hit = ray.hit;
distance = ray.distance;
position = ray.position;

View File

@@ -32,7 +32,7 @@
namespace raylib {
class Rectangle : public ::Rectangle {
public:
Rectangle(::Rectangle vec) {
Rectangle(const ::Rectangle& vec) {
set(vec);
}
@@ -94,7 +94,7 @@ class Rectangle : public ::Rectangle {
return *this;
}
inline Rectangle& DrawLinesEx(int lineThick, ::Color color) {
inline Rectangle& DrawLines(::Color color, int lineThick) {
::DrawRectangleLinesEx(*this, lineThick, color);
return *this;
}
@@ -139,7 +139,7 @@ class Rectangle : public ::Rectangle {
}
protected:
inline void set(::Rectangle rect) {
inline void set(const ::Rectangle& rect) {
x = rect.x;
y = rect.y;
width = rect.width;

View File

@@ -34,7 +34,7 @@
namespace raylib {
class Shader : public ::Shader {
public:
Shader(::Shader shader) {
Shader(const ::Shader& shader) {
set(shader);
}
@@ -153,7 +153,7 @@ class Shader : public ::Shader {
}
protected:
inline void set(::Shader shader) {
inline void set(const ::Shader& shader) {
id = shader.id;
locs = shader.locs;
}

View File

@@ -36,7 +36,7 @@ namespace raylib {
*/
class Sound : public ::Sound {
public:
Sound(::Sound vec) {
Sound(const ::Sound& vec) {
set(vec);
}
@@ -152,7 +152,7 @@ class Sound : public ::Sound {
}
protected:
inline void set(::Sound sound) {
inline void set(const ::Sound& sound) {
sampleCount = sound.sampleCount;
stream = sound.stream;
}

View File

@@ -35,6 +35,10 @@
namespace raylib {
class Texture : public ::Texture {
public:
Texture(const ::Texture& texture) {
set(texture);
}
Texture() {
set(::GetTextureDefault());
}
@@ -70,6 +74,13 @@ class Texture : public ::Texture {
return *this;
}
/**
* Retrieve the width and height of the texture.
*/
inline ::Vector2 GetSize() {
return {static_cast<float>(width), static_cast<float>(height)};
}
/**
* Load texture from image data
*/
@@ -117,7 +128,7 @@ class Texture : public ::Texture {
/**
* Get pixel data from GPU texture and return an Image
*/
inline Image GetTextureData() const {
inline ::Image GetData() const {
return ::GetTextureData(*this);
}
@@ -125,7 +136,7 @@ class Texture : public ::Texture {
* Get pixel data from GPU texture and return an Image
*/
inline operator raylib::Image() {
return GetTextureData();
return GetData();
}
/**
@@ -229,13 +240,13 @@ class Texture : public ::Texture {
/**
* Define default texture used to draw shapes
*/
inline Texture& SetShapesTexture(::Rectangle source) {
inline Texture& SetShapes(::Rectangle source) {
::SetShapesTexture(*this, source);
return *this;
}
protected:
inline void set(::Texture texture) {
inline void set(const ::Texture& texture) {
id = texture.id;
width = texture.width;
height = texture.height;

View File

@@ -36,7 +36,7 @@
namespace raylib {
class Vector2 : public ::Vector2 {
public:
Vector2(::Vector2 vec) {
Vector2(const ::Vector2& vec) {
set(vec);
}
@@ -339,7 +339,7 @@ class Vector2 : public ::Vector2 {
}
protected:
inline void set(::Vector2 vec) {
inline void set(const ::Vector2& vec) {
x = vec.x;
y = vec.y;
}

View File

@@ -36,7 +36,7 @@
namespace raylib {
class Vector3 : public ::Vector3 {
public:
Vector3(::Vector3 vec) {
Vector3(const ::Vector3& vec) {
set(vec);
}
@@ -271,7 +271,7 @@ class Vector3 : public ::Vector3 {
}
inline Vector3& DrawCubeTexture(
::Texture2D texture,
const ::Texture2D& texture,
float width,
float height,
float length,
@@ -325,7 +325,7 @@ class Vector3 : public ::Vector3 {
}
protected:
inline void set(::Vector3 vec) {
inline void set(const ::Vector3& vec) {
x = vec.x;
y = vec.y;
z = vec.z;

View File

@@ -37,7 +37,7 @@
namespace raylib {
class Vector4 : public ::Vector4 {
public:
Vector4(::Vector4 vec) {
Vector4(const ::Vector4& vec) {
set(vec);
}
@@ -167,7 +167,7 @@ class Vector4 : public ::Vector4 {
}
protected:
inline void set(::Vector4 vec4) {
inline void set(const ::Vector4& vec4) {
x = vec4.x;
y = vec4.y;
z = vec4.z;

View File

@@ -33,7 +33,7 @@
namespace raylib {
class Wave : public ::Wave {
public:
Wave(::Wave wave) {
Wave(const ::Wave& wave) {
set(wave);
}
@@ -160,7 +160,7 @@ class Wave : public ::Wave {
}
protected:
inline void set(::Wave wave) {
inline void set(const ::Wave& wave) {
sampleCount = wave.sampleCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;

View File

@@ -57,7 +57,7 @@ class Window {
Close();
}
void Init(int width, int height, const std::string& title) {
void Init(int width = 800, int height = 450, const std::string& title = "raylib") {
::InitWindow(width, height, title.c_str());
}
@@ -234,6 +234,13 @@ class Window {
return *this;
}
/**
* Get the screen's width and height.
*/
inline ::Vector2 GetSize() {
return {static_cast<float>(GetWidth()), static_cast<float>(GetHeight())};
}
/**
* Get native window handle
*/
@@ -260,28 +267,28 @@ class Window {
/**
* Get current screen width
*/
inline int GetScreenWidth() const {
inline int GetWidth() const {
return ::GetScreenWidth();
}
/**
* Get current screen height
*/
inline int GetScreenHeight() const {
inline int GetHeight() const {
return ::GetScreenHeight();
}
/**
* Get window position XY on monitor
*/
inline Vector2 GetPosition() const {
inline ::Vector2 GetPosition() const {
return ::GetWindowPosition();
}
/**
* Get window scale DPI factor
*/
inline Vector2 GetScaleDPI() const {
inline ::Vector2 GetScaleDPI() const {
return ::GetWindowScaleDPI();
}