mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-12-03 01:18:26 +00:00
3.5.0-beta3
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set noparent
|
||||
root=..
|
||||
linelength=100
|
||||
linelength=120
|
||||
exclude_files=vendor
|
||||
exclude_files=docs
|
||||
filter=-runtime/explicit
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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<float>(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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
Player::Player() {
|
||||
position = Rectangle{
|
||||
GetScreenWidth() / 2 - 50,
|
||||
GetScreenHeight() / 2 - 50,
|
||||
GetScreenWidth() / 2.0f - 50,
|
||||
GetScreenHeight() / 2.0f - 50,
|
||||
100,
|
||||
100
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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());
|
||||
|
||||
74
include/Text.hpp
Normal file
74
include/Text.hpp
Normal file
@@ -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 <string>
|
||||
|
||||
#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_
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "./Material.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Texture type
|
||||
*/
|
||||
class Texture : public ::Texture {
|
||||
public:
|
||||
Texture(const ::Texture& texture) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user