mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 10:59:00 +00:00
@@ -50,8 +50,8 @@ class Camera2D : public ::Camera2D {
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(Vector2, Offset, offset)
|
||||
GETTERSETTER(Vector2, Target, target)
|
||||
GETTERSETTER(::Vector2, Offset, offset)
|
||||
GETTERSETTER(::Vector2, Target, target)
|
||||
GETTERSETTER(float, Rotation, rotation)
|
||||
GETTERSETTER(float, Zoom, zoom)
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ class Camera3D : public ::Camera3D {
|
||||
|
||||
Camera3D() {}
|
||||
|
||||
GETTERSETTER(Vector3, Position, position)
|
||||
GETTERSETTER(Vector3, Target, target)
|
||||
GETTERSETTER(Vector3, Up, up)
|
||||
GETTERSETTER(::Vector3, Position, position)
|
||||
GETTERSETTER(::Vector3, Target, target)
|
||||
GETTERSETTER(::Vector3, Up, up)
|
||||
GETTERSETTER(float, Fovy, fovy)
|
||||
GETTERSETTER(int, Type, type)
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ class Font : public ::Font {
|
||||
|
||||
GETTERSETTER(int, BaseSize, baseSize)
|
||||
GETTERSETTER(int, CharsCount, charsCount)
|
||||
GETTERSETTER(Texture2D, Texture, texture)
|
||||
GETTERSETTER(Rectangle*, Recs, recs)
|
||||
GETTERSETTER(CharInfo*, Chars, chars)
|
||||
GETTERSETTER(::Texture2D, Texture, texture)
|
||||
GETTERSETTER(::Rectangle*, Recs, recs)
|
||||
GETTERSETTER(::CharInfo*, Chars, chars)
|
||||
|
||||
Font& operator=(const ::Font& font) {
|
||||
set(font);
|
||||
|
||||
@@ -140,6 +140,7 @@ class Image : public ::Image {
|
||||
::ExportImage(*this, fileName.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Image& ExportAsCode(const std::string& fileName) {
|
||||
::ExportImageAsCode(*this, fileName.c_str());
|
||||
return *this;
|
||||
@@ -368,10 +369,14 @@ class Image : public ::Image {
|
||||
return ::GetImageDataNormalized(*this);
|
||||
}
|
||||
|
||||
inline operator Texture2D() {
|
||||
::Texture2D LoadTexture() {
|
||||
return ::LoadTextureFromImage(*this);
|
||||
}
|
||||
|
||||
inline operator ::Texture2D() {
|
||||
return LoadTexture();
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Image image) {
|
||||
data = image.data;
|
||||
|
||||
@@ -73,6 +73,7 @@ class Mesh : public ::Mesh {
|
||||
inline raylib::BoundingBox BoundingBox() {
|
||||
return ::MeshBoundingBox(*this);
|
||||
}
|
||||
|
||||
operator raylib::BoundingBox() {
|
||||
return BoundingBox();
|
||||
}
|
||||
@@ -95,6 +96,7 @@ class Mesh : public ::Mesh {
|
||||
inline raylib::Model LoadModelFrom() {
|
||||
return ::LoadModelFromMesh(*this);
|
||||
}
|
||||
|
||||
operator raylib::Model() {
|
||||
return LoadModelFrom();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class Model : public ::Model {
|
||||
GETTERSETTER(::Matrix, Transform, transform)
|
||||
GETTERSETTER(int, MeshCount, meshCount)
|
||||
GETTERSETTER(int, MaterialCount, materialCount)
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
|
||||
Model& operator=(const ::Model& model) {
|
||||
set(model);
|
||||
@@ -91,11 +92,11 @@ class Model : public ::Model {
|
||||
transform = model.transform;
|
||||
|
||||
meshCount = model.meshCount;
|
||||
meshes = model.meshes;
|
||||
|
||||
materialCount = model.materialCount;
|
||||
meshes = model.meshes;
|
||||
materials = model.materials;
|
||||
meshMaterial = model.meshMaterial;
|
||||
|
||||
boneCount = model.boneCount;
|
||||
bones = model.bones;
|
||||
bindPose = model.bindPose;
|
||||
|
||||
@@ -43,7 +43,7 @@ class ModelAnimation : public ::ModelAnimation {
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
GETTERSETTER(::BoneInfo*, Bones, bones)
|
||||
GETTERSETTER(int, FrameCount, frameCount)
|
||||
GETTERSETTER(Transform**, FramePoses, framePoses)
|
||||
GETTERSETTER(::Transform**, FramePoses, framePoses)
|
||||
|
||||
ModelAnimation& operator=(const ::ModelAnimation& model) {
|
||||
set(model);
|
||||
|
||||
@@ -82,24 +82,30 @@ class Music : public ::Music {
|
||||
::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);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_PHYSICS_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_PHYSICS_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#include "physac.h" // NOLINT
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -87,47 +88,60 @@ class Physics {
|
||||
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;
|
||||
|
||||
@@ -44,8 +44,8 @@ class RenderTexture : public ::RenderTexture {
|
||||
}
|
||||
|
||||
GETTERSETTER(unsigned int, Id, id)
|
||||
GETTERSETTER(Texture2D, Texture, texture)
|
||||
GETTERSETTER(Texture2D, Depth, depth)
|
||||
GETTERSETTER(::Texture2D, Texture, texture)
|
||||
GETTERSETTER(::Texture2D, Depth, depth)
|
||||
|
||||
RenderTexture& operator=(const ::RenderTexture& texture) {
|
||||
set(texture);
|
||||
|
||||
@@ -136,16 +136,19 @@ class Texture : public ::Texture {
|
||||
::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);
|
||||
|
||||
@@ -25,23 +25,14 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include "raymath.h" // NOLINT
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "./raylib-cpp-utils.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:
|
||||
|
||||
@@ -25,22 +25,14 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include "raymath.h" // NOLINT
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "./raylib-cpp-utils.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:
|
||||
|
||||
@@ -25,23 +25,15 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "raylib.h" // NOLINT
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include "raymath.h" // NOLINT
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "./raylib-cpp-utils.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:
|
||||
@@ -171,6 +163,10 @@ class Vector4 : public ::Vector4 {
|
||||
return ::ColorFromNormalized(*this);
|
||||
}
|
||||
|
||||
operator Color() {
|
||||
return ColorFromNormalized();
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void set(::Vector4 vec4) {
|
||||
x = vec4.x;
|
||||
|
||||
@@ -110,6 +110,10 @@ class Wave : public ::Wave {
|
||||
return ::LoadSoundFromWave(*this);
|
||||
}
|
||||
|
||||
inline operator Sound() {
|
||||
return LoadSound();
|
||||
}
|
||||
|
||||
inline float* GetData() {
|
||||
return ::GetWaveData(*this);
|
||||
}
|
||||
|
||||
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_
|
||||
Reference in New Issue
Block a user