Make set() function protected

This commit is contained in:
Rob Loach
2020-10-25 13:00:48 -04:00
parent e657fcb41f
commit 232e8ba8da
25 changed files with 251 additions and 221 deletions

View File

@@ -32,13 +32,6 @@ namespace raylib {
Close();
}
inline void set(::AudioStream stream) {
sampleRate = stream.sampleRate;
sampleSize = stream.sampleSize;
channels = stream.channels;
buffer = stream.buffer;
}
GETTERSETTER(unsigned int,SampleRate,sampleRate)
GETTERSETTER(unsigned int,SampleSize,sampleSize)
GETTERSETTER(unsigned int,Channels,channels)
@@ -139,6 +132,14 @@ namespace raylib {
return *this;
}
protected:
inline void set(::AudioStream stream) {
sampleRate = stream.sampleRate;
sampleSize = stream.sampleSize;
channels = stream.channels;
buffer = stream.buffer;
}
};
}

View File

@@ -24,10 +24,6 @@ namespace raylib {
min = Min;
max = Max;
};
inline void set(::BoundingBox box) {
min = box.min;
max = box.max;
}
GETTERSETTER(::Vector3,Min,min)
GETTERSETTER(::Vector3,Max,max)
@@ -58,6 +54,12 @@ namespace raylib {
inline bool CheckCollision(::Ray ray) {
return CheckCollisionRayBox(ray, *this);
}
protected:
inline void set(::BoundingBox box) {
min = box.min;
max = box.max;
}
};
}

View File

@@ -22,20 +22,6 @@ namespace raylib {
zoom = zoomValue;
};
inline void set(const ::Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
inline void set(const Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
inline Camera2D& BeginMode2D() {
::BeginMode2D(*this);
return *this;
@@ -69,6 +55,20 @@ namespace raylib {
inline Vector2 GetScreenToWorld2D(Vector2 position) {
return ::GetScreenToWorld2D(position, *this);
}
protected:
inline void set(const ::Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
inline void set(const Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
};
}

View File

@@ -41,22 +41,6 @@ namespace raylib {
return *this;
}
inline void set(const ::Camera3D& camera) {
position = camera.position;
target = camera.target;
up = camera.up;
fovy = camera.fovy;
type = camera.type;
}
inline void set(const Camera3D& camera) {
position = camera.position;
target = camera.target;
up = camera.up;
fovy = camera.fovy;
type = camera.type;
}
Camera3D& BeginMode3D() {
::BeginMode3D(*this);
return *this;
@@ -117,6 +101,23 @@ namespace raylib {
::DrawBillboardRec(*this, texture, sourceRec, center, size, tint);
return *this;
}
protected:
inline void set(const ::Camera3D& camera) {
position = camera.position;
target = camera.target;
up = camera.up;
fovy = camera.fovy;
type = camera.type;
}
inline void set(const Camera3D& camera) {
position = camera.position;
target = camera.target;
up = camera.up;
fovy = camera.fovy;
type = camera.type;
}
};
typedef Camera3D Camera;

View File

@@ -49,20 +49,6 @@ namespace raylib {
set(::ColorFromNormalized(normalized));
}
inline void set(const ::Color& color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
inline void set(const Color& color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
static Color LightGray;
static Color Gray;
static Color DarkGray;
@@ -205,6 +191,21 @@ namespace raylib {
return *this;
}
protected:
inline void set(const ::Color& color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
inline void set(const Color& color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
};
inline Color Color::LightGray = ::LIGHTGRAY;

View File

@@ -44,22 +44,6 @@ namespace raylib {
UnloadFont(*this);
}
void set(const ::Font font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
texture = font.texture;
recs = font.recs;
chars = font.chars;
}
void set(const Font& font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
texture = font.texture;
recs = font.recs;
chars = font.chars;
}
GETTERSETTER(int,BaseSize,baseSize)
GETTERSETTER(int,CharsCount,charsCount)
GETTERSETTER(Texture2D,Texture,texture)
@@ -96,6 +80,23 @@ namespace raylib {
inline int GetGlyphIndex(int character) {
return ::GetGlyphIndex(*this, character);
}
protected:
void set(const ::Font font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
texture = font.texture;
recs = font.recs;
chars = font.chars;
}
void set(const Font& font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
texture = font.texture;
recs = font.recs;
chars = font.chars;
}
};
}

View File

@@ -21,10 +21,6 @@ namespace raylib {
}
int number;
inline void set(int gamepadNumber) {
number = gamepadNumber;
}
GETTERSETTER(int,Number,number)
Gamepad& operator=(const Gamepad& gamepad) {
@@ -32,6 +28,11 @@ namespace raylib {
return *this;
}
Gamepad& operator=(int gamepadNumber) {
set(gamepadNumber);
return *this;
}
operator int() const { return number; }
inline bool IsAvailable() {
@@ -69,6 +70,11 @@ namespace raylib {
inline float GetAxisMovement(int axis) {
return ::GetGamepadAxisMovement(number, axis);
}
protected:
inline void set(int gamepadNumber) {
number = gamepadNumber;
}
};
}

View File

@@ -93,14 +93,6 @@ namespace raylib {
return *this;
}
inline void set(::Image image) {
data = image.data;
width = image.width;
height = image.height;
mipmaps = image.mipmaps;
format = image.format;
}
void Load(const std::string& fileName) {
set(::LoadImage(fileName.c_str()));
}
@@ -329,6 +321,15 @@ namespace raylib {
inline operator Texture2D() {
return ::LoadTextureFromImage(*this);
}
protected:
inline void set(::Image image) {
data = image.data;
width = image.width;
height = image.height;
mipmaps = image.mipmaps;
format = image.format;
}
};
}

View File

@@ -26,12 +26,6 @@ namespace raylib {
Unload();
}
inline void set(::Material material) {
shader = material.shader;
maps = material.maps;
params = material.params;
}
GETTERSETTER(::Shader,Shader,shader)
Material& operator=(const ::Material& material) {
@@ -53,6 +47,13 @@ namespace raylib {
return *this;
}
protected:
inline void set(::Material material) {
shader = material.shader;
maps = material.maps;
params = material.params;
}
};
}

View File

@@ -43,25 +43,6 @@ namespace raylib {
m15 = M15;
};
inline void set(::Matrix mat) {
m0 = mat.m0;
m1 = mat.m1;
m2 = mat.m2;
m3 = mat.m3;
m4 = mat.m4;
m5 = mat.m5;
m6 = mat.m6;
m7 = mat.m7;
m8 = mat.m8;
m9 = mat.m9;
m10 = mat.m10;
m11 = mat.m11;
m12 = mat.m12;
m13 = mat.m13;
m14 = mat.m14;
m15 = mat.m15;
}
GETTERSETTER(float,M0,m0)
GETTERSETTER(float,M1,m1)
GETTERSETTER(float,M2,m2)
@@ -205,6 +186,27 @@ namespace raylib {
return ToFloatV();
}
#endif
protected:
inline void set(::Matrix mat) {
m0 = mat.m0;
m1 = mat.m1;
m2 = mat.m2;
m3 = mat.m3;
m4 = mat.m4;
m5 = mat.m5;
m6 = mat.m6;
m7 = mat.m7;
m8 = mat.m8;
m9 = mat.m9;
m10 = mat.m10;
m11 = mat.m11;
m12 = mat.m12;
m13 = mat.m13;
m14 = mat.m14;
m15 = mat.m15;
}
};
}

View File

@@ -26,24 +26,6 @@ namespace raylib {
triangleCount = TriangleCount;
};
inline void set(::Mesh mesh) {
vertexCount = mesh.vertexCount;
triangleCount = mesh.triangleCount;
vertices = mesh.vertices;
texcoords = mesh.texcoords;
texcoords2 = mesh.texcoords2;
normals = mesh.normals;
tangents = mesh.tangents;
colors = mesh.colors;
indices = mesh.indices;
animVertices = mesh.animVertices;
animNormals = mesh.animNormals;
boneIds = mesh.boneIds;
boneWeights = mesh.boneWeights;
vaoId = mesh.vaoId;
vboId = mesh.vboId;
}
GETTERSETTER(int,VertexCount,vertexCount)
GETTERSETTER(int,TriangleCount,triangleCount)
@@ -98,6 +80,25 @@ namespace raylib {
operator raylib::Model() {
return LoadModelFrom();
}
protected:
inline void set(::Mesh mesh) {
vertexCount = mesh.vertexCount;
triangleCount = mesh.triangleCount;
vertices = mesh.vertices;
texcoords = mesh.texcoords;
texcoords2 = mesh.texcoords2;
normals = mesh.normals;
tangents = mesh.tangents;
colors = mesh.colors;
indices = mesh.indices;
animVertices = mesh.animVertices;
animNormals = mesh.animNormals;
boneIds = mesh.boneIds;
boneWeights = mesh.boneWeights;
vaoId = mesh.vaoId;
vboId = mesh.vboId;
}
};
}

View File

@@ -31,20 +31,6 @@ namespace raylib {
Unload();
}
inline void set(::Model model) {
transform = model.transform;
meshCount = model.meshCount;
meshes = model.meshes;
materialCount = model.materialCount;
materials = model.materials;
meshMaterial = model.meshMaterial;
boneCount = model.boneCount;
bones = model.bones;
bindPose = model.bindPose;
}
GETTERSETTER(::Matrix,Transform,transform)
GETTERSETTER(int,MeshCount,meshCount)
GETTERSETTER(int,MaterialCount,materialCount)
@@ -80,6 +66,21 @@ namespace raylib {
inline bool IsModelAnimationValid(::ModelAnimation anim) {
return ::IsModelAnimationValid(*this, anim);
}
protected:
inline void set(::Model model) {
transform = model.transform;
meshCount = model.meshCount;
meshes = model.meshes;
materialCount = model.materialCount;
materials = model.materials;
meshMaterial = model.meshMaterial;
boneCount = model.boneCount;
bones = model.bones;
bindPose = model.bindPose;
}
};
}

View File

@@ -23,13 +23,6 @@ namespace raylib {
Unload();
}
inline void set(::ModelAnimation model) {
boneCount = model.boneCount;
bones = model.bones;
frameCount = model.frameCount;
framePoses = model.framePoses;
}
GETTERSETTER(int,BoneCount,boneCount)
GETTERSETTER(::BoneInfo*,Bones,bones)
GETTERSETTER(int,FrameCount,frameCount)
@@ -61,6 +54,14 @@ namespace raylib {
inline bool IsModelAnimationValid(::Model model) {
return ::IsModelAnimationValid(model, *this);
}
protected:
inline void set(::ModelAnimation model) {
boneCount = model.boneCount;
bones = model.bones;
frameCount = model.frameCount;
framePoses = model.framePoses;
}
};
}

View File

@@ -26,14 +26,6 @@ namespace raylib {
Unload();
}
inline void set(::Music music) {
ctxType = music.ctxType;
ctxData = music.ctxData;
looping = music.looping;
sampleCount = music.sampleCount;
stream = music.stream;
}
GETTERSETTER(int,CtxType,ctxType)
GETTERSETTER(bool,Looping,looping)
GETTERSETTER(unsigned int,SampleCount,sampleCount)
@@ -93,7 +85,14 @@ namespace raylib {
return ::GetMusicTimePlayed(*this);
}
protected:
inline void set(::Music music) {
ctxType = music.ctxType;
ctxData = music.ctxData;
looping = music.looping;
sampleCount = music.sampleCount;
stream = music.stream;
}
};
}

View File

@@ -29,11 +29,6 @@ namespace raylib {
set(GetMouseRay(mousePosition, camera));
}
inline void set(::Ray ray) {
position = ray.position;
direction = ray.direction;
}
Ray& operator=(const ::Ray& ray) {
set(ray);
return *this;
@@ -75,6 +70,12 @@ namespace raylib {
inline RayHitInfo GetCollisionGround(float groundHeight) {
return GetCollisionRayGround(*this, groundHeight);
}
protected:
inline void set(::Ray ray) {
position = ray.position;
direction = ray.direction;
}
};
}

View File

@@ -35,17 +35,18 @@ namespace raylib {
return *this;
}
GETTERSETTER(bool,Hit,hit)
GETTERSETTER(float,Distance,distance)
GETTERSETTER(::Vector3,Position,position)
GETTERSETTER(::Vector3,Normal,normal)
protected:
inline void set(::RayHitInfo ray) {
hit = ray.hit;
distance = ray.distance;
position = ray.position;
normal = ray.normal;
}
GETTERSETTER(bool,Hit,hit)
GETTERSETTER(float,Distance,distance)
GETTERSETTER(::Vector3,Position,position)
GETTERSETTER(::Vector3,Normal,normal)
};
}

View File

@@ -25,13 +25,6 @@ namespace raylib {
height = Height;
};
inline void set(::Rectangle rect) {
x = rect.x;
y = rect.y;
width = rect.width;
height = rect.height;
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
GETTERSETTER(float,Width,width)
@@ -101,6 +94,14 @@ namespace raylib {
inline bool CheckCollision(::Vector2 point) {
return ::CheckCollisionPointRec(point, *this);
}
protected:
inline void set(::Rectangle rect) {
x = rect.x;
y = rect.y;
width = rect.width;
height = rect.height;
}
};
}

View File

@@ -24,12 +24,6 @@ namespace raylib {
set(LoadRenderTexture(width, height));
}
inline void set(::RenderTexture2D renderTexture) {
id = renderTexture.id;
texture = renderTexture.texture;
depth = renderTexture.depth;
}
GETTERSETTER(unsigned int,Id,id)
GETTERSETTER(Texture2D,Texture,texture)
GETTERSETTER(Texture2D,Depth,depth)
@@ -61,6 +55,13 @@ namespace raylib {
::EndTextureMode();
return *this;
}
protected:
inline void set(::RenderTexture2D renderTexture) {
id = renderTexture.id;
texture = renderTexture.texture;
depth = renderTexture.depth;
}
};
typedef RenderTexture2D RenderTexture;
}

View File

@@ -27,11 +27,6 @@ namespace raylib {
set(GetShaderDefault());
}
inline void set(::Shader shader) {
id = shader.id;
locs = shader.locs;
}
GETTERSETTER(unsigned int,Id,id)
GETTERSETTER(int*,Locs,locs)
@@ -75,6 +70,12 @@ namespace raylib {
inline int GetLocation(const std::string& uniformName) {
return ::GetShaderLocation(*this, uniformName.c_str());
}
protected:
inline void set(::Shader shader) {
id = shader.id;
locs = shader.locs;
}
};
}

View File

@@ -32,11 +32,6 @@ namespace raylib {
Unload();
}
inline void set(::Sound sound) {
sampleCount = sound.sampleCount;
stream = sound.stream;
}
GETTERSETTER(unsigned int,SampleCount,sampleCount)
GETTERSETTER(::AudioStream,Stream,stream)
@@ -99,6 +94,11 @@ namespace raylib {
return *this;
}
protected:
inline void set(::Sound sound) {
sampleCount = sound.sampleCount;
stream = sound.stream;
}
};
}

View File

@@ -34,14 +34,6 @@ namespace raylib {
Unload();
};
inline void set(::Texture2D texture) {
id = texture.id;
width = texture.width;
height = texture.height;
mipmaps = texture.mipmaps;
format = texture.format;
}
GETTERSETTER(unsigned int,Id,id)
GETTERSETTER(int,Width,width)
GETTERSETTER(int,Height,height)
@@ -155,6 +147,15 @@ namespace raylib {
static int GetPixelDataSize(int width, int height, int format) {
return ::GetPixelDataSize(width, height, format);
}
protected:
inline void set(::Texture2D texture) {
id = texture.id;
width = texture.width;
height = texture.height;
mipmaps = texture.mipmaps;
format = texture.format;
}
};
// Create the Texture2D aliases.

View File

@@ -28,10 +28,6 @@ namespace raylib {
x = X;
y = Y;
};
inline void set(::Vector2 vec) {
x = vec.x;
y = vec.y;
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
@@ -227,6 +223,12 @@ namespace raylib {
::DrawPoly(*this, sides, radius, rotation, color);
return *this;
}
protected:
inline void set(::Vector2 vec) {
x = vec.x;
y = vec.y;
}
};
}

View File

@@ -32,11 +32,6 @@ namespace raylib {
Vector3(::Color color) {
set(ColorToHSV(color));
}
inline void set(::Vector3 vec) {
x = vec.x;
y = vec.y;
z = vec.z;
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
@@ -299,6 +294,13 @@ namespace raylib {
inline bool CheckCollision(float radiusA, Vector3 centerB, float radiusB) {
return CheckCollisionSpheres(*this, radiusA, centerB, radiusB);
}
protected:
inline void set(::Vector3 vec) {
x = vec.x;
y = vec.y;
z = vec.z;
}
};
}

View File

@@ -35,13 +35,6 @@ namespace raylib {
set(ColorNormalize(color));
}
inline void set(::Vector4 vec4) {
x = vec4.x;
y = vec4.y;
z = vec4.z;
w = vec4.w;
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
GETTERSETTER(float,Z,z)
@@ -152,6 +145,14 @@ namespace raylib {
inline Color ColorFromNormalized() {
return ::ColorFromNormalized(*this);
}
protected:
inline void set(::Vector4 vec4) {
x = vec4.x;
y = vec4.y;
z = vec4.z;
w = vec4.w;
}
};
// Alias the Vector4 as Quaternion.

View File

@@ -33,14 +33,6 @@ namespace raylib {
Unload();
}
inline void set(::Wave wave) {
sampleCount = wave.sampleCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;
channels = wave.channels;
data = wave.data;
}
GETTERSETTER(unsigned int, SampleCount, sampleCount)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
@@ -94,6 +86,15 @@ namespace raylib {
inline float* GetWaveData() {
return ::GetWaveData(*this);
}
protected:
inline void set(::Wave wave) {
sampleCount = wave.sampleCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;
channels = wave.channels;
data = wave.data;
}
};
}