mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 10:59:00 +00:00
Update documentation and add loading functions
This commit is contained in:
@@ -57,19 +57,31 @@ class BoundingBox : public ::BoundingBox {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a bounding box with wires
|
||||
*/
|
||||
inline BoundingBox& Draw(::Color color = WHITE) {
|
||||
DrawBoundingBox(*this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between two boxes
|
||||
*/
|
||||
inline bool CheckCollision(::BoundingBox box2) const {
|
||||
return CheckCollisionBoxes(*this, box2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between box and sphere
|
||||
*/
|
||||
inline bool CheckCollision(::Vector3 center, float radius) const {
|
||||
return CheckCollisionBoxSphere(*this, center, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between ray and bounding box
|
||||
*/
|
||||
inline bool CheckCollision(::Ray ray) const {
|
||||
return CheckCollisionRayBox(ray, *this);
|
||||
}
|
||||
|
||||
@@ -25,13 +25,15 @@ install(FILES
|
||||
Physics.hpp
|
||||
RayHitInfo.hpp
|
||||
Ray.hpp
|
||||
raylib.hpp
|
||||
raylib-cpp.hpp
|
||||
raylib-cpp-utils.hpp
|
||||
raymath.hpp
|
||||
Rectangle.hpp
|
||||
RenderTexture2D.hpp
|
||||
RenderTexture.hpp
|
||||
Shader.hpp
|
||||
Sound.hpp
|
||||
Texture2D.hpp
|
||||
Texture.hpp
|
||||
Vector2.hpp
|
||||
Vector3.hpp
|
||||
Vector4.hpp
|
||||
|
||||
@@ -41,8 +41,10 @@ class Color : public ::Color {
|
||||
a = color.a;
|
||||
}
|
||||
|
||||
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) : ::Color{red, green, blue, alpha} {};
|
||||
Color(unsigned char red, unsigned char green, unsigned char blue) : ::Color{red, green, blue, 255} {};
|
||||
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) :
|
||||
::Color{red, green, blue, alpha} {};
|
||||
Color(unsigned char red, unsigned char green, unsigned char blue) :
|
||||
::Color{red, green, blue, 255} {};
|
||||
|
||||
/**
|
||||
* Black.
|
||||
|
||||
@@ -56,6 +56,8 @@ class DroppedFiles {
|
||||
*/
|
||||
inline DroppedFiles& Clear() {
|
||||
::ClearDroppedFiles();
|
||||
m_count = 0;
|
||||
m_files = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,14 +99,27 @@ class Font : public ::Font {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string size for Font
|
||||
*/
|
||||
inline Vector2 MeasureText(const std::string& text, float fontSize, float spacing) {
|
||||
return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index position for a unicode character on font
|
||||
*/
|
||||
inline int GetGlyphIndex(int character) const {
|
||||
return ::GetGlyphIndex(*this, character);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image from text (custom sprite font)
|
||||
*/
|
||||
inline Image ImageText(const std::string& text, float fontSize, float spacing, ::Color tint) {
|
||||
return ::ImageTextEx(*this, text.c_str(), fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
protected:
|
||||
void set(const ::Font font) {
|
||||
baseSize = font.baseSize;
|
||||
|
||||
@@ -55,12 +55,15 @@ class Gamepad {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -55,27 +55,42 @@ class Image : public ::Image {
|
||||
Image(int width, int height, Color color = WHITE) {
|
||||
set(::GenImageColor(width, height, color));
|
||||
}
|
||||
Image(::Font font, const std::string& text, float fontSize, float spacing, ::Color tint) {
|
||||
set(::ImageTextEx(font, text.c_str(), fontSize, spacing, tint));
|
||||
}
|
||||
|
||||
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) {
|
||||
static Image Text(::Font font, std::string text, float fontSize, float spacing, ::Color tint) {
|
||||
return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel data from screen buffer and return an Image (screenshot)
|
||||
*/
|
||||
static Image GetScreenData() {
|
||||
return Image(::GetScreenData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: plain color
|
||||
*/
|
||||
static Image GenColor(int width, int height, Color color) {
|
||||
return ::GenImageColor(width, height, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: vertical gradient
|
||||
*/
|
||||
static Image GenGradientV(int width, int height, Color top, Color bottom) {
|
||||
return ::GenImageGradientV(width, height, top, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: horizontal gradient
|
||||
*/
|
||||
static Image GenGradientH(int width, int height, Color left, Color right) {
|
||||
return ::GenImageGradientH(width, height, left, right);
|
||||
}
|
||||
@@ -136,14 +151,19 @@ class Image : public ::Image {
|
||||
::UnloadImage(*this);
|
||||
}
|
||||
|
||||
inline Image& Export(const std::string& fileName) {
|
||||
::ExportImage(*this, fileName.c_str());
|
||||
return *this;
|
||||
/**
|
||||
* Export image data to file, returns true on success
|
||||
*/
|
||||
inline bool Export(const std::string& fileName) {
|
||||
// TODO(RobLoach): Switch to an invalid loading exception on false.
|
||||
return ::ExportImage(*this, fileName.c_str());
|
||||
}
|
||||
|
||||
inline Image& ExportAsCode(const std::string& fileName) {
|
||||
::ExportImageAsCode(*this, fileName.c_str());
|
||||
return *this;
|
||||
/**
|
||||
* Export image as code file defining an array of bytes, returns true on success
|
||||
*/
|
||||
inline bool ExportAsCode(const std::string& fileName) {
|
||||
return ::ExportImageAsCode(*this, fileName.c_str());
|
||||
}
|
||||
|
||||
GETTERSETTER(void*, Data, data)
|
||||
@@ -152,42 +172,71 @@ class Image : public ::Image {
|
||||
GETTERSETTER(int, Mipmaps, mipmaps)
|
||||
GETTERSETTER(int, Format, format)
|
||||
|
||||
/**
|
||||
* Create an image duplicate (useful for transformations)
|
||||
*/
|
||||
inline Image Copy() {
|
||||
return ::ImageCopy(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image from another image piece
|
||||
*/
|
||||
inline Image FromImage(::Rectangle rec) {
|
||||
return ::ImageFromImage(*this, rec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert image to POT (power-of-two)
|
||||
*/
|
||||
inline Image& ToPOT(Color fillColor) {
|
||||
::ImageToPOT(this, fillColor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert image data to desired format
|
||||
*/
|
||||
inline Image& Format(int newFormat) {
|
||||
::ImageFormat(this, newFormat);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply alpha mask to image
|
||||
*/
|
||||
inline Image& AlphaMask(Image alphaMask) {
|
||||
::ImageAlphaMask(this, alphaMask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop image depending on alpha value
|
||||
*/
|
||||
inline Image& AlphaCrop(float threshold) {
|
||||
::ImageAlphaCrop(this, threshold);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Premultiply alpha channel
|
||||
*/
|
||||
inline Image& AlphaPremultiply() {
|
||||
::ImageAlphaPremultiply(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop an image to area defined by a rectangle
|
||||
*/
|
||||
inline Image& Crop(::Rectangle crop) {
|
||||
::ImageCrop(this, crop);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop an image to area defined by a rectangle
|
||||
*/
|
||||
inline Image& Crop(int offsetX, int offsetY, int newWidth, int newHeight) {
|
||||
::Rectangle rect{
|
||||
static_cast<float>(offsetX),
|
||||
@@ -199,26 +248,41 @@ class Image : public ::Image {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize and image to new size
|
||||
*/
|
||||
inline Image& Resize(int newWidth, int newHeight) {
|
||||
::ImageResize(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize and image to new size using Nearest-Neighbor scaling algorithm
|
||||
*/
|
||||
inline Image& ResizeNN(int newWidth, int newHeight) {
|
||||
::ImageResizeNN(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize canvas and fill with color
|
||||
*/
|
||||
inline Image& ResizeCanvas(int newWidth, int newHeight, int offsetX, int offsetY, Color color) {
|
||||
::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all mipmap levels for a provided image
|
||||
*/
|
||||
inline Image& Mipmaps() {
|
||||
::ImageMipmaps(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
||||
*/
|
||||
inline Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
|
||||
::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
|
||||
return *this;
|
||||
@@ -228,6 +292,7 @@ class Image : public ::Image {
|
||||
::ImageFlipVertical(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& FlipHorizontal() {
|
||||
::ImageFlipHorizontal(this);
|
||||
return *this;
|
||||
@@ -257,14 +322,17 @@ class Image : public ::Image {
|
||||
::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;
|
||||
@@ -349,6 +417,7 @@ class Image : public ::Image {
|
||||
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);
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
@@ -43,6 +46,15 @@ class Material : public ::Material {
|
||||
Unload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load materials from model file
|
||||
*/
|
||||
static std::vector<Material> Load(const std::string& fileName) {
|
||||
int count = 0;
|
||||
::Material* materials = ::LoadMaterials(fileName.c_str(), &count);
|
||||
return std::vector<Material>(materials, materials + count);
|
||||
}
|
||||
|
||||
GETTERSETTER(::Shader, Shader, shader)
|
||||
|
||||
Material& operator=(const ::Material& material) {
|
||||
@@ -59,6 +71,9 @@ class Material : public ::Material {
|
||||
::UnloadMaterial(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
|
||||
*/
|
||||
inline Material& SetTexture(int mapType, ::Texture2D texture) {
|
||||
::SetMaterialTexture(this, mapType, texture);
|
||||
return *this;
|
||||
|
||||
@@ -116,20 +116,32 @@ class Matrix : public ::Matrix {
|
||||
&& m15 == other.m15;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom projection matrix (replaces internal projection matrix)
|
||||
*/
|
||||
inline Matrix& SetProjection() {
|
||||
::SetMatrixProjection(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
*/
|
||||
inline Matrix& SetModelview() {
|
||||
::SetMatrixModelview(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get internal modelview matrix
|
||||
*/
|
||||
static Matrix GetModelview() {
|
||||
return ::GetMatrixModelview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get internal projection matrix
|
||||
*/
|
||||
static Matrix GetProjection() {
|
||||
return ::GetMatrixProjection();
|
||||
}
|
||||
@@ -232,6 +244,15 @@ class Matrix : public ::Matrix {
|
||||
operator float16() {
|
||||
return ToFloatV();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value (matrix 4x4)
|
||||
*/
|
||||
inline Matrix& SetShaderValue(::Shader shader, int uniformLoc) {
|
||||
::SetShaderValueMatrix(shader, uniformLoc, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
@@ -44,6 +45,15 @@ class Mesh : public ::Mesh {
|
||||
triangleCount = TriangleCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load meshes from model file
|
||||
*/
|
||||
static std::vector<Mesh> Load(const std::string fileName) {
|
||||
int count = 0;
|
||||
::Mesh* meshes = LoadMeshes(fileName.c_str(), &count);
|
||||
return std::vector<Mesh>(meshes, meshes + count);
|
||||
}
|
||||
|
||||
GETTERSETTER(int, VertexCount, vertexCount)
|
||||
GETTERSETTER(int, TriangleCount, triangleCount)
|
||||
|
||||
@@ -61,9 +71,12 @@ class Mesh : public ::Mesh {
|
||||
Unload();
|
||||
}
|
||||
|
||||
inline Mesh& Export(const std::string& fileName) {
|
||||
ExportMesh(*this, fileName.c_str());
|
||||
return *this;
|
||||
/**
|
||||
* Export mesh data to file
|
||||
*/
|
||||
inline bool Export(const std::string& fileName) {
|
||||
// TODO(RobLoach): Switch to an exception when failed.
|
||||
return ExportMesh(*this, fileName.c_str());
|
||||
}
|
||||
|
||||
inline void Unload() {
|
||||
@@ -98,7 +111,7 @@ class Mesh : public ::Mesh {
|
||||
}
|
||||
|
||||
operator raylib::Model() {
|
||||
return LoadModelFrom();
|
||||
return ::LoadModelFromMesh(*this);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -39,11 +39,11 @@ class Model : public ::Model {
|
||||
}
|
||||
|
||||
Model(const std::string& fileName) {
|
||||
set(LoadModel(fileName.c_str()));
|
||||
set(::LoadModel(fileName.c_str()));
|
||||
}
|
||||
|
||||
Model(::Mesh mesh) {
|
||||
set(LoadModelFromMesh(mesh));
|
||||
set(::LoadModelFromMesh(mesh));
|
||||
}
|
||||
|
||||
~Model() {
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./Mesh.hpp"
|
||||
@@ -40,6 +43,15 @@ class ModelAnimation : public ::ModelAnimation {
|
||||
Unload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load model animations from file
|
||||
*/
|
||||
static std::vector<ModelAnimation> Load(const std::string& fileName) {
|
||||
int count = 0;
|
||||
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
|
||||
return std::vector<ModelAnimation>(modelAnimations, modelAnimations + count);
|
||||
}
|
||||
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
GETTERSETTER(::BoneInfo*, Bones, bones)
|
||||
GETTERSETTER(int, FrameCount, frameCount)
|
||||
@@ -55,23 +67,28 @@ class ModelAnimation : public ::ModelAnimation {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload animation data
|
||||
*/
|
||||
inline void Unload() {
|
||||
::UnloadModelAnimation(*this);
|
||||
}
|
||||
|
||||
inline ModelAnimation& UpdateAnimation(::Model model, int frame) {
|
||||
/**
|
||||
* Update model animation pose
|
||||
*/
|
||||
inline ModelAnimation& Update(::Model model, int frame) {
|
||||
::UpdateModelAnimation(model, *this, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check model animation skeleton match
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -63,6 +63,9 @@ class Music : public ::Music {
|
||||
::UnloadMusicStream(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start music playing
|
||||
*/
|
||||
inline Music& Play() {
|
||||
::PlayMusicStream(*this);
|
||||
return *this;
|
||||
|
||||
@@ -43,10 +43,12 @@ class Physics {
|
||||
Physics() {
|
||||
Init();
|
||||
}
|
||||
|
||||
Physics(float gravityY) {
|
||||
Init();
|
||||
SetGravity(0, gravityY);
|
||||
}
|
||||
|
||||
Physics(float gravityX, float gravityY) {
|
||||
Init();
|
||||
SetGravity(gravityX, gravityY);
|
||||
|
||||
@@ -65,27 +65,45 @@ class Ray : public ::Ray {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between ray and sphere
|
||||
*/
|
||||
inline bool CheckCollisionSphere(::Vector3 center, float radius) const {
|
||||
return CheckCollisionRaySphere(*this, center, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between ray and sphere, returns collision point
|
||||
*/
|
||||
inline bool CheckCollisionSphereEx(::Vector3 center, float radius,
|
||||
::Vector3 *collisionPoint) const {
|
||||
return CheckCollisionRaySphereEx(*this, center, radius, collisionPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between ray and box
|
||||
*/
|
||||
inline bool CheckCollisionBox(::BoundingBox box) const {
|
||||
return CheckCollisionRayBox(*this, box);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and model
|
||||
*/
|
||||
inline RayHitInfo GetCollisionModel(::Model model) {
|
||||
return GetCollisionRayModel(*this, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and triangle
|
||||
*/
|
||||
inline RayHitInfo GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
|
||||
return GetCollisionRayTriangle(*this, p1, p2, p3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and ground plane (Y-normal plane)
|
||||
*/
|
||||
inline RayHitInfo GetCollisionGround(float groundHeight) {
|
||||
return GetCollisionRayGround(*this, groundHeight);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,27 @@ class RayHitInfo : public ::RayHitInfo {
|
||||
normal = Normal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and model
|
||||
*/
|
||||
RayHitInfo(::Ray ray, ::Model model) {
|
||||
set(::GetCollisionRayModel(ray, model));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and triangle
|
||||
*/
|
||||
RayHitInfo(::Ray ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
|
||||
set(::GetCollisionRayTriangle(ray, p1, p2, p3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and ground plane (Y-normal plane)
|
||||
*/
|
||||
RayHitInfo(::Ray ray, float groundHeight) {
|
||||
set(::GetCollisionRayGround(ray, groundHeight));
|
||||
}
|
||||
|
||||
RayHitInfo& operator=(const ::RayHitInfo& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
|
||||
@@ -36,11 +36,11 @@ class Rectangle : public ::Rectangle {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {};
|
||||
Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, height} {};
|
||||
Rectangle(float x, float y) : ::Rectangle{x, y, 0, 0} {};
|
||||
Rectangle(float x) : ::Rectangle{x, 0, 0, 0} {};
|
||||
Rectangle() {};
|
||||
Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {}
|
||||
Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, height} {}
|
||||
Rectangle(float x, float y) : ::Rectangle{x, y, 0, 0} {}
|
||||
Rectangle(float x) : ::Rectangle{x, 0, 0, 0} {}
|
||||
Rectangle() : ::Rectangle{0, 0, 0, 0} {}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
@@ -105,18 +105,34 @@ class Rectangle : public ::Rectangle {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collision between two rectangles
|
||||
*/
|
||||
inline bool CheckCollision(::Rectangle rec2) const {
|
||||
return ::CheckCollisionRecs(*this, rec2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision rectangle for two rectangles collision
|
||||
*/
|
||||
inline Rectangle GetCollision(::Rectangle rec2) const {
|
||||
return ::GetCollisionRec(*this, rec2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if point is inside rectangle
|
||||
*/
|
||||
inline bool CheckCollision(::Vector2 point) const {
|
||||
return ::CheckCollisionPointRec(point, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collision between circle and rectangle
|
||||
*/
|
||||
inline bool CheckCollision(::Vector2 center, float radius) {
|
||||
return CheckCollisionCircleRec(center, radius, *this);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Rectangle rect) {
|
||||
x = rect.x;
|
||||
|
||||
@@ -65,11 +65,17 @@ class RenderTexture : public ::RenderTexture {
|
||||
UnloadRenderTexture(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes render texture for drawing
|
||||
*/
|
||||
inline RenderTexture& BeginTextureMode() {
|
||||
::BeginTextureMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends drawing to render texture
|
||||
*/
|
||||
inline RenderTexture& EndTextureMode() {
|
||||
::EndTextureMode();
|
||||
return *this;
|
||||
|
||||
@@ -47,6 +47,18 @@ class Shader : public ::Shader {
|
||||
set(GetShaderDefault());
|
||||
}
|
||||
|
||||
Shader(const std::string& vsFileName, const std::string& fsFileName) {
|
||||
set(::LoadShader(vsFileName.c_str(), fsFileName.c_str()));
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, Id, id)
|
||||
GETTERSETTER(int*, Locs, locs)
|
||||
|
||||
@@ -68,14 +80,6 @@ class Shader : public ::Shader {
|
||||
::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;
|
||||
@@ -116,7 +120,7 @@ class Shader : public ::Shader {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ::SetShaderValueTexture
|
||||
* Set shader uniform value for texture
|
||||
*/
|
||||
inline Shader& SetValue(int uniformLoc, Texture2D texture) {
|
||||
::SetShaderValueTexture(*this, uniformLoc, texture);
|
||||
|
||||
@@ -62,15 +62,24 @@ class Sound : public ::Sound {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sound buffer with new data
|
||||
*/
|
||||
inline Sound& Update(const void *data, int sampleCount) {
|
||||
::UpdateSound(*this, data, sampleCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload sound
|
||||
*/
|
||||
inline void Unload() {
|
||||
::UnloadSound(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a sound
|
||||
*/
|
||||
inline Sound& Play() {
|
||||
::PlaySound(*this);
|
||||
return *this;
|
||||
|
||||
@@ -43,6 +43,9 @@ class Texture : public ::Texture {
|
||||
LoadFromImage(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load texture from file into GPU memory (VRAM)
|
||||
*/
|
||||
Texture(const std::string& fileName) {
|
||||
Load(fileName);
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ class Vector2 : public ::Vector2 {
|
||||
set(vec);
|
||||
}
|
||||
|
||||
Vector2(float x, float y) : ::Vector2{x, y} {};
|
||||
Vector2(float x) : ::Vector2{x, 0} {};
|
||||
Vector2() : ::Vector2{0, 0} {};
|
||||
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)
|
||||
|
||||
@@ -40,10 +40,10 @@ class Vector3 : public ::Vector3 {
|
||||
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(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));
|
||||
|
||||
@@ -41,11 +41,11 @@ class Vector4 : public ::Vector4 {
|
||||
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(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));
|
||||
|
||||
@@ -76,6 +76,7 @@ class VrSimulator {
|
||||
::EndVrDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
::CloseVrSimulator();
|
||||
}
|
||||
|
||||
@@ -48,12 +48,18 @@ class Wave : public ::Wave {
|
||||
channels = Channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load wave data from file
|
||||
*/
|
||||
Wave(const std::string& fileName) {
|
||||
set(LoadWave(fileName.c_str()));
|
||||
set(::LoadWave(fileName.c_str()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load wave from memory buffer, fileType refers to extension: i.e. "wav"
|
||||
*/
|
||||
Wave(const std::string& fileType, const unsigned char *fileData, int dataSize) {
|
||||
set(LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
}
|
||||
|
||||
~Wave() {
|
||||
|
||||
@@ -131,15 +131,24 @@ class Window {
|
||||
return ::IsWindowResized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if one specific window flag is enabled
|
||||
*/
|
||||
inline bool IsState(unsigned int flag) {
|
||||
return ::IsWindowState(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window configuration state using flags
|
||||
*/
|
||||
inline Window& SetState(unsigned int flag) {
|
||||
::SetWindowState(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear window configuration state flags
|
||||
*/
|
||||
inline Window& ClearState(unsigned int flag) {
|
||||
::ClearWindowState(flag);
|
||||
return *this;
|
||||
@@ -153,16 +162,25 @@ class Window {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
inline Window& Maximize() {
|
||||
::MaximizeWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
inline Window& Minimize() {
|
||||
::MinimizeWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
inline Window& Restore() {
|
||||
::RestoreWindow();
|
||||
return *this;
|
||||
@@ -304,10 +322,16 @@ class Window {
|
||||
return ::GetFPS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns time in seconds for last frame drawn
|
||||
*/
|
||||
inline float GetFrameTime() const {
|
||||
return ::GetFrameTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns elapsed time in seconds since InitWindow()
|
||||
*/
|
||||
inline double GetTime() const {
|
||||
return ::GetTime();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user