This commit is contained in:
Rob Loach
2019-08-10 16:21:08 -04:00
parent 9bb55ed296
commit da3fa800b4
8 changed files with 118 additions and 15 deletions

View File

@@ -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 };

View File

@@ -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"

View File

@@ -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);
}

59
include/raylib/Model.hpp Normal file
View File

@@ -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

View File

@@ -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);
}
};
}

View File

@@ -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
#endif

View File

@@ -49,6 +49,10 @@ namespace raylib {
void EndShaderMode() {
EndShaderMode();
}
int GetLocation(const std::string& uniformName) {
return ::GetShaderLocation(*this, uniformName.c_str());
}
};
}

View File

@@ -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);
}