mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 17:19:27 +00:00
Add Method Chaining - fixes #9
This commit is contained in:
19
README.md
19
README.md
@@ -116,6 +116,25 @@ position.setX(50);
|
||||
position.setY(100);
|
||||
```
|
||||
|
||||
### Method Chaining
|
||||
|
||||
When there's a method that doesn't return anything, it'll instead return the object itself, allowing [method chaining](https://en.wikipedia.org/wiki/Method_chaining).
|
||||
|
||||
``` cpp
|
||||
// raylib
|
||||
Image cat = ImageLoad("cat.png");
|
||||
ImageCrop(&cat, (Rectangle){ 100, 10, 280, 380 });
|
||||
ImageFlipHorizontal(&cat);
|
||||
ImageResize(&cat, 150, 200);
|
||||
|
||||
// raylib-cpp
|
||||
raylib::Image cat("cat.png");
|
||||
cat
|
||||
.Crop((Rectangle){ 100, 10, 280, 380 })
|
||||
.FlipHorizontal()
|
||||
.Resize(150, 200);
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
``` bash
|
||||
|
||||
@@ -26,18 +26,18 @@ int main(void)
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
raylib::Image cat("resources/cat.png"); // Load image in CPU memory (RAM)
|
||||
cat.Crop(raylib::Rectangle(100, 10, 280, 380)); // Crop an image piece
|
||||
cat.FlipHorizontal(); // Flip cropped image horizontally
|
||||
cat.Resize(150, 200); // Resize flipped-cropped image
|
||||
cat.Crop(raylib::Rectangle(100, 10, 280, 380)) // Crop an image piece
|
||||
.FlipHorizontal() // Flip cropped image horizontally
|
||||
.Resize(150, 200); // Resize flipped-cropped image
|
||||
|
||||
raylib::Image parrots("resources/parrots.png"); // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
parrots.Draw(cat,
|
||||
parrots
|
||||
.Draw(cat,
|
||||
raylib::Rectangle(0, 0, cat.width, cat.height),
|
||||
raylib::Rectangle(30, 40, cat.width*1.5f, cat.height*1.5f));
|
||||
|
||||
parrots.Crop(raylib::Rectangle(0, 50, parrots.width, parrots.height - 100)); // Crop resulting image
|
||||
raylib::Rectangle(30, 40, cat.width*1.5f, cat.height*1.5f))
|
||||
.Crop(raylib::Rectangle(0, 50, parrots.width, parrots.height - 100)); // Crop resulting image
|
||||
|
||||
// Load custom font for frawing on image
|
||||
raylib::Font font("resources/custom_jupiter_crash.png");
|
||||
|
||||
@@ -24,20 +24,23 @@ namespace raylib {
|
||||
Close();
|
||||
};
|
||||
|
||||
inline void Init() {
|
||||
inline AudioDevice& Init() {
|
||||
::InitAudioDevice();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
inline AudioDevice& Close() {
|
||||
::CloseAudioDevice();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsReady() {
|
||||
return ::IsAudioDeviceReady();
|
||||
}
|
||||
|
||||
inline void SetVolume(float volume) {
|
||||
inline AudioDevice& SetVolume(float volume) {
|
||||
::SetMasterVolume(volume);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,39 +47,48 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Update(const void *data, int samplesCount) {
|
||||
inline AudioStream& Update(const void *data, int samplesCount) {
|
||||
::UpdateAudioStream(*this, data, samplesCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
inline AudioStream& Close() {
|
||||
::CloseAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline bool IsProcessed() {
|
||||
return ::IsAudioStreamProcessed(*this);
|
||||
}
|
||||
inline void Play() {
|
||||
inline AudioStream& Play() {
|
||||
::PlayAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void Pause() {
|
||||
inline AudioStream& Pause() {
|
||||
::PauseAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void Resume() {
|
||||
inline AudioStream& Resume() {
|
||||
::ResumeAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline bool IsPlaying() {
|
||||
return ::IsAudioStreamPlaying(*this);
|
||||
}
|
||||
inline void Stop() {
|
||||
inline AudioStream& Stop() {
|
||||
::StopAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void SetVolume(float volume) {
|
||||
inline AudioStream& SetVolume(float volume) {
|
||||
::SetAudioStreamVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
inline void SetPitch(float pitch) {
|
||||
inline AudioStream& SetPitch(float pitch) {
|
||||
::SetAudioStreamPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
inline void SetBufferSizeDefault(int size) {
|
||||
inline AudioStream& SetBufferSizeDefault(int size) {
|
||||
::SetAudioStreamBufferSizeDefault(size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -42,8 +42,9 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Draw(::Color color = WHITE) {
|
||||
inline BoundingBox& Draw(::Color color = WHITE) {
|
||||
DrawBoundingBox(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::BoundingBox box2) {
|
||||
|
||||
@@ -36,11 +36,13 @@ namespace raylib {
|
||||
zoom = camera.zoom;
|
||||
}
|
||||
|
||||
inline void BeginMode2D() {
|
||||
inline Camera2D& BeginMode2D() {
|
||||
::BeginMode2D(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void EndMode2D() {
|
||||
inline Camera2D& EndMode2D() {
|
||||
::EndMode2D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(Vector2,Offset,offset)
|
||||
|
||||
@@ -57,39 +57,47 @@ namespace raylib {
|
||||
type = camera.type;
|
||||
}
|
||||
|
||||
void BeginMode3D() {
|
||||
Camera3D& BeginMode3D() {
|
||||
::BeginMode3D(*this);
|
||||
return *this;
|
||||
}
|
||||
void EndMode3D() {
|
||||
Camera3D& EndMode3D() {
|
||||
::EndMode3D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix GetMatrix() {
|
||||
return ::GetCameraMatrix(*this);
|
||||
}
|
||||
|
||||
inline void SetMode(int mode) {
|
||||
inline Camera3D& SetMode(int mode) {
|
||||
::SetCameraMode(*this, mode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void SetAltControl(int altKey) {
|
||||
inline Camera3D& SetAltControl(int altKey) {
|
||||
::SetCameraAltControl(altKey);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void SetSmoothZoomControl(int szKey) {
|
||||
inline Camera3D& SetSmoothZoomControl(int szKey) {
|
||||
::SetCameraSmoothZoomControl(szKey);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void SetMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey) {
|
||||
inline Camera3D& SetMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey) {
|
||||
::SetCameraMoveControls(frontKey, backKey, rightKey, leftKey, upKey, downKey);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Update() {
|
||||
inline Camera3D& Update() {
|
||||
::UpdateCamera(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void UpdateVrTracking() {
|
||||
inline Camera3D& UpdateVrTracking() {
|
||||
::UpdateVrTracking(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Ray GetMouseRay(::Vector2 mousePosition) {
|
||||
@@ -100,12 +108,14 @@ namespace raylib {
|
||||
return ::GetWorldToScreen(position, *this);
|
||||
}
|
||||
|
||||
inline void DrawBillboard(::Texture2D texture, ::Vector3 center, float size, ::Color tint = WHITE) {
|
||||
inline Camera3D& DrawBillboard(::Texture2D texture, ::Vector3 center, float size, ::Color tint = WHITE) {
|
||||
::DrawBillboard(*this, texture, center, size, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawBillboard(Texture2D texture, Rectangle sourceRec, Vector3 center, float size, ::Color tint = WHITE) {
|
||||
inline Camera3D& DrawBillboard(Texture2D texture, Rectangle sourceRec, Vector3 center, float size, ::Color tint = WHITE) {
|
||||
::DrawBillboardRec(*this, texture, sourceRec, center, size, tint);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -121,51 +121,64 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void ClearBackground() {
|
||||
inline Color& ClearBackground() {
|
||||
::ClearBackground(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawPixel(int x, int y) {
|
||||
inline Color& DrawPixel(int x, int y) {
|
||||
::DrawPixel(x, y, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawPixel(::Vector2 pos) {
|
||||
inline Color& DrawPixel(::Vector2 pos) {
|
||||
::DrawPixelV(pos, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) {
|
||||
inline Color& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) {
|
||||
::DrawLine(startPosX, startPosY, endPosX, endPosY, *this);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLine(::Vector2 startPos, ::Vector2 endPos) {
|
||||
inline Color& DrawLine(::Vector2 startPos, ::Vector2 endPos) {
|
||||
::DrawLineV(startPos, endPos, *this);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) {
|
||||
inline Color& DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) {
|
||||
::DrawLineEx(startPos, endPos, thick, *this);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLineBezier(::Vector2 startPos, Vector2 endPos, float thick) {
|
||||
inline Color& DrawLineBezier(::Vector2 startPos, Vector2 endPos, float thick) {
|
||||
::DrawLineBezier(startPos, endPos, thick, *this);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLineStrip(::Vector2 *points, int numPoints) {
|
||||
inline Color& DrawLineStrip(::Vector2 *points, int numPoints) {
|
||||
::DrawLineStrip(points, numPoints, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawText(const std::string& text, int posX, int posY, int fontSize) {
|
||||
inline Color& DrawText(const std::string& text, int posX, int posY, int fontSize) {
|
||||
::DrawText(text.c_str(), posX, posY, fontSize, *this);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawText(::Font font, const std::string& text, ::Vector2 position, float fontSize, float spacing) {
|
||||
inline Color& DrawText(::Font font, const std::string& text, ::Vector2 position, float fontSize, float spacing) {
|
||||
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawText(::Font font, const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap = false) {
|
||||
inline Color& DrawText(::Font font, const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap = false) {
|
||||
::DrawTextRec(font, text.c_str(), rec, fontSize, spacing, wordWrap, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawRectangleLines(int posX, int posY, int width, int height) {
|
||||
inline Color& DrawRectangleLines(int posX, int posY, int width, int height) {
|
||||
::DrawRectangleLines(posX, posY, width, height, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawRectangleLines(Rectangle rec, int lineThick) {
|
||||
inline Color& DrawRectangleLines(Rectangle rec, int lineThick) {
|
||||
::DrawRectangleLinesEx(rec, lineThick, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -72,14 +72,17 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawText(const std::string& text, ::Vector2 position, float fontSize, float spacing, ::Color tint = WHITE) {
|
||||
inline Font& DrawText(const std::string& text, ::Vector2 position, float fontSize, float spacing, ::Color tint = WHITE) {
|
||||
::DrawTextEx(*this, text.c_str(), position, fontSize, spacing, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap, ::Color tint = WHITE) {
|
||||
inline Font& DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap, ::Color tint = WHITE) {
|
||||
::DrawTextRec(*this, text.c_str(), rec, fontSize, spacing, wordWrap, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, ::Color selectText, Color selectBack) {
|
||||
inline Font& DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, ::Color selectText, Color selectBack) {
|
||||
::DrawTextRecEx(*this, text.c_str(), rec, fontSize, spacing, wordWrap, tint, selectStart, selectLength, selectText, selectBack);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2 MeasureText(const std::string& text, float fontSize, float spacing) {
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace raylib {
|
||||
Image(const std::string& fileName) {
|
||||
Load(fileName);
|
||||
};
|
||||
Image(::Color *pixels, int width, int height) {
|
||||
Image(::Color* pixels, int width, int height) {
|
||||
LoadEx(pixels, width, height);
|
||||
};
|
||||
Image(void *data, int width, int height, int format) {
|
||||
Image(void* data, int width, int height, int format) {
|
||||
LoadPro(data, width, height, format);
|
||||
};
|
||||
Image(const std::string& fileName, int width, int height, int format, int headerSize) {
|
||||
@@ -65,11 +65,11 @@ namespace raylib {
|
||||
set(::LoadImage(fileName.c_str()));
|
||||
}
|
||||
|
||||
void LoadEx(::Color *pixels, int width, int height) {
|
||||
void LoadEx(::Color* pixels, int width, int height) {
|
||||
set(::LoadImageEx(pixels, width, height));
|
||||
}
|
||||
|
||||
void LoadPro(void *data, int width, int height, int format) {
|
||||
void LoadPro(void* data, int width, int height, int format) {
|
||||
set(::LoadImagePro(data, width, height, format));
|
||||
}
|
||||
|
||||
@@ -93,57 +93,74 @@ namespace raylib {
|
||||
inline Image FromImage(::Rectangle rec) {
|
||||
return ::ImageFromImage(*this, rec);
|
||||
}
|
||||
inline void Crop(::Rectangle crop){
|
||||
inline Image& Crop(::Rectangle crop){
|
||||
::ImageCrop(this, crop);
|
||||
return *this;
|
||||
}
|
||||
inline void Resize(int newWidth, int newHeight){
|
||||
inline Image& Resize(int newWidth, int newHeight){
|
||||
::ImageResize(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
inline void Draw(::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = WHITE){
|
||||
inline Image& Draw(::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = WHITE){
|
||||
::ImageDraw(this, src, srcRec, dstRec, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawRectangle(::Rectangle rec, ::Color color = WHITE){
|
||||
inline Image& DrawRectangle(::Rectangle rec, ::Color color = WHITE){
|
||||
::ImageDrawRectangle(this, rec, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawRectangleLines(::Rectangle rec, int thick, ::Color color = WHITE){
|
||||
inline Image& DrawRectangleLines(::Rectangle rec, int thick, ::Color color = WHITE){
|
||||
::ImageDrawRectangleLines(this, rec, thick, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawText(::Vector2 position, const std::string& text, int fontSize, ::Color color = WHITE){
|
||||
inline Image& DrawText(::Vector2 position, const std::string& text, int fontSize, ::Color color = WHITE){
|
||||
::ImageDrawText(this, position, text.c_str(), fontSize, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawText(::Vector2 position, ::Font font, const std::string& text, float fontSize, float spacing, ::Color color = WHITE){
|
||||
inline Image& DrawText(::Vector2 position, ::Font font, const std::string& text, float fontSize, float spacing, ::Color color = WHITE){
|
||||
::ImageDrawTextEx(this, position, font, text.c_str(), fontSize, spacing, color);
|
||||
return *this;
|
||||
}
|
||||
inline void FlipVertical() {
|
||||
inline Image& FlipVertical() {
|
||||
::ImageFlipVertical(this);
|
||||
return *this;
|
||||
}
|
||||
inline void FlipHorizontal() {
|
||||
inline Image& FlipHorizontal() {
|
||||
::ImageFlipHorizontal(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void RotateCW() {
|
||||
inline Image& RotateCW() {
|
||||
::ImageRotateCW(this);
|
||||
return *this;
|
||||
}
|
||||
inline void RotateCCW() {
|
||||
inline Image& RotateCCW() {
|
||||
::ImageRotateCCW(this);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorTint(::Color color) {
|
||||
inline Image& ColorTint(::Color color) {
|
||||
::ImageColorTint(this, color);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorInvert() {
|
||||
inline Image& ColorInvert() {
|
||||
::ImageColorInvert(this);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorGrayscale() {
|
||||
inline Image& ColorGrayscale() {
|
||||
::ImageColorGrayscale(this);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorContrast(float contrast) {
|
||||
inline Image& ColorContrast(float contrast) {
|
||||
::ImageColorContrast(this, contrast);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorBrightness(int brightness) {
|
||||
inline Image& ColorBrightness(int brightness) {
|
||||
::ImageColorBrightness(this, brightness);
|
||||
return *this;
|
||||
}
|
||||
inline void ColorReplace(::Color color, ::Color replace) {
|
||||
inline Image& ColorReplace(::Color color, ::Color replace) {
|
||||
::ImageColorReplace(this, color, replace);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ::Color* GetData() {
|
||||
|
||||
@@ -48,8 +48,9 @@ namespace raylib {
|
||||
::UnloadMaterial(*this);
|
||||
}
|
||||
|
||||
inline void SetTexture(int mapType, ::Texture2D texture) {
|
||||
inline Material& SetTexture(int mapType, ::Texture2D texture) {
|
||||
::SetMaterialTexture(this, mapType, texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -72,12 +72,14 @@ namespace raylib {
|
||||
return BoundingBox(MeshBoundingBox(*this));
|
||||
}
|
||||
|
||||
inline void Tangents() {
|
||||
inline Mesh& Tangents() {
|
||||
::MeshTangents(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Binormals() {
|
||||
inline Mesh& Binormals() {
|
||||
::MeshBinormals(this);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,16 +63,18 @@ namespace raylib {
|
||||
::UnloadModel(*this);
|
||||
}
|
||||
|
||||
inline void SetMeshMaterial(int meshId, int materialId) {
|
||||
inline Model& SetMeshMaterial(int meshId, int materialId) {
|
||||
::SetModelMeshMaterial(this, meshId, materialId);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RayHitInfo GetCollision(::Ray ray) {
|
||||
return ::GetCollisionRayModel(ray, *this);
|
||||
}
|
||||
|
||||
inline void UpdateModelAnimation(::ModelAnimation anim, int frame) {
|
||||
inline Model& UpdateModelAnimation(::ModelAnimation anim, int frame) {
|
||||
::UpdateModelAnimation(*this, anim, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsModelAnimationValid(::ModelAnimation anim) {
|
||||
|
||||
@@ -49,8 +49,9 @@ namespace raylib {
|
||||
::UnloadModelAnimation(*this);
|
||||
}
|
||||
|
||||
inline void UpdateAnimation(::Model model, int frame) {
|
||||
inline ModelAnimation& UpdateAnimation(::Model model, int frame) {
|
||||
::UpdateModelAnimation(model, *this, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsValid(::Model model) {
|
||||
|
||||
@@ -52,35 +52,43 @@ namespace raylib {
|
||||
::UnloadMusicStream(*this);
|
||||
}
|
||||
|
||||
inline void Play() {
|
||||
inline Music& Play() {
|
||||
::PlayMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Update() {
|
||||
inline Music& Update() {
|
||||
::UpdateMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Stop() {
|
||||
inline Music& Stop() {
|
||||
::StopMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Pause() {
|
||||
inline Music& Pause() {
|
||||
::PauseMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void Resume() {
|
||||
inline Music& Resume() {
|
||||
::ResumeMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
inline bool IsPlaying() {
|
||||
return ::IsMusicPlaying(*this);
|
||||
}
|
||||
inline void SetVolume(float volume) {
|
||||
inline Music& SetVolume(float volume) {
|
||||
::SetMusicVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
inline void SetPitch(float pitch) {
|
||||
inline Music& SetPitch(float pitch) {
|
||||
::SetMusicPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
inline void SetLoopCount(int count) {
|
||||
inline Music& SetLoopCount(int count) {
|
||||
::SetMusicLoopCount(*this, count);
|
||||
return *this;
|
||||
}
|
||||
inline float GetTimeLength() {
|
||||
return ::GetMusicTimeLength(*this);
|
||||
|
||||
@@ -47,8 +47,9 @@ namespace raylib {
|
||||
GETTERSETTER(::Vector3,Position,position)
|
||||
GETTERSETTER(::Vector3,Direction,direction)
|
||||
|
||||
inline void Draw(::Color color) {
|
||||
inline Ray& Draw(::Color color) {
|
||||
DrawRay(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollisionSphere(::Vector3 center, float radius) {
|
||||
|
||||
@@ -46,33 +46,42 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Draw(::Color color) {
|
||||
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 void Draw(::Vector2 origin, float rotation, ::Color color) {
|
||||
inline Rectangle& Draw(::Vector2 origin, float rotation, ::Color color) {
|
||||
::DrawRectanglePro(*this, origin, rotation, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawGradientV(::Color color1, ::Color color2){
|
||||
inline Rectangle& DrawGradientV(::Color color1, ::Color color2){
|
||||
::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawGradientH(::Color color1, ::Color color2) {
|
||||
inline Rectangle& DrawGradientH(::Color color1, ::Color color2) {
|
||||
::DrawRectangleGradientH(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color1, color2);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
|
||||
inline Rectangle& DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
|
||||
::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLines(::Color color){
|
||||
inline Rectangle& DrawLines(::Color color){
|
||||
::DrawRectangleLines(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawLinesEx(int lineThick, ::Color color){
|
||||
inline Rectangle& DrawLinesEx(int lineThick, ::Color color){
|
||||
::DrawRectangleLinesEx(*this, lineThick, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawRounded(float roundness, int segments, ::Color color){
|
||||
inline Rectangle& DrawRounded(float roundness, int segments, ::Color color){
|
||||
::DrawRectangleRounded(*this, roundness, segments, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) {
|
||||
inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) {
|
||||
::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::Rectangle rec2) {
|
||||
|
||||
@@ -54,8 +54,14 @@ namespace raylib {
|
||||
UnloadRenderTexture(*this);
|
||||
}
|
||||
|
||||
inline void BeginTextureMode() {
|
||||
inline RenderTexture2D& BeginTextureMode() {
|
||||
::BeginTextureMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RenderTexture2D& EndTextureMode() {
|
||||
::EndTextureMode();
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
typedef RenderTexture2D RenderTexture;
|
||||
|
||||
@@ -62,12 +62,14 @@ namespace raylib {
|
||||
return ::LoadShaderCode(param1, param2);
|
||||
}
|
||||
|
||||
inline void BeginShaderMode() {
|
||||
inline Shader& BeginShaderMode() {
|
||||
::BeginShaderMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void EndShaderMode() {
|
||||
inline Shader& EndShaderMode() {
|
||||
::EndShaderMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetLocation(const std::string& uniformName) {
|
||||
|
||||
@@ -50,44 +50,53 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Update(const void *data, int sampleCount) {
|
||||
UpdateSound(*this, data, sampleCount);
|
||||
inline Sound& Update(const void *data, int sampleCount) {
|
||||
::UpdateSound(*this, data, sampleCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
UnloadSound(*this);
|
||||
::UnloadSound(*this);
|
||||
}
|
||||
|
||||
inline void Play() {
|
||||
PlaySound(*this);
|
||||
inline Sound& Play() {
|
||||
::PlaySound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Stop() {
|
||||
StopSound(*this);
|
||||
inline Sound& Stop() {
|
||||
::StopSound(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void Pause() {
|
||||
PauseSound(*this);
|
||||
inline Sound& Pause() {
|
||||
::PauseSound(*this);
|
||||
return *this;
|
||||
}
|
||||
inline void Resume() {
|
||||
ResumeSound(*this);
|
||||
inline Sound& Resume() {
|
||||
::ResumeSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void PlayMulti() {
|
||||
PlaySoundMulti(*this);
|
||||
inline Sound& PlayMulti() {
|
||||
::PlaySoundMulti(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void StopMulti() {
|
||||
StopSoundMulti();
|
||||
inline Sound& StopMulti() {
|
||||
::StopSoundMulti();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsPlaying() {
|
||||
return IsSoundPlaying(*this);
|
||||
return ::IsSoundPlaying(*this);
|
||||
}
|
||||
inline void SetVolume(float volume) {
|
||||
SetSoundVolume(*this, volume);
|
||||
inline Sound& SetVolume(float volume) {
|
||||
::SetSoundVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
inline void SetPitch(float pitch) {
|
||||
SetSoundPitch(*this, pitch);
|
||||
inline Sound& SetPitch(float pitch) {
|
||||
::SetSoundPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -65,40 +65,49 @@ namespace raylib {
|
||||
set(LoadTexture(fileName.c_str()));
|
||||
}
|
||||
|
||||
inline void Draw(int posX, int posY, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(int posX, int posY, ::Color tint = WHITE) {
|
||||
::DrawTexture(*this, posX, posY, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Draw(::Vector2 position, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::Vector2 position, ::Color tint = WHITE) {
|
||||
::DrawTextureV(*this, position, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void Draw(::Vector2 position, float rotation, float scale = 1.0f, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::Vector2 position, float rotation, float scale = 1.0f, ::Color tint = WHITE) {
|
||||
::DrawTextureEx(*this, position, rotation, scale, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Draw(::Rectangle sourceRec, ::Vector2 position, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::Rectangle sourceRec, ::Vector2 position, ::Color tint = WHITE) {
|
||||
::DrawTextureRec(*this, sourceRec, position, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint = WHITE) {
|
||||
::DrawTextureQuad(*this, tiling, offset, quad, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) {
|
||||
::DrawTexturePro(*this, sourceRec, destRec, origin, rotation, tint);
|
||||
return *this;
|
||||
}
|
||||
inline void Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) {
|
||||
inline Texture2D& Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) {
|
||||
::DrawTextureNPatch(*this, nPatchInfo, destRec, origin, rotation, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Draw(::Vector3 position, float width, float height, float length, ::Color color = WHITE) {
|
||||
inline Texture2D& Draw(::Vector3 position, float width, float height, float length, ::Color color = WHITE) {
|
||||
::DrawCubeTexture(*this, position, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadTexture(*this);
|
||||
}
|
||||
|
||||
inline void SetMaterialTexture(Material *material, int mapType) {
|
||||
inline Texture2D& SetMaterialTexture(Material *material, int mapType) {
|
||||
::SetMaterialTexture(material, mapType, *this);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,32 +39,39 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawPixel(::Color color) {
|
||||
inline Vector2& DrawPixel(::Color color) {
|
||||
::DrawPixelV(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawLine(::Vector2 endPos, ::Color color) {
|
||||
inline Vector2& DrawLine(::Vector2 endPos, ::Color color) {
|
||||
::DrawLineV(*this, endPos, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawLine(::Vector2 endPos, float thick, ::Color color) {
|
||||
inline Vector2& DrawLine(::Vector2 endPos, float thick, ::Color color) {
|
||||
::DrawLineEx(*this, endPos, thick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawLineBezier(::Vector2 endPos, float thick, ::Color color) {
|
||||
inline Vector2& DrawLineBezier(::Vector2 endPos, float thick, ::Color color) {
|
||||
::DrawLineBezier(*this, endPos, thick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCircle(float radius, ::Color color) {
|
||||
inline Vector2& DrawCircle(float radius, ::Color color) {
|
||||
::DrawCircleV(*this, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawRectangle(::Vector2 size, ::Color color) {
|
||||
inline Vector2& DrawRectangle(::Vector2 size, ::Color color) {
|
||||
::DrawRectangleV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawPoly(int sides, float radius, float rotation, ::Color color) {
|
||||
inline Vector2& DrawPoly(int sides, float radius, float rotation, ::Color color) {
|
||||
::DrawPoly(*this, sides, radius, rotation, color);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,60 +46,75 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawLine3D(::Vector3 endPos, ::Color color) {
|
||||
inline Vector3& DrawLine3D(::Vector3 endPos, ::Color color) {
|
||||
::DrawLine3D(*this, endPos, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawPoint3D(::Color color) {
|
||||
inline Vector3& DrawPoint3D(::Color color) {
|
||||
::DrawPoint3D(*this, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawCircle3D(float radius, Vector3 rotationAxis, float rotationAngle, Color color) {
|
||||
inline Vector3& DrawCircle3D(float radius, Vector3 rotationAxis, float rotationAngle, Color color) {
|
||||
::DrawCircle3D(*this, radius, rotationAxis, rotationAngle, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCube(float width, float height, float length, ::Color color) {
|
||||
inline Vector3& DrawCube(float width, float height, float length, ::Color color) {
|
||||
::DrawCube(*this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawCube(::Vector3 size, ::Color color) {
|
||||
inline Vector3& DrawCube(::Vector3 size, ::Color color) {
|
||||
::DrawCubeV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCubeWires(float width, float height, float length, ::Color color) {
|
||||
inline Vector3& DrawCubeWires(float width, float height, float length, ::Color color) {
|
||||
::DrawCubeWires(*this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
inline void DrawCubeWires(::Vector3 size, ::Color color) {
|
||||
inline Vector3& DrawCubeWires(::Vector3 size, ::Color color) {
|
||||
::DrawCubeWiresV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCubeTexture(::Texture2D texture, float width, float height, float length, ::Color color) {
|
||||
inline Vector3& DrawCubeTexture(::Texture2D texture, float width, float height, float length, ::Color color) {
|
||||
::DrawCubeTexture(texture, *this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawSphere(float radius, Color color) {
|
||||
inline Vector3& DrawSphere(float radius, Color color) {
|
||||
::DrawSphere(*this, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawSphere(float radius, int rings, int slices, Color color) {
|
||||
inline Vector3& DrawSphere(float radius, int rings, int slices, Color color) {
|
||||
::DrawSphereEx(*this, radius, rings, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawSphereWires(float radius, int rings, int slices, Color color) {
|
||||
inline Vector3& DrawSphereWires(float radius, int rings, int slices, Color color) {
|
||||
::DrawSphereWires(*this, radius, rings, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCylinder(float radiusTop, float radiusBottom, float height, int slices, Color color) {
|
||||
inline Vector3& DrawCylinder(float radiusTop, float radiusBottom, float height, int slices, Color color) {
|
||||
::DrawCylinder(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawCylinderWires(float radiusTop, float radiusBottom, float height, int slices, Color color) {
|
||||
inline Vector3& DrawCylinderWires(float radiusTop, float radiusBottom, float height, int slices, Color color) {
|
||||
::DrawCylinderWires(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawPlane(::Vector2 size, ::Color color) {
|
||||
inline Vector3& DrawPlane(::Vector2 size, ::Color color) {
|
||||
::DrawPlane(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void DrawGizmo() {
|
||||
inline Vector3& DrawGizmo() {
|
||||
::DrawGizmo(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollision(float radiusA, Vector3 centerB, float radiusB) {
|
||||
|
||||
@@ -34,20 +34,25 @@ namespace raylib {
|
||||
return ::IsVrSimulatorReady();
|
||||
}
|
||||
|
||||
inline void Update(Camera *camera) {
|
||||
inline VrSimulator& Update(Camera *camera) {
|
||||
::UpdateVrTracking(camera);
|
||||
return *this;
|
||||
}
|
||||
inline void Set(VrDeviceInfo info, Shader distortion) {
|
||||
inline VrSimulator& Set(VrDeviceInfo info, Shader distortion) {
|
||||
::SetVrConfiguration(info, distortion);
|
||||
return *this;
|
||||
}
|
||||
inline void Toggle() {
|
||||
inline VrSimulator& Toggle() {
|
||||
::ToggleVrMode();
|
||||
return *this;
|
||||
}
|
||||
inline void Begin() {
|
||||
inline VrSimulator& Begin() {
|
||||
::BeginVrDrawing();
|
||||
return *this;
|
||||
}
|
||||
inline void End() {
|
||||
inline VrSimulator& End() {
|
||||
::EndVrDrawing();
|
||||
return *this;
|
||||
}
|
||||
inline void Close() {
|
||||
::CloseVrSimulator();
|
||||
|
||||
@@ -57,23 +57,27 @@ namespace raylib {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
|
||||
inline Wave& Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
|
||||
::WaveFormat(this, SampleRate, SampleSize, Channels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Wave Copy() {
|
||||
return ::WaveCopy(*this);
|
||||
}
|
||||
|
||||
inline void Crop(int initSample, int finalSample) {
|
||||
inline Wave& Crop(int initSample, int finalSample) {
|
||||
::WaveCrop(this, initSample, finalSample);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Export(const std::string& fileName) {
|
||||
inline Wave& Export(const std::string& fileName) {
|
||||
::ExportWave(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
inline void ExportAsCode(const std::string& fileName) {
|
||||
inline Wave& ExportAsCode(const std::string& fileName) {
|
||||
::ExportWaveAsCode(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
|
||||
@@ -40,11 +40,13 @@ namespace raylib {
|
||||
return ::IsWindowReady();
|
||||
};
|
||||
|
||||
inline void BeginDrawing() {
|
||||
inline Window& BeginDrawing() {
|
||||
::BeginDrawing();
|
||||
return *this;
|
||||
}
|
||||
inline void EndDrawing() {
|
||||
inline Window& EndDrawing() {
|
||||
::EndDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsMinimized() {
|
||||
@@ -56,32 +58,41 @@ namespace raylib {
|
||||
inline bool IsHidden() {
|
||||
return ::IsWindowHidden();
|
||||
}
|
||||
inline void ToggleFullscreen() {
|
||||
return ::ToggleFullscreen();
|
||||
inline Window& ToggleFullscreen() {
|
||||
::ToggleFullscreen();
|
||||
return *this;
|
||||
}
|
||||
inline void Unhide() {
|
||||
return ::UnhideWindow();
|
||||
inline Window& Unhide() {
|
||||
::UnhideWindow();
|
||||
return *this;
|
||||
}
|
||||
inline void Hide() {
|
||||
return ::HideWindow();
|
||||
inline Window& Hide() {
|
||||
::HideWindow();
|
||||
return *this;
|
||||
}
|
||||
inline void SetIcon(Image image) {
|
||||
inline Window& SetIcon(Image image) {
|
||||
::SetWindowIcon(image);
|
||||
return *this;
|
||||
}
|
||||
inline void SetTitle(const std::string& title) {
|
||||
inline Window& SetTitle(const std::string& title) {
|
||||
::SetWindowTitle(title.c_str());
|
||||
return *this;
|
||||
}
|
||||
inline void SetPosition(int x, int y) {
|
||||
inline Window& SetPosition(int x, int y) {
|
||||
::SetWindowPosition(x, y);
|
||||
return *this;
|
||||
}
|
||||
inline void SetMonitor(int monitor) {
|
||||
inline Window& SetMonitor(int monitor) {
|
||||
::SetWindowMonitor(monitor);
|
||||
return *this;
|
||||
}
|
||||
inline void SetMinSize(int width, int height) {
|
||||
inline Window& SetMinSize(int width, int height) {
|
||||
::SetWindowMinSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
inline void SetSize(int width, int height) {
|
||||
inline Window& SetSize(int width, int height) {
|
||||
::SetWindowSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
inline void* GetHandle() {
|
||||
return ::GetWindowHandle();
|
||||
|
||||
Reference in New Issue
Block a user