Initial commit
This commit is contained in:
commit
85f1dd7a1e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build/
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
#https://opensource.com/article/18/8/what-how-makefile
|
||||
|
||||
buildfile = ./build/app
|
||||
|
||||
macOSFrameworks = -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL
|
||||
|
||||
all: compile run clean
|
||||
|
||||
compile:
|
||||
clang++ -std=c++17 $(macOSFrameworks) -I ./include/ ./lib/libraylib.a ./src/main.cpp -o $(buildfile)
|
||||
|
||||
run:
|
||||
$(buildfile)
|
||||
|
||||
clean:
|
||||
rm $(buildfile)
|
85
include/AudioDevice.hpp
Normal file
85
include/AudioDevice.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Audio device management functions.
|
||||
*/
|
||||
class AudioDevice {
|
||||
public:
|
||||
/**
|
||||
* Initialize audio device and context.
|
||||
*
|
||||
* @param lateInit Whether or not to post-pone initializing the context.
|
||||
*/
|
||||
AudioDevice(bool lateInit = false) {
|
||||
if (!lateInit) {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
~AudioDevice() {
|
||||
Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize audio device and context.
|
||||
*/
|
||||
inline AudioDevice& Init() {
|
||||
::InitAudioDevice();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the audio device and context.
|
||||
*/
|
||||
inline AudioDevice& Close() {
|
||||
::CloseAudioDevice();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if audio device has been initialized successfully.
|
||||
*/
|
||||
inline bool IsReady() const {
|
||||
return ::IsAudioDeviceReady();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set master volume (listener).
|
||||
*/
|
||||
inline AudioDevice& SetVolume(float volume) {
|
||||
::SetMasterVolume(volume);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
161
include/AudioStream.hpp
Normal file
161
include/AudioStream.hpp
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* AudioStream management functions
|
||||
*/
|
||||
class AudioStream : public ::AudioStream {
|
||||
public:
|
||||
AudioStream(::AudioStream music) {
|
||||
set(music);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init audio stream (to stream raw audio pcm data)
|
||||
*/
|
||||
AudioStream(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels) {
|
||||
set(InitAudioStream(SampleRate, SampleSize, Channels));
|
||||
}
|
||||
|
||||
~AudioStream() {
|
||||
Close();
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, SampleRate, sampleRate)
|
||||
GETTERSETTER(unsigned int, SampleSize, sampleSize)
|
||||
GETTERSETTER(unsigned int, Channels, channels)
|
||||
|
||||
AudioStream& operator=(const ::AudioStream& stream) {
|
||||
set(stream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
AudioStream& operator=(const AudioStream& stream) {
|
||||
set(stream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update audio stream buffers with data
|
||||
*/
|
||||
inline AudioStream& Update(const void *data, int samplesCount) {
|
||||
::UpdateAudioStream(*this, data, samplesCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close audio stream and free memory
|
||||
*/
|
||||
inline AudioStream& Close() {
|
||||
::CloseAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any audio stream buffers requires refill
|
||||
*/
|
||||
inline bool IsProcessed() const {
|
||||
return ::IsAudioStreamProcessed(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play audio stream
|
||||
*/
|
||||
inline AudioStream& Play() {
|
||||
::PlayAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause audio stream
|
||||
*/
|
||||
inline AudioStream& Pause() {
|
||||
::PauseAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume audio stream
|
||||
*/
|
||||
inline AudioStream& Resume() {
|
||||
::ResumeAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if audio stream is playing
|
||||
*/
|
||||
inline bool IsPlaying() const {
|
||||
return ::IsAudioStreamPlaying(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop audio stream
|
||||
*/
|
||||
inline AudioStream& Stop() {
|
||||
::StopAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set volume for audio stream (1.0 is max level)
|
||||
*/
|
||||
inline AudioStream& SetVolume(float volume) {
|
||||
::SetAudioStreamVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pitch for audio stream (1.0 is base level)
|
||||
*/
|
||||
inline AudioStream& SetPitch(float pitch) {
|
||||
::SetAudioStreamPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default size for new audio streams
|
||||
*/
|
||||
inline static void SetBufferSizeDefault(int size) {
|
||||
::SetAudioStreamBufferSizeDefault(size);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::AudioStream stream) {
|
||||
sampleRate = stream.sampleRate;
|
||||
sampleSize = stream.sampleSize;
|
||||
channels = stream.channels;
|
||||
buffer = stream.buffer;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
85
include/BoundingBox.hpp
Normal file
85
include/BoundingBox.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class BoundingBox : public ::BoundingBox {
|
||||
public:
|
||||
BoundingBox(::BoundingBox box) {
|
||||
set(box);
|
||||
}
|
||||
|
||||
BoundingBox(::Mesh mesh) {
|
||||
set(MeshBoundingBox(mesh));
|
||||
}
|
||||
|
||||
BoundingBox(::Vector3 Min, ::Vector3 Max) {
|
||||
min = Min;
|
||||
max = Max;
|
||||
}
|
||||
|
||||
GETTERSETTER(::Vector3, Min, min)
|
||||
GETTERSETTER(::Vector3, Max, max)
|
||||
|
||||
BoundingBox& operator=(const ::BoundingBox& box) {
|
||||
set(box);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BoundingBox& operator=(const BoundingBox& box) {
|
||||
set(box);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline BoundingBox& Draw(::Color color = WHITE) {
|
||||
DrawBoundingBox(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::BoundingBox box2) const {
|
||||
return CheckCollisionBoxes(*this, box2);
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::Vector3 center, float radius) const {
|
||||
return CheckCollisionBoxSphere(*this, center, radius);
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::Ray ray) const {
|
||||
return CheckCollisionRayBox(ray, *this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::BoundingBox box) {
|
||||
min = box.min;
|
||||
max = box.max;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
97
include/Camera2D.hpp
Normal file
97
include/Camera2D.hpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Camera2D : public ::Camera2D {
|
||||
public:
|
||||
Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue = 0,
|
||||
float zoomValue = 1) {
|
||||
offset = offsetValue;
|
||||
target = targetValue;
|
||||
rotation = rotationValue;
|
||||
zoom = zoomValue;
|
||||
}
|
||||
|
||||
inline Camera2D& BeginMode2D() {
|
||||
::BeginMode2D(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Camera2D& EndMode2D() {
|
||||
::EndMode2D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(::Vector2, Offset, offset)
|
||||
GETTERSETTER(::Vector2, Target, target)
|
||||
GETTERSETTER(float, Rotation, rotation)
|
||||
GETTERSETTER(float, Zoom, zoom)
|
||||
|
||||
Camera2D& operator=(const ::Camera2D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Camera2D& operator=(const Camera2D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix GetMatrix() const {
|
||||
return ::GetCameraMatrix2D(*this);
|
||||
}
|
||||
|
||||
inline Vector2 GetWorldToScreen2D(Vector2 position) const {
|
||||
return ::GetWorldToScreen2D(position, *this);
|
||||
}
|
||||
|
||||
inline Vector2 GetScreenToWorld2D(Vector2 position) const {
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
147
include/Camera3D.hpp
Normal file
147
include/Camera3D.hpp
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./Vector3.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Camera3D : public ::Camera3D {
|
||||
public:
|
||||
Camera3D(::Vector3 positionValue, ::Vector3 targetValue, ::Vector3 upValue,
|
||||
float fovyValue = 0, int typeValue = 0) {
|
||||
position = positionValue;
|
||||
target = targetValue;
|
||||
up = upValue;
|
||||
fovy = fovyValue;
|
||||
type = typeValue;
|
||||
}
|
||||
|
||||
Camera3D() {}
|
||||
|
||||
GETTERSETTER(::Vector3, Position, position)
|
||||
GETTERSETTER(::Vector3, Target, target)
|
||||
GETTERSETTER(::Vector3, Up, up)
|
||||
GETTERSETTER(float, Fovy, fovy)
|
||||
GETTERSETTER(int, Type, type)
|
||||
|
||||
Camera3D& operator=(const ::Camera3D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Camera3D& operator=(const Camera3D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Camera3D& BeginMode3D() {
|
||||
::BeginMode3D(*this);
|
||||
return *this;
|
||||
}
|
||||
Camera3D& EndMode3D() {
|
||||
::EndMode3D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix GetMatrix() const {
|
||||
return ::GetCameraMatrix(*this);
|
||||
}
|
||||
|
||||
inline Camera3D& SetMode(int mode) {
|
||||
::SetCameraMode(*this, mode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Camera3D& SetAltControl(int altKey) {
|
||||
::SetCameraAltControl(altKey);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Camera3D& SetSmoothZoomControl(int szKey) {
|
||||
::SetCameraSmoothZoomControl(szKey);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 Camera3D& Update() {
|
||||
::UpdateCamera(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Camera3D& UpdateVrTracking() {
|
||||
::UpdateVrTracking(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Ray GetMouseRay(::Vector2 mousePosition) const {
|
||||
return ::GetMouseRay(mousePosition, *this);
|
||||
}
|
||||
|
||||
inline Vector2 GetWorldToScreen(::Vector3 position) const {
|
||||
return ::GetWorldToScreen(position, *this);
|
||||
}
|
||||
|
||||
inline Camera3D& DrawBillboard(::Texture2D texture, ::Vector3 center, float size,
|
||||
::Color tint = WHITE) {
|
||||
::DrawBillboard(*this, texture, center, size, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Camera3D& DrawBillboard(Texture2D texture, Rectangle sourceRec, Vector3 center,
|
||||
float size, ::Color tint = WHITE) {
|
||||
::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;
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
213
include/Color.hpp
Normal file
213
include/Color.hpp
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./Vector4.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
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;
|
||||
b = color.b;
|
||||
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(::Vector3 hsv) {
|
||||
set(::ColorFromHSV(hsv.x, hsv.y, hsv.z));
|
||||
}
|
||||
|
||||
static Color FromHSV(float hue, float saturation, float value) {
|
||||
::Color color = ::ColorFromHSV(hue, saturation, value);
|
||||
return color;
|
||||
}
|
||||
|
||||
Color(int hexValue) {
|
||||
set(::GetColor(hexValue));
|
||||
}
|
||||
|
||||
Color(Vector4 normalized) {
|
||||
set(::ColorFromNormalized(normalized));
|
||||
}
|
||||
|
||||
int ToInt() const {
|
||||
return ::ColorToInt(*this);
|
||||
}
|
||||
|
||||
operator int() const { return ::ColorToInt(*this); }
|
||||
|
||||
Color Fade(float alpha) const {
|
||||
return ::Fade(*this, alpha);
|
||||
}
|
||||
|
||||
Vector4 Normalize() const {
|
||||
return ::ColorNormalize(*this);
|
||||
}
|
||||
|
||||
Vector3 ToHSV() const {
|
||||
return ::ColorToHSV(*this);
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned char, R, r)
|
||||
GETTERSETTER(unsigned char, G, g)
|
||||
GETTERSETTER(unsigned char, B, b)
|
||||
GETTERSETTER(unsigned char, A, a)
|
||||
|
||||
Color& operator=(const ::Color& color) {
|
||||
set(color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color& operator=(const Color& color) {
|
||||
set(color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& ClearBackground() {
|
||||
::ClearBackground(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawPixel(int x, int y) {
|
||||
::DrawPixel(x, y, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawPixel(::Vector2 pos) {
|
||||
::DrawPixelV(pos, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) {
|
||||
::DrawLine(startPosX, startPosY, endPosX, endPosY, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawLine(::Vector2 startPos, ::Vector2 endPos) {
|
||||
::DrawLineV(startPos, endPos, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) {
|
||||
::DrawLineEx(startPos, endPos, thick, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawLineBezier(::Vector2 startPos, Vector2 endPos, float thick) {
|
||||
::DrawLineBezier(startPos, endPos, thick, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawLineStrip(::Vector2 *points, int numPoints) {
|
||||
::DrawLineStrip(points, numPoints, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawText(const std::string& text, int posX, int posY, int fontSize) {
|
||||
::DrawText(text.c_str(), posX, posY, fontSize, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 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 Color& DrawRectangle(int posX, int posY, int width, int height) {
|
||||
::DrawRectangle(posX, posY, width, height, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawRectangle(Vector2 position, Vector2 size) {
|
||||
::DrawRectangleV(position, size, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawRectangle(Rectangle rec) {
|
||||
::DrawRectangleRec(rec, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawRectangle(Rectangle rec, Vector2 origin, float rotation) {
|
||||
::DrawRectanglePro(rec, origin, rotation, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawRectangleLines(int posX, int posY, int width, int height) {
|
||||
::DrawRectangleLines(posX, posY, width, height, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Color& DrawRectangleLines(Rectangle rec, int lineThick) {
|
||||
::DrawRectangleLinesEx(rec, lineThick, *this);
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
107
include/DroppedFiles.hpp
Normal file
107
include/DroppedFiles.hpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_DROPPEDFILES_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_DROPPEDFILES_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class DroppedFiles {
|
||||
public:
|
||||
DroppedFiles() {
|
||||
Get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dropped files names.
|
||||
*/
|
||||
DroppedFiles& Get() {
|
||||
m_files = ::GetDroppedFiles(&m_count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file has been dropped into window.
|
||||
*/
|
||||
inline bool IsFileDropped() const {
|
||||
return ::IsFileDropped();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear dropped files paths buffer.
|
||||
*/
|
||||
inline DroppedFiles& Clear() {
|
||||
::ClearDroppedFiles();
|
||||
return *this;
|
||||
}
|
||||
|
||||
~DroppedFiles() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
inline std::string operator[](int pos) {
|
||||
return at(pos);
|
||||
}
|
||||
|
||||
inline int Count() const {
|
||||
return m_count;
|
||||
}
|
||||
|
||||
inline int size() const {
|
||||
return m_count;
|
||||
}
|
||||
|
||||
inline bool empty() const {
|
||||
return m_count == 0;
|
||||
}
|
||||
|
||||
inline void clear() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
inline std::string front() const {
|
||||
return at(0);
|
||||
}
|
||||
|
||||
inline std::string back() const {
|
||||
return at(m_count - 1);
|
||||
}
|
||||
|
||||
std::string at(int pos) const {
|
||||
if (m_files != NULL && pos < m_count && pos >= 0) {
|
||||
return std::string(m_files[pos]);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected:
|
||||
char** m_files;
|
||||
int m_count;
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_DROPPEDFILES_HPP_
|
129
include/Font.hpp
Normal file
129
include/Font.hpp
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FONT_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FONT_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Font : public ::Font {
|
||||
public:
|
||||
Font() {
|
||||
set(::GetFontDefault());
|
||||
}
|
||||
|
||||
Font(const std::string& fileName) {
|
||||
set(::LoadFont(fileName.c_str()));
|
||||
}
|
||||
|
||||
Font(const std::string& fileName, int fontSize, int* fontChars, int charCount) {
|
||||
set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount));
|
||||
}
|
||||
|
||||
Font(const ::Image& image, ::Color key, int firstChar) {
|
||||
set(::LoadFontFromImage(image, key, firstChar));
|
||||
}
|
||||
|
||||
Font(const std::string& fileType, const unsigned char *fileData, int dataSize, int fontSize,
|
||||
int *fontChars, int charsCount) {
|
||||
set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, fontChars,
|
||||
charsCount));
|
||||
}
|
||||
|
||||
~Font() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
UnloadFont(*this);
|
||||
}
|
||||
|
||||
GETTERSETTER(int, BaseSize, baseSize)
|
||||
GETTERSETTER(int, CharsCount, charsCount)
|
||||
GETTERSETTER(::Texture2D, Texture, texture)
|
||||
GETTERSETTER(::Rectangle*, Recs, recs)
|
||||
GETTERSETTER(::CharInfo*, Chars, chars)
|
||||
|
||||
Font& operator=(const ::Font& font) {
|
||||
set(font);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Font& operator=(const Font& font) {
|
||||
set(font);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 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 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) {
|
||||
return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing);
|
||||
}
|
||||
|
||||
inline int GetGlyphIndex(int character) const {
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FONT_HPP_
|
99
include/Gamepad.hpp
Normal file
99
include/Gamepad.hpp
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Gamepad {
|
||||
public:
|
||||
Gamepad(int gamepadNumber = 0) {
|
||||
set(gamepadNumber);
|
||||
}
|
||||
int number;
|
||||
|
||||
GETTERSETTER(int, Number, number)
|
||||
|
||||
Gamepad& operator=(const Gamepad& gamepad) {
|
||||
set(gamepad);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Gamepad& operator=(int gamepadNumber) {
|
||||
set(gamepadNumber);
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator int() const { return number; }
|
||||
|
||||
inline bool IsAvailable() const {
|
||||
return ::IsGamepadAvailable(number);
|
||||
}
|
||||
inline bool IsName(const std::string& name) const {
|
||||
return ::IsGamepadName(number, name.c_str());
|
||||
}
|
||||
std::string GetName() const {
|
||||
return std::string(::GetGamepadName(number));
|
||||
}
|
||||
inline bool IsButtonPressed(int button) const {
|
||||
return ::IsGamepadButtonPressed(number, button);
|
||||
}
|
||||
|
||||
inline bool IsButtonDown(int button) const {
|
||||
return ::IsGamepadButtonDown(number, button);
|
||||
}
|
||||
|
||||
inline bool IsButtonReleased(int button) const {
|
||||
return ::IsGamepadButtonReleased(number, button);
|
||||
}
|
||||
|
||||
inline bool IsButtonUp(int button) const {
|
||||
return ::IsGamepadButtonUp(number, button);
|
||||
}
|
||||
|
||||
inline int GetButtonPressed() const {
|
||||
return ::GetGamepadButtonPressed();
|
||||
}
|
||||
|
||||
inline int GetAxisCount() const {
|
||||
return ::GetGamepadAxisCount(number);
|
||||
}
|
||||
|
||||
inline float GetAxisMovement(int axis) const {
|
||||
return ::GetGamepadAxisMovement(number, axis);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(int gamepadNumber) {
|
||||
number = gamepadNumber;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
391
include/Image.hpp
Normal file
391
include/Image.hpp
Normal file
@ -0,0 +1,391 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Image : public ::Image {
|
||||
public:
|
||||
Image() {}
|
||||
Image(::Image image) {
|
||||
set(image);
|
||||
}
|
||||
Image(const std::string& fileName) {
|
||||
Load(fileName);
|
||||
}
|
||||
Image(const std::string& fileName, int width, int height, int format, int headerSize) {
|
||||
LoadRaw(fileName, width, height, format, headerSize);
|
||||
}
|
||||
Image(const std::string& fileName, int* frames) {
|
||||
LoadAnim(fileName, frames);
|
||||
}
|
||||
Image(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
LoadFromMemory(fileType, fileData, dataSize);
|
||||
}
|
||||
Image(::Texture2D texture) {
|
||||
set(::GetTextureData(texture));
|
||||
}
|
||||
Image(int width, int height, Color color = WHITE) {
|
||||
set(::GenImageColor(width, height, color));
|
||||
}
|
||||
|
||||
static Image Text(std::string text, int fontSize, Color color) {
|
||||
return ::ImageText(text.c_str(), fontSize, color);
|
||||
}
|
||||
|
||||
static Image Text(Font font, std::string text, float fontSize, float spacing, Color tint) {
|
||||
return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
static Image GetScreenData() {
|
||||
return Image(::GetScreenData());
|
||||
}
|
||||
|
||||
static Image GenColor(int width, int height, Color color) {
|
||||
return ::GenImageColor(width, height, color);
|
||||
}
|
||||
|
||||
static Image GenGradientV(int width, int height, Color top, Color bottom) {
|
||||
return ::GenImageGradientV(width, height, top, bottom);
|
||||
}
|
||||
|
||||
static Image GenGradientH(int width, int height, Color left, Color right) {
|
||||
return ::GenImageGradientH(width, height, left, right);
|
||||
}
|
||||
|
||||
static Image GenGradientRadial(int width, int height, float density,
|
||||
Color inner, Color outer) {
|
||||
return ::GenImageGradientRadial(width, height, density, inner, outer);
|
||||
}
|
||||
|
||||
static Image GenChecked(int width, int height, int checksX, int checksY,
|
||||
Color col1, Color col2) {
|
||||
return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
|
||||
}
|
||||
|
||||
static Image GenWhiteNoise(int width, int height, float factor) {
|
||||
return ::GenImageWhiteNoise(width, height, factor);
|
||||
}
|
||||
|
||||
static Image GenPerlinNoise(int width, int height, int offsetX, int offsetY, float scale) {
|
||||
return ::GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
|
||||
}
|
||||
|
||||
static Image GenCellular(int width, int height, int tileSize) {
|
||||
return ::GenImageCellular(width, height, tileSize);
|
||||
}
|
||||
|
||||
~Image() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
Image& operator=(const ::Image& image) {
|
||||
set(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Image& operator=(const Image& image) {
|
||||
set(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadImage(fileName.c_str()));
|
||||
}
|
||||
|
||||
void LoadRaw(const std::string& fileName, int width, int height, int format, int headerSize) {
|
||||
set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
|
||||
}
|
||||
|
||||
void LoadAnim(const std::string& fileName, int* frames) {
|
||||
set(::LoadImageAnim(fileName.c_str(), frames));
|
||||
}
|
||||
|
||||
void LoadFromMemory(const std::string& fileType, const unsigned char *fileData, int dataSize) {
|
||||
set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadImage(*this);
|
||||
}
|
||||
|
||||
inline Image& Export(const std::string& fileName) {
|
||||
::ExportImage(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ExportAsCode(const std::string& fileName) {
|
||||
::ExportImageAsCode(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(void*, Data, data)
|
||||
GETTERSETTER(int, Width, width)
|
||||
GETTERSETTER(int, Height, height)
|
||||
GETTERSETTER(int, Mipmaps, mipmaps)
|
||||
GETTERSETTER(int, Format, format)
|
||||
|
||||
inline Image Copy() {
|
||||
return ::ImageCopy(*this);
|
||||
}
|
||||
inline Image FromImage(::Rectangle rec) {
|
||||
return ::ImageFromImage(*this, rec);
|
||||
}
|
||||
|
||||
inline Image& ToPOT(Color fillColor) {
|
||||
::ImageToPOT(this, fillColor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Format(int newFormat) {
|
||||
::ImageFormat(this, newFormat);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& AlphaMask(Image alphaMask) {
|
||||
::ImageAlphaMask(this, alphaMask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& AlphaCrop(float threshold) {
|
||||
::ImageAlphaCrop(this, threshold);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& AlphaPremultiply() {
|
||||
::ImageAlphaPremultiply(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Crop(::Rectangle crop) {
|
||||
::ImageCrop(this, crop);
|
||||
return *this;
|
||||
}
|
||||
inline Image& Crop(int offsetX, int offsetY, int newWidth, int newHeight) {
|
||||
::Rectangle rect{
|
||||
static_cast<float>(offsetX),
|
||||
static_cast<float>(offsetY),
|
||||
static_cast<float>(newWidth),
|
||||
static_cast<float>(newHeight)
|
||||
};
|
||||
::ImageCrop(this, rect);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Resize(int newWidth, int newHeight) {
|
||||
::ImageResize(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ResizeNN(int newWidth, int newHeight) {
|
||||
::ImageResizeNN(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ResizeCanvas(int newWidth, int newHeight, int offsetX, int offsetY, Color color) {
|
||||
::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Mipmaps() {
|
||||
::ImageMipmaps(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
|
||||
::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& FlipVertical() {
|
||||
::ImageFlipVertical(this);
|
||||
return *this;
|
||||
}
|
||||
inline Image& FlipHorizontal() {
|
||||
::ImageFlipHorizontal(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& RotateCW() {
|
||||
::ImageRotateCW(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& RotateCCW() {
|
||||
::ImageRotateCCW(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ColorTint(::Color color = WHITE) {
|
||||
::ImageColorTint(this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ColorInvert() {
|
||||
::ImageColorInvert(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ColorGrayscale() {
|
||||
::ImageColorGrayscale(this);
|
||||
return *this;
|
||||
}
|
||||
inline Image& ColorContrast(float contrast) {
|
||||
::ImageColorContrast(this, contrast);
|
||||
return *this;
|
||||
}
|
||||
inline Image& ColorBrightness(int brightness) {
|
||||
::ImageColorBrightness(this, brightness);
|
||||
return *this;
|
||||
}
|
||||
inline Image& ColorReplace(::Color color, ::Color replace) {
|
||||
::ImageColorReplace(this, color, replace);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ::Color* GetPalette(int maxPaletteSize, int *extractCount) {
|
||||
return ::GetImagePalette(*this, maxPaletteSize, extractCount);
|
||||
}
|
||||
|
||||
inline Rectangle GetAlphaBorder(float threshold) const {
|
||||
return ::GetImageAlphaBorder(*this, threshold);
|
||||
}
|
||||
|
||||
inline Image& ClearBackground(::Color color = WHITE) {
|
||||
::ImageClearBackground(this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawPixel(int posX, int posY, ::Color color) {
|
||||
::ImageDrawPixel(this, posX, posY, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawPixel(::Vector2 position, ::Color color) {
|
||||
::ImageDrawPixelV(this, position, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, ::Color color) {
|
||||
::ImageDrawLine(this, startPosX, startPosY, endPosX, endPosY, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawLine(::Vector2 start, ::Vector2 end, ::Color color) {
|
||||
::ImageDrawLineV(this, start, end, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawCircle(int centerX, int centerY, int radius, ::Color color) {
|
||||
::ImageDrawCircle(this, centerX, centerY, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawCircle(::Vector2 center, int radius, ::Color color) {
|
||||
::ImageDrawCircleV(this, center, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawRectangle(int posX, int posY, int width, int height, ::Color color = WHITE) {
|
||||
::ImageDrawRectangle(this, posX, posY, width, height, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawRectangle(Vector2 position, Vector2 size, ::Color color = WHITE) {
|
||||
::ImageDrawRectangleV(this, position, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawRectangle(::Rectangle rec, ::Color color = WHITE) {
|
||||
::ImageDrawRectangleRec(this, rec, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawRectangleLines(::Rectangle rec, int thick, ::Color color) {
|
||||
::ImageDrawRectangleLines(this, rec, thick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec,
|
||||
::Color tint = WHITE) {
|
||||
::ImageDraw(this, src, srcRec, dstRec, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawText(const std::string& text, ::Vector2 position, int fontSize,
|
||||
::Color color = WHITE) {
|
||||
::ImageDrawText(this,
|
||||
text.c_str(),
|
||||
static_cast<int>(position.x),
|
||||
static_cast<int>(position.y),
|
||||
fontSize,
|
||||
color);
|
||||
return *this;
|
||||
}
|
||||
inline Image& DrawText(const std::string& text, int x, int y, int fontSize,
|
||||
::Color color = WHITE) {
|
||||
::ImageDrawText(this, text.c_str(), x, y, fontSize, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& DrawText(::Font font, const std::string& text, ::Vector2 position,
|
||||
float fontSize, float spacing, ::Color tint = WHITE) {
|
||||
::ImageDrawTextEx(this, font, text.c_str(), position, fontSize, spacing, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ::Color* GetImageData() {
|
||||
return ::GetImageData(*this);
|
||||
}
|
||||
|
||||
inline ::Vector4* GetImageDataNormalized() {
|
||||
return ::GetImageDataNormalized(*this);
|
||||
}
|
||||
|
||||
::Texture2D LoadTexture() {
|
||||
return ::LoadTextureFromImage(*this);
|
||||
}
|
||||
|
||||
inline operator ::Texture2D() {
|
||||
return LoadTexture();
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Image image) {
|
||||
data = image.data;
|
||||
width = image.width;
|
||||
height = image.height;
|
||||
mipmaps = image.mipmaps;
|
||||
format = image.format;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
76
include/Material.hpp
Normal file
76
include/Material.hpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Material : public ::Material {
|
||||
public:
|
||||
Material(::Material material) {
|
||||
set(material);
|
||||
}
|
||||
|
||||
Material() {
|
||||
set(LoadMaterialDefault());
|
||||
}
|
||||
|
||||
~Material() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(::Shader, Shader, shader)
|
||||
|
||||
Material& operator=(const ::Material& material) {
|
||||
set(material);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Material& operator=(const Material& material) {
|
||||
set(material);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadMaterial(*this);
|
||||
}
|
||||
|
||||
inline Material& SetTexture(int mapType, ::Texture2D texture) {
|
||||
::SetMaterialTexture(this, mapType, texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Material material) {
|
||||
shader = material.shader;
|
||||
maps = material.maps;
|
||||
params = material.params;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
260
include/Matrix.hpp
Normal file
260
include/Matrix.hpp
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include "raymath.h" // NOLINT
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Matrix : public ::Matrix {
|
||||
public:
|
||||
Matrix(::Matrix mat) {
|
||||
set(mat);
|
||||
}
|
||||
|
||||
Matrix(float M0 = 0, float M1 = 0, float M2 = 0, float M3 = 0, float M4 = 0, float M5 = 0,
|
||||
float M6 = 0, float M7 = 0, float M8 = 0, float M9 = 0, float M10 = 0, float M11 = 0,
|
||||
float M12 = 0, float M13 = 0, float M14 = 0, float M15 = 0) {
|
||||
m0 = M0;
|
||||
m1 = M1;
|
||||
m2 = M2;
|
||||
m3 = M3;
|
||||
m4 = M4;
|
||||
m5 = M5;
|
||||
m6 = M6;
|
||||
m7 = M7;
|
||||
m8 = M8;
|
||||
m9 = M9;
|
||||
m10 = M10;
|
||||
m11 = M11;
|
||||
m12 = M12;
|
||||
m13 = M13;
|
||||
m14 = M14;
|
||||
m15 = M15;
|
||||
}
|
||||
|
||||
GETTERSETTER(float, M0, m0)
|
||||
GETTERSETTER(float, M1, m1)
|
||||
GETTERSETTER(float, M2, m2)
|
||||
GETTERSETTER(float, M3, m3)
|
||||
GETTERSETTER(float, M4, m4)
|
||||
GETTERSETTER(float, M5, m5)
|
||||
GETTERSETTER(float, M6, m6)
|
||||
GETTERSETTER(float, M7, m7)
|
||||
GETTERSETTER(float, M8, m8)
|
||||
GETTERSETTER(float, M9, m9)
|
||||
GETTERSETTER(float, M10, m10)
|
||||
GETTERSETTER(float, M11, m11)
|
||||
GETTERSETTER(float, M12, m12)
|
||||
GETTERSETTER(float, M13, m13)
|
||||
GETTERSETTER(float, M14, m14)
|
||||
GETTERSETTER(float, M15, m15)
|
||||
|
||||
Matrix& operator=(const ::Matrix& matrix) {
|
||||
set(matrix);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Matrix& operator=(const Matrix& matrix) {
|
||||
set(matrix);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Matrix& other) {
|
||||
return m0 == other.m0
|
||||
&& m1 == other.m1
|
||||
&& m2 == other.m2
|
||||
&& m3 == other.m3
|
||||
&& m4 == other.m4
|
||||
&& m5 == other.m5
|
||||
&& m6 == other.m6
|
||||
&& m7 == other.m7
|
||||
&& m8 == other.m8
|
||||
&& m9 == other.m9
|
||||
&& m10 == other.m10
|
||||
&& m11 == other.m11
|
||||
&& m12 == other.m12
|
||||
&& m13 == other.m13
|
||||
&& m14 == other.m14
|
||||
&& m15 == other.m15;
|
||||
}
|
||||
|
||||
inline Matrix& SetProjection() {
|
||||
::SetMatrixProjection(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Matrix& SetModelview() {
|
||||
::SetMatrixModelview(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
static Matrix GetModelview() {
|
||||
return ::GetMatrixModelview();
|
||||
}
|
||||
|
||||
static Matrix GetProjection() {
|
||||
return ::GetMatrixProjection();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
inline float Trace() {
|
||||
return ::MatrixTrace(*this);
|
||||
}
|
||||
|
||||
inline Matrix Transpose() {
|
||||
return ::MatrixTranspose(*this);
|
||||
}
|
||||
|
||||
inline Matrix Invert() {
|
||||
return ::MatrixInvert(*this);
|
||||
}
|
||||
|
||||
inline Matrix Normalize() {
|
||||
return ::MatrixNormalize(*this);
|
||||
}
|
||||
|
||||
static Matrix Identity() {
|
||||
return ::MatrixIdentity();
|
||||
}
|
||||
|
||||
Matrix Add(::Matrix right) {
|
||||
return ::MatrixAdd(*this, right);
|
||||
}
|
||||
|
||||
Matrix operator+(const Matrix& matrix) {
|
||||
return ::MatrixAdd(*this, matrix);
|
||||
}
|
||||
|
||||
Matrix Subtract(::Matrix right) {
|
||||
return ::MatrixSubtract(*this, right);
|
||||
}
|
||||
|
||||
Matrix operator-(const Matrix& matrix) {
|
||||
return ::MatrixSubtract(*this, matrix);
|
||||
}
|
||||
|
||||
static Matrix Translate(float x, float y, float z) {
|
||||
return ::MatrixTranslate(x, y, z);
|
||||
}
|
||||
|
||||
static Matrix Rotate(Vector3 axis, float angle) {
|
||||
return ::MatrixRotate(axis, angle);
|
||||
}
|
||||
|
||||
static Matrix RotateXYZ(Vector3 angle) {
|
||||
return ::MatrixRotateXYZ(angle);
|
||||
}
|
||||
|
||||
static Matrix RotateX(float angle) {
|
||||
return ::MatrixRotateX(angle);
|
||||
}
|
||||
|
||||
static Matrix RotateY(float angle) {
|
||||
return ::MatrixRotateY(angle);
|
||||
}
|
||||
|
||||
static Matrix RotateZ(float angle) {
|
||||
return ::MatrixRotateZ(angle);
|
||||
}
|
||||
|
||||
static Matrix Scale(float x, float y, float z) {
|
||||
return ::MatrixScale(x, y, z);
|
||||
}
|
||||
|
||||
Matrix Multiply(Matrix right) {
|
||||
return ::MatrixMultiply(*this, right);
|
||||
}
|
||||
|
||||
Matrix operator*(const Matrix& matrix) {
|
||||
return ::MatrixMultiply(*this, matrix);
|
||||
}
|
||||
|
||||
static Matrix Frustum(double left, double right, double bottom, double top,
|
||||
double near, double far) {
|
||||
return ::MatrixFrustum(left, right, bottom, top, near, far);
|
||||
}
|
||||
|
||||
static Matrix Perspective(double fovy, double aspect, double near, double far) {
|
||||
return ::MatrixPerspective(fovy, aspect, near, far);
|
||||
}
|
||||
|
||||
static Matrix Ortho(double left, double right, double bottom, double top,
|
||||
double near, double far) {
|
||||
return ::MatrixOrtho(left, right, bottom, top, near, far);
|
||||
}
|
||||
|
||||
static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up) {
|
||||
return ::MatrixLookAt(eye, target, up);
|
||||
}
|
||||
|
||||
inline float16 ToFloatV() {
|
||||
return ::MatrixToFloatV(*this);
|
||||
}
|
||||
|
||||
operator float16() {
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
125
include/Mesh.hpp
Normal file
125
include/Mesh.hpp
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./BoundingBox.hpp"
|
||||
#include "./Model.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Mesh : public ::Mesh {
|
||||
public:
|
||||
Mesh(::Mesh mesh) {
|
||||
set(mesh);
|
||||
}
|
||||
|
||||
Mesh(int VertexCount = 0, int TriangleCount = 0) {
|
||||
vertexCount = VertexCount;
|
||||
triangleCount = TriangleCount;
|
||||
}
|
||||
|
||||
GETTERSETTER(int, VertexCount, vertexCount)
|
||||
GETTERSETTER(int, TriangleCount, triangleCount)
|
||||
|
||||
Mesh& operator=(const ::Mesh& mesh) {
|
||||
set(mesh);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Mesh& operator=(const Mesh& mesh) {
|
||||
set(mesh);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Mesh() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
inline Mesh& Export(const std::string& fileName) {
|
||||
ExportMesh(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadMesh(*this);
|
||||
}
|
||||
|
||||
inline raylib::BoundingBox BoundingBox() {
|
||||
return ::MeshBoundingBox(*this);
|
||||
}
|
||||
|
||||
operator raylib::BoundingBox() {
|
||||
return BoundingBox();
|
||||
}
|
||||
|
||||
inline Mesh& Tangents() {
|
||||
::MeshTangents(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Mesh& Binormals() {
|
||||
::MeshBinormals(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Mesh& NormalsSmooth() {
|
||||
::MeshNormalsSmooth(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline raylib::Model LoadModelFrom() {
|
||||
return ::LoadModelFromMesh(*this);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MESH_HPP_
|
107
include/Model.hpp
Normal file
107
include/Model.hpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./Mesh.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Model : public ::Model {
|
||||
public:
|
||||
Model(::Model model) {
|
||||
set(model);
|
||||
}
|
||||
|
||||
Model(const std::string& fileName) {
|
||||
set(LoadModel(fileName.c_str()));
|
||||
}
|
||||
|
||||
Model(::Mesh mesh) {
|
||||
set(LoadModelFromMesh(mesh));
|
||||
}
|
||||
|
||||
~Model() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(::Matrix, Transform, transform)
|
||||
GETTERSETTER(int, MeshCount, meshCount)
|
||||
GETTERSETTER(int, MaterialCount, materialCount)
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
|
||||
Model& operator=(const ::Model& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Model& operator=(const Model& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadModel(*this);
|
||||
}
|
||||
|
||||
inline Model& SetMeshMaterial(int meshId, int materialId) {
|
||||
::SetModelMeshMaterial(this, meshId, materialId);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RayHitInfo GetCollision(::Ray ray) const {
|
||||
return ::GetCollisionRayModel(ray, *this);
|
||||
}
|
||||
|
||||
inline Model& UpdateModelAnimation(::ModelAnimation anim, int frame) {
|
||||
::UpdateModelAnimation(*this, anim, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsModelAnimationValid(::ModelAnimation anim) const {
|
||||
return ::IsModelAnimationValid(*this, anim);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Model model) {
|
||||
transform = model.transform;
|
||||
|
||||
meshCount = model.meshCount;
|
||||
materialCount = model.materialCount;
|
||||
meshes = model.meshes;
|
||||
materials = model.materials;
|
||||
meshMaterial = model.meshMaterial;
|
||||
|
||||
boneCount = model.boneCount;
|
||||
bones = model.bones;
|
||||
bindPose = model.bindPose;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
85
include/ModelAnimation.hpp
Normal file
85
include/ModelAnimation.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./Mesh.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class ModelAnimation : public ::ModelAnimation {
|
||||
public:
|
||||
ModelAnimation(::ModelAnimation model) {
|
||||
set(model);
|
||||
}
|
||||
|
||||
~ModelAnimation() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
GETTERSETTER(::BoneInfo*, Bones, bones)
|
||||
GETTERSETTER(int, FrameCount, frameCount)
|
||||
GETTERSETTER(::Transform**, FramePoses, framePoses)
|
||||
|
||||
ModelAnimation& operator=(const ::ModelAnimation& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ModelAnimation& operator=(const ModelAnimation& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadModelAnimation(*this);
|
||||
}
|
||||
|
||||
inline ModelAnimation& UpdateAnimation(::Model model, int frame) {
|
||||
::UpdateModelAnimation(model, *this, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsValid(::Model model) const {
|
||||
return ::IsModelAnimationValid(model, *this);
|
||||
}
|
||||
|
||||
inline bool IsModelAnimationValid(::Model model) const {
|
||||
return ::IsModelAnimationValid(model, *this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::ModelAnimation model) {
|
||||
boneCount = model.boneCount;
|
||||
bones = model.bones;
|
||||
frameCount = model.frameCount;
|
||||
framePoses = model.framePoses;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
115
include/Mouse.hpp
Normal file
115
include/Mouse.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
#include "./Vector2.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Mouse {
|
||||
public:
|
||||
inline bool IsButtonPressed(int button) const {
|
||||
return ::IsMouseButtonPressed(button);
|
||||
}
|
||||
|
||||
inline bool IsButtonDown(int button) const {
|
||||
return ::IsMouseButtonDown(button);
|
||||
}
|
||||
|
||||
inline bool IsButtonReleased(int button) const {
|
||||
return ::IsMouseButtonReleased(button);
|
||||
}
|
||||
|
||||
inline bool IsButtonUp(int button) const {
|
||||
return ::IsMouseButtonUp(button);
|
||||
}
|
||||
|
||||
inline int GetX() const {
|
||||
return ::GetMouseX();
|
||||
}
|
||||
|
||||
inline int GetY() const {
|
||||
return ::GetMouseY();
|
||||
}
|
||||
|
||||
inline Mouse& SetX(int x) {
|
||||
::SetMouseOffset(x, GetY());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Mouse& SetY(int y) {
|
||||
::SetMouseOffset(GetX(), y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2 GetPosition() const {
|
||||
return ::GetMousePosition();
|
||||
}
|
||||
|
||||
inline Mouse& SetPosition(int x, int y) {
|
||||
::SetMousePosition(x, y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Mouse& SetOffset(int offsetX, int offsetY) {
|
||||
::SetMouseOffset(offsetX, offsetY);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Mouse& SetScale(float scaleX, float scaleY) {
|
||||
::SetMouseScale(scaleX, scaleY);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float GetWheelMove() const {
|
||||
return ::GetMouseWheelMove();
|
||||
}
|
||||
|
||||
inline int GetCursor() const {
|
||||
return ::GetMouseCursor();
|
||||
}
|
||||
|
||||
inline Mouse& SetCursor(int cursor) {
|
||||
::SetMouseCursor(cursor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetTouchX() const {
|
||||
return ::GetTouchX();
|
||||
}
|
||||
|
||||
inline int GetTouchY() const {
|
||||
return ::GetTouchY();
|
||||
}
|
||||
|
||||
inline Vector2 GetTouchPosition(int index) const {
|
||||
return ::GetTouchPosition(index);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
124
include/Music.hpp
Normal file
124
include/Music.hpp
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Music : public ::Music {
|
||||
public:
|
||||
Music(::Music music) {
|
||||
set(music);
|
||||
}
|
||||
|
||||
Music(const std::string& fileName) {
|
||||
set(::LoadMusicStream(fileName.c_str()));
|
||||
}
|
||||
|
||||
~Music() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(int, CtxType, ctxType)
|
||||
GETTERSETTER(bool, Looping, looping)
|
||||
GETTERSETTER(unsigned int, SampleCount, sampleCount)
|
||||
|
||||
Music& operator=(const ::Music& music) {
|
||||
set(music);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Music& operator=(const Music& music) {
|
||||
set(music);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadMusicStream(*this);
|
||||
}
|
||||
|
||||
inline Music& Play() {
|
||||
::PlayMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Music& Update() {
|
||||
::UpdateMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Music& Stop() {
|
||||
::StopMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Music& Pause() {
|
||||
::PauseMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Music& Resume() {
|
||||
::ResumeMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsPlaying() const {
|
||||
return ::IsMusicPlaying(*this);
|
||||
}
|
||||
|
||||
inline Music& SetVolume(float volume) {
|
||||
::SetMusicVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Music& SetPitch(float pitch) {
|
||||
::SetMusicPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float GetTimeLength() const {
|
||||
return ::GetMusicTimeLength(*this);
|
||||
}
|
||||
|
||||
inline float GetTimePlayed() const {
|
||||
return ::GetMusicTimePlayed(*this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Music music) {
|
||||
ctxType = music.ctxType;
|
||||
ctxData = music.ctxData;
|
||||
looping = music.looping;
|
||||
sampleCount = music.sampleCount;
|
||||
stream = music.stream;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
152
include/Physics.hpp
Normal file
152
include/Physics.hpp
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_PHYSICS_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_PHYSICS_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "physac.h" // NOLINT
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "./Vector2.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Physics {
|
||||
public:
|
||||
Physics() {
|
||||
Init();
|
||||
}
|
||||
Physics(float gravityY) {
|
||||
Init();
|
||||
SetGravity(0, gravityY);
|
||||
}
|
||||
Physics(float gravityX, float gravityY) {
|
||||
Init();
|
||||
SetGravity(gravityX, gravityY);
|
||||
}
|
||||
|
||||
~Physics() {
|
||||
Close();
|
||||
}
|
||||
|
||||
inline Physics& Init() {
|
||||
::InitPhysics();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& Close() {
|
||||
::ClosePhysics();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& RunStep() {
|
||||
::RunPhysicsStep();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& SetTimeStep(double delta) {
|
||||
::SetPhysicsTimeStep(delta);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsEnabled() {
|
||||
return ::IsPhysicsEnabled();
|
||||
}
|
||||
|
||||
inline Physics& SetGravity(float x, float y) {
|
||||
::SetPhysicsGravity(x, y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PhysicsBody CreateBodyCircle(Vector2 pos, float radius, float density) {
|
||||
return ::CreatePhysicsBodyCircle(pos, radius, density);
|
||||
}
|
||||
|
||||
inline PhysicsBody CreateBodyRectangle(Vector2 pos, float width, float height, float density) {
|
||||
return ::CreatePhysicsBodyRectangle(pos, width, height, density);
|
||||
}
|
||||
|
||||
inline PhysicsBody CreateBodyPolygon(Vector2 pos, float radius, int sides, float density) {
|
||||
return ::CreatePhysicsBodyPolygon(pos, radius, sides, density);
|
||||
}
|
||||
|
||||
inline Physics& AddForce(PhysicsBody body, Vector2 force) {
|
||||
::PhysicsAddForce(body, force);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& AddTorque(PhysicsBody body, float amount) {
|
||||
::PhysicsAddTorque(body, amount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& Shatter(PhysicsBody body, Vector2 position, float force) {
|
||||
::PhysicsShatter(body, position, force);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetBodiesCount() const {
|
||||
return ::GetPhysicsBodiesCount();
|
||||
}
|
||||
|
||||
inline PhysicsBody GetBody(int index) const {
|
||||
return ::GetPhysicsBody(index);
|
||||
}
|
||||
|
||||
inline int GetShapeType(int index) const {
|
||||
return ::GetPhysicsShapeType(index);
|
||||
}
|
||||
|
||||
inline int GetShapeVerticesCount(int index) const {
|
||||
return ::GetPhysicsShapeVerticesCount(index);
|
||||
}
|
||||
|
||||
inline Vector2 GetShapeVertex(PhysicsBody body, int vertex) const {
|
||||
return ::GetPhysicsShapeVertex(body, vertex);
|
||||
}
|
||||
|
||||
inline Physics& SetBodyRotation(PhysicsBody body, float radians) {
|
||||
::SetPhysicsBodyRotation(body, radians);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& DestroyBody(PhysicsBody body) {
|
||||
::DestroyPhysicsBody(body);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Physics& Reset() {
|
||||
::ResetPhysics();
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_PHYSICS_HPP_
|
101
include/Ray.hpp
Normal file
101
include/Ray.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAY_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAY_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
#include "./RayHitInfo.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Ray : public ::Ray {
|
||||
public:
|
||||
Ray(::Ray ray) {
|
||||
set(ray);
|
||||
}
|
||||
|
||||
Ray(::Vector3 Position, ::Vector3 Direction) {
|
||||
position = Position;
|
||||
direction = Direction;
|
||||
}
|
||||
|
||||
Ray(::Vector2 mousePosition, ::Camera camera) {
|
||||
set(GetMouseRay(mousePosition, camera));
|
||||
}
|
||||
|
||||
Ray& operator=(const ::Ray& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Ray& operator=(const Ray& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(::Vector3, Position, position)
|
||||
GETTERSETTER(::Vector3, Direction, direction)
|
||||
|
||||
inline Ray& Draw(::Color color) {
|
||||
DrawRay(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollisionSphere(::Vector3 center, float radius) const {
|
||||
return CheckCollisionRaySphere(*this, center, radius);
|
||||
}
|
||||
|
||||
inline bool CheckCollisionSphereEx(::Vector3 center, float radius,
|
||||
::Vector3 *collisionPoint) const {
|
||||
return CheckCollisionRaySphereEx(*this, center, radius, collisionPoint);
|
||||
}
|
||||
|
||||
inline bool CheckCollisionBox(::BoundingBox box) const {
|
||||
return CheckCollisionRayBox(*this, box);
|
||||
}
|
||||
|
||||
inline RayHitInfo GetCollisionModel(::Model model) {
|
||||
return GetCollisionRayModel(*this, model);
|
||||
}
|
||||
|
||||
inline RayHitInfo GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
|
||||
return GetCollisionRayTriangle(*this, p1, p2, p3);
|
||||
}
|
||||
|
||||
inline RayHitInfo GetCollisionGround(float groundHeight) {
|
||||
return GetCollisionRayGround(*this, groundHeight);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Ray ray) {
|
||||
position = ray.position;
|
||||
direction = ray.direction;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAY_HPP_
|
70
include/RayHitInfo.hpp
Normal file
70
include/RayHitInfo.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class RayHitInfo : public ::RayHitInfo {
|
||||
public:
|
||||
RayHitInfo(::RayHitInfo ray) {
|
||||
set(ray);
|
||||
}
|
||||
|
||||
RayHitInfo(bool Hit, float Distance, ::Vector3 Position, ::Vector3 Normal) {
|
||||
hit = Hit;
|
||||
distance = Distance;
|
||||
position = Position;
|
||||
normal = Normal;
|
||||
}
|
||||
|
||||
RayHitInfo& operator=(const ::RayHitInfo& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RayHitInfo& operator=(const RayHitInfo& ray) {
|
||||
set(ray);
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_
|
131
include/Rectangle.hpp
Normal file
131
include/Rectangle.hpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Rectangle : public ::Rectangle {
|
||||
public:
|
||||
Rectangle(::Rectangle vec) {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Rectangle(float X = 0, float Y = 0, float Width = 0, float Height = 0) {
|
||||
x = X;
|
||||
y = Y;
|
||||
width = Width;
|
||||
height = Height;
|
||||
}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Width, width)
|
||||
GETTERSETTER(float, Height, height)
|
||||
|
||||
Rectangle& operator=(const ::Rectangle& rect) {
|
||||
set(rect);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rectangle& operator=(const Rectangle& rect) {
|
||||
set(rect);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline Rectangle& DrawGradientV(::Color color1, ::Color color2) {
|
||||
::DrawRectangleGradientV(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width),
|
||||
static_cast<int>(height), color1, color2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 Rectangle& DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) {
|
||||
::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 Rectangle& DrawLinesEx(int lineThick, ::Color color) {
|
||||
::DrawRectangleLinesEx(*this, lineThick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Rectangle& DrawRounded(float roundness, int segments, ::Color color) {
|
||||
::DrawRectangleRounded(*this, roundness, segments, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Rectangle& DrawRoundedLines(float roundness, int segments, int lineThick,
|
||||
::Color color) {
|
||||
::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::Rectangle rec2) const {
|
||||
return ::CheckCollisionRecs(*this, rec2);
|
||||
}
|
||||
|
||||
inline Rectangle GetCollision(::Rectangle rec2) const {
|
||||
return ::GetCollisionRec(*this, rec2);
|
||||
}
|
||||
|
||||
inline bool CheckCollision(::Vector2 point) const {
|
||||
return ::CheckCollisionPointRec(point, *this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Rectangle rect) {
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
88
include/RenderTexture.hpp
Normal file
88
include/RenderTexture.hpp
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class RenderTexture : public ::RenderTexture {
|
||||
public:
|
||||
RenderTexture(::RenderTexture renderTexture) {
|
||||
set(renderTexture);
|
||||
}
|
||||
|
||||
RenderTexture(unsigned int Id) {
|
||||
id = Id;
|
||||
}
|
||||
|
||||
RenderTexture(int width, int height) {
|
||||
set(LoadRenderTexture(width, height));
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, Id, id)
|
||||
GETTERSETTER(::Texture2D, Texture, texture)
|
||||
GETTERSETTER(::Texture2D, Depth, depth)
|
||||
|
||||
RenderTexture& operator=(const ::RenderTexture& texture) {
|
||||
set(texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderTexture& operator=(const RenderTexture& texture) {
|
||||
set(texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~RenderTexture() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
UnloadRenderTexture(*this);
|
||||
}
|
||||
|
||||
inline RenderTexture& BeginTextureMode() {
|
||||
::BeginTextureMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RenderTexture& EndTextureMode() {
|
||||
::EndTextureMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::RenderTexture renderTexture) {
|
||||
id = renderTexture.id;
|
||||
texture = renderTexture.texture;
|
||||
depth = renderTexture.depth;
|
||||
}
|
||||
};
|
||||
typedef RenderTexture RenderTexture2D;
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
150
include/Shader.hpp
Normal file
150
include/Shader.hpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "Texture.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Shader : public ::Shader {
|
||||
public:
|
||||
Shader(::Shader shader) {
|
||||
set(shader);
|
||||
}
|
||||
|
||||
Shader(unsigned int Id, int* Locs) {
|
||||
id = Id;
|
||||
locs = Locs;
|
||||
}
|
||||
|
||||
Shader() {
|
||||
set(GetShaderDefault());
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, Id, id)
|
||||
GETTERSETTER(int*, Locs, locs)
|
||||
|
||||
Shader& operator=(const ::Shader& shader) {
|
||||
set(shader);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Shader& operator=(const Shader& shader) {
|
||||
set(shader);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Shader() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
::UnloadShader(*this);
|
||||
}
|
||||
|
||||
static Shader Load(const std::string& vsFileName, const std::string& fsFileName) {
|
||||
return ::LoadShader(vsFileName.c_str(), fsFileName.c_str());
|
||||
}
|
||||
|
||||
static Shader LoadCode(const std::string& vsCode, const std::string& fsCode) {
|
||||
return ::LoadShaderCode(vsCode.c_str(), fsCode.c_str());
|
||||
}
|
||||
|
||||
inline Shader& BeginShaderMode() {
|
||||
::BeginShaderMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Shader& EndShaderMode() {
|
||||
::EndShaderMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetLocation(const std::string& uniformName) const {
|
||||
return ::GetShaderLocation(*this, uniformName.c_str());
|
||||
}
|
||||
|
||||
inline int GetLocationAttrib(const std::string& attribName) const {
|
||||
return ::GetShaderLocationAttrib(*this, attribName.c_str());
|
||||
}
|
||||
|
||||
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType) {
|
||||
::SetShaderValue(*this, uniformLoc, value.c_str(), uniformType);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SetShaderValueV
|
||||
*/
|
||||
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType, int count) {
|
||||
::SetShaderValueV(*this, uniformLoc, value.c_str(), uniformType, count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ::SetShaderValueMatrix
|
||||
*/
|
||||
inline Shader& SetValue(int uniformLoc, Matrix mat) {
|
||||
::SetShaderValueMatrix(*this, uniformLoc, mat);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ::SetShaderValueTexture
|
||||
*/
|
||||
inline Shader& SetValue(int uniformLoc, Texture2D texture) {
|
||||
::SetShaderValueTexture(*this, uniformLoc, texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
::TextureCubemap GenTextureCubemap(Texture2D panorama, int size, int format) {
|
||||
return ::GenTextureCubemap(*this, panorama, size, format);
|
||||
}
|
||||
|
||||
::TextureCubemap GenTextureIrradiance(Texture2D panorama, int size) {
|
||||
return ::GenTextureIrradiance(*this, panorama, size);
|
||||
}
|
||||
|
||||
::TextureCubemap GenTexturePrefilter(Texture2D panorama, int size) {
|
||||
return ::GenTexturePrefilter(*this, panorama, size);
|
||||
}
|
||||
|
||||
::Texture2D GenTextureBRDF(int size) {
|
||||
return ::GenTextureBRDF(*this, size);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Shader shader) {
|
||||
id = shader.id;
|
||||
locs = shader.locs;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
125
include/Sound.hpp
Normal file
125
include/Sound.hpp
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Sound : public ::Sound {
|
||||
public:
|
||||
Sound(::Sound vec) {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Sound(const std::string& fileName) {
|
||||
set(LoadSound(fileName.c_str()));
|
||||
}
|
||||
|
||||
Sound(::Wave wave) {
|
||||
set(LoadSoundFromWave(wave));
|
||||
}
|
||||
|
||||
~Sound() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, SampleCount, sampleCount)
|
||||
GETTERSETTER(::AudioStream, Stream, stream)
|
||||
|
||||
Sound& operator=(const ::Sound& sound) {
|
||||
set(sound);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Sound& operator=(const Sound& sound) {
|
||||
set(sound);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& Update(const void *data, int sampleCount) {
|
||||
::UpdateSound(*this, data, sampleCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadSound(*this);
|
||||
}
|
||||
|
||||
inline Sound& Play() {
|
||||
::PlaySound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& Stop() {
|
||||
::StopSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& Pause() {
|
||||
::PauseSound(*this);
|
||||
return *this;
|
||||
}
|
||||
inline Sound& Resume() {
|
||||
::ResumeSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& PlayMulti() {
|
||||
::PlaySoundMulti(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& StopMulti() {
|
||||
::StopSoundMulti();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool IsPlaying() const {
|
||||
return ::IsSoundPlaying(*this);
|
||||
}
|
||||
|
||||
inline Sound& SetVolume(float volume) {
|
||||
::SetSoundVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Sound& SetPitch(float pitch) {
|
||||
::SetSoundPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Sound sound) {
|
||||
sampleCount = sound.sampleCount;
|
||||
stream = sound.stream;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
194
include/Texture.hpp
Normal file
194
include/Texture.hpp
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./Material.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Texture : public ::Texture {
|
||||
public:
|
||||
Texture() {
|
||||
set(::GetTextureDefault());
|
||||
}
|
||||
|
||||
Texture(const ::Image& image) {
|
||||
LoadFromImage(image);
|
||||
}
|
||||
|
||||
Texture(const std::string& fileName) {
|
||||
Load(fileName);
|
||||
}
|
||||
|
||||
~Texture() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, Id, id)
|
||||
GETTERSETTER(int, Width, width)
|
||||
GETTERSETTER(int, Height, height)
|
||||
GETTERSETTER(int, Mipmaps, mipmaps)
|
||||
GETTERSETTER(int, Format, format)
|
||||
|
||||
Texture& operator=(const ::Texture& texture) {
|
||||
set(texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Texture& operator=(const Texture& texture) {
|
||||
set(texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void LoadFromImage(const ::Image& image) {
|
||||
set(::LoadTextureFromImage(image));
|
||||
}
|
||||
|
||||
void LoadTextureCubemap(const ::Image& image, int layoutType) {
|
||||
set(::LoadTextureCubemap(image, layoutType));
|
||||
}
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadTexture(fileName.c_str()));
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
::UnloadTexture(*this);
|
||||
}
|
||||
|
||||
inline Texture& Update(const void *pixels) {
|
||||
::UpdateTexture(*this, pixels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& UpdateRec(Rectangle rec, const void *pixels) {
|
||||
UpdateTextureRec(*this, rec, pixels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image GetTextureData() const {
|
||||
return ::GetTextureData(*this);
|
||||
}
|
||||
|
||||
inline operator raylib::Image() {
|
||||
return GetTextureData();
|
||||
}
|
||||
|
||||
inline Texture& GenMipmaps() {
|
||||
::GenTextureMipmaps(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& SetFilter(int filterMode) {
|
||||
::SetTextureFilter(*this, filterMode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& SetWrap(int wrapMode) {
|
||||
::SetTextureWrap(*this, wrapMode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(int posX, int posY, ::Color tint = WHITE) {
|
||||
::DrawTexture(*this, posX, posY, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Vector2 position, ::Color tint = WHITE) {
|
||||
::DrawTextureV(*this, position, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Vector2 position, float rotation, float scale = 1.0f,
|
||||
::Color tint = WHITE) {
|
||||
::DrawTextureEx(*this, position, rotation, scale, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Rectangle sourceRec, ::Vector2 position, ::Color tint = WHITE) {
|
||||
::DrawTextureRec(*this, sourceRec, position, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad,
|
||||
::Color tint = WHITE) {
|
||||
::DrawTextureQuad(*this, tiling, offset, quad, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin,
|
||||
float rotation = 0, ::Color tint = WHITE) {
|
||||
::DrawTexturePro(*this, sourceRec, destRec, origin, rotation, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin,
|
||||
float rotation = 0, ::Color tint = WHITE) {
|
||||
::DrawTextureNPatch(*this, nPatchInfo, destRec, origin, rotation, tint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Texture& Draw(::Vector3 position, float width, float height, float length,
|
||||
::Color color = WHITE) {
|
||||
::DrawCubeTexture(*this, position, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline Texture& SetMaterialTexture(Material *material, int mapType) {
|
||||
::SetMaterialTexture(material, mapType, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
static int GetPixelDataSize(int width, int height, int format) {
|
||||
return ::GetPixelDataSize(width, height, format);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Texture texture) {
|
||||
id = texture.id;
|
||||
width = texture.width;
|
||||
height = texture.height;
|
||||
mipmaps = texture.mipmaps;
|
||||
format = texture.format;
|
||||
}
|
||||
};
|
||||
|
||||
// Create the Texture aliases.
|
||||
typedef Texture Texture2D;
|
||||
typedef Texture TextureCubemap;
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
251
include/Vector2.hpp
Normal file
251
include/Vector2.hpp
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Vector2 : public ::Vector2 {
|
||||
public:
|
||||
Vector2(::Vector2 vec) {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Vector2(float x, float y) : ::Vector2{x, y} {};
|
||||
Vector2(float x) : ::Vector2{x, 0} {};
|
||||
Vector2() : ::Vector2{0, 0} {};
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
|
||||
Vector2& operator=(const ::Vector2& vector2) {
|
||||
set(vector2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator=(const Vector2& vector2) {
|
||||
set(vector2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Vector2& other) {
|
||||
return x == other.x
|
||||
&& y == other.y;
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
Vector2 Add(const Vector2& vector2) {
|
||||
return Vector2Add(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 operator+(const Vector2& vector2) {
|
||||
return Vector2Add(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 Subtract(const Vector2& vector2) {
|
||||
return Vector2Subtract(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 operator-(const Vector2& vector2) {
|
||||
return Vector2Subtract(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 Negate() {
|
||||
return Vector2Negate(*this);
|
||||
}
|
||||
|
||||
Vector2 operator-() {
|
||||
return Vector2Negate(*this);
|
||||
}
|
||||
|
||||
Vector2 Multiply(const Vector2& vector2) {
|
||||
return Vector2Multiply(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 operator*(const Vector2& vector2) {
|
||||
return Vector2Multiply(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 Scale(const float scale) {
|
||||
return Vector2Scale(*this, scale);
|
||||
}
|
||||
|
||||
Vector2 operator*(const float scale) {
|
||||
return Vector2Scale(*this, scale);
|
||||
}
|
||||
|
||||
Vector2 Divide(const Vector2& vector2) {
|
||||
return Vector2Divide(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 operator/(const Vector2& vector2) {
|
||||
return Vector2Divide(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2& Divide(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator/(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator+=(const Vector2& vector2) {
|
||||
set(Vector2Add(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator-=(const Vector2& vector2) {
|
||||
set(Vector2Subtract(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Vector2& operator*=(const Vector2& vector2) {
|
||||
set(Vector2Multiply(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator*=(const float scale) {
|
||||
set(Vector2Scale(*this, scale));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator/=(const Vector2& vector2) {
|
||||
set(Vector2Divide(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2& operator/=(const float div) {
|
||||
this->x /= div;
|
||||
this->y /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
float Length() const {
|
||||
return Vector2Length(*this);
|
||||
}
|
||||
|
||||
Vector2 Normalize() {
|
||||
return Vector2Normalize(*this);
|
||||
}
|
||||
|
||||
float DotProduct(const Vector2& vector2) {
|
||||
return Vector2DotProduct(*this, vector2);
|
||||
}
|
||||
|
||||
float Angle(const Vector2& vector2) {
|
||||
return Vector2Angle(*this, vector2);
|
||||
}
|
||||
|
||||
float Distance(const Vector2& vector2) {
|
||||
return Vector2Distance(*this, vector2);
|
||||
}
|
||||
|
||||
Vector2 Lerp(const Vector2& vector2, const float amount) {
|
||||
return Vector2Lerp(*this, vector2, amount);
|
||||
}
|
||||
|
||||
Vector2 Reflect(const Vector2& normal) {
|
||||
return Vector2Reflect(*this, normal);
|
||||
}
|
||||
|
||||
Vector2 Rotate(float degrees) {
|
||||
return Vector2Rotate(*this, degrees);
|
||||
}
|
||||
|
||||
static Vector2 Zero() {
|
||||
return Vector2Zero();
|
||||
}
|
||||
|
||||
static Vector2 One() {
|
||||
return Vector2One();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline Vector2& DrawPixel(::Color color) {
|
||||
::DrawPixelV(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawLine(::Vector2 endPos, ::Color color) {
|
||||
::DrawLineV(*this, endPos, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawLine(::Vector2 endPos, float thick, ::Color color) {
|
||||
::DrawLineEx(*this, endPos, thick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawLineBezier(::Vector2 endPos, float thick, ::Color color) {
|
||||
::DrawLineBezier(*this, endPos, thick, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawCircle(float radius, ::Color color) {
|
||||
::DrawCircleV(*this, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawRectangle(::Vector2 size, ::Color color) {
|
||||
::DrawRectangleV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2& DrawPoly(int sides, float radius, float rotation, ::Color color) {
|
||||
::DrawPoly(*this, sides, radius, rotation, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Vector2 vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
329
include/Vector3.hpp
Normal file
329
include/Vector3.hpp
Normal file
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Vector3 : public ::Vector3 {
|
||||
public:
|
||||
Vector3(::Vector3 vec) {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Vector3(float x, float y, float z) : ::Vector3{x, y, z} {};
|
||||
Vector3(float x, float y) : ::Vector3{x, y, 0} {};
|
||||
Vector3(float x) : ::Vector3{x, 0, 0} {};
|
||||
Vector3() {};
|
||||
|
||||
Vector3(::Color color) {
|
||||
set(ColorToHSV(color));
|
||||
}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Z, z)
|
||||
|
||||
Vector3& operator=(const ::Vector3& vector3) {
|
||||
set(vector3);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const ::Vector3& other) {
|
||||
return x == other.x
|
||||
&& y == other.y
|
||||
&& z == other.z;
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
Vector3 Add(const Vector3& vector3) {
|
||||
return Vector3Add(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 operator+(const Vector3& vector3) {
|
||||
return Vector3Add(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Subtract(const Vector3& vector3) {
|
||||
return Vector3Subtract(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 operator-(const Vector3& vector3) {
|
||||
return Vector3Subtract(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Negate() {
|
||||
return Vector3Negate(*this);
|
||||
}
|
||||
|
||||
Vector3 operator-() {
|
||||
return Vector3Negate(*this);
|
||||
}
|
||||
|
||||
Vector3 Multiply(const Vector3& vector3) {
|
||||
return Vector3Multiply(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 operator*(const Vector3& vector3) {
|
||||
return Vector3Multiply(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Scale(const float scale) {
|
||||
return Vector3Scale(*this, scale);
|
||||
}
|
||||
|
||||
Vector3 operator*(const float scale) {
|
||||
return Vector3Scale(*this, scale);
|
||||
}
|
||||
|
||||
Vector3 Divide(const Vector3& vector3) {
|
||||
return Vector3Divide(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 operator/(const Vector3& vector3) {
|
||||
return Vector3Divide(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3& Divide(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
z /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3 operator/(const float div) {
|
||||
return Divide(div);
|
||||
}
|
||||
|
||||
Vector3& operator+=(const Vector3& vector3) {
|
||||
set(Vector3Add(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3& operator-=(const Vector3& vector3) {
|
||||
set(Vector3Subtract(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Vector3& operator*=(const Vector3& vector3) {
|
||||
set(Vector3Multiply(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3& operator*=(const float scale) {
|
||||
set(Vector3Scale(*this, scale));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3& operator/=(const Vector3& vector3) {
|
||||
x /= vector3.x;
|
||||
y /= vector3.y;
|
||||
z /= vector3.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3& operator/=(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
z /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
float Length() const {
|
||||
return Vector3Length(*this);
|
||||
}
|
||||
|
||||
Vector3 Normalize() {
|
||||
return Vector3Normalize(*this);
|
||||
}
|
||||
|
||||
float DotProduct(const Vector3& vector3) {
|
||||
return Vector3DotProduct(*this, vector3);
|
||||
}
|
||||
|
||||
float Distance(const Vector3& vector3) {
|
||||
return Vector3Distance(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Lerp(const Vector3& vector3, const float amount) {
|
||||
return Vector3Lerp(*this, vector3, amount);
|
||||
}
|
||||
|
||||
Vector3 CrossProduct(const Vector3& vector3) {
|
||||
return Vector3CrossProduct(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Perpendicular() {
|
||||
return Vector3Perpendicular(*this);
|
||||
}
|
||||
|
||||
void OrthoNormalize(Vector3* vector3) {
|
||||
return Vector3OrthoNormalize(this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Transform(const ::Matrix& matrix) {
|
||||
return Vector3Transform(*this, matrix);
|
||||
}
|
||||
|
||||
Vector3 RotateByQuaternion(Quaternion quaternion) {
|
||||
return Vector3RotateByQuaternion(*this, quaternion);
|
||||
}
|
||||
|
||||
Vector3 Reflect(const Vector3& normal) {
|
||||
return Vector3Reflect(*this, normal);
|
||||
}
|
||||
|
||||
Vector3 Min(const Vector3& vector3) {
|
||||
return Vector3Min(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Max(const Vector3& vector3) {
|
||||
return Vector3Max(*this, vector3);
|
||||
}
|
||||
|
||||
Vector3 Barycenter(const Vector3& a, const Vector3& b, const Vector3& c) {
|
||||
return Vector3Barycenter(*this, a, b, c);
|
||||
}
|
||||
|
||||
static Vector3 Zero() {
|
||||
return Vector3Zero();
|
||||
}
|
||||
|
||||
static Vector3 One() {
|
||||
return Vector3One();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline Vector3& DrawLine3D(::Vector3 endPos, ::Color color) {
|
||||
::DrawLine3D(*this, endPos, color);
|
||||
return *this;
|
||||
}
|
||||
inline Vector3& DrawPoint3D(::Color color) {
|
||||
::DrawPoint3D(*this, color);
|
||||
return *this;
|
||||
}
|
||||
inline Vector3& DrawCircle3D(
|
||||
float radius,
|
||||
Vector3 rotationAxis,
|
||||
float rotationAngle,
|
||||
Color color) {
|
||||
::DrawCircle3D(*this, radius, rotationAxis, rotationAngle, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawCube(float width, float height, float length, ::Color color) {
|
||||
::DrawCube(*this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
inline Vector3& DrawCube(::Vector3 size, ::Color color) {
|
||||
::DrawCubeV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawCubeWires(float width, float height, float length, ::Color color) {
|
||||
::DrawCubeWires(*this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
inline Vector3& DrawCubeWires(::Vector3 size, ::Color color) {
|
||||
::DrawCubeWiresV(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawCubeTexture(
|
||||
::Texture2D texture,
|
||||
float width,
|
||||
float height,
|
||||
float length,
|
||||
::Color color) {
|
||||
::DrawCubeTexture(texture, *this, width, height, length, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawSphere(float radius, Color color) {
|
||||
::DrawSphere(*this, radius, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawSphere(float radius, int rings, int slices, Color color) {
|
||||
::DrawSphereEx(*this, radius, rings, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawSphereWires(float radius, int rings, int slices, Color color) {
|
||||
::DrawSphereWires(*this, radius, rings, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawCylinder(float radiusTop, float radiusBottom, float height,
|
||||
int slices, Color color) {
|
||||
::DrawCylinder(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawCylinderWires(float radiusTop, float radiusBottom, float height,
|
||||
int slices, Color color) {
|
||||
::DrawCylinderWires(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawPlane(::Vector2 size, ::Color color) {
|
||||
::DrawPlane(*this, size, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector3& DrawGizmo() {
|
||||
::DrawGizmo(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
182
include/Vector4.hpp
Normal file
182
include/Vector4.hpp
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Vector4 : public ::Vector4 {
|
||||
public:
|
||||
Vector4(::Vector4 vec) {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Vector4(float x, float y, float z, float w) : ::Vector4{x, y, z, w} {};
|
||||
Vector4(float x, float y, float z) : ::Vector4{x, y, z, 0} {};
|
||||
Vector4(float x, float y) : ::Vector4{x, y, 0, 0} {};
|
||||
Vector4(float x) : ::Vector4{x, 0, 0, 0} {};
|
||||
Vector4() {};
|
||||
|
||||
Vector4(::Color color) {
|
||||
set(ColorNormalize(color));
|
||||
}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Z, z)
|
||||
GETTERSETTER(float, W, w)
|
||||
|
||||
Vector4& operator=(const ::Vector4& vector4) {
|
||||
set(vector4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector4& operator=(const Vector4& vector4) {
|
||||
set(vector4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Vector4& other) {
|
||||
return x == other.x
|
||||
&& y == other.y
|
||||
&& z == other.z
|
||||
&& w == other.w;
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
Vector4 Multiply(const Vector4& vector4) {
|
||||
return QuaternionMultiply(*this, vector4);
|
||||
}
|
||||
|
||||
Vector4 operator*(const Vector4& vector4) {
|
||||
return QuaternionMultiply(*this, vector4);
|
||||
}
|
||||
|
||||
Vector4 Lerp(const Vector4& vector4, float amount) {
|
||||
return QuaternionLerp(*this, vector4, amount);
|
||||
}
|
||||
|
||||
Vector4 Nlerp(const Vector4& vector4, float amount) {
|
||||
return QuaternionNlerp(*this, vector4, amount);
|
||||
}
|
||||
|
||||
Vector4 Slerp(const Vector4& vector4, float amount) {
|
||||
return QuaternionSlerp(*this, vector4, amount);
|
||||
}
|
||||
|
||||
Matrix ToMatrix() {
|
||||
return QuaternionToMatrix(*this);
|
||||
}
|
||||
|
||||
float Length() const {
|
||||
return QuaternionLength(*this);
|
||||
}
|
||||
|
||||
Vector4 Normalize() {
|
||||
return QuaternionNormalize(*this);
|
||||
}
|
||||
|
||||
Vector4 Invert() {
|
||||
return QuaternionInvert(*this);
|
||||
}
|
||||
|
||||
void ToAxisAngle(Vector3 *outAxis, float *outAngle) {
|
||||
return QuaternionToAxisAngle(*this, outAxis, outAngle);
|
||||
}
|
||||
|
||||
std::pair<Vector3, float> ToAxisAngle() {
|
||||
Vector3 outAxis;
|
||||
float outAngle;
|
||||
|
||||
QuaternionToAxisAngle(*this, &outAxis, &outAngle);
|
||||
|
||||
std::pair<Vector3, float> out(outAxis, outAngle);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Vector4 Transform(const ::Matrix& matrix) {
|
||||
return ::QuaternionTransform(*this, matrix);
|
||||
}
|
||||
|
||||
static Vector4 Identity() {
|
||||
return ::QuaternionIdentity();
|
||||
}
|
||||
|
||||
static Vector4 FromVector3ToVector3(const Vector3& from , const Vector3& to) {
|
||||
return ::QuaternionFromVector3ToVector3(from , to);
|
||||
}
|
||||
|
||||
static Vector4 FromMatrix(const ::Matrix& matrix) {
|
||||
return ::QuaternionFromMatrix(matrix);
|
||||
}
|
||||
|
||||
static Vector4 FromAxisAngle(const Vector3& axis, const float angle) {
|
||||
return ::QuaternionFromAxisAngle(axis, angle);
|
||||
}
|
||||
|
||||
static Vector4 FromEuler(const float roll, const float pitch, const float yaw) {
|
||||
return ::QuaternionFromEuler(roll, pitch, yaw);
|
||||
}
|
||||
|
||||
static Vector4 FromEuler(const Vector3& vector3) {
|
||||
return ::QuaternionFromEuler(vector3.x, vector3.y, vector3.z);
|
||||
}
|
||||
|
||||
Vector3 ToEuler() {
|
||||
return ::QuaternionToEuler(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline Color ColorFromNormalized() {
|
||||
return ::ColorFromNormalized(*this);
|
||||
}
|
||||
|
||||
operator Color() {
|
||||
return ColorFromNormalized();
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Vector4 vec4) {
|
||||
x = vec4.x;
|
||||
y = vec4.y;
|
||||
z = vec4.z;
|
||||
w = vec4.w;
|
||||
}
|
||||
};
|
||||
|
||||
// Alias the Vector4 as Quaternion.
|
||||
typedef Vector4 Quaternion;
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
85
include/VrSimulator.hpp
Normal file
85
include/VrSimulator.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VRSIMULATOR_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VRSIMULATOR_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class VrSimulator {
|
||||
public:
|
||||
VrSimulator() {
|
||||
Init();
|
||||
}
|
||||
|
||||
VrSimulator(::VrDeviceInfo info, ::Shader distortion) {
|
||||
Init();
|
||||
Set(info, distortion);
|
||||
}
|
||||
|
||||
inline void Init() {
|
||||
InitVrSimulator();
|
||||
}
|
||||
|
||||
~VrSimulator() {
|
||||
Close();
|
||||
}
|
||||
|
||||
inline bool IsReady() const {
|
||||
return ::IsVrSimulatorReady();
|
||||
}
|
||||
|
||||
inline VrSimulator& Update(Camera *camera) {
|
||||
::UpdateVrTracking(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VrSimulator& Set(::VrDeviceInfo info, ::Shader distortion) {
|
||||
::SetVrConfiguration(info, distortion);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VrSimulator& Toggle() {
|
||||
::ToggleVrMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VrSimulator& Begin() {
|
||||
::BeginVrDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline VrSimulator& End() {
|
||||
::EndVrDrawing();
|
||||
return *this;
|
||||
}
|
||||
inline void Close() {
|
||||
::CloseVrSimulator();
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VRSIMULATOR_HPP_
|
133
include/Wave.hpp
Normal file
133
include/Wave.hpp
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Wave : public ::Wave {
|
||||
public:
|
||||
Wave(::Wave wave) {
|
||||
set(wave);
|
||||
}
|
||||
|
||||
Wave(
|
||||
unsigned int SampleCount = 0,
|
||||
unsigned int SampleRate = 0,
|
||||
unsigned int SampleSize = 0,
|
||||
unsigned int Channels = 0) {
|
||||
sampleCount = SampleCount;
|
||||
sampleRate = SampleRate;
|
||||
sampleSize = SampleSize;
|
||||
channels = Channels;
|
||||
}
|
||||
|
||||
Wave(const std::string& fileName) {
|
||||
set(LoadWave(fileName.c_str()));
|
||||
}
|
||||
|
||||
Wave(const std::string& fileType, const unsigned char *fileData, int dataSize) {
|
||||
set(LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
}
|
||||
|
||||
~Wave() {
|
||||
Unload();
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, SampleCount, sampleCount)
|
||||
GETTERSETTER(unsigned int, SampleRate, sampleRate)
|
||||
GETTERSETTER(unsigned int, SampleSize, sampleSize)
|
||||
GETTERSETTER(unsigned int, Channels, channels)
|
||||
GETTERSETTER(void *, Data, data)
|
||||
|
||||
Wave& operator=(const ::Wave& wave) {
|
||||
set(wave);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Wave& operator=(const Wave& wave) {
|
||||
set(wave);
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
inline Wave& ExportAsCode(const std::string& fileName) {
|
||||
::ExportWaveAsCode(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
if (data != NULL) {
|
||||
::UnloadWave(*this);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline Sound LoadSound() {
|
||||
return ::LoadSoundFromWave(*this);
|
||||
}
|
||||
|
||||
inline operator Sound() {
|
||||
return LoadSound();
|
||||
}
|
||||
|
||||
inline float* GetData() {
|
||||
return ::GetWaveData(*this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Wave wave) {
|
||||
sampleCount = wave.sampleCount;
|
||||
sampleRate = wave.sampleRate;
|
||||
sampleSize = wave.sampleSize;
|
||||
channels = wave.channels;
|
||||
data = wave.data;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
216
include/Window.hpp
Normal file
216
include/Window.hpp
Normal file
@ -0,0 +1,216 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Window and Graphics Device Functions.
|
||||
*
|
||||
* @code
|
||||
*
|
||||
* raylib::Window w(640, 480, "raylib-cpp");
|
||||
* while (!w.ShouldClose()) {
|
||||
* // Update
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
class Window {
|
||||
public:
|
||||
/**
|
||||
* Initialize window and OpenGL context.
|
||||
*/
|
||||
Window(int width = 800, int height = 450, const std::string& title = "raylib",
|
||||
bool lateInit = false) {
|
||||
if (!lateInit) {
|
||||
Init(width, height, title);
|
||||
}
|
||||
}
|
||||
|
||||
~Window() {
|
||||
Close();
|
||||
}
|
||||
|
||||
void Init(int width, int height, const std::string& title) {
|
||||
::InitWindow(width, height, title.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
*/
|
||||
inline bool ShouldClose() {
|
||||
return ::WindowShouldClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close window and unload OpenGL context
|
||||
*/
|
||||
inline void Close() {
|
||||
::CloseWindow();
|
||||
}
|
||||
|
||||
inline bool IsCursorOnScreen() {
|
||||
return ::IsCursorOnScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if window has been initialized successfully
|
||||
*/
|
||||
inline static bool IsReady() {
|
||||
return ::IsWindowReady();
|
||||
}
|
||||
|
||||
inline bool IsMinimized() const {
|
||||
return ::IsWindowMinimized();
|
||||
}
|
||||
|
||||
inline bool IsFocused() const {
|
||||
return ::IsWindowFocused();
|
||||
}
|
||||
|
||||
inline bool IsResized() const {
|
||||
return ::IsWindowResized();
|
||||
}
|
||||
|
||||
inline bool IsHidden() const {
|
||||
return ::IsWindowHidden();
|
||||
}
|
||||
|
||||
inline bool IsFullscreen() const {
|
||||
return ::IsWindowFullscreen();
|
||||
}
|
||||
|
||||
inline Window& ToggleFullscreen() {
|
||||
::ToggleFullscreen();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& Unhide() {
|
||||
::UnhideWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& Hide() {
|
||||
::HideWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetIcon(Image image) {
|
||||
::SetWindowIcon(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetTitle(const std::string& title) {
|
||||
::SetWindowTitle(title.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetPosition(int x, int y) {
|
||||
::SetWindowPosition(x, y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetMonitor(int monitor) {
|
||||
::SetWindowMonitor(monitor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetMinSize(int width, int height) {
|
||||
::SetWindowMinSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetSize(int width, int height) {
|
||||
::SetWindowSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void* GetHandle() const {
|
||||
return ::GetWindowHandle();
|
||||
}
|
||||
|
||||
inline Window& BeginDrawing() {
|
||||
::BeginDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& EndDrawing() {
|
||||
::EndDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetScreenWidth() const {
|
||||
return ::GetScreenWidth();
|
||||
}
|
||||
|
||||
inline int GetScreenHeight() const {
|
||||
return ::GetScreenHeight();
|
||||
}
|
||||
|
||||
inline Vector2 GetPosition() const {
|
||||
return ::GetWindowPosition();
|
||||
}
|
||||
|
||||
inline Vector2 GetScaleDPI() const {
|
||||
return ::GetWindowScaleDPI();
|
||||
}
|
||||
|
||||
std::string GetMonitorName(int monitor) const {
|
||||
return std::string(::GetMonitorName(monitor));
|
||||
}
|
||||
|
||||
std::string GetClipboardText() const {
|
||||
return std::string(::GetClipboardText());
|
||||
}
|
||||
|
||||
inline Window& SetClipboardText(const std::string& text) {
|
||||
::SetClipboardText(text.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Window& SetTargetFPS(int fps) {
|
||||
::SetTargetFPS(fps);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline int GetFPS() const {
|
||||
return ::GetFPS();
|
||||
}
|
||||
|
||||
inline float GetFrameTime() const {
|
||||
return ::GetFrameTime();
|
||||
}
|
||||
|
||||
inline double GetTime() const {
|
||||
return ::GetTime();
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
41
include/raylib-cpp-utils.hpp
Normal file
41
include/raylib-cpp-utils.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
||||
|
||||
#ifndef GETTERSETTER
|
||||
/**
|
||||
* A utility to build get and set methods on top of a property.
|
||||
*
|
||||
* @param type The type of the property.
|
||||
* @param method The human-readable name for the method.
|
||||
* @param name The machine-readable name of the property.
|
||||
*/
|
||||
#define GETTERSETTER(type, method, name) \
|
||||
inline type Get##method() const { return name; } \
|
||||
inline void Set##method(type value) { name = value; }
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
108
include/raylib-cpp.hpp
Normal file
108
include/raylib-cpp.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* \mainpage raylib-cpp
|
||||
*
|
||||
* [raylib-cpp](https://github.com/robloach/raylib-cpp) is a C++ wrapper library for raylib, a simple and easy-to-use library to enjoy videogames programming. This C++ header provides object-oriented wrappers around raylib's struct interfaces.
|
||||
*
|
||||
* See the ::raylib namespace for all available classes.
|
||||
*
|
||||
* @code
|
||||
* #include "raylib-cpp.hpp"
|
||||
*
|
||||
* int main()
|
||||
* {
|
||||
* int screenWidth = 800;
|
||||
* int screenHeight = 450;
|
||||
*
|
||||
* raylib::Window w(screenWidth, screenHeight, "raylib-cpp - basic window");
|
||||
* raylib::Texture logo("raylib_logo.png");
|
||||
*
|
||||
* SetTargetFPS(60);
|
||||
*
|
||||
* while (!w.ShouldClose())
|
||||
* {
|
||||
* BeginDrawing();
|
||||
*
|
||||
* ClearBackground(RAYWHITE);
|
||||
*
|
||||
* DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
*
|
||||
* // Object methods.
|
||||
* logo.Draw(
|
||||
* screenWidth / 2 - texture.getWidth() / 2,
|
||||
* screenHeight / 2 - texture.getHeight() / 2);
|
||||
*
|
||||
* EndDrawing();
|
||||
* }
|
||||
*
|
||||
* // UnloadTexture() and CloseWindow() are called automatically.
|
||||
*
|
||||
* return 0;
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
||||
|
||||
/**
|
||||
* Provides all the classes associated with raylib-cpp.
|
||||
*/
|
||||
namespace raylib {
|
||||
// Nothing.
|
||||
} // namespace raylib
|
||||
|
||||
#include "./AudioDevice.hpp"
|
||||
#include "./AudioStream.hpp"
|
||||
#include "./BoundingBox.hpp"
|
||||
#include "./Camera2D.hpp"
|
||||
#include "./Camera3D.hpp"
|
||||
#include "./Color.hpp"
|
||||
#include "./DroppedFiles.hpp"
|
||||
#include "./Font.hpp"
|
||||
#include "./Gamepad.hpp"
|
||||
#include "./Image.hpp"
|
||||
#include "./Material.hpp"
|
||||
#include "./Matrix.hpp"
|
||||
#include "./Mesh.hpp"
|
||||
#include "./Model.hpp"
|
||||
#include "./ModelAnimation.hpp"
|
||||
#include "./Mouse.hpp"
|
||||
#include "./Music.hpp"
|
||||
#include "./Ray.hpp"
|
||||
#include "./RayHitInfo.hpp"
|
||||
#include "./Rectangle.hpp"
|
||||
#include "./RenderTexture.hpp"
|
||||
#include "./Shader.hpp"
|
||||
#include "./Sound.hpp"
|
||||
#include "./Texture.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./Vector3.hpp"
|
||||
#include "./Vector4.hpp"
|
||||
#include "./VrSimulator.hpp"
|
||||
#include "./Wave.hpp"
|
||||
#include "./Window.hpp"
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
1504
include/raylib.h
Normal file
1504
include/raylib.h
Normal file
File diff suppressed because it is too large
Load Diff
36
include/raylib.hpp
Normal file
36
include/raylib.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
1519
include/raymath.h
Normal file
1519
include/raymath.h
Normal file
File diff suppressed because it is too large
Load Diff
38
include/raymath.hpp
Normal file
38
include/raymath.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2020 Rob Loach (@RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include "raymath.h" // NOLINT
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
BIN
lib/libraylib.a
Normal file
BIN
lib/libraylib.a
Normal file
Binary file not shown.
35
src/main.cpp
Normal file
35
src/main.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <raylib-cpp.hpp>
|
||||
|
||||
int main() {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
raylib::Color textColor(LIGHTGRAY);
|
||||
raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!w.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user