From da3fa800b4fb1e0ccc8a8c5c6d975ba0d6c7f7e4 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 10 Aug 2019 16:21:08 -0400 Subject: [PATCH] Update --- examples/core/core_3d_camera_first_person.cpp | 14 ++--- include/raylib/Camera3D.hpp | 4 +- include/raylib/Color.hpp | 16 +++++ include/raylib/Model.hpp | 59 +++++++++++++++++++ include/raylib/Rectangle.hpp | 28 ++++++++- include/raylib/RenderTexture2D.hpp | 7 ++- include/raylib/Shader.hpp | 4 ++ include/raylib/Vector3.hpp | 1 - 8 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 include/raylib/Model.hpp diff --git a/examples/core/core_3d_camera_first_person.cpp b/examples/core/core_3d_camera_first_person.cpp index 7311258..e1be227 100644 --- a/examples/core/core_3d_camera_first_person.cpp +++ b/examples/core/core_3d_camera_first_person.cpp @@ -9,7 +9,7 @@ * ********************************************************************************************/ -#include "raylib/raylib.h" +#include "raylib/raylib.hpp" #define MAX_COLUMNS 20 @@ -24,12 +24,12 @@ int main(void) raylib::Color background(RAYWHITE); // Define the camera to look into our 3d world (position, target, up vector) - raylib::Camera camera(); - camera.position = raylib::Vector3(4.0f, 2.0f, 4.0f); - camera.target = raylib::Vector3(0.0f, 1.8f, 0.0f); - camera.up = raylib::Vector3(0.0f, 1.0f, 0.0f); - camera.fovy = 60.0f; - camera.type = CAMERA_PERSPECTIVE; + raylib::Camera camera( + raylib::Vector3(4.0f, 2.0f, 4.0f), + raylib::Vector3(0.0f, 1.8f, 0.0f), + raylib::Vector3(0.0f, 1.0f, 0.0f), + 60.0f, + CAMERA_PERSPECTIVE); // Generates some random columns float heights[MAX_COLUMNS] = { 0.0f }; diff --git a/include/raylib/Camera3D.hpp b/include/raylib/Camera3D.hpp index 19bab30..01ae266 100644 --- a/include/raylib/Camera3D.hpp +++ b/include/raylib/Camera3D.hpp @@ -1,5 +1,5 @@ -#ifndef RAYLIB_CPP_CAMERA_HPP_ -#define RAYLIB_CPP_CAMERA_HPP_ +#ifndef RAYLIB_CPP_CAMERA3D_HPP_ +#define RAYLIB_CPP_CAMERA3D_HPP_ #include "raylib.h" #include "Vector3.hpp" diff --git a/include/raylib/Color.hpp b/include/raylib/Color.hpp index 059b201..31406eb 100644 --- a/include/raylib/Color.hpp +++ b/include/raylib/Color.hpp @@ -96,6 +96,22 @@ namespace raylib { ::DrawPixelV(pos, *this); } + void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) { + ::DrawLine(startPosX, startPosY, endPosX, endPosY, *this); + } + void DrawLine(::Vector2 startPos, ::Vector2 endPos) { + ::DrawLineV(startPos, endPos, *this); + } + void DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) { + ::DrawLineEx(startPos, endPos, thick, *this); + } + void DrawLineBezier(::Vector2 startPos, Vector2 endPos, float thick) { + ::DrawLineBezier(startPos, endPos, thick, *this); + } + void DrawLineStrip(::Vector2 *points, int numPoints) { + ::DrawLineStrip(points, numPoints, *this); + } + void DrawText(const std::string& text, int posX, int posY, int fontSize) { ::DrawText(text.c_str(), posX, posY, fontSize, *this); } diff --git a/include/raylib/Model.hpp b/include/raylib/Model.hpp new file mode 100644 index 0000000..2ef09e5 --- /dev/null +++ b/include/raylib/Model.hpp @@ -0,0 +1,59 @@ +#ifndef RAYLIB_CPP_MODEL_HPP_ +#define RAYLIB_CPP_MODEL_HPP_ + +#include "raylib.h" +#include "utils.hpp" +#include "Mesh.hpp" + +namespace raylib { + class Model : public ::Model { + public: + Model(::Model model) { + set(model); + }; + + Model(const std::string& fileName) { + set(LoadModel(fileName.c_str())); + }; + + Model(::Mesh mesh) { + set(LoadModelFromMesh(mesh)); + }; + + ~Model() { + Unload(); + } + + inline void set(::Model model) { + transform = model.transform; + + meshCount = model.meshCount; + meshes = model.meshes; + + materialCount = model.materialCount; + materials = model.materials; + meshMaterial = model.meshMaterial; + boneCount = model.boneCount; + bones = model.bones; + bindPose = model.bindPose; + } + + GETTERSETTER(::Matrix,Transform,transform) + GETTERSETTER(int,MeshCount,meshCount) + GETTERSETTER(int,MaterialCount,materialCount) + + void Unload() { + UnloadModel(*this); + } + + void SetMeshMaterial(int meshId, int materialId) { + SetModelMeshMaterial(this, meshId, materialId); + } + + RayHitInfo GetCollision(::Ray ray) { + return GetCollisionRayModel(ray, *this); + } + }; +} + +#endif diff --git a/include/raylib/Rectangle.hpp b/include/raylib/Rectangle.hpp index 3e9a27f..014c874 100644 --- a/include/raylib/Rectangle.hpp +++ b/include/raylib/Rectangle.hpp @@ -29,7 +29,6 @@ namespace raylib { GETTERSETTER(float,Width,width) GETTERSETTER(float,Height,height) - Rectangle& operator=(const ::Rectangle& rect) { set(rect); return *this; @@ -43,9 +42,32 @@ namespace raylib { void Draw(::Color color) { DrawRectangle(x, y, width, height, color); } - void DrawLines(::Color color) { - DrawRectangleLines(x, y, width, height, color); + void Draw(::Vector2 origin, float rotation, ::Color color) { + ::DrawRectanglePro(*this, origin, rotation, color); } + + void DrawGradientV(::Color color1, ::Color color2){ + ::DrawRectangleGradientH(x, y, width, height, color1, color2); + } + void DrawGradientH(::Color color1, ::Color color2) { + ::DrawRectangleGradientH(x, y, width, height, color1, color2); + } + void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) { + ::DrawRectangleGradientEx(*this, col1, col2, col3, col4); + } + void DrawLines(::Color color){ + ::DrawRectangleLines(x, y, width, height, color); + } + void DrawLinesEx(int lineThick, ::Color color){ + ::DrawRectangleLinesEx(*this, lineThick, color); + } + void DrawRounded(float roundness, int segments, ::Color color){ + ::DrawRectangleRounded(*this, roundness, segments, color); + } + void DrawRoundedLines(float roundness, int segments, int lineThick, ::Color color) { + ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color); + } + }; } diff --git a/include/raylib/RenderTexture2D.hpp b/include/raylib/RenderTexture2D.hpp index dd98a82..af1d94a 100644 --- a/include/raylib/RenderTexture2D.hpp +++ b/include/raylib/RenderTexture2D.hpp @@ -29,7 +29,6 @@ namespace raylib { GETTERSETTER(Texture2D,Depth,depth) GETTERSETTER(bool,DepthTexture,depthTexture) - ~RenderTexture2D() { Unload(); }; @@ -37,7 +36,11 @@ namespace raylib { void Unload() { UnloadRenderTexture(*this); } + + void BeginTextureMode() { + ::BeginTextureMode(*this); + } }; } -#endif \ No newline at end of file +#endif diff --git a/include/raylib/Shader.hpp b/include/raylib/Shader.hpp index cb254de..22ebd5e 100644 --- a/include/raylib/Shader.hpp +++ b/include/raylib/Shader.hpp @@ -49,6 +49,10 @@ namespace raylib { void EndShaderMode() { EndShaderMode(); } + + int GetLocation(const std::string& uniformName) { + return ::GetShaderLocation(*this, uniformName.c_str()); + } }; } diff --git a/include/raylib/Vector3.hpp b/include/raylib/Vector3.hpp index 6c45e26..626bb81 100644 --- a/include/raylib/Vector3.hpp +++ b/include/raylib/Vector3.hpp @@ -44,7 +44,6 @@ namespace raylib { ::DrawCubeV(*this, size, color); } - void DrawCubeWires(float width, float height, float length, ::Color color) { ::DrawCubeWires(*this, width, height, length, color); }