Update some more functions

This commit is contained in:
Rob Loach
2020-12-03 17:59:55 -05:00
parent 6722153c0d
commit cb2da33f8b
7 changed files with 130 additions and 11 deletions

View File

@@ -54,15 +54,14 @@ class Color : public ::Color {
}
static Color FromHSV(float hue, float saturation, float value) {
::Color color = ::ColorFromHSV(hue, saturation, value);
return color;
return ::ColorFromHSV(hue, saturation, value);
}
Color(int hexValue) {
set(::GetColor(hexValue));
}
Color(Vector4 normalized) {
Color(::Vector4 normalized) {
set(::ColorFromNormalized(normalized));
}
@@ -99,6 +98,9 @@ class Color : public ::Color {
return *this;
}
/**
* Set background color (framebuffer clear color)
*/
inline Color& ClearBackground() {
::ClearBackground(*this);
return *this;
@@ -109,6 +111,9 @@ class Color : public ::Color {
return *this;
}
/**
* Draw a pixel
*/
inline Color& DrawPixel(::Vector2 pos) {
::DrawPixelV(pos, *this);
return *this;
@@ -186,6 +191,20 @@ class Color : public ::Color {
return *this;
}
/**
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
*/
Color Alpha(float alpha) {
return ::ColorAlpha(*this, alpha);
}
/**
* Returns src alpha-blended into dst color with tint
*/
Color AlphaBlend(::Color dst, ::Color tint) {
return ::ColorAlphaBlend(dst, *this, tint);
}
protected:
inline void set(const ::Color& color) {
r = color.r;

View File

@@ -75,8 +75,9 @@ class Model : public ::Model {
/**
* Unload model (but not meshes) from memory (RAM and/or VRAM)
*/
inline void UnloadKeepMeshes() {
inline Model& UnloadKeepMeshes() {
::UnloadModelKeepMeshes(*this);
return *this;
}
/**

View File

@@ -57,11 +57,15 @@ class Rectangle : public ::Rectangle {
return *this;
}
/**
* Draw a color-filled rectangle
*/
inline Rectangle& Draw(::Color color) {
::DrawRectangle(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width),
static_cast<int>(height), color);
return *this;
}
inline Rectangle& Draw(::Vector2 origin, float rotation, ::Color color) {
::DrawRectanglePro(*this, origin, rotation, color);
return *this;
@@ -89,6 +93,7 @@ class Rectangle : public ::Rectangle {
static_cast<int>(height), color);
return *this;
}
inline Rectangle& DrawLinesEx(int lineThick, ::Color color) {
::DrawRectangleLinesEx(*this, lineThick, color);
return *this;
@@ -105,18 +110,34 @@ class Rectangle : public ::Rectangle {
return *this;
}
/**
* Check collision between two rectangles
*/
inline bool CheckCollision(::Rectangle rec2) const {
return ::CheckCollisionRecs(*this, rec2);
}
/**
* Get collision rectangle for two rectangles collision
*/
inline Rectangle GetCollision(::Rectangle rec2) const {
return ::GetCollisionRec(*this, rec2);
}
/**
* Check if point is inside rectangle
*/
inline bool CheckCollision(::Vector2 point) const {
return ::CheckCollisionPointRec(point, *this);
}
/**
* Check collision between circle and rectangle
*/
inline bool CheckCollision(::Vector2 center, float radius) {
return ::CheckCollisionCircleRec(center, radius, *this);
}
protected:
inline void set(::Rectangle rect) {
x = rect.x;

View File

@@ -86,21 +86,30 @@ class Shader : public ::Shader {
return *this;
}
/**
* Get shader uniform location
*/
inline int GetLocation(const std::string& uniformName) const {
return ::GetShaderLocation(*this, uniformName.c_str());
}
/**
* Get shader attribute location
*/
inline int GetLocationAttrib(const std::string& attribName) const {
return ::GetShaderLocationAttrib(*this, attribName.c_str());
}
/**
* Set shader uniform value
*/
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType) {
::SetShaderValue(*this, uniformLoc, value.c_str(), uniformType);
return *this;
}
/**
* @see SetShaderValueV
* @see ::SetShaderValueV
*/
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType, int count) {
::SetShaderValueV(*this, uniformLoc, value.c_str(), uniformType, count);

View File

@@ -62,53 +62,87 @@ class Sound : public ::Sound {
return *this;
}
/**
* Update sound buffer with new data
*/
inline Sound& Update(const void *data, int sampleCount) {
::UpdateSound(*this, data, sampleCount);
return *this;
}
/**
* Unload sound
*/
inline void Unload() {
::UnloadSound(*this);
}
/**
* Play a sound
*/
inline Sound& Play() {
::PlaySound(*this);
return *this;
}
/**
* Stop playing a sound
*/
inline Sound& Stop() {
::StopSound(*this);
return *this;
}
/**
* Pause a sound
*/
inline Sound& Pause() {
::PauseSound(*this);
return *this;
}
/**
* Resume a paused sound
*/
inline Sound& Resume() {
::ResumeSound(*this);
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
*/
inline bool IsPlaying() const {
return ::IsSoundPlaying(*this);
}
/**
* Set volume for a sound (1.0 is max level)
*/
inline Sound& SetVolume(float volume) {
::SetSoundVolume(*this, volume);
return *this;
}
/**
* Set pitch for a sound (1.0 is base level)
*/
inline Sound& SetPitch(float pitch) {
::SetSoundPitch(*this, pitch);
return *this;

View File

@@ -209,6 +209,14 @@ class Texture : public ::Texture {
return ::GetPixelDataSize(width, height, format);
}
/**
* Define default texture used to draw shapes
*/
inline Texture& SetShapesTexture(Rectangle source) {
::SetShapesTexture(*this, source);
return *this;
}
protected:
inline void set(::Texture texture) {
id = texture.id;

View File

@@ -76,30 +76,48 @@ class Wave : public ::Wave {
return *this;
}
/**
* Convert wave data to desired format
*/
inline Wave& Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
::WaveFormat(this, SampleRate, SampleSize, Channels);
return *this;
}
/**
* Copy a wave to a new wave
*/
inline Wave Copy() {
return ::WaveCopy(*this);
}
/**
* Crop a wave to defined samples range
*/
inline Wave& Crop(int initSample, int finalSample) {
::WaveCrop(this, initSample, finalSample);
return *this;
}
inline Wave& Export(const std::string& fileName) {
::ExportWave(*this, fileName.c_str());
return *this;
/**
* Export wave data to file, returns true on success
*/
inline bool Export(const std::string& fileName) {
// TODO: Throw exception on error.
return ::ExportWave(*this, fileName.c_str());
}
inline Wave& ExportAsCode(const std::string& fileName) {
::ExportWaveAsCode(*this, fileName.c_str());
return *this;
/**
* Export wave sample data to code (.h), returns true on success
*/
inline bool ExportAsCode(const std::string& fileName) {
// TODO: Throw exception on error.
return ::ExportWaveAsCode(*this, fileName.c_str());
}
/**
* Unload wave data
*/
void Unload() {
if (data != NULL) {
::UnloadWave(*this);
@@ -107,14 +125,23 @@ class Wave : public ::Wave {
}
}
/**
* Load sound from wave data
*/
inline Sound LoadSound() {
return ::LoadSoundFromWave(*this);
}
/**
* Load sound from wave data
*/
inline operator Sound() {
return LoadSound();
}
/**
* Get samples data from wave as a floats array
*/
inline float* GetData() {
return ::GetWaveData(*this);
}