diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a03fe99..31d0b33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ 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). -## [x.x.x] - Unreleased +## [3.5.0-beta3] - 2021-02-18 ### Added - Added a C++ version of raylib's loading thread example (by (@pkeir)[https://github.com/pkeir]) +- Updated documentation ### Fixed - Made the global wrapped functions static to avoid redeclaration diff --git a/CPPLINT.cfg b/CPPLINT.cfg index a1d09215..14d6dd00 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,6 +1,6 @@ set noparent root=.. -linelength=100 +linelength=120 exclude_files=vendor exclude_files=docs filter=-runtime/explicit diff --git a/examples/audio/audio_music_stream.cpp b/examples/audio/audio_music_stream.cpp index fb1565d0..b68b7a48 100644 --- a/examples/audio/audio_music_stream.cpp +++ b/examples/audio/audio_music_stream.cpp @@ -32,7 +32,7 @@ int main() { //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -63,7 +63,7 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY); @@ -74,7 +74,7 @@ int main() { DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY); DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/audio/audio_sound_loading.cpp b/examples/audio/audio_sound_loading.cpp index 425f44a0..fe7b4fac 100644 --- a/examples/audio/audio_sound_loading.cpp +++ b/examples/audio/audio_sound_loading.cpp @@ -39,12 +39,12 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY); DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/core/core_3d_camera_first_person.cpp b/examples/core/core_3d_camera_first_person.cpp index 36eb94dd..a2f8ac60 100644 --- a/examples/core/core_3d_camera_first_person.cpp +++ b/examples/core/core_3d_camera_first_person.cpp @@ -44,11 +44,11 @@ int main() { camera.SetMode(CAMERA_FIRST_PERSON); // Set a first person camera mode - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!window.ShouldClose()) // Detect window close button or ESC key + while (!window.ShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -58,11 +58,11 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); camera.BeginMode(); - + { DrawPlane(Vector3{ 0.0f, 0.0f, 0.0f }, Vector2{ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground DrawCube(Vector3{ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall DrawCube(Vector3{ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall @@ -74,16 +74,16 @@ int main() { positions[i].DrawCube(2.0f, heights[i], 2.0f, colors[i]); positions[i].DrawCubeWires(2.0f, heights[i], 2.0f, MAROON); } - + } camera.EndMode(); - DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); + DrawRectangle( 10, 10, 220, 70, raylib::Color::SkyBlue().Fade(0.5f)); DrawRectangleLines( 10, 10, 220, 70, BLUE); DrawText("First person camera default controls:", 20, 20, 10, BLACK); DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY); DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/core/core_basic_window.cpp b/examples/core/core_basic_window.cpp index 89253433..dbd753a6 100644 --- a/examples/core/core_basic_window.cpp +++ b/examples/core/core_basic_window.cpp @@ -43,11 +43,10 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - - ClearBackground(RAYWHITE); - - textColor.DrawText("Congrats! You created your first window!", 190, 200, 20); - + { + ClearBackground(RAYWHITE); + textColor.DrawText("Congrats! You created your first window!", 190, 200, 20); + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/core/core_drop_files.cpp b/examples/core/core_drop_files.cpp index 7078f5c6..59ceabe9 100644 --- a/examples/core/core_drop_files.cpp +++ b/examples/core/core_drop_files.cpp @@ -51,13 +51,13 @@ int main() { // Iterate through all the dropped files. for (int i = 0; i < droppedFiles.size(); i++) { - if (i%2 == 0) + if (i % 2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); else 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); + DrawText(droppedFiles[i].c_str(), 120, 100 + 40 * i, 10, GRAY); } DrawText("Drop new files...", 100, 110 + 40 * droppedFiles.size(), 20, DARKGRAY); diff --git a/examples/core/core_input_mouse.cpp b/examples/core/core_input_mouse.cpp index fed16c07..abb6f315 100644 --- a/examples/core/core_input_mouse.cpp +++ b/examples/core/core_input_mouse.cpp @@ -42,13 +42,13 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); ballPosition.DrawCircle(40, ballColor); textColor.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/core/core_loading_thread.cpp b/examples/core/core_loading_thread.cpp index 770d162f..02e0b793 100644 --- a/examples/core/core_loading_thread.cpp +++ b/examples/core/core_loading_thread.cpp @@ -90,6 +90,7 @@ int main(void) // Draw //---------------------------------------------------------------------- BeginDrawing(); + { ClearBackground(RAYWHITE); @@ -110,12 +111,10 @@ int main(void) DrawRectangle(150, 200, 500, 60, LIME); DrawText("DATA LOADED!", 250, 210, 40, GREEN); break; - - default: - break; } DrawRectangleLines(150, 200, 500, 60, DARKGRAY); + } EndDrawing(); //---------------------------------------------------------------------- diff --git a/examples/core/core_random_values.cpp b/examples/core/core_random_values.cpp index 7090afc3..99f0ed01 100644 --- a/examples/core/core_random_values.cpp +++ b/examples/core/core_random_values.cpp @@ -44,13 +44,13 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON); DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/core/core_world_screen.cpp b/examples/core/core_world_screen.cpp index f87269cc..7f380078 100644 --- a/examples/core/core_world_screen.cpp +++ b/examples/core/core_world_screen.cpp @@ -49,21 +49,21 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); - BeginMode3D(camera); - + camera.BeginMode(); + { DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - - EndMode3D(); + } + camera.EndMode(); DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, cubeScreenPosition.y, 20, BLACK); DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20))/2, 25, 20, GRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/models/models_billboard.cpp b/examples/models/models_billboard.cpp index 8bf2053d..0a902ba5 100644 --- a/examples/models/models_billboard.cpp +++ b/examples/models/models_billboard.cpp @@ -47,19 +47,19 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); + { ClearBackground(RAYWHITE); camera.BeginMode(); - + { DrawGrid(10, 1.0f); // Draw a grid - camera.DrawBillboard(bill, billPosition, 2.0f, WHITE); - + } camera.EndMode(); DrawFPS(10, 10); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/models/models_first_person_maze.cpp b/examples/models/models_first_person_maze.cpp index abdef839..6757fc6d 100644 --- a/examples/models/models_first_person_maze.cpp +++ b/examples/models/models_first_person_maze.cpp @@ -88,14 +88,14 @@ int main(void) // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); camera.BeginMode(); - + { model.Draw(mapPosition); // Draw maze map // playerPosition.DrawCube((Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player - + } camera.EndMode(); cubicmap.Draw((Vector2){ static_cast(GetScreenWidth() - cubicmap.width*4 - 20), 20 }, 0.0f, 4.0f, WHITE); @@ -105,7 +105,7 @@ int main(void) DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED); DrawFPS(10, 10); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/multiple/Player.cpp b/examples/multiple/Player.cpp index 869ead07..4ae9b45b 100644 --- a/examples/multiple/Player.cpp +++ b/examples/multiple/Player.cpp @@ -4,8 +4,8 @@ Player::Player() { position = Rectangle{ - GetScreenWidth() / 2 - 50, - GetScreenHeight() / 2 - 50, + GetScreenWidth() / 2.0f - 50, + GetScreenHeight() / 2.0f - 50, 100, 100 }; diff --git a/examples/multiple/main.cpp b/examples/multiple/main.cpp index a0e0d743..947e45a8 100644 --- a/examples/multiple/main.cpp +++ b/examples/multiple/main.cpp @@ -9,9 +9,11 @@ int main() { Player player; while (!window.ShouldClose()) { window.BeginDrawing(); - ClearBackground(SKYBLUE); - player.Update(); - player.Draw(); + { + ClearBackground(SKYBLUE); + player.Update(); + player.Draw(); + } window.EndDrawing(); } diff --git a/examples/physics/physics_demo.cpp b/examples/physics/physics_demo.cpp index 39dbdb8e..b187c58c 100644 --- a/examples/physics/physics_demo.cpp +++ b/examples/physics/physics_demo.cpp @@ -92,7 +92,7 @@ int main(void) // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(BLACK); DrawFPS(screenWidth - 90, screenHeight - 30); @@ -126,7 +126,7 @@ int main(void) DrawText("Physac", logoX, logoY, 30, WHITE); DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/shapes/shapes_collision_area.cpp b/examples/shapes/shapes_collision_area.cpp index 8458f403..6ced6ca3 100644 --- a/examples/shapes/shapes_collision_area.cpp +++ b/examples/shapes/shapes_collision_area.cpp @@ -30,7 +30,6 @@ int main(void) raylib::Rectangle boxB(GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60); raylib::Rectangle boxCollision(0); // Collision rectangle - ///raylib::Rectangle boxCollision(0,0); // Collision rectangle int screenUpperLimit = 40; // Top menu limits diff --git a/examples/shapes/shapes_logo_raylib.cpp b/examples/shapes/shapes_logo_raylib.cpp index 69305c94..98b845d6 100644 --- a/examples/shapes/shapes_logo_raylib.cpp +++ b/examples/shapes/shapes_logo_raylib.cpp @@ -35,7 +35,7 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); foreground.DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256); @@ -44,7 +44,7 @@ int main() { foreground.DrawText("cpp", screenWidth/2 - 74, screenHeight/2 + 54, 50); DrawText("this is NOT a texture!", 350, 370, 10, GRAY); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/text/text_font_loading.cpp b/examples/text/text_font_loading.cpp index 1cc959dc..f42b5d58 100644 --- a/examples/text/text_font_loading.cpp +++ b/examples/text/text_font_loading.cpp @@ -59,6 +59,7 @@ int main() { // Draw //---------------------------------------------------------------------------------- window.BeginDrawing(); + { ClearBackground(RAYWHITE); @@ -74,8 +75,8 @@ int main() { fontTtf.DrawText(msg, (Vector2){ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME); DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY); } - - EndDrawing(); + } + window.EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/text/text_font_spritefont.cpp b/examples/text/text_font_spritefont.cpp index 97a4d83a..6a988b90 100644 --- a/examples/text/text_font_spritefont.cpp +++ b/examples/text/text_font_spritefont.cpp @@ -54,13 +54,13 @@ int main(void) // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); font1.DrawText(msg1, fontPosition1, font1.baseSize, -3); font2.DrawText(msg2, fontPosition2, font2.baseSize, -2); font3.DrawText(msg3, fontPosition3, font3.baseSize, 2); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/text/text_raylib_fonts.cpp b/examples/text/text_raylib_fonts.cpp index 9f53ae2f..e6dd00e0 100644 --- a/examples/text/text_raylib_fonts.cpp +++ b/examples/text/text_raylib_fonts.cpp @@ -82,7 +82,7 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); textColor.DrawText("free fonts included with raylib", 250, 20, 20); @@ -92,7 +92,7 @@ int main() { { fonts[i].DrawText(messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); } - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/textures/textures_bunnymark.cpp b/examples/textures/textures_bunnymark.cpp index 1a1781a3..be6c2e85 100644 --- a/examples/textures/textures_bunnymark.cpp +++ b/examples/textures/textures_bunnymark.cpp @@ -90,7 +90,7 @@ int main(void) // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { ClearBackground(RAYWHITE); for (Bunny& bunny: bunnies) { @@ -108,7 +108,7 @@ int main(void) DrawText(FormatText("batched draw calls: %i", 1 + bunnies.size()/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON); DrawFPS(10, 10); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/textures/textures_image_drawing.cpp b/examples/textures/textures_image_drawing.cpp index f760da5e..73b324c6 100644 --- a/examples/textures/textures_image_drawing.cpp +++ b/examples/textures/textures_image_drawing.cpp @@ -61,7 +61,7 @@ int main(void) // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); texture.Draw(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40); @@ -69,7 +69,7 @@ int main(void) darkGray.DrawText("We are drawing only one texture from various images composed!", 240, 350, 10); darkGray.DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/examples/textures/textures_image_loading.cpp b/examples/textures/textures_image_loading.cpp index f18dee86..c65315d3 100644 --- a/examples/textures/textures_image_loading.cpp +++ b/examples/textures/textures_image_loading.cpp @@ -21,8 +21,8 @@ int main() { raylib::Window window(screenWidth, screenHeight, "raylib [textures] example - image loading"); raylib::Texture texture("resources/raylib_logo.png"); - raylib::Color background(RAYWHITE); - raylib::Color textColor(LIGHTGRAY); + raylib::Color background = raylib::Color::RayWhite(); + raylib::Color textColor = raylib::Color::LightGray(); // Main game loop while (!window.ShouldClose()) // Detect window close button or ESC key @@ -35,13 +35,13 @@ int main() { // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + { background.ClearBackground(); texture.Draw(screenWidth / 2 - texture.GetWidth() / 2, screenHeight / 2 - texture.GetHeight() / 2); textColor.DrawText("this IS a texture loaded from an image!", 300, 370, 10); - + } EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 522f263d..a7c4d138 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -11,8 +11,8 @@ install(FILES Camera2D.hpp Camera3D.hpp Color.hpp - Functions.hpp Font.hpp + Functions.hpp Gamepad.hpp Image.hpp Material.hpp @@ -25,14 +25,15 @@ install(FILES Physics.hpp RayHitInfo.hpp Ray.hpp - raylib.hpp raylib-cpp.hpp raylib-cpp-utils.hpp + raylib.hpp raymath.hpp Rectangle.hpp RenderTexture.hpp Shader.hpp Sound.hpp + Text.hpp Texture.hpp Vector2.hpp Vector3.hpp diff --git a/include/Functions.hpp b/include/Functions.hpp index cd8bed1f..18e701ec 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -30,10 +30,10 @@ #include "./raylib.hpp" -#ifndef RLCPPAPI /** * Allow changing the declare type for all raylib-cpp global functions. Defaults to static. */ +#ifndef RLCPPAPI #define RLCPPAPI static #endif @@ -204,39 +204,63 @@ RLCPPAPI inline void OpenURL(const std::string& url) { return ::OpenURL(url.c_str()); } +/** + * Check gamepad name (if available) + */ RLCPPAPI inline bool IsGamepadName(int gamepad, const std::string& name) { return ::IsGamepadName(gamepad, name.c_str()); } +/** + * Update camera depending on selected mode + */ RLCPPAPI inline void UpdateCamera(const ::Camera& camera) { ::Camera* cameraPointer = (::Camera*)&camera; ::UpdateCamera(cameraPointer); } +/** + * Load an image. + */ RLCPPAPI inline ::Image LoadImage(const std::string& fileName) { return ::LoadImage(fileName.c_str()); } +/** + * Load an image from RAW file data + */ RLCPPAPI inline ::Image LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) { return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize); } +/** + * Load animated image data + */ RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int *frames) { return ::LoadImageAnim(fileName.c_str(), frames); } +/** + * Load image from memory buffer, fileType refers to extension: i.e. "png" + */ RLCPPAPI inline ::Image LoadImageFromMemory(const std::string& fileType, const unsigned char *fileData, int dataSize) { return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize); } +/** + * Export image data to file + */ RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) { return ::ExportImage(image, fileName.c_str()); } +/** + * Export image as code file (.h) defining an array of bytes + */ RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) { return ::ExportImageAsCode(image, fileName.c_str()); } diff --git a/include/Ray.hpp b/include/Ray.hpp index 96ffda2c..49a1623f 100644 --- a/include/Ray.hpp +++ b/include/Ray.hpp @@ -47,7 +47,7 @@ class Ray : public ::Ray { } Ray(::Vector2 mousePosition, ::Camera camera) { - set(GetMouseRay(mousePosition, camera)); + set(::GetMouseRay(mousePosition, camera)); } Ray& operator=(const ::Ray& ray) { @@ -91,21 +91,21 @@ class Ray : public ::Ray { /** * Get collision info between ray and model */ - inline RayHitInfo GetCollision(const ::Model& model) { + inline RayHitInfo GetCollision(const ::Model& model) const { return GetCollisionRayModel(*this, model); } /** * Get collision info between ray and triangle */ - inline RayHitInfo GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) { + inline RayHitInfo GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const { return GetCollisionRayTriangle(*this, p1, p2, p3); } /** * Get collision info between ray and ground plane (Y-normal plane) */ - inline RayHitInfo GetCollisionGround(float groundHeight) { + inline RayHitInfo GetCollisionGround(float groundHeight) const { return GetCollisionRayGround(*this, groundHeight); } diff --git a/include/RayHitInfo.hpp b/include/RayHitInfo.hpp index ab9c9418..746f472a 100644 --- a/include/RayHitInfo.hpp +++ b/include/RayHitInfo.hpp @@ -45,6 +45,13 @@ class RayHitInfo : public ::RayHitInfo { normal = Normal; } + /** + * Get collision info between ray and mesh + */ + RayHitInfo(const ::Ray& ray, const ::Mesh& mesh, const ::Matrix& transform) { + set(::GetCollisionRayMesh(ray, mesh, transform)); + } + /** * Get collision info between ray and model */ diff --git a/include/Shader.hpp b/include/Shader.hpp index 44e77371..9147e0dc 100644 --- a/include/Shader.hpp +++ b/include/Shader.hpp @@ -99,6 +99,8 @@ class Shader : public ::Shader { /** * Get shader uniform location + * + * @see GetShaderLocation() */ inline int GetLocation(const std::string& uniformName) const { return ::GetShaderLocation(*this, uniformName.c_str()); @@ -106,6 +108,8 @@ class Shader : public ::Shader { /** * Get shader attribute location + * + * @see GetShaderLocationAttrib() */ inline int GetLocationAttrib(const std::string& attribName) const { return ::GetShaderLocationAttrib(*this, attribName.c_str()); diff --git a/include/Text.hpp b/include/Text.hpp new file mode 100644 index 00000000..1c70539d --- /dev/null +++ b/include/Text.hpp @@ -0,0 +1,74 @@ +/* +* Font Loading and Text Drawing Functions (Module: text) +* +* 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_TEXT_HPP_ +#define RAYLIB_CPP_INCLUDE_TEXT_HPP_ + +#include + +#include "./raylib.hpp" + +/** + * Allow changing the declare type for all raylib-cpp global functions. Defaults to static. + */ +#ifndef RLCPPAPI +#define RLCPPAPI static +#endif + +namespace raylib { + +/** + * Draw text (using default font) + */ +RLCPPAPI inline void DrawText( + const std::string& title, + int posX, + int posY, + int fontSize, + ::Color color) { + ::DrawText(title.c_str(), posX, posY, fontSize, color); +} + +/** + * Measure string width for default font + */ +RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { + return ::MeasureText(text.c_str(), fontSize); +} + +/** + * Check if two text string are equal + */ +RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) { + return ::TextIsEqual(text1.c_str(), text2.c_str()); +} + +// TODO(RobLoach): Add remaining raylib C functions with string c_str() wrappers. + +} // namespace raylib + +#endif // RAYLIB_CPP_INCLUDE_TEXT_HPP_ diff --git a/include/Texture.hpp b/include/Texture.hpp index a4cea8a5..4470674b 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -33,6 +33,9 @@ #include "./Material.hpp" namespace raylib { +/** + * Texture type + */ class Texture : public ::Texture { public: Texture(const ::Texture& texture) { diff --git a/package.json b/package.json index 8dcd6ef0..853e0fd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "raylib-cpp", - "version": "3.5.0-beta2", + "version": "3.5.0-beta3", "description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib", "homepage": "https://github.com/robloach/raylib-cpp", "bugs": { @@ -51,6 +51,7 @@ "include/RenderTexture2D.hpp", "include/Shader.hpp", "include/Sound.hpp", + "include/Text.hpp", "include/Texture2D.hpp", "include/Vector2.hpp", "include/Vector3.hpp",