Adopt cpplint

This commit is contained in:
Rob Loach
2020-10-25 16:27:09 -04:00
parent 43dbffc5fe
commit f5b1dd7ffa
58 changed files with 4143 additions and 3415 deletions

View File

@@ -1,7 +1,7 @@
root = true
[*]
indent_style = tabs
indent_style = space
charset = utf-8
end_of_line = lf
indent_size = 4

1
.gitignore vendored
View File

@@ -1 +1,2 @@
build
.vscode

View File

@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project (raylib-cpp
VERSION 3.1.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX)
VERSION 3.1.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX)
# Options
option(BUILD_RAYLIB_CPP_EXAMPLES "Examples" ON)
@@ -19,17 +19,17 @@ add_subdirectory(include)
# Examples
if(BUILD_RAYLIB_CPP_EXAMPLES)
add_subdirectory(examples)
set(BUILD_RAYLIB_CPP_STATIC ON)
add_subdirectory(examples)
set(BUILD_RAYLIB_CPP_STATIC ON)
endif()
# Testing
include(CTest)
enable_testing()
if(BUILD_TESTING)
set(CTEST_CUSTOM_TESTS_IGNORE
pkg-config--static
)
set(CTEST_CUSTOM_TESTS_IGNORE
pkg-config--static
)
add_subdirectory(tests)
add_subdirectory(tests)
endif()

6
CPPLINT.cfg Normal file
View File

@@ -0,0 +1,6 @@
set noparent
root=..
linelength=100
exclude_files=vendor
exclude_files=docs
filter=-runtime/explicit

View File

@@ -9,8 +9,7 @@
``` cpp
#include "raylib-cpp.hpp"
int main()
{
int main() {
int screenWidth = 800;
int screenHeight = 450;
@@ -211,6 +210,10 @@ If there's a project template you would like to see added, feel free to [make an
## Development
The following are some tools in order to build and contribute to raylib-cpp...
### Compiling
*raylib-cpp* uses [CMake](https://cmake.org) as a primary target for development. To build it, and run the tests or examples, use...
``` bash
@@ -225,7 +228,7 @@ make test
./examples/core_basic_window
```
## Documentation
### Documentation
To build the document with [Doxygen](http://www.doxygen.nl/), use...
@@ -233,6 +236,14 @@ To build the document with [Doxygen](http://www.doxygen.nl/), use...
doxygen projects/Doxygen/Doxyfile
```
### Coding Standards
This uses cpplint to adopt coding standards.
```
cpplint --recursive include
```
### Defines
- `RAYLIB_CPP_NO_MATH` - When set, will skip adding the `raymath.h` integrations

View File

@@ -6,34 +6,34 @@ set(example_resources)
# raylib
find_package(raylib QUIET)
if (NOT raylib_FOUND)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib)
endif()
foreach(example_dir ${example_dirs})
file(GLOB sources ${example_dir}/*.cpp)
list(APPEND example_sources ${sources})
file(GLOB sources ${example_dir}/*.cpp)
list(APPEND example_sources ${sources})
# Any any resources
file(GLOB resources ${example_dir}/resources/*)
list(APPEND example_resources ${resources})
# Any any resources
file(GLOB resources ${example_dir}/resources/*)
list(APPEND example_resources ${resources})
endforeach()
# Do each example
foreach(example_source ${example_sources})
# Create the basename for the example
get_filename_component(example_name ${example_source} NAME)
string(REPLACE ".cpp" "${OUTPUT_EXT}" example_name ${example_name})
# Create the basename for the example
get_filename_component(example_name ${example_source} NAME)
string(REPLACE ".cpp" "${OUTPUT_EXT}" example_name ${example_name})
# Setup the example
add_executable(${example_name} ${example_source})
# Setup the example
add_executable(${example_name} ${example_source})
# Link raylib and raylib-cpp
target_link_libraries(${example_name} PUBLIC raylib-cpp raylib)
# Link raylib and raylib-cpp
target_link_libraries(${example_name} PUBLIC raylib-cpp raylib)
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources")
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources")
endforeach()

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main(void)
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main(void)
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -13,8 +13,7 @@
#define MAX_COLUMNS 20
int main(void)
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -21,37 +21,36 @@
#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");
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);
//--------------------------------------------------------------------------------------
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!w.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Main game loop
while (!w.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
raylib::Color::RayWhite.ClearBackground();
raylib::Color::RayWhite.ClearBackground();
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
EndDrawing();
//----------------------------------------------------------------------------------
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
return 0;
}

View File

@@ -13,8 +13,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
@@ -34,7 +33,7 @@ int main()
// Update
//----------------------------------------------------------------------------------
if (droppedFiles.IsFileDropped()) {
droppedFiles.Get();
droppedFiles.Get();
}
//----------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ int main()
// Check if there are files to process.
if (droppedFiles.empty()) {
DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
}
else {
DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
@@ -54,9 +53,9 @@ int main()
// Iterate through all the dropped files.
for (int i = 0; i < droppedFiles.size(); i++) {
if (i%2 == 0)
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
else
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
// Display the path to the dropped file.
DrawText(droppedFiles[i].c_str(), 120, 100 + 40*i, 10, GRAY);

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
@@ -22,11 +21,11 @@ int main()
// Define the camera to look into our 3d world
raylib::Camera camera(
raylib::Vector3(10.0f, 10.0f, 10.0f),
raylib::Vector3(),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE);
raylib::Vector3(10.0f, 10.0f, 10.0f),
raylib::Vector3(),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE);
Vector3 cubePosition;
Vector2 cubeScreenPosition;

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
@@ -22,11 +21,11 @@ int main()
// Define the camera to look into our 3d world
raylib::Camera camera(
raylib::Vector3(5.0f, 4.0f, 5.0f),
raylib::Vector3(0.0f, 2.0f, 0.0f),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE
raylib::Vector3(5.0f, 4.0f, 5.0f),
raylib::Vector3(0.0f, 2.0f, 0.0f),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE
);
raylib::Texture2D bill("resources/billboard.png"); // Our texture billboard

View File

@@ -11,8 +11,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -21,8 +21,7 @@
#include <string>
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;

View File

@@ -18,27 +18,26 @@
#define MAX_FONTS 8
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
raylib::Window w(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
raylib::Window w(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
raylib::Color background(RAYWHITE);
raylib::Color textColor(DARKGRAY);
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
raylib::Font fonts[MAX_FONTS] = {
raylib::Font("resources/fonts/alagard.png"),
raylib::Font("resources/fonts/pixelplay.png"),
raylib::Font("resources/fonts/mecha.png"),
raylib::Font("resources/fonts/setback.png"),
raylib::Font("resources/fonts/romulus.png"),
raylib::Font("resources/fonts/pixantiqua.png"),
raylib::Font("resources/fonts/alpha_beta.png"),
raylib::Font("resources/fonts/jupiter_crash.png")
raylib::Font("resources/fonts/alagard.png"),
raylib::Font("resources/fonts/pixelplay.png"),
raylib::Font("resources/fonts/mecha.png"),
raylib::Font("resources/fonts/setback.png"),
raylib::Font("resources/fonts/romulus.png"),
raylib::Font("resources/fonts/pixantiqua.png"),
raylib::Font("resources/fonts/alpha_beta.png"),
raylib::Font("resources/fonts/jupiter_crash.png")
};
std::string messages[MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi",

View File

@@ -21,29 +21,29 @@
class Bunny {
public:
Bunny() {
Bunny() {
position = GetMousePosition();
speed.x = (float)GetRandomValue(-250, 250)/60.0f;
speed.y = (float)GetRandomValue(-250, 250)/60.0f;
color = raylib::Color(
GetRandomValue(50, 240),
GetRandomValue(50, 240),
GetRandomValue(80, 240),
GetRandomValue(100, 240), 255);
}
}
void Update(const raylib::Texture2D& texBunny) {
position.x += speed.x;
void Update(const raylib::Texture2D& texBunny) {
position.x += speed.x;
position.y += speed.y;
if (((position.x + texBunny.width/2) > GetScreenWidth()) ||
((position.x + texBunny.width/2) < 0)) speed.x *= -1;
if (((position.y + texBunny.height/2) > GetScreenHeight()) ||
((position.y + texBunny.height/2 - 40) < 0)) speed.y *= -1;
}
}
Vector2 position;
Vector2 speed;
Color color;
Vector2 position;
Vector2 speed;
Color color;
};
int main(void)
@@ -75,7 +75,7 @@ int main(void)
{
if (bunnies.size() < MAX_BUNNIES)
{
bunnies.emplace_back();
bunnies.emplace_back();
}
}
}

View File

@@ -13,8 +13,7 @@
#include "raylib-cpp.hpp"
int main()
{
int main() {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;

View File

@@ -1,68 +1,85 @@
#ifndef RAYLIB_CPP_AUDIODEVICE_HPP_
#define RAYLIB_CPP_AUDIODEVICE_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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();
}
};
/**
* 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();
};
~AudioDevice() {
Close();
}
/**
* Initialize audio device and context.
*/
inline AudioDevice& Init() {
::InitAudioDevice();
return *this;
}
/**
* Initialize audio device and context.
*/
inline AudioDevice& Init() {
::InitAudioDevice();
return *this;
}
/**
* Close the audio device and context.
*/
inline AudioDevice& Close() {
::CloseAudioDevice();
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();
}
/**
* 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;
}
};
}
/**
* Set master volume (listener).
*/
inline AudioDevice& SetVolume(float volume) {
::SetMasterVolume(volume);
return *this;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_

View File

@@ -1,146 +1,162 @@
#ifndef RAYLIB_CPP_AUDIOSTREAM_HPP_
#define RAYLIB_CPP_AUDIOSTREAM_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
/**
* 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));
}
/**
* 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();
}
~AudioStream() {
Close();
}
GETTERSETTER(unsigned int,SampleRate,sampleRate)
GETTERSETTER(unsigned int,SampleSize,sampleSize)
GETTERSETTER(unsigned int,Channels,channels)
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;
}
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;
}
/**
* 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;
}
/**
* 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);
}
/**
* 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;
}
/**
* Play audio stream
*/
inline AudioStream& Play() {
::PlayAudioStream(*this);
return *this;
}
/**
* Pause audio stream
*/
inline AudioStream& Pause() {
::PauseAudioStream(*this);
return *this;
}
/**
* Pause audio stream
*/
inline AudioStream& Pause() {
::PauseAudioStream(*this);
return *this;
}
/**
* Resume audio stream
*/
inline AudioStream& Resume() {
::ResumeAudioStream(*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);
}
/**
* Check if audio stream is playing
*/
inline bool IsPlaying() const {
return ::IsAudioStreamPlaying(*this);
}
/**
* Stop audio stream
*/
inline AudioStream& Stop() {
::StopAudioStream(*this);
return *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 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;
}
/**
* 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 AudioStream& SetBufferSizeDefault(int size) {
::SetAudioStreamBufferSizeDefault(size);
return *this;
}
/**
* Default size for new audio streams
*/
inline AudioStream& SetBufferSizeDefault(int size) {
::SetAudioStreamBufferSizeDefault(size);
return *this;
}
protected:
inline void set(::AudioStream stream) {
sampleRate = stream.sampleRate;
sampleSize = stream.sampleSize;
channels = stream.channels;
buffer = stream.buffer;
}
protected:
inline void set(::AudioStream stream) {
sampleRate = stream.sampleRate;
sampleSize = stream.sampleSize;
channels = stream.channels;
buffer = stream.buffer;
}
};
} // namespace raylib
};
}
#endif
#endif // RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_

View File

@@ -1,66 +1,83 @@
#ifndef RAYLIB_CPP_BOUNDINGBOX_HPP_
#define RAYLIB_CPP_BOUNDINGBOX_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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;
};
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)
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;
}
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 BoundingBox& Draw(::Color color = WHITE) {
DrawBoundingBox(*this, color);
return *this;
}
inline bool CheckCollision(::BoundingBox box2) const {
return CheckCollisionBoxes(*this, box2);
}
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(::Vector3 center, float radius) const {
return CheckCollisionBoxSphere(*this, center, radius);
}
inline bool CheckCollision(::Ray ray) const {
return CheckCollisionRayBox(ray, *this);
}
inline bool CheckCollision(::Ray ray) const {
return CheckCollisionRayBox(ray, *this);
}
protected:
inline void set(::BoundingBox box) {
min = box.min;
max = box.max;
}
};
}
protected:
inline void set(::BoundingBox box) {
min = box.min;
max = box.max;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_

View File

@@ -5,38 +5,38 @@ target_include_directories(raylib-cpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)
# Set the header files as install files.
install(FILES
AudioDevice.hpp
AudioStream.hpp
BoundingBox.hpp
Camera2D.hpp
Camera3D.hpp
Color.hpp
DroppedFiles.hpp
Font.hpp
Gamepad.hpp
Image.hpp
Material.hpp
Matrix.hpp
Mesh.hpp
ModelAnimation.hpp
Model.hpp
Mouse.hpp
Music.hpp
Physics.hpp
RayHitInfo.hpp
Ray.hpp
raylib-cpp.hpp
raylib-cpp-utils.hpp
Rectangle.hpp
RenderTexture2D.hpp
Shader.hpp
Sound.hpp
Texture2D.hpp
Vector2.hpp
Vector3.hpp
Vector4.hpp
VrSimulator.hpp
Wave.hpp
Window.hpp
DESTINATION include
AudioDevice.hpp
AudioStream.hpp
BoundingBox.hpp
Camera2D.hpp
Camera3D.hpp
Color.hpp
DroppedFiles.hpp
Font.hpp
Gamepad.hpp
Image.hpp
Material.hpp
Matrix.hpp
Mesh.hpp
ModelAnimation.hpp
Model.hpp
Mouse.hpp
Music.hpp
Physics.hpp
RayHitInfo.hpp
Ray.hpp
raylib-cpp.hpp
raylib-cpp-utils.hpp
Rectangle.hpp
RenderTexture2D.hpp
Shader.hpp
Sound.hpp
Texture2D.hpp
Vector2.hpp
Vector3.hpp
Vector4.hpp
VrSimulator.hpp
Wave.hpp
Window.hpp
DESTINATION include
)

View File

@@ -1,75 +1,94 @@
#ifndef RAYLIB_CPP_CAMERA_HPP_
#define RAYLIB_CPP_CAMERA_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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;
};
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;
}
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)
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;
}
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 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);
}
inline void set(const Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
};
}
protected:
inline void set(const ::Camera2D& camera) {
offset = camera.offset;
target = camera.target;
rotation = camera.rotation;
zoom = camera.zoom;
}
#endif
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_

View File

@@ -1,126 +1,147 @@
#ifndef RAYLIB_CPP_CAMERA3D_HPP_
#define RAYLIB_CPP_CAMERA3D_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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;
};
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() {}
Camera3D() {}
GETTERSETTER(Vector3,Position,position)
GETTERSETTER(Vector3,Target,target)
GETTERSETTER(Vector3,Up,up)
GETTERSETTER(float,Fovy,fovy)
GETTERSETTER(int,Type,type)
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& 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;
}
Camera3D& BeginMode3D() {
::BeginMode3D(*this);
return *this;
}
Camera3D& EndMode3D() {
::EndMode3D();
return *this;
}
inline Matrix GetMatrix() const {
return ::GetCameraMatrix(*this);
}
inline Matrix GetMatrix() const {
return ::GetCameraMatrix(*this);
}
inline Camera3D& SetMode(int mode) {
::SetCameraMode(*this, mode);
return *this;
}
inline Camera3D& SetMode(int mode) {
::SetCameraMode(*this, mode);
return *this;
}
inline Camera3D& SetAltControl(int altKey) {
::SetCameraAltControl(altKey);
return *this;
}
inline Camera3D& SetAltControl(int altKey) {
::SetCameraAltControl(altKey);
return *this;
}
inline Camera3D& SetSmoothZoomControl(int szKey) {
::SetCameraSmoothZoomControl(szKey);
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& 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& Update() {
::UpdateCamera(this);
return *this;
}
inline Camera3D& UpdateVrTracking() {
::UpdateVrTracking(this);
return *this;
}
inline Camera3D& UpdateVrTracking() {
::UpdateVrTracking(this);
return *this;
}
inline Ray GetMouseRay(::Vector2 mousePosition) const {
return ::GetMouseRay(mousePosition, *this);
}
inline Ray GetMouseRay(::Vector2 mousePosition) const {
return ::GetMouseRay(mousePosition, *this);
}
inline Vector2 GetWorldToScreen(::Vector3 position) const {
return ::GetWorldToScreen(position, *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, ::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;
}
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;
}
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;
}
};
inline void set(const Camera3D& camera) {
position = camera.position;
target = camera.target;
up = camera.up;
fovy = camera.fovy;
type = camera.type;
}
};
typedef Camera3D Camera;
}
typedef Camera3D Camera;
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_

View File

@@ -1,237 +1,255 @@
#ifndef RAYLIB_CPP_COLOR_HPP_
#define RAYLIB_CPP_COLOR_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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));
}
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));
}
static Color LightGray;
static Color Gray;
static Color DarkGray;
static Color Yellow;
static Color Gold;
static Color Orange;
static Color Pink;
static Color Red;
static Color Maroon;
static Color Green;
static Color Lime;
static Color DarkGreen;
static Color SkyBlue;
static Color Blue;
static Color DarkBlue;
static Color Purple;
static Color Violet;
static Color DarkPurple;
static Color Beige;
static Color Brown;
static Color DarkBrown;
static Color White;
static Color Black;
static Color Blank;
static Color Magenta;
static Color RayWhite;
static Color LightGray;
static Color Gray;
static Color DarkGray;
static Color Yellow;
static Color Gold;
static Color Orange;
static Color Pink;
static Color Red;
static Color Maroon;
static Color Green;
static Color Lime;
static Color DarkGreen;
static Color SkyBlue;
static Color Blue;
static Color DarkBlue;
static Color Purple;
static Color Violet;
static Color DarkPurple;
static Color Beige;
static Color Brown;
static Color DarkBrown;
static Color White;
static Color Black;
static Color Blank;
static Color Magenta;
static Color RayWhite;
int ToInt() const {
return ::ColorToInt(*this);
}
int ToInt() const {
return ::ColorToInt(*this);
}
operator int() const { return ::ColorToInt(*this); }
operator int() const { return ::ColorToInt(*this); }
Color Fade(float alpha) const {
return ::Fade(*this, alpha);
}
Color Fade(float alpha) const {
return ::Fade(*this, alpha);
}
Vector4 Normalize() const {
return ::ColorNormalize(*this);
}
Vector4 Normalize() const {
return ::ColorNormalize(*this);
}
Vector3 ToHSV() const {
return ::ColorToHSV(*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)
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;
}
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& ClearBackground() {
::ClearBackground(*this);
return *this;
}
inline Color& DrawPixel(int x, int y) {
::DrawPixel(x, y, *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& 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& 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(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& 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(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(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) {
::DrawRectangleRec(rec, *this);
return *this;
}
inline Color& DrawRectangle(Rectangle rec, Vector2 origin, float rotation) {
::DrawRectanglePro(rec, origin, rotation, *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(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;
}
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;
}
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;
}
inline void set(const Color& color) {
r = color.r;
g = color.g;
b = color.b;
a = color.a;
}
};
};
inline Color Color::LightGray = ::LIGHTGRAY;
inline Color Color::Gray = ::GRAY;
inline Color Color::DarkGray = ::DARKGRAY;
inline Color Color::Yellow = ::YELLOW;
inline Color Color::Gold = ::GOLD;
inline Color Color::Orange = ::ORANGE;
inline Color Color::Pink = ::PINK;
inline Color Color::Red = ::RED;
inline Color Color::Maroon = ::MAROON;
inline Color Color::Green = ::GREEN;
inline Color Color::Lime = ::LIME;
inline Color Color::DarkGreen = ::DARKGREEN;
inline Color Color::SkyBlue = ::SKYBLUE;
inline Color Color::Blue = ::BLUE;
inline Color Color::DarkBlue = ::DARKBLUE;
inline Color Color::Purple = ::PURPLE;
inline Color Color::Violet = ::VIOLET;
inline Color Color::DarkPurple = ::DARKPURPLE;
inline Color Color::Beige = ::BEIGE;
inline Color Color::Brown = ::BROWN;
inline Color Color::DarkBrown = ::DARKBROWN;
inline Color Color::White = ::WHITE;
inline Color Color::Black = ::BLACK;
inline Color Color::Blank = ::BLANK;
inline Color Color::Magenta = ::MAGENTA;
inline Color Color::RayWhite = ::RAYWHITE;
} // namespace raylib
inline Color Color::LightGray = ::LIGHTGRAY;
inline Color Color::Gray = ::GRAY;
inline Color Color::DarkGray = ::DARKGRAY;
inline Color Color::Yellow = ::YELLOW;
inline Color Color::Gold = ::GOLD;
inline Color Color::Orange = ::ORANGE;
inline Color Color::Pink = ::PINK;
inline Color Color::Red = ::RED;
inline Color Color::Maroon = ::MAROON;
inline Color Color::Green = ::GREEN;
inline Color Color::Lime = ::LIME;
inline Color Color::DarkGreen = ::DARKGREEN;
inline Color Color::SkyBlue = ::SKYBLUE;
inline Color Color::Blue = ::BLUE;
inline Color Color::DarkBlue = ::DARKBLUE;
inline Color Color::Purple = ::PURPLE;
inline Color Color::Violet = ::VIOLET;
inline Color Color::DarkPurple = ::DARKPURPLE;
inline Color Color::Beige = ::BEIGE;
inline Color Color::Brown = ::BROWN;
inline Color Color::DarkBrown = ::DARKBROWN;
inline Color Color::White = ::WHITE;
inline Color Color::Black = ::BLACK;
inline Color Color::Blank = ::BLANK;
inline Color Color::Magenta = ::MAGENTA;
inline Color Color::RayWhite = ::RAYWHITE;
}
#endif
#endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_

View File

@@ -1,88 +1,107 @@
#ifndef RAYLIB_CPP_DROPPEDFILES_HPP_
#define RAYLIB_CPP_DROPPEDFILES_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "./raylib.hpp"
namespace raylib {
class DroppedFiles {
protected:
char** m_files;
int m_count;
public:
DroppedFiles() {
Get();
}
class DroppedFiles {
public:
DroppedFiles() {
Get();
}
/**
* Get the dropped files names.
*/
DroppedFiles& Get() {
m_files = ::GetDroppedFiles(&m_count);
return *this;
}
/**
* 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();
}
/**
* 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;
}
/**
* Clear dropped files paths buffer.
*/
inline DroppedFiles& Clear() {
::ClearDroppedFiles();
return *this;
}
~DroppedFiles() {
Clear();
}
~DroppedFiles() {
Clear();
}
inline std::string operator[](int pos) {
return at(pos);
}
inline std::string operator[](int pos) {
return at(pos);
}
inline int Count() const {
return m_count;
}
inline int Count() const {
return m_count;
}
inline int size() const {
return m_count;
}
inline int size() const {
return m_count;
}
inline bool empty() const {
return m_count == 0;
}
inline bool empty() const {
return m_count == 0;
}
inline void clear() {
Clear();
}
inline void clear() {
Clear();
}
inline std::string front() const {
return at(0);
}
inline std::string front() const {
return at(0);
}
inline std::string back() const {
return at(m_count - 1);
}
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 "";
}
};
}
std::string at(int pos) const {
if (m_files != NULL && pos < m_count && pos >= 0) {
return std::string(m_files[pos]);
}
return "";
}
#endif
protected:
char** m_files;
int m_count;
};
} // namespace raylib
#endif // RAYLIB_CPP_INCLUDE_DROPPEDFILES_HPP_

View File

@@ -1,103 +1,127 @@
#ifndef RAYLIB_CPP_FONT_HPP_
#define RAYLIB_CPP_FONT_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
namespace raylib {
class Font : public ::Font {
public:
Font() {
set(::GetFontDefault());
}
class Font : public ::Font {
public:
Font() {
set(::GetFontDefault());
}
Font(const std::string& fileName) {
set(::LoadFont(fileName.c_str()));
}
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 std::string& fileName, int fontSize, int* fontChars, int charCount) {
set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount));
}
Font(::Image& image, ::Color key, int firstChar) {
set(::LoadFontFromImage(image, key, firstChar));
}
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(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();
}
~Font() {
Unload();
}
void Unload() {
UnloadFont(*this);
}
void Unload() {
UnloadFont(*this);
}
GETTERSETTER(int,BaseSize,baseSize)
GETTERSETTER(int,CharsCount,charsCount)
GETTERSETTER(Texture2D,Texture,texture)
GETTERSETTER(Rectangle*,Recs,recs)
GETTERSETTER(CharInfo*,Chars,chars)
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;
}
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 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 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);
}
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;
}
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;
}
};
}
void set(const Font& font) {
baseSize = font.baseSize;
charsCount = font.charsCount;
texture = font.texture;
recs = font.recs;
chars = font.chars;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_FONT_HPP_

View File

@@ -1,81 +1,98 @@
#ifndef RAYLIB_CPP_GAMEPAD_HPP_
#define RAYLIB_CPP_GAMEPAD_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
namespace raylib {
class Gamepad {
public:
Gamepad(int gamepadNumber = 0) {
set(gamepadNumber);
}
int number;
class Gamepad {
public:
Gamepad(int gamepadNumber = 0) {
set(gamepadNumber);
}
int number;
GETTERSETTER(int,Number,number)
GETTERSETTER(int, Number, number)
Gamepad& operator=(const Gamepad& gamepad) {
set(gamepad);
return *this;
}
Gamepad& operator=(const Gamepad& gamepad) {
set(gamepad);
return *this;
}
Gamepad& operator=(int gamepadNumber) {
set(gamepadNumber);
return *this;
}
Gamepad& operator=(int gamepadNumber) {
set(gamepadNumber);
return *this;
}
operator int() const { return number; }
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 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 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 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 GetButtonPressed() const {
return ::GetGamepadButtonPressed();
}
inline int GetAxisCount() const {
return ::GetGamepadAxisCount(number);
}
inline int GetAxisCount() const {
return ::GetGamepadAxisCount(number);
}
inline float GetAxisMovement(int axis) const {
return ::GetGamepadAxisMovement(number, axis);
}
inline float GetAxisMovement(int axis) const {
return ::GetGamepadAxisMovement(number, axis);
}
protected:
inline void set(int gamepadNumber) {
number = gamepadNumber;
}
};
}
protected:
inline void set(int gamepadNumber) {
number = gamepadNumber;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_

View File

@@ -1,336 +1,371 @@
#ifndef RAYLIB_CPP_IMAGE_HPP_
#define RAYLIB_CPP_IMAGE_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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(::Texture2D texture) {
set(::GetTextureData(texture));
}
Image(int width, int height, Color color = WHITE) {
set(::GenImageColor(width, height, color));
}
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(::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(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 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 GetScreenData() {
return Image(::GetScreenData());
}
static Image GenColor(int width, int height, Color color) {
return ::GenImageColor(width, height, color);
}
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 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 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 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 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 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 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);
}
static Image GenCellular(int width, int height, int tileSize) {
return ::GenImageCellular(width, height, tileSize);
}
~Image() {
Unload();
};
~Image() {
Unload();
}
Image& operator=(const ::Image& image) {
set(image);
return *this;
}
Image& operator=(const ::Image& image) {
set(image);
return *this;
}
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 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 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 LoadAnim(const std::string& fileName, int* frames) {
set(::LoadImageAnim(fileName.c_str(), frames));
}
inline void Unload() {
::UnloadImage(*this);
};
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;
}
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)
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 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& ToPOT(Color fillColor) {
::ImageToPOT(this, fillColor);
return *this;
}
inline Image& Format(int newFormat) {
::ImageFormat(this, newFormat);
return *this;
}
inline Image& Format(int newFormat) {
::ImageFormat(this, newFormat);
return *this;
}
inline Image& AlphaMask(Image alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}
inline Image& AlphaMask(Image alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}
inline Image& AlphaCrop(float threshold) {
::ImageAlphaCrop(this, threshold);
return *this;
}
inline Image& AlphaCrop(float threshold) {
::ImageAlphaCrop(this, threshold);
return *this;
}
inline Image& AlphaPremultiply() {
::ImageAlphaPremultiply(this);
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) {
::ImageCrop(this, (Rectangle){ (float)offsetX, (float)offsetY, (float)newWidth, (float)newHeight });
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& 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& 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& 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& 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& FlipVertical() {
::ImageFlipVertical(this);
return *this;
}
inline Image& FlipHorizontal() {
::ImageFlipHorizontal(this);
return *this;
}
inline Image& RotateCW() {
::ImageRotateCW(this);
return *this;
}
inline Image& RotateCW() {
::ImageRotateCW(this);
return *this;
}
inline Image& RotateCCW() {
::ImageRotateCCW(this);
return *this;
}
inline Image& RotateCCW() {
::ImageRotateCCW(this);
return *this;
}
inline Image& ColorTint(::Color color = WHITE) {
::ImageColorTint(this, color);
return *this;
}
inline Image& ColorTint(::Color color = WHITE) {
::ImageColorTint(this, color);
return *this;
}
inline Image& ColorInvert() {
::ImageColorInvert(this);
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 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 ::Color* GetPalette(int maxPaletteSize, int *extractCount) {
return ::GetImagePalette(*this, maxPaletteSize, extractCount);
}
inline Rectangle GetAlphaBorder(float threshold) const {
return ::GetImageAlphaBorder(*this, threshold);
}
inline Rectangle GetAlphaBorder(float threshold) const {
return ::GetImageAlphaBorder(*this, threshold);
}
inline Image& ClearBackground(::Color color = WHITE) {
::ImageClearBackground(this, color);
return *this;
}
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(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& 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(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& 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(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(::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = WHITE) {
::ImageDraw(this, src, srcRec, dstRec, tint);
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(), (int)position.x, (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 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 ::Color* GetImageData() {
return ::GetImageData(*this);
}
inline ::Vector4* GetImageDataNormalized() {
return ::GetImageDataNormalized(*this);
}
inline operator Texture2D() {
return ::LoadTextureFromImage(*this);
}
inline ::Vector4* GetImageDataNormalized() {
return ::GetImageDataNormalized(*this);
}
inline operator Texture2D() {
return ::LoadTextureFromImage(*this);
}
protected:
inline void set(::Image image) {
data = image.data;
width = image.width;
height = image.height;
mipmaps = image.mipmaps;
format = image.format;
}
};
}
protected:
inline void set(::Image image) {
data = image.data;
width = image.width;
height = image.height;
mipmaps = image.mipmaps;
format = image.format;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_IMAGE_HPP_

View File

@@ -1,60 +1,76 @@
#ifndef RAYLIB_CPP_MATERIAL_HPP_
#define RAYLIB_CPP_MATERIAL_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Material : public ::Material {
public:
Material(::Material material) {
set(material);
}
Material() {
set(LoadMaterialDefault());
};
Material() {
set(LoadMaterialDefault());
}
~Material() {
Unload();
}
~Material() {
Unload();
}
GETTERSETTER(::Shader,Shader,shader)
GETTERSETTER(::Shader, Shader, shader)
Material& operator=(const ::Material& material) {
set(material);
return *this;
}
Material& operator=(const ::Material& material) {
set(material);
return *this;
}
Material& operator=(const Material& material) {
set(material);
return *this;
}
Material& operator=(const Material& material) {
set(material);
return *this;
}
inline void Unload() {
::UnloadMaterial(*this);
}
inline void Unload() {
::UnloadMaterial(*this);
}
inline Material& SetTexture(int mapType, ::Texture2D texture) {
::SetMaterialTexture(this, mapType, texture);
return *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;
}
protected:
inline void set(::Material material) {
shader = material.shader;
maps = material.maps;
params = material.params;
}
};
} // namespace raylib
};
}
#endif
#endif // RAYLIB_CPP_INCLUDE_MATERIAL_HPP_

View File

@@ -1,214 +1,242 @@
#ifndef RAYLIB_CPP_MATRIX_HPP_
#define RAYLIB_CPP_MATRIX_HPP_
/*
* 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"{
extern "C" {
#endif
#include "raylib.h"
#include "raylib.h" // NOLINT
#ifndef RAYLIB_CPP_NO_MATH
#include "raymath.h"
#include "raymath.h" // NOLINT
#endif
#ifdef __cplusplus
}
#endif
#include "./raylib-cpp-utils.hpp"
#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);
};
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;
};
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)
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;
}
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;
}
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& SetProjection() {
::SetMatrixProjection(*this);
return *this;
}
inline Matrix& SetModelview() {
::SetMatrixModelview(*this);
return *this;
}
inline Matrix& SetModelview() {
::SetMatrixModelview(*this);
return *this;
}
static Matrix GetModelview() {
return ::GetMatrixModelview();
}
static Matrix GetModelview() {
return ::GetMatrixModelview();
}
static Matrix GetProjection() {
return ::GetMatrixProjection();
}
static Matrix GetProjection() {
return ::GetMatrixProjection();
}
#ifndef RAYLIB_CPP_NO_MATH
float Trace() {
return ::MatrixTrace(*this);
}
Matrix Transpose() {
return ::MatrixTranspose(*this);
}
Matrix Invert() {
return ::MatrixInvert(*this);
}
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);
}
float Trace() {
return ::MatrixTrace(*this);
}
Matrix Transpose() {
return ::MatrixTranspose(*this);
}
Matrix Invert() {
return ::MatrixInvert(*this);
}
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 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 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 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);
}
static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up) {
return ::MatrixLookAt(eye, target, up);
}
inline float16 ToFloatV() {
return ::MatrixToFloatV(*this);
}
operator float16() {
return ToFloatV();
}
inline float16 ToFloatV() {
return ::MatrixToFloatV(*this);
}
operator float16() {
return ToFloatV();
}
#endif
protected:
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
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;
}
};
}
#endif
#endif // RAYLIB_CPP_INCLUDE_MATRIX_HPP_

View File

@@ -1,105 +1,123 @@
#ifndef RAYLIB_CPP_MESH_HPP_
#define RAYLIB_CPP_MESH_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Mesh : public ::Mesh {
public:
Mesh(::Mesh mesh) {
set(mesh);
}
Mesh(int VertexCount = 0, int TriangleCount = 0) {
vertexCount = VertexCount;
triangleCount = TriangleCount;
};
Mesh(int VertexCount = 0, int TriangleCount = 0) {
vertexCount = VertexCount;
triangleCount = TriangleCount;
}
GETTERSETTER(int,VertexCount,vertexCount)
GETTERSETTER(int,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& operator=(const Mesh& mesh) {
set(mesh);
return *this;
}
Mesh& operator=(const Mesh& mesh) {
set(mesh);
return *this;
}
~Mesh() {
Unload();
}
~Mesh() {
Unload();
}
inline Mesh& Export(const std::string& fileName) {
ExportMesh(*this, fileName.c_str());
return *this;
}
inline Mesh& Export(const std::string& fileName) {
ExportMesh(*this, fileName.c_str());
return *this;
}
inline void Unload() {
::UnloadMesh(*this);
}
inline void Unload() {
::UnloadMesh(*this);
}
inline raylib::BoundingBox BoundingBox() {
return ::MeshBoundingBox(*this);
}
operator raylib::BoundingBox() {
return BoundingBox();
}
inline raylib::BoundingBox BoundingBox() {
return ::MeshBoundingBox(*this);
}
operator raylib::BoundingBox() {
return BoundingBox();
}
inline Mesh& Tangents() {
::MeshTangents(this);
return *this;
}
inline Mesh& Tangents() {
::MeshTangents(this);
return *this;
}
inline Mesh& Binormals() {
::MeshBinormals(this);
return *this;
}
inline Mesh& Binormals() {
::MeshBinormals(this);
return *this;
}
inline Mesh& NormalsSmooth() {
::MeshNormalsSmooth(this);
return *this;
}
inline Mesh& NormalsSmooth() {
::MeshNormalsSmooth(this);
return *this;
}
inline raylib::Model LoadModelFrom() {
return ::LoadModelFromMesh(*this);
}
operator raylib::Model() {
return LoadModelFrom();
}
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;
}
};
}
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
#endif // RAYLIB_CPP_INCLUDE_MESH_HPP_

View File

@@ -1,87 +1,106 @@
#ifndef RAYLIB_CPP_MODEL_HPP_
#define RAYLIB_CPP_MODEL_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Model : public ::Model {
public:
Model(::Model model) {
set(model);
}
Model(const std::string& fileName) {
set(LoadModel(fileName.c_str()));
};
Model(const std::string& fileName) {
set(LoadModel(fileName.c_str()));
}
Model(::Mesh mesh) {
set(LoadModelFromMesh(mesh));
};
Model(::Mesh mesh) {
set(LoadModelFromMesh(mesh));
}
~Model() {
Unload();
}
~Model() {
Unload();
}
GETTERSETTER(::Matrix,Transform,transform)
GETTERSETTER(int,MeshCount,meshCount)
GETTERSETTER(int,MaterialCount,materialCount)
GETTERSETTER(::Matrix, Transform, transform)
GETTERSETTER(int, MeshCount, meshCount)
GETTERSETTER(int, MaterialCount, materialCount)
Model& operator=(const ::Model& model) {
set(model);
return *this;
}
Model& operator=(const ::Model& model) {
set(model);
return *this;
}
Model& operator=(const Model& model) {
set(model);
return *this;
}
Model& operator=(const Model& model) {
set(model);
return *this;
}
inline void Unload() {
::UnloadModel(*this);
}
inline void Unload() {
::UnloadModel(*this);
}
inline Model& SetMeshMaterial(int meshId, int materialId) {
::SetModelMeshMaterial(this, meshId, materialId);
return *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 RayHitInfo GetCollision(::Ray ray) const {
return ::GetCollisionRayModel(ray, *this);
}
inline Model& UpdateModelAnimation(::ModelAnimation anim, int frame) {
::UpdateModelAnimation(*this, anim, frame);
return *this;
}
inline Model& UpdateModelAnimation(::ModelAnimation anim, int frame) {
::UpdateModelAnimation(*this, anim, frame);
return *this;
}
inline bool IsModelAnimationValid(::ModelAnimation anim) const {
return ::IsModelAnimationValid(*this, anim);
}
inline bool IsModelAnimationValid(::ModelAnimation anim) const {
return ::IsModelAnimationValid(*this, anim);
}
protected:
inline void set(::Model model) {
transform = model.transform;
protected:
inline void set(::Model model) {
transform = model.transform;
meshCount = model.meshCount;
meshes = model.meshes;
meshCount = model.meshCount;
meshes = model.meshes;
materialCount = model.materialCount;
materials = model.materials;
meshMaterial = model.meshMaterial;
boneCount = model.boneCount;
bones = model.bones;
bindPose = model.bindPose;
}
};
}
materialCount = model.materialCount;
materials = model.materials;
meshMaterial = model.meshMaterial;
boneCount = model.boneCount;
bones = model.bones;
bindPose = model.bindPose;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_MODEL_HPP_

View File

@@ -1,68 +1,85 @@
#ifndef RAYLIB_CPP_MODEL_HPP_
#define RAYLIB_CPP_MODEL_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class ModelAnimation : public ::ModelAnimation {
public:
ModelAnimation(::ModelAnimation model) {
set(model);
}
~ModelAnimation() {
Unload();
}
~ModelAnimation() {
Unload();
}
GETTERSETTER(int,BoneCount,boneCount)
GETTERSETTER(::BoneInfo*,Bones,bones)
GETTERSETTER(int,FrameCount,frameCount)
GETTERSETTER(Transform**,FramePoses,framePoses)
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;
}
ModelAnimation& operator=(const ModelAnimation& model) {
set(model);
return *this;
}
ModelAnimation& operator=(const ModelAnimation& model) {
set(model);
return *this;
}
inline void Unload() {
::UnloadModelAnimation(*this);
}
inline void Unload() {
::UnloadModelAnimation(*this);
}
inline ModelAnimation& UpdateAnimation(::Model model, int frame) {
::UpdateModelAnimation(model, *this, frame);
return *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 IsValid(::Model model) const {
return ::IsModelAnimationValid(model, *this);
}
inline bool IsModelAnimationValid(::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;
}
};
}
protected:
inline void set(::ModelAnimation model) {
boneCount = model.boneCount;
bones = model.bones;
frameCount = model.frameCount;
framePoses = model.framePoses;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_

View File

@@ -1,82 +1,100 @@
#ifndef RAYLIB_CPP_MOUSE_HPP_
#define RAYLIB_CPP_MOUSE_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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();
}
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 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);
}
};
}
inline int GetTouchX() const {
return ::GetTouchX();
}
inline int GetTouchY() const {
return ::GetTouchY();
}
inline Vector2 GetTouchPosition(int index) const {
return ::GetTouchPosition(index);
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_MOUSE_HPP_

View File

@@ -1,99 +1,118 @@
#ifndef RAYLIB_CPP_MUSIC_HPP_
#define RAYLIB_CPP_MUSIC_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Music : public ::Music {
public:
Music(::Music music) {
set(music);
}
Music(const std::string& fileName) {
set(::LoadMusicStream(fileName.c_str()));
}
Music(const std::string& fileName) {
set(::LoadMusicStream(fileName.c_str()));
}
~Music() {
Unload();
}
~Music() {
Unload();
}
GETTERSETTER(int,CtxType,ctxType)
GETTERSETTER(bool,Looping,looping)
GETTERSETTER(unsigned int,SampleCount,sampleCount)
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;
}
Music& operator=(const Music& music) {
set(music);
return *this;
}
Music& operator=(const Music& music) {
set(music);
return *this;
}
inline void Unload() {
::UnloadMusicStream(*this);
}
inline void Unload() {
::UnloadMusicStream(*this);
}
inline Music& Play() {
::PlayMusicStream(*this);
return *this;
}
inline Music& Play() {
::PlayMusicStream(*this);
return *this;
}
inline Music& Update() {
::UpdateMusicStream(*this);
return *this;
}
inline Music& Update() {
::UpdateMusicStream(*this);
return *this;
}
inline Music& Stop() {
::StopMusicStream(*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);
}
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;
}
};
}
protected:
inline void set(::Music music) {
ctxType = music.ctxType;
ctxData = music.ctxData;
looping = music.looping;
sampleCount = music.sampleCount;
stream = music.stream;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_MUSIC_HPP_

View File

@@ -1,11 +1,35 @@
#ifndef RAYLIB_CPP_PHYSICS_HPP_
#define RAYLIB_CPP_PHYSICS_HPP_
/*
* 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_
#ifdef __cplusplus
extern "C"{
extern "C" {
#endif
#include "raylib.h"
#include "physac.h"
#include "raylib.h" // NOLINT
#include "physac.h" // NOLINT
#ifdef __cplusplus
}
#endif
@@ -13,98 +37,102 @@ extern "C"{
#include "./Vector2.hpp"
namespace raylib {
class Physics {
public:
Physics() {
Init();
};
Physics(float gravityX, float gravityY) {
Init();
SetGravity(gravityX, gravityY);
};
class Physics {
public:
Physics() {
Init();
}
Physics(float gravityY) {
Init();
SetGravity(0, gravityY);
}
Physics(float gravityX, float gravityY) {
Init();
SetGravity(gravityX, gravityY);
}
~Physics() {
Close();
}
~Physics() {
Close();
}
inline Physics& Init() {
::InitPhysics();
return *this;
}
inline Physics& Init() {
::InitPhysics();
return *this;
}
inline Physics& Close() {
::ClosePhysics();
return *this;
}
inline Physics& Close() {
::ClosePhysics();
return *this;
}
inline Physics& RunStep() {
::RunPhysicsStep();
return *this;
}
inline Physics& RunStep() {
::RunPhysicsStep();
return *this;
}
inline Physics& SetTimeStep(double delta) {
::SetPhysicsTimeStep(delta);
return *this;
}
inline Physics& SetTimeStep(double delta) {
::SetPhysicsTimeStep(delta);
return *this;
}
inline bool IsEnabled() {
return ::IsPhysicsEnabled();
}
inline bool IsEnabled() {
return ::IsPhysicsEnabled();
}
inline Physics& SetGravity(float x, float y) {
::SetPhysicsGravity(x, y);
return *this;
}
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;
}
};
}
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
#endif // RAYLIB_CPP_INCLUDE_PHYSICS_HPP_

View File

@@ -1,82 +1,101 @@
#ifndef RAYLIB_CPP_RAY_HPP_
#define RAYLIB_CPP_RAY_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Ray : public ::Ray {
public:
Ray(::Ray ray) {
set(ray);
}
Ray(::Vector3 Position, ::Vector3 Direction) {
position = Position;
direction = Direction;
};
Ray(::Vector3 Position, ::Vector3 Direction) {
position = Position;
direction = Direction;
}
Ray(::Vector2 mousePosition, ::Camera camera) {
set(GetMouseRay(mousePosition, camera));
}
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;
}
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)
GETTERSETTER(::Vector3, Position, position)
GETTERSETTER(::Vector3, Direction, direction)
inline Ray& Draw(::Color color) {
DrawRay(*this, color);
return *this;
}
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 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 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 bool CheckCollisionBox(::BoundingBox box) const {
return CheckCollisionRayBox(*this, box);
}
inline RayHitInfo GetCollisionModel(::Model model) {
return GetCollisionRayModel(*this, model);
}
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 GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) {
return GetCollisionRayTriangle(*this, p1, p2, p3);
}
inline RayHitInfo GetCollisionGround(float groundHeight) {
return GetCollisionRayGround(*this, groundHeight);
}
inline RayHitInfo GetCollisionGround(float groundHeight) {
return GetCollisionRayGround(*this, groundHeight);
}
protected:
inline void set(::Ray ray) {
position = ray.position;
direction = ray.direction;
}
};
}
protected:
inline void set(::Ray ray) {
position = ray.position;
direction = ray.direction;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_RAY_HPP_

View File

@@ -1,53 +1,70 @@
#ifndef RAYLIB_CPP_RAYHITINFO_HPP_
#define RAYLIB_CPP_RAYHITINFO_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
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(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;
}
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)
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;
}
};
}
protected:
inline void set(::RayHitInfo ray) {
hit = ray.hit;
distance = ray.distance;
position = ray.position;
normal = ray.normal;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_RAYHITINFO_HPP_

View File

@@ -1,108 +1,130 @@
#ifndef RAYLIB_CPP_RECTANGLE_HPP_
#define RAYLIB_CPP_RECTANGLE_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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;
};
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)
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;
}
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& 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& 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& 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& 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& 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& 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 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 bool CheckCollision(::Rectangle rec2) const {
return ::CheckCollisionRecs(*this, rec2);
}
inline Rectangle GetCollision(::Rectangle rec2) const {
return ::GetCollisionRec(*this, rec2);
}
inline Rectangle GetCollision(::Rectangle rec2) const {
return ::GetCollisionRec(*this, rec2);
}
inline bool CheckCollision(::Vector2 point) const {
return ::CheckCollisionPointRec(point, *this);
}
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;
}
};
}
protected:
inline void set(::Rectangle rect) {
x = rect.x;
y = rect.y;
width = rect.width;
height = rect.height;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_

View File

@@ -1,69 +1,86 @@
#ifndef RAYLIB_CPP_RenderTexture_HPP_
#define RAYLIB_CPP_RenderTexture_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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));
}
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)
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& operator=(const RenderTexture& texture) {
set(texture);
return *this;
}
RenderTexture& operator=(const RenderTexture& texture) {
set(texture);
return *this;
}
~RenderTexture() {
Unload();
};
~RenderTexture() {
Unload();
}
inline void Unload() {
UnloadRenderTexture(*this);
}
inline void Unload() {
UnloadRenderTexture(*this);
}
inline RenderTexture& BeginTextureMode() {
::BeginTextureMode(*this);
return *this;
}
inline RenderTexture& BeginTextureMode() {
::BeginTextureMode(*this);
return *this;
}
inline RenderTexture& EndTextureMode() {
::EndTextureMode();
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;
}
protected:
inline void set(::RenderTexture renderTexture) {
id = renderTexture.id;
texture = renderTexture.texture;
depth = renderTexture.depth;
}
};
typedef RenderTexture RenderTexture2D;
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_

View File

@@ -1,132 +1,149 @@
#ifndef RAYLIB_CPP_SHADER_HPP_
#define RAYLIB_CPP_SHADER_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class Shader : public ::Shader {
public:
Shader(::Shader shader) {
set(shader);
}
Shader(unsigned int Id, int* Locs) {
id = Id;
locs = Locs;
};
Shader(unsigned int Id, int* Locs) {
id = Id;
locs = Locs;
}
Shader() {
set(GetShaderDefault());
}
Shader() {
set(GetShaderDefault());
}
GETTERSETTER(unsigned int,Id,id)
GETTERSETTER(int*,Locs,locs)
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& operator=(const Shader& shader) {
set(shader);
return *this;
}
Shader& operator=(const Shader& shader) {
set(shader);
return *this;
}
~Shader() {
Unload();
}
~Shader() {
Unload();
}
void Unload() {
::UnloadShader(*this);
}
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) {
char* param1 = (char*)vsCode.c_str();
char* param2 = (char*)fsCode.c_str();
return ::LoadShaderCode(param1, param2);
}
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& BeginShaderMode() {
::BeginShaderMode(*this);
return *this;
}
inline Shader& EndShaderMode() {
::EndShaderMode();
return *this;
}
inline Shader& EndShaderMode() {
::EndShaderMode();
return *this;
}
inline int GetLocation(const std::string& uniformName) const {
return ::GetShaderLocation(*this, uniformName.c_str());
}
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 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;
}
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 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 ::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;
}
/**
* @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 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 GenTextureIrradiance(Texture2D panorama, int size) {
return ::GenTextureIrradiance(*this, panorama, size);
}
::TextureCubemap GenTexturePrefilter(Texture2D panorama, int size) {
return ::GenTexturePrefilter(*this, panorama, size);
}
::TextureCubemap GenTexturePrefilter(Texture2D panorama, int size) {
return ::GenTexturePrefilter(*this, panorama, size);
}
::Texture2D GenTextureBRDF(int size) {
return ::GenTextureBRDF(*this, size);
}
::Texture2D GenTextureBRDF(int size) {
return ::GenTextureBRDF(*this, size);
}
protected:
inline void set(::Shader shader) {
id = shader.id;
locs = shader.locs;
}
};
}
protected:
inline void set(::Shader shader) {
id = shader.id;
locs = shader.locs;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_SHADER_HPP_

View File

@@ -1,105 +1,122 @@
#ifndef RAYLIB_CPP_SOUND_HPP_
#define RAYLIB_CPP_SOUND_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
namespace raylib {
class Sound : public ::Sound {
public:
Sound(::Sound vec) {
set(vec);
};
class Sound : public ::Sound {
public:
Sound(::Sound vec) {
set(vec);
}
Sound(const std::string& fileName) {
set(LoadSound(fileName.c_str()));
};
Sound(const std::string& fileName) {
set(LoadSound(fileName.c_str()));
}
Sound(::Wave wave) {
set(LoadSoundFromWave(wave));
};
Sound(::Wave wave) {
set(LoadSoundFromWave(wave));
}
~Sound() {
Unload();
}
~Sound() {
Unload();
}
GETTERSETTER(unsigned int,SampleCount,sampleCount)
GETTERSETTER(::AudioStream,Stream,stream)
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;
}
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 Sound& Update(const void *data, int sampleCount) {
::UpdateSound(*this, data, sampleCount);
return *this;
}
inline void Unload() {
::UnloadSound(*this);
}
inline void Unload() {
::UnloadSound(*this);
}
inline Sound& Play() {
::PlaySound(*this);
return *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& 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& PlayMulti() {
::PlaySoundMulti(*this);
return *this;
}
inline Sound& StopMulti() {
::StopSoundMulti();
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;
}
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;
}
};
}
protected:
inline void set(::Sound sound) {
sampleCount = sound.sampleCount;
stream = sound.stream;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_

View File

@@ -1,166 +1,189 @@
#ifndef RAYLIB_CPP_Texture_HPP_
#define RAYLIB_CPP_Texture_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./Vector2.hpp"
#include "./Material.hpp"
namespace raylib {
class Texture : public ::Texture {
public:
Texture() {
set(::GetTextureDefault());
};
class Texture : public ::Texture {
public:
Texture() {
set(::GetTextureDefault());
}
Texture(::Image& image) {
LoadFromImage(image);
}
Texture(const ::Image& image) {
LoadFromImage(image);
}
Texture(const std::string& fileName) {
Load(fileName);
}
Texture(const std::string& fileName) {
Load(fileName);
}
~Texture() {
Unload();
};
~Texture() {
Unload();
}
GETTERSETTER(unsigned int,Id,id)
GETTERSETTER(int,Width,width)
GETTERSETTER(int,Height,height)
GETTERSETTER(int,Mipmaps,mipmaps)
GETTERSETTER(int,Format,format)
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;
}
Texture& operator=(const Texture& texture) {
set(texture);
return *this;
}
Texture& operator=(const Texture& texture) {
set(texture);
return *this;
}
void LoadFromImage(::Image& image) {
set(::LoadTextureFromImage(image));
}
void LoadFromImage(const ::Image& image) {
set(::LoadTextureFromImage(image));
}
void LoadTextureCubemap(::Image& image, int layoutType) {
set(::LoadTextureCubemap(image, layoutType));
}
void LoadTextureCubemap(const ::Image& image, int layoutType) {
set(::LoadTextureCubemap(image, layoutType));
}
void Load(const std::string& fileName) {
set(::LoadTexture(fileName.c_str()));
}
void Load(const std::string& fileName) {
set(::LoadTexture(fileName.c_str()));
}
inline void Unload() {
::UnloadTexture(*this);
}
inline void Unload() {
::UnloadTexture(*this);
}
inline Texture& Update(const void *pixels) {
::UpdateTexture(*this, pixels);
return *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 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 Image GetTextureData() const {
return ::GetTextureData(*this);
}
inline operator raylib::Image() {
return GetTextureData();
}
inline Texture& GenMipmaps() {
::GenTextureMipmaps(this);
return *this;
}
inline Texture& GenMipmaps() {
::GenTextureMipmaps(this);
return *this;
}
inline Texture& SetFilter(int filterMode) {
::SetTextureFilter(*this, filterMode);
return *this;
}
inline Texture& SetFilter(int filterMode) {
::SetTextureFilter(*this, filterMode);
return *this;
}
inline Texture& SetWrap(int wrapMode) {
::SetTextureWrap(*this, wrapMode);
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(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(::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(::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& 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& 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;
}
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);
}
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;
}
};
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;
}
// Create the Texture aliases.
typedef Texture Texture2D;
typedef Texture TextureCubemap;
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_

View File

@@ -1,12 +1,36 @@
#ifndef RAYLIB_CPP_VECTOR2_HPP_
#define RAYLIB_CPP_VECTOR2_HPP_
/*
* 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_
#ifdef __cplusplus
extern "C"{
extern "C" {
#endif
#include "raylib.h"
#include "raylib.h" // NOLINT
#ifndef RAYLIB_CPP_NO_MATH
#include "raymath.h"
#include "raymath.h" // NOLINT
#endif
#ifdef __cplusplus
}
@@ -19,217 +43,217 @@ extern "C"{
#endif
namespace raylib {
class Vector2 : public ::Vector2 {
public:
Vector2(::Vector2 vec) {
set(vec);
};
Vector2(float X = 0, float Y = 0) {
x = X;
y = Y;
};
class Vector2 : public ::Vector2 {
public:
Vector2(::Vector2 vec) {
set(vec);
}
Vector2(float X = 0, float Y = 0) {
x = X;
y = Y;
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
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;
}
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;
}
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 Add(const Vector2& vector2) {
return Vector2Add(*this, vector2);
}
Vector2 operator+(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 Subtract(const Vector2& vector2) {
return Vector2Subtract(*this, vector2);
}
Vector2 operator-(const Vector2& vector2) {
return Vector2Subtract(*this, vector2);
}
Vector2 operator-(const Vector2& vector2) {
return Vector2Subtract(*this, vector2);
}
Vector2 Negate() {
return Vector2Negate(*this);
}
Vector2 Negate() {
return Vector2Negate(*this);
}
Vector2 operator-() {
return Vector2Negate(*this);
}
Vector2 operator-() {
return Vector2Negate(*this);
}
Vector2 Multiply(const Vector2& vector2) {
return Vector2Multiply(*this, vector2);
}
Vector2 Multiply(const Vector2& vector2) {
return Vector2Multiply(*this, vector2);
}
Vector2 operator*(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 Scale(const float scale) {
return Vector2Scale(*this, scale);
}
Vector2 operator*(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 Divide(const Vector2& vector2) {
return Vector2Divide(*this, vector2);
}
Vector2 operator/(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;
Vector2& Divide(const float div) {
x /= div;
y /= div;
return *this;
}
return *this;
}
Vector2& operator/(const float div) {
x /= div;
y /= div;
Vector2& operator/(const float div) {
x /= div;
y /= div;
return *this;
}
return *this;
}
Vector2& operator+=(const Vector2& vector2) {
set(Vector2Add(*this, vector2));
Vector2& operator+=(const Vector2& vector2) {
set(Vector2Add(*this, vector2));
return *this;
}
return *this;
}
Vector2& operator-=(const Vector2& vector2) {
set(Vector2Subtract(*this, vector2));
Vector2& operator-=(const Vector2& vector2) {
set(Vector2Subtract(*this, vector2));
return *this;
}
return *this;
}
Vector2& operator*=(const Vector2& vector2) {
set(Vector2Multiply(*this, vector2));
Vector2& operator*=(const Vector2& vector2) {
set(Vector2Multiply(*this, vector2));
return *this;
}
return *this;
}
Vector2& operator*=(const float scale) {
set(Vector2Scale(*this, scale));
Vector2& operator*=(const float scale) {
set(Vector2Scale(*this, scale));
return *this;
}
return *this;
}
Vector2& operator/=(const Vector2& vector2) {
set(Vector2Divide(*this, vector2));
Vector2& operator/=(const Vector2& vector2) {
set(Vector2Divide(*this, vector2));
return *this;
}
return *this;
}
Vector2& operator/=(const float div) {
this->x /= div;
this->y /= div;
Vector2& operator/=(const float div) {
this->x /= div;
this->y /= div;
return *this;
}
return *this;
}
float Length() const {
return Vector2Length(*this);
}
float Length() const {
return Vector2Length(*this);
}
Vector2 Normalize() {
return Vector2Normalize(*this);
}
Vector2 Normalize() {
return Vector2Normalize(*this);
}
float DotProduct(const Vector2& vector2) {
return Vector2DotProduct(*this, vector2);
}
float DotProduct(const Vector2& vector2) {
return Vector2DotProduct(*this, vector2);
}
float Angle(const Vector2& vector2) {
return Vector2Angle(*this, vector2);
}
float Angle(const Vector2& vector2) {
return Vector2Angle(*this, vector2);
}
float Distance(const Vector2& vector2) {
return Vector2Distance(*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 Lerp(const Vector2& vector2, const float amount) {
return Vector2Lerp(*this, vector2, amount);
}
Vector2 Reflect(const Vector2& normal) {
return Vector2Reflect(*this, normal);
}
Vector2 Reflect(const Vector2& normal) {
return Vector2Reflect(*this, normal);
}
Vector2 Rotate(float degrees) {
return Vector2Rotate(*this, degrees);
}
Vector2 Rotate(float degrees) {
return Vector2Rotate(*this, degrees);
}
static Vector2 Zero() {
return Vector2Zero();
}
static Vector2 Zero() {
return Vector2Zero();
}
static Vector2 One() {
return Vector2One();
}
static Vector2 One() {
return Vector2One();
}
#endif
inline Vector2& DrawPixel(::Color color) {
::DrawPixelV(*this, color);
return *this;
}
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, ::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& 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& 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& 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& 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;
}
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;
}
};
}
protected:
inline void set(::Vector2 vec) {
x = vec.x;
y = vec.y;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_VECTOR2_HPP_

View File

@@ -1,12 +1,36 @@
#ifndef RAYLIB_CPP_VECTOR3_HPP_
#define RAYLIB_CPP_VECTOR3_HPP_
/*
* 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_
#ifdef __cplusplus
extern "C"{
extern "C" {
#endif
#include "raylib.h"
#include "raylib.h" // NOLINT
#ifndef RAYLIB_CPP_NO_MATH
#include "raymath.h"
#include "raymath.h" // NOLINT
#endif
#ifdef __cplusplus
}
@@ -18,290 +42,301 @@ extern "C"{
#endif
namespace raylib {
class Vector3 : public ::Vector3 {
public:
Vector3(::Vector3 vec) {
set(vec);
};
Vector3(float X = 0, float Y = 0, float Z = 0) {
x = X;
y = Y;
z = Z;
};
class Vector3 : public ::Vector3 {
public:
Vector3(::Vector3 vec) {
set(vec);
}
Vector3(float X = 0, float Y = 0, float Z = 0) {
x = X;
y = Y;
z = Z;
}
Vector3(::Color color) {
set(ColorToHSV(color));
}
Vector3(::Color color) {
set(ColorToHSV(color));
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
GETTERSETTER(float,Z,z)
GETTERSETTER(float, X, x)
GETTERSETTER(float, Y, y)
GETTERSETTER(float, Z, z)
Vector3& operator=(const ::Vector3& vector3) {
set(vector3);
return *this;
}
Vector3& operator=(const ::Vector3& vector3) {
set(vector3);
return *this;
}
Vector3& operator=(const Vector3& vector3) {
set(vector3);
return *this;
}
Vector3& operator=(const Vector3& vector3) {
set(vector3);
return *this;
}
bool operator==(const Vector3& other) {
return x == other.x
&& y == other.y
&& z == other.z;
}
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 Add(const Vector3& vector3) {
return Vector3Add(*this, vector3);
}
Vector3 operator+(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 Subtract(const Vector3& vector3) {
return Vector3Subtract(*this, vector3);
}
Vector3 operator-(const Vector3& vector3) {
return Vector3Subtract(*this, vector3);
}
Vector3 operator-(const Vector3& vector3) {
return Vector3Subtract(*this, vector3);
}
Vector3 Negate() {
return Vector3Negate(*this);
}
Vector3 Negate() {
return Vector3Negate(*this);
}
Vector3 operator-() {
return Vector3Negate(*this);
}
Vector3 operator-() {
return Vector3Negate(*this);
}
Vector3 Multiply(const Vector3& vector3) {
return Vector3Multiply(*this, vector3);
}
Vector3 Multiply(const Vector3& vector3) {
return Vector3Multiply(*this, vector3);
}
Vector3 operator*(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 Scale(const float scale) {
return Vector3Scale(*this, scale);
}
Vector3 operator*(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 Divide(const Vector3& vector3) {
return Vector3Divide(*this, vector3);
}
Vector3 operator/(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;
Vector3& Divide(const float div) {
x /= div;
y /= div;
z /= div;
return *this;
}
return *this;
}
Vector3 operator/(const float div) {
return Divide(div);
}
Vector3 operator/(const float div) {
return Divide(div);
}
Vector3& operator+=(const Vector3& vector3) {
set(Vector3Add(*this, vector3));
Vector3& operator+=(const Vector3& vector3) {
set(Vector3Add(*this, vector3));
return *this;
}
return *this;
}
Vector3& operator-=(const Vector3& vector3) {
set(Vector3Subtract(*this, vector3));
Vector3& operator-=(const Vector3& vector3) {
set(Vector3Subtract(*this, vector3));
return *this;
}
return *this;
}
Vector3& operator*=(const Vector3& vector3) {
set(Vector3Multiply(*this, vector3));
Vector3& operator*=(const Vector3& vector3) {
set(Vector3Multiply(*this, vector3));
return *this;
}
return *this;
}
Vector3& operator*=(const float scale) {
set(Vector3Scale(*this, scale));
Vector3& operator*=(const float scale) {
set(Vector3Scale(*this, scale));
return *this;
}
return *this;
}
Vector3& operator/=(const Vector3& vector3) {
x /= vector3.x;
y /= vector3.y;
z /= vector3.z;
Vector3& operator/=(const Vector3& vector3) {
x /= vector3.x;
y /= vector3.y;
z /= vector3.z;
return *this;
}
return *this;
}
Vector3& operator/=(const float div) {
x /= div;
y /= div;
z /= div;
Vector3& operator/=(const float div) {
x /= div;
y /= div;
z /= div;
return *this;
}
return *this;
}
float Length() const {
return Vector3Length(*this);
}
float Length() const {
return Vector3Length(*this);
}
Vector3 Normalize() {
return Vector3Normalize(*this);
}
Vector3 Normalize() {
return Vector3Normalize(*this);
}
float DotProduct(const Vector3& vector3) {
return Vector3DotProduct(*this, vector3);
}
float DotProduct(const Vector3& vector3) {
return Vector3DotProduct(*this, vector3);
}
float Distance(const Vector3& vector3) {
return Vector3Distance(*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 Lerp(const Vector3& vector3, const float amount) {
return Vector3Lerp(*this, vector3, amount);
}
Vector3 CrossProduct(const Vector3& vector3) {
return Vector3CrossProduct(*this, vector3);
}
Vector3 CrossProduct(const Vector3& vector3) {
return Vector3CrossProduct(*this, vector3);
}
Vector3 Perpendicular() {
return Vector3Perpendicular(*this);
}
Vector3 Perpendicular() {
return Vector3Perpendicular(*this);
}
void OrthoNormalize(Vector3* vector3) {
return Vector3OrthoNormalize(this, vector3);
}
void OrthoNormalize(Vector3* vector3) {
return Vector3OrthoNormalize(this, vector3);
}
Vector3 Transform(const ::Matrix& matrix) {
return Vector3Transform(*this, matrix);
}
Vector3 Transform(const ::Matrix& matrix) {
return Vector3Transform(*this, matrix);
}
Vector3 RotateByQuaternion(Quaternion quaternion) {
return Vector3RotateByQuaternion(*this, quaternion);
}
Vector3 RotateByQuaternion(Quaternion quaternion) {
return Vector3RotateByQuaternion(*this, quaternion);
}
Vector3 Reflect(const Vector3& normal) {
return Vector3Reflect(*this, normal);
}
Vector3 Reflect(const Vector3& normal) {
return Vector3Reflect(*this, normal);
}
Vector3 Min(const Vector3& vector3) {
return Vector3Min(*this, vector3);
}
Vector3 Min(const Vector3& vector3) {
return Vector3Min(*this, vector3);
}
Vector3 Max(const Vector3& vector3) {
return Vector3Max(*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);
}
Vector3 Barycenter(const Vector3& a, const Vector3& b, const Vector3& c) {
return Vector3Barycenter(*this, a, b, c);
}
static Vector3 Zero() {
return Vector3Zero();
}
static Vector3 Zero() {
return Vector3Zero();
}
static Vector3 One() {
return Vector3One();
}
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& 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& 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& 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& 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, 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& 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& 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& 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& 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& DrawPlane(::Vector2 size, ::Color color) {
::DrawPlane(*this, size, color);
return *this;
}
inline Vector3& DrawGizmo() {
::DrawGizmo(*this);
return *this;
}
inline Vector3& DrawGizmo() {
::DrawGizmo(*this);
return *this;
}
inline bool CheckCollision(float radiusA, Vector3 centerB, float radiusB) {
return CheckCollisionSpheres(*this, radiusA, centerB, radiusB);
}
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;
}
};
}
protected:
inline void set(::Vector3 vec) {
x = vec.x;
y = vec.y;
z = vec.z;
}
};
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_VECTOR3_HPP_

View File

@@ -1,12 +1,36 @@
#ifndef RAYLIB_CPP_VECTOR4_HPP_
#define RAYLIB_CPP_VECTOR4_HPP_
/*
* 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_
#ifdef __cplusplus
extern "C"{
extern "C" {
#endif
#include "raylib.h"
#include "raylib.h" // NOLINT
#ifndef RAYLIB_CPP_NO_MATH
#include "raymath.h"
#include "raymath.h" // NOLINT
#endif
#ifdef __cplusplus
}
@@ -15,148 +39,149 @@ extern "C"{
#include "./raylib-cpp-utils.hpp"
#ifndef RAYLIB_CPP_NO_MATH
#include <cmath>
#include <utility>
#endif
namespace raylib {
class Vector4 : public ::Vector4 {
public:
Vector4(::Vector4 vec) {
set(vec);
};
class Vector4 : public ::Vector4 {
public:
Vector4(::Vector4 vec) {
set(vec);
}
Vector4(float X = 0, float Y = 0, float Z = 0, float W = 0) {
x = X;
y = Y;
z = Z;
w = W;
};
Vector4(float X = 0, float Y = 0, float Z = 0, float W = 0) {
x = X;
y = Y;
z = Z;
w = W;
}
Vector4(::Color color) {
set(ColorNormalize(color));
}
Vector4(::Color color) {
set(ColorNormalize(color));
}
GETTERSETTER(float,X,x)
GETTERSETTER(float,Y,y)
GETTERSETTER(float,Z,z)
GETTERSETTER(float,W,w)
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;
}
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;
}
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 Multiply(const Vector4& vector4) {
return QuaternionMultiply(*this, vector4);
}
Vector4 operator*(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 Lerp(const Vector4& vector4, float amount) {
return QuaternionLerp(*this, vector4, amount);
}
Vector4 Nlerp(const Vector4& vector4, float amount) {
return QuaternionNlerp(*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);
}
Vector4 Slerp(const Vector4& vector4, float amount) {
return QuaternionSlerp(*this, vector4, amount);
}
Matrix ToMatrix() {
return QuaternionToMatrix(*this);
}
Matrix ToMatrix() {
return QuaternionToMatrix(*this);
}
float Length() const {
return QuaternionLength(*this);
}
float Length() const {
return QuaternionLength(*this);
}
Vector4 Normalize() {
return QuaternionNormalize(*this);
}
Vector4 Normalize() {
return QuaternionNormalize(*this);
}
Vector4 Invert() {
return QuaternionInvert(*this);
}
Vector4 Invert() {
return QuaternionInvert(*this);
}
void ToAxisAngle(Vector3 *outAxis, float *outAngle) {
return QuaternionToAxisAngle(*this, outAxis, outAngle);
}
void ToAxisAngle(Vector3 *outAxis, float *outAngle) {
return QuaternionToAxisAngle(*this, outAxis, outAngle);
}
std::pair<Vector3, float> ToAxisAngle() {
Vector3 outAxis;
float outAngle;
std::pair<Vector3, float> ToAxisAngle() {
Vector3 outAxis;
float outAngle;
QuaternionToAxisAngle(*this, &outAxis, &outAngle);
QuaternionToAxisAngle(*this, &outAxis, &outAngle);
std::pair<Vector3, float> out(outAxis, outAngle);
std::pair<Vector3, float> out(outAxis, outAngle);
return out;
}
return out;
}
Vector4 Transform(const ::Matrix& matrix) {
return ::QuaternionTransform(*this, matrix);
}
Vector4 Transform(const ::Matrix& matrix) {
return ::QuaternionTransform(*this, matrix);
}
static Vector4 Identity() {
return ::QuaternionIdentity();
}
static Vector4 Identity() {
return ::QuaternionIdentity();
}
static Vector4 FromVector3ToVector3(const Vector3& from , const Vector3& to) {
return ::QuaternionFromVector3ToVector3(from , to);
}
static Vector4 FromVector3ToVector3(const Vector3& from , const Vector3& to) {
return ::QuaternionFromVector3ToVector3(from , to);
}
static Vector4 FromMatrix(const ::Matrix& matrix) {
return ::QuaternionFromMatrix(matrix);
}
static Vector4 FromMatrix(const ::Matrix& matrix) {
return ::QuaternionFromMatrix(matrix);
}
static Vector4 FromAxisAngle(const Vector3& axis, const float angle) {
return ::QuaternionFromAxisAngle(axis, angle);
}
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 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);
}
static Vector4 FromEuler(const Vector3& vector3) {
return ::QuaternionFromEuler(vector3.x, vector3.y, vector3.z);
}
Vector3 ToEuler() {
return ::QuaternionToEuler(*this);
}
Vector3 ToEuler() {
return ::QuaternionToEuler(*this);
}
#endif
inline Color ColorFromNormalized() {
return ::ColorFromNormalized(*this);
}
inline Color ColorFromNormalized() {
return ::ColorFromNormalized(*this);
}
protected:
inline void set(::Vector4 vec4) {
x = vec4.x;
y = vec4.y;
z = vec4.z;
w = vec4.w;
}
};
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;
}
// Alias the Vector4 as Quaternion.
typedef Vector4 Quaternion;
} // namespace raylib
#endif
#endif // RAYLIB_CPP_INCLUDE_VECTOR4_HPP_

View File

@@ -1,63 +1,80 @@
#ifndef RAYLIB_CPP_VRSIMULATOR_HPP_
#define RAYLIB_CPP_VRSIMULATOR_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
class VrSimulator {
public:
VrSimulator() {
Init();
}
VrSimulator(::VrDeviceInfo info, ::Shader distortion) {
Init();
Set(info, distortion);
}
inline void Init() {
InitVrSimulator();
}
inline void Init() {
InitVrSimulator();
}
~VrSimulator() {
Close();
}
~VrSimulator() {
Close();
}
inline bool IsReady() const {
return ::IsVrSimulatorReady();
}
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();
}
};
}
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
#endif // RAYLIB_CPP_INCLUDE_VRSIMULATOR_HPP_

View File

@@ -1,101 +1,124 @@
#ifndef RAYLIB_CPP_WAVE_HPP_
#define RAYLIB_CPP_WAVE_HPP_
/*
* 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.
*/
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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);
};
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(
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& fileName) {
set(LoadWave(fileName.c_str()));
}
~Wave() {
Unload();
}
~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)
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;
}
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;
}
}
Wave& operator=(const Wave& wave) {
set(wave);
return *this;
}
inline Sound LoadSound() {
return ::LoadSoundFromWave(*this);
}
inline Wave& Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
::WaveFormat(this, SampleRate, SampleSize, Channels);
return *this;
}
inline float* GetWaveData() {
return ::GetWaveData(*this);
}
inline Wave Copy() {
return ::WaveCopy(*this);
}
protected:
inline void set(::Wave wave) {
sampleCount = wave.sampleCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;
channels = wave.channels;
data = wave.data;
}
};
} // namespace raylib
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 float* GetWaveData() {
return ::GetWaveData(*this);
}
protected:
inline void set(::Wave wave) {
sampleCount = wave.sampleCount;
sampleRate = wave.sampleRate;
sampleSize = wave.sampleSize;
channels = wave.channels;
data = wave.data;
}
};
}
#endif
#endif // RAYLIB_CPP_INCLUDE_WAVE_HPP_

View File

@@ -1,179 +1,198 @@
#ifndef RAYLIB_CPP_WINDOW_HPP_
#define RAYLIB_CPP_WINDOW_HPP_
/*
* 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>
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#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 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();
};
~Window() {
Close();
}
void Init(int width, int height, const std::string& title) {
::InitWindow(width, height, title.c_str());
}
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();
};
/**
* Check if KEY_ESCAPE pressed or Close icon pressed
*/
inline bool ShouldClose() {
return ::WindowShouldClose();
}
/**
* Close window and unload OpenGL context
*/
inline void Close() {
::CloseWindow();
};
/**
* Close window and unload OpenGL context
*/
inline void Close() {
::CloseWindow();
}
inline bool IsCursorOnScreen() {
return ::IsCursorOnScreen();
}
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();
}
/**
* 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 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 Window& BeginDrawing() {
::BeginDrawing();
return *this;
}
inline Window& EndDrawing() {
::EndDrawing();
return *this;
}
inline int GetScreenWidth() const {
return ::GetScreenWidth();
}
inline int GetScreenWidth() const {
return ::GetScreenWidth();
}
inline int GetScreenHeight() const {
return ::GetScreenHeight();
}
inline int GetScreenHeight() const {
return ::GetScreenHeight();
}
inline Vector2 GetPosition() const {
return ::GetWindowPosition();
}
inline Vector2 GetPosition() const {
return ::GetWindowPosition();
}
inline Vector2 GetScaleDPI() const {
return ::GetWindowScaleDPI();
}
inline Vector2 GetScaleDPI() const {
return ::GetWindowScaleDPI();
}
std::string GetMonitorName(int monitor) const {
return std::string(::GetMonitorName(monitor));
}
std::string GetMonitorName(int monitor) const {
return std::string(::GetMonitorName(monitor));
}
std::string GetClipboardText() const {
return std::string(::GetClipboardText());
}
std::string GetClipboardText() const {
return std::string(::GetClipboardText());
}
inline Window& SetClipboardText(const std::string& text) {
::SetClipboardText(text.c_str());
return *this;
}
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();
}
};
}
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
#endif // RAYLIB_CPP_INCLUDE_WINDOW_HPP_

View File

@@ -1,5 +1,29 @@
#ifndef RAYLIB_CPP_UTILS_HPP_
#define RAYLIB_CPP_UTILS_HPP_
/*
* 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
/**
@@ -10,8 +34,8 @@
* @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; }
inline type Get##method() const { return name; } \
inline void Set##method(type value) { name = value; }
#endif
#endif
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_

View File

@@ -1,55 +1,78 @@
/**
* \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();
*
* raylib::Color::RayWhite.ClearBackground();
*
* 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
*/
* 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();
*
* raylib::Color::RayWhite.ClearBackground();
*
* 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_HPP_
#define RAYLIB_CPP_HPP_
#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 yet.
}
// Nothing.
} // namespace raylib
#include "./AudioDevice.hpp"
#include "./AudioStream.hpp"
@@ -82,4 +105,4 @@ namespace raylib {
#include "./Wave.hpp"
#include "./Window.hpp"
#endif
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_

36
include/raylib.hpp Normal file
View 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_

View File

@@ -4,40 +4,40 @@ project(raylib-cpp-example)
# raylib
find_package(raylib 3.0.0 QUIET)
if (NOT raylib_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG bd512764ff7c82fa6e1395c51accb3ba18162827
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG bd512764ff7c82fa6e1395c51accb3ba18162827
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()
# raylib-cpp
find_package(raylib-cpp 3.0.1 QUIET)
if (NOT raylib-cpp_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib-cpp
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
GIT_TAG ebb379029bd8f73dc42791f5d8fc9c9e607ffd1a
)
FetchContent_GetProperties(raylib-cpp)
if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib-cpp)
set(BUILD_RAYLIB_CPP_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib-cpp_SOURCE_DIR} ${raylib-cpp_BINARY_DIR})
endif()
include(FetchContent)
FetchContent_Declare(
raylib-cpp
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
GIT_TAG ebb379029bd8f73dc42791f5d8fc9c9e607ffd1a
)
FetchContent_GetProperties(raylib-cpp)
if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib-cpp)
set(BUILD_RAYLIB_CPP_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib-cpp_SOURCE_DIR} ${raylib-cpp_BINARY_DIR})
endif()
endif()
# This is the main part:

View File

@@ -21,38 +21,37 @@
#include "raylib-cpp.hpp"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
raylib::Color background(RAYWHITE);
raylib::Color textColor(LIGHTGRAY);
raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window");
int main() {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
raylib::Color background(RAYWHITE);
raylib::Color textColor(LIGHTGRAY);
raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!w.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Main game loop
while (!w.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
background.ClearBackground();
background.ClearBackground();
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
EndDrawing();
//----------------------------------------------------------------------------------
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
return 0;
}

View File

@@ -4,35 +4,35 @@
#include "catch.hpp"
TEST_CASE("raylib_test", "[raylib_test]" ) {
SECTION("Vector2") {
raylib::Vector2 position(50, 100);
REQUIRE(position.GetX() == position.x);
position.x = 150;
REQUIRE(position.GetX() == 150);
SECTION("Vector2") {
raylib::Vector2 position(50, 100);
REQUIRE(position.GetX() == position.x);
position.x = 150;
REQUIRE(position.GetX() == 150);
// Addition operator.
raylib::Vector2 speed(10, 10);
position += speed;
REQUIRE(position.x == 160);
}
// Addition operator.
raylib::Vector2 speed(10, 10);
position += speed;
REQUIRE(position.x == 160);
}
SECTION("Window") {
REQUIRE(raylib::Window::IsReady() == false);
}
SECTION("Window") {
REQUIRE(raylib::Window::IsReady() == false);
}
SECTION("Color") {
raylib::Color c(RED);
REQUIRE(c.ToInt() == ::ColorToInt(RED));
SECTION("Color") {
raylib::Color c(RED);
REQUIRE(c.ToInt() == ::ColorToInt(RED));
c = RAYWHITE;
REQUIRE(c.r == RAYWHITE.r);
c = RAYWHITE;
REQUIRE(c.r == RAYWHITE.r);
REQUIRE(raylib::Color::LightGray.r == LIGHTGRAY.r);
}
REQUIRE(raylib::Color::LightGray.r == LIGHTGRAY.r);
}
SECTION("RayMath") {
raylib::Vector2 direction(50, 50);
raylib::Vector2 newDirection = direction.Rotate(30);
REQUIRE((int)newDirection.x == 18);
}
SECTION("RayMath") {
raylib::Vector2 direction(50, 50);
raylib::Vector2 newDirection = direction.Rotate(30);
REQUIRE((int)newDirection.x == 18);
}
}