Skip to content

Commit 7a4d64b

Browse files
committed
Update
1 parent 6b5db70 commit 7a4d64b

File tree

11 files changed

+69
-13
lines changed

11 files changed

+69
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.11)
22
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33
project (raylib-cpp
4-
VERSION 3.5.0
4+
VERSION 3.6.0
55
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
66
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
77
LANGUAGES C CXX)

include/Image.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Image : public ::Image {
9797
* Generate image: checked
9898
*/
9999
static ::Image Checked(int width, int height, int checksX, int checksY,
100-
::Color col1, ::Color col2) {
100+
::Color col1 = {255, 255, 255, 255}, ::Color col2 = {0, 0, 0, 255}) {
101101
return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
102102
}
103103

include/Material.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ class Material : public ::Material {
6565
return *this;
6666
}
6767

68+
/**
69+
* Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
70+
*/
71+
inline Material& SetModelMesh(int meshId, int materialId) {
72+
::SetModelMeshMaterial(this, meshId, materialId);
73+
return *this;
74+
}
75+
6876
private:
6977
inline void set(const ::Material& material) {
7078
shader = material.shader;

include/Mesh.hpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ class Mesh : public ::Mesh {
1919
set(mesh);
2020
}
2121

22-
Mesh(int VertexCount = 0, int TriangleCount = 0) {
22+
Mesh(int VertexCount, int TriangleCount) {
2323
vertexCount = VertexCount;
2424
triangleCount = TriangleCount;
2525
}
2626

27+
Mesh(int vertexCount) {
28+
set(GenMeshDefault(vertexCount));
29+
}
30+
2731
/**
2832
* Load meshes from model file
2933
*/
@@ -33,6 +37,13 @@ class Mesh : public ::Mesh {
3337
// return std::vector<Mesh>(meshes, meshes + count);
3438
// }
3539

40+
/**
41+
* Generate default mesh
42+
*/
43+
static ::Mesh Default(int vertexCount) {
44+
return ::GenMeshDefault(vertexCount);
45+
}
46+
3647
/**
3748
* Generate polygonal mesh
3849
*/
@@ -135,6 +146,21 @@ class Mesh : public ::Mesh {
135146
::UploadMesh(this, dynamic);
136147
}
137148

149+
/**
150+
* Upload mesh vertex data to GPU (VRAM)
151+
*/
152+
inline void UpdateBuffer(int index, void *data, int dataSize, int offset = 0) {
153+
::UpdateMeshBuffer(*this, index, data, dataSize, offsetof);
154+
}
155+
156+
inline void Draw(const ::Material& material, const ::Matrix& transform) {
157+
::DrawMesh(*this, material, transform);
158+
}
159+
160+
inline void DrawInstanced(const ::Material& material, ::Matrix* transforms, int instances) {
161+
::DrawMeshInstanced(*this, material, transforms, instances);
162+
}
163+
138164
/**
139165
* Export mesh data to file
140166
*/

include/Model.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Model : public ::Model {
8181
/**
8282
* Update model animation pose
8383
*/
84-
inline Model& UpdateModelAnimation(const ::ModelAnimation& anim, int frame) {
84+
inline Model& UpdateAnimation(const ::ModelAnimation& anim, int frame) {
8585
::UpdateModelAnimation(*this, anim, frame);
8686
return *this;
8787
}

include/Music.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class Music : public ::Music {
2323
set(::LoadMusicStream(fileName.c_str()));
2424
}
2525

26+
/**
27+
* Load music stream from memory
28+
*/
29+
Music(const std::string& fileType, unsigned char* data, int dataSize) {
30+
set(::LoadMusicStreamFromMemory(fileType.c_str(), data, dataSize));
31+
}
32+
2633
/**
2734
* Unload music stream
2835
*/

include/Shader.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class Shader : public ::Shader {
3333
return ::LoadShader(vsFileName.c_str(), fsFileName.c_str());
3434
}
3535

36+
static ::Shader LoadFromMemory(const std::string& vsCode, const std::string& fsCode) {
37+
return ::LoadShaderFromMemory(vsCode.c_str(), fsCode.c_str());
38+
}
39+
3640
GETTERSETTER(unsigned int, Id, id)
3741
GETTERSETTER(int*, Locs, locs)
3842

@@ -46,7 +50,13 @@ class Shader : public ::Shader {
4650
}
4751

4852
void Unload() {
49-
::UnloadShader(*this);
53+
if (locs != NULL) {
54+
::UnloadShader(*this);
55+
}
56+
}
57+
58+
inline Shader& LoadFromMemory(const std::string& vsCode, const std::string& fsCode) {
59+
set(::LoadShaderFromMemory(vsCode.c_str(), fsCode.c_str()));
5060
}
5161

5262
/**

include/Texture.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ class Texture : public ::Texture {
204204
return *this;
205205
}
206206

207+
inline Texture& DrawPoly(Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint = {255, 255, 255, 255}) {
208+
::DrawTexturePoly(*this, center, points, texcoords, pointsCount, tint);
209+
return *this;
210+
}
211+
207212
/**
208213
* Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
209214
*/

projects/CMake/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
22
project(raylib-cpp-example)
33

44
# raylib
5-
find_package(raylib 3.5.0 QUIET)
5+
find_package(raylib 3.7.0 QUIET)
66
if (NOT raylib_FOUND)
77
include(FetchContent)
88
FetchContent_Declare(
99
raylib
1010
GIT_REPOSITORY https://github.com/raysan5/raylib.git
11-
GIT_TAG e25e380e80a117f2404d65b37700fb620dc1f990
11+
GIT_TAG b6c8d343dca2ef19c23c50975328a028124cf3cb
1212
)
1313
FetchContent_GetProperties(raylib)
1414
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
@@ -22,13 +22,13 @@ if (NOT raylib_FOUND)
2222
endif()
2323

2424
# raylib-cpp
25-
find_package(raylib-cpp 3.5.0 QUIET)
25+
find_package(raylib-cpp 3.6.0 QUIET)
2626
if (NOT raylib-cpp_FOUND)
2727
include(FetchContent)
2828
FetchContent_Declare(
2929
raylib-cpp
3030
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
31-
GIT_TAG 21d26ca66e3a8fc70a39ad13b40dcabbc1840a78
31+
GIT_TAG 6b5db70b4f9b90c60a53dea13157a01e01092bd5
3232
)
3333
FetchContent_GetProperties(raylib-cpp)
3434
if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet?

projects/CMake/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
* You can find all basic examples on C:\raylib\raylib\examples folder or
1111
* raylib official webpage: www.raylib.com
1212
*
13-
* Enjoy using raylib. :)
13+
* Enjoy using raylib-cpp. :)
1414
*
1515
* This example has been created using raylib 1.0 (www.raylib.com)
16-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
16+
* raylib-cpp is licensed under an unmodified zlib/libpng license (View raylib-cpp.hpp for details)
1717
*
18-
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
18+
* Copyright (c) 2021 Rob Loach (@RobLoach)
1919
*
2020
********************************************************************************************/
2121

0 commit comments

Comments
 (0)