Update documentation

This commit is contained in:
Rob Loach
2020-12-19 15:37:11 -05:00
parent b91ce6d995
commit aed5b287c9
16 changed files with 284 additions and 6 deletions

View File

@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [v3.5.0] - xxxx-xx-xx
### Changed
- Update to raylib 3.5
### Added
- Documentation
### Removed
- Static inline Color variables (for example, `raylib::Color::RayWhite`)
- Static inline Color variables (for example, `raylib::Color::RayWhite`). Use `::RAYWHITE` instead.

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project (raylib-cpp
VERSION 3.1.0
VERSION 3.5.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX)

View File

@@ -45,6 +45,9 @@ class AudioDevice {
}
}
/**
* Close the audio device and context.
*/
~AudioDevice() {
Close();
}

View File

@@ -35,6 +35,9 @@ class BoundingBox : public ::BoundingBox {
set(box);
}
/**
* Compute mesh bounding box limits
*/
BoundingBox(::Mesh mesh) {
set(MeshBoundingBox(mesh));
}

View File

@@ -65,14 +65,23 @@ class Camera2D : public ::Camera2D {
return *this;
}
/**
* Returns camera 2d transform matrix
*/
inline Matrix GetMatrix() const {
return ::GetCameraMatrix2D(*this);
}
/**
* Returns the screen space position for a 3d world space position
*/
inline Vector2 GetWorldToScreen2D(Vector2 position) const {
return ::GetWorldToScreen2D(position, *this);
}
/**
* Returns the world space position for a 2d camera screen space position
*/
inline Vector2 GetScreenToWorld2D(Vector2 position) const {
return ::GetScreenToWorld2D(position, *this);
}

View File

@@ -68,45 +68,72 @@ class Camera3D : public ::Camera3D {
return *this;
}
/**
* Get transform matrix for camera
*/
inline Matrix GetMatrix() const {
return ::GetCameraMatrix(*this);
}
/**
* Set camera mode (multiple camera modes available)
*/
inline Camera3D& SetMode(int mode) {
::SetCameraMode(*this, mode);
return *this;
}
/**
* Set camera alt key to combine with mouse movement (free camera)
*/
inline Camera3D& SetAltControl(int altKey) {
::SetCameraAltControl(altKey);
return *this;
}
/**
* Set camera smooth zoom key to combine with mouse (free camera)
*/
inline Camera3D& SetSmoothZoomControl(int szKey) {
::SetCameraSmoothZoomControl(szKey);
return *this;
}
/**
* Set camera move controls (1st person and 3rd person cameras)
*/
inline Camera3D& SetMoveControls(int frontKey, int backKey, int rightKey, int leftKey,
int upKey, int downKey) {
::SetCameraMoveControls(frontKey, backKey, rightKey, leftKey, upKey, downKey);
return *this;
}
/**
* Update camera position for selected mode
*/
inline Camera3D& Update() {
::UpdateCamera(this);
return *this;
}
/**
* Update VR tracking (position and orientation) and camera
*/
inline Camera3D& UpdateVrTracking() {
::UpdateVrTracking(this);
return *this;
}
/**
* Returns a ray trace from mouse position
*/
inline Ray GetMouseRay(::Vector2 mousePosition) const {
return ::GetMouseRay(mousePosition, *this);
}
/**
* Returns the screen space position for a 3d world space position
*/
inline Vector2 GetWorldToScreen(::Vector3 position) const {
return ::GetWorldToScreen(position, *this);
}

View File

@@ -73,14 +73,23 @@ class Color : public ::Color {
operator int() const { return ::ColorToInt(*this); }
/**
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
*/
Color Fade(float alpha) const {
return ::Fade(*this, alpha);
}
/**
* Returns Color normalized as float [0..1]
*/
Vector4 Normalize() const {
return ::ColorNormalize(*this);
}
/**
* Returns HSV values for a Color
*/
Vector3 ToHSV() const {
return ::ColorToHSV(*this);
}
@@ -121,6 +130,9 @@ class Color : public ::Color {
return *this;
}
/**
* Draw a line
*/
inline Color& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) {
::DrawLine(startPosX, startPosY, endPosX, endPosY, *this);
return *this;

View File

@@ -52,42 +52,72 @@ class Gamepad {
operator int() const { return number; }
/**
* Detect if a gamepad is available
*/
inline bool IsAvailable() const {
return ::IsGamepadAvailable(number);
}
/**
* Check gamepad name (if available)
*/
inline bool IsName(const std::string& name) const {
return ::IsGamepadName(number, name.c_str());
}
/**
* Return gamepad internal name id
*/
std::string GetName() const {
return std::string(::GetGamepadName(number));
}
/**
* Detect if a gamepad button has been pressed once
*/
inline bool IsButtonPressed(int button) const {
return ::IsGamepadButtonPressed(number, button);
}
/**
* Detect if a gamepad button is being pressed
*/
inline bool IsButtonDown(int button) const {
return ::IsGamepadButtonDown(number, button);
}
/**
* Detect if a gamepad button has been released once
*/
inline bool IsButtonReleased(int button) const {
return ::IsGamepadButtonReleased(number, button);
}
/**
* Detect if a gamepad button is NOT being pressed
*/
inline bool IsButtonUp(int button) const {
return ::IsGamepadButtonUp(number, button);
}
/**
* Get the last gamepad button pressed
*/
inline int GetButtonPressed() const {
return ::GetGamepadButtonPressed();
}
/**
* Return gamepad axis count for a gamepad
*/
inline int GetAxisCount() const {
return ::GetGamepadAxisCount(number);
}
/**
* Return axis movement value for a gamepad axis
*/
inline float GetAxisMovement(int axis) const {
return ::GetGamepadAxisMovement(number, axis);
}

View File

@@ -95,24 +95,39 @@ class Image : public ::Image {
return ::GenImageGradientH(width, height, left, right);
}
/**
* Generate image: radial gradient
*/
static Image GenGradientRadial(int width, int height, float density,
Color inner, Color outer) {
return ::GenImageGradientRadial(width, height, density, inner, outer);
}
/**
* Generate image: checked
*/
static Image GenChecked(int width, int height, int checksX, int checksY,
Color col1, Color col2) {
return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
}
/**
* Generate image: white noise
*/
static Image GenWhiteNoise(int width, int height, float factor) {
return ::GenImageWhiteNoise(width, height, factor);
}
/**
* Generate image: perlin noise
*/
static Image GenPerlinNoise(int width, int height, int offsetX, int offsetY, float scale) {
return ::GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
}
/**
* Generate image: cellular algorithm. Bigger tileSize means bigger cells
*/
static Image GenCellular(int width, int height, int tileSize) {
return ::GenImageCellular(width, height, tileSize);
}
@@ -288,65 +303,110 @@ class Image : public ::Image {
return *this;
}
/**
* Flip image vertically
*/
inline Image& FlipVertical() {
::ImageFlipVertical(this);
return *this;
}
/**
* Flip image horizontally
*/
inline Image& FlipHorizontal() {
::ImageFlipHorizontal(this);
return *this;
}
/**
* Rotate image clockwise 90deg
*/
inline Image& RotateCW() {
::ImageRotateCW(this);
return *this;
}
/**
* Rotate image counter-clockwise 90deg
*/
inline Image& RotateCCW() {
::ImageRotateCCW(this);
return *this;
}
/**
* Modify image color: tint
*/
inline Image& ColorTint(::Color color = WHITE) {
::ImageColorTint(this, color);
return *this;
}
/**
* Modify image color: invert
*/
inline Image& ColorInvert() {
::ImageColorInvert(this);
return *this;
}
/**
* Modify image color: grayscale
*/
inline Image& ColorGrayscale() {
::ImageColorGrayscale(this);
return *this;
}
/**
* Modify image color: contrast
*
* @param contrast Contrast values between -100 and 100
*/
inline Image& ColorContrast(float contrast) {
::ImageColorContrast(this, contrast);
return *this;
}
/**
* Modify image color: brightness
*
* @param brightness Brightness values between -255 and 255
*/
inline Image& ColorBrightness(int brightness) {
::ImageColorBrightness(this, brightness);
return *this;
}
/**
* Modify image color: replace color
*/
inline Image& ColorReplace(::Color color, ::Color replace) {
::ImageColorReplace(this, color, replace);
return *this;
}
/**
* Get image alpha border rectangle
*
* @param threshold Threshold is defined as a percentatge: 0.0f -> 1.0f
*/
inline Rectangle GetAlphaBorder(float threshold) const {
return ::GetImageAlphaBorder(*this, threshold);
}
/**
* Clear image background with given color
*/
inline Image& ClearBackground(::Color color = WHITE) {
::ImageClearBackground(this, color);
return *this;
}
/**
* Draw pixel within an image
*/
inline Image& DrawPixel(int posX, int posY, ::Color color) {
::ImageDrawPixel(this, posX, posY, color);
return *this;

View File

@@ -38,6 +38,9 @@ class Material : public ::Material {
set(material);
}
/**
* Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
*/
Material() {
set(LoadMaterialDefault());
}
@@ -67,6 +70,9 @@ class Material : public ::Material {
return *this;
}
/**
* Unload material from memory
*/
inline void Unload() {
::UnloadMaterial(*this);
}

View File

@@ -91,25 +91,40 @@ class Mesh : public ::Mesh {
return BoundingBox();
}
/**
* Compute mesh tangents
*/
inline Mesh& Tangents() {
::MeshTangents(this);
return *this;
}
/**
* Compute mesh binormals (aka bitangent)
*/
inline Mesh& Binormals() {
::MeshBinormals(this);
return *this;
}
/**
* Smooth (average) vertex normals
*/
inline Mesh& NormalsSmooth() {
::MeshNormalsSmooth(this);
return *this;
}
/**
* Load model from generated mesh
*/
inline raylib::Model LoadModelFrom() {
return ::LoadModelFromMesh(*this);
}
/**
* Load model from generated mesh
*/
operator raylib::Model() {
return ::LoadModelFromMesh(*this);
}

View File

@@ -37,10 +37,16 @@ class Music : public ::Music {
set(music);
}
/**
* Load music stream from file
*/
Music(const std::string& fileName) {
set(::LoadMusicStream(fileName.c_str()));
}
/**
* Unload music stream
*/
~Music() {
Unload();
}
@@ -59,6 +65,9 @@ class Music : public ::Music {
return *this;
}
/**
* Unload music stream
*/
inline void Unload() {
::UnloadMusicStream(*this);
}
@@ -71,44 +80,71 @@ class Music : public ::Music {
return *this;
}
/**
* Updates buffers for music streaming
*/
inline Music& Update() {
::UpdateMusicStream(*this);
return *this;
}
/**
* Stop music playing
*/
inline Music& Stop() {
::StopMusicStream(*this);
return *this;
}
/**
* Pause music playing
*/
inline Music& Pause() {
::PauseMusicStream(*this);
return *this;
}
/**
* Resume music playing
*/
inline Music& Resume() {
::ResumeMusicStream(*this);
return *this;
}
/**
* Check if music is playing
*/
inline bool IsPlaying() const {
return ::IsMusicPlaying(*this);
}
/**
* Set volume for music
*/
inline Music& SetVolume(float volume) {
::SetMusicVolume(*this, volume);
return *this;
}
/**
* Set pitch for music
*/
inline Music& SetPitch(float pitch) {
::SetMusicPitch(*this, pitch);
return *this;
}
/**
* Get music time length (in seconds)
*/
inline float GetTimeLength() const {
return ::GetMusicTimeLength(*this);
}
/**
* Get current music time played (in seconds)
*/
inline float GetTimePlayed() const {
return ::GetMusicTimePlayed(*this);
}

View File

@@ -163,42 +163,86 @@ class Vector2 : public ::Vector2 {
return *this;
}
/**
* Calculate vector length
*/
float Length() const {
return Vector2Length(*this);
}
/**
* Calculate vector square length
*/
float LengthSqr() {
return Vector2LengthSqr(*this);
}
/**
* Normalize provided vector
*/
Vector2 Normalize() {
return Vector2Normalize(*this);
}
/**
* Calculate two vectors dot product
*/
float DotProduct(const Vector2& vector2) {
return Vector2DotProduct(*this, vector2);
}
/**
* Calculate angle from two vectors in X-axis
*/
float Angle(const Vector2& vector2) {
return Vector2Angle(*this, vector2);
}
/**
* Calculate distance between two vectors
*/
float Distance(const Vector2& vector2) {
return Vector2Distance(*this, vector2);
}
/**
* Calculate linear interpolation between two vectors
*/
Vector2 Lerp(const Vector2& vector2, const float amount) {
return Vector2Lerp(*this, vector2, amount);
}
/**
* Calculate reflected vector to normal
*/
Vector2 Reflect(const Vector2& normal) {
return Vector2Reflect(*this, normal);
}
/**
* Rotate Vector by float in Degrees
*/
Vector2 Rotate(float degrees) {
return Vector2Rotate(*this, degrees);
}
/**
* Move Vector towards target
*/
Vector2 MoveTowards(Vector2 target, float maxDistance) {
return Vector2MoveTowards(*this, target, maxDistance);
}
/**
* Vector with components value 0.0f
*/
static Vector2 Zero() {
return Vector2Zero();
}
/**
* Vector with components value 1.0f
*/
static Vector2 One() {
return Vector2One();
}

View File

@@ -40,43 +40,70 @@ class VrSimulator {
Set(info, distortion);
}
/**
* Init VR simulator for selected device parameters
*/
inline void Init() {
InitVrSimulator();
}
/**
* Close VR simulator for current device
*/
~VrSimulator() {
Close();
}
/**
* Detect if VR simulator is ready
*/
inline bool IsReady() const {
return ::IsVrSimulatorReady();
}
/**
* Update VR tracking (position and orientation) and camera
*/
inline VrSimulator& Update(Camera *camera) {
::UpdateVrTracking(camera);
return *this;
}
/**
* Set stereo rendering configuration parameters
*/
inline VrSimulator& Set(::VrDeviceInfo info, ::Shader distortion) {
::SetVrConfiguration(info, distortion);
return *this;
}
/**
* Enable/Disable VR experience
*/
inline VrSimulator& Toggle() {
::ToggleVrMode();
return *this;
}
/**
* Begin VR simulator stereo rendering
*/
inline VrSimulator& Begin() {
::BeginVrDrawing();
return *this;
}
/**
* End VR simulator stereo rendering
*/
inline VrSimulator& End() {
::EndVrDrawing();
return *this;
}
/**
* Close VR simulator for current device
*/
inline void Close() {
::CloseVrSimulator();
}

View File

@@ -109,7 +109,7 @@ class Wave : public ::Wave {
* Export wave data to file, returns true on success
*/
inline bool Export(const std::string& fileName) {
// TODO: Throw exception on error.
// TODO(RobLoach): Throw exception on error.
return ::ExportWave(*this, fileName.c_str());
}
@@ -117,7 +117,7 @@ class Wave : public ::Wave {
* Export wave sample data to code (.h), returns true on success
*/
inline bool ExportAsCode(const std::string& fileName) {
// TODO: Throw exception on error.
// TODO(RobLoach): Throw exception on error.
return ::ExportWaveAsCode(*this, fileName.c_str());
}

View File

@@ -1,6 +1,6 @@
{
"name": "raylib-cpp",
"version": "3.1.0",
"version": "3.5.0",
"repo": "robloach/raylib-cpp",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"keywords": ["raylib"],