Update to raylib 3.0

This commit is contained in:
Rob Loach
2020-03-31 19:14:28 -04:00
parent 55f8396b27
commit eddfc01dfc
7 changed files with 316 additions and 58 deletions

View File

@@ -4,7 +4,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 3c3dfde3f900378c47c12b2098f13ca3a1c75e9a
GIT_TAG 6a8b1079c13b7d5e1bddc0ecc86ad7e16fc2556d
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?

View File

@@ -18,7 +18,7 @@ namespace raylib {
public:
Gamepad(int gamepadNumber = 0) {
set(gamepadNumber);
};
}
int number;
inline void set(int gamepadNumber) {

View File

@@ -18,27 +18,70 @@ namespace raylib {
Image() {};
Image(::Image image) {
set(image);
};
}
Image(const std::string& fileName) {
Load(fileName);
};
}
Image(::Color* pixels, int width, int height) {
LoadEx(pixels, width, height);
};
}
Image(void* data, int width, int height, int format) {
LoadPro(data, width, height, format);
};
}
Image(const std::string& fileName, int width, int height, int format, int headerSize) {
LoadRaw(fileName, width, height, format, headerSize);
};
}
Image(::Texture2D texture) {
set(GetTextureData(texture));
set(::GetTextureData(texture));
}
Image(int width, int height, Color color) {
set(::GenImageColor(width, height, color));
}
static Image Text(std::string text, int fontSize, Color color) {
return ::ImageText(text.c_str(), fontSize, color);
}
static Image Text(Font font, std::string text, float fontSize, float spacing, Color tint) {
return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
}
static Image GetScreenData() {
return Image(::GetScreenData());
}
static Image GenColor(int width, int height, Color color) {
return ::GenImageColor(width, height, color);
}
static Image GenGradientV(int width, int height, Color top, Color bottom) {
return ::GenImageGradientV(width, height, top, bottom);
}
static Image GenGradientH(int width, int height, Color left, Color right) {
return ::GenImageGradientH(width, height, left, right);
}
static Image GenGradientRadial(int width, int height, float density, Color inner, Color outer) {
return ::GenImageGradientRadial(width, height, density, inner, outer);
}
static Image GenChecked(int width, int height, int checksX, int checksY, Color col1, Color col2) {
return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
}
static Image GenWhiteNoise(int width, int height, float factor) {
return ::GenImageWhiteNoise(width, height, factor);
}
static Image GenPerlinNoise(int width, int height, int offsetX, int offsetY, float scale) {
return ::GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
}
static Image GenCellular(int width, int height, int tileSize) {
return ::GenImageCellular(width, height, tileSize);
}
~Image() {
Unload();
};
@@ -81,6 +124,15 @@ namespace raylib {
::UnloadImage(*this);
};
inline Image& Export(const std::string& fileName) {
::ExportImage(*this, fileName.c_str());
return *this;
}
inline Image& ExportAsCode(const std::string& fileName) {
::ExportImageAsCode(*this, fileName.c_str());
return *this;
}
GETTERSETTER(void*,Data,data)
GETTERSETTER(int,Width,width)
GETTERSETTER(int,Height,height)
@@ -93,6 +145,32 @@ namespace raylib {
inline Image FromImage(::Rectangle rec) {
return ::ImageFromImage(*this, rec);
}
inline Image& ToPOT(Color fillColor) {
::ImageToPOT(this, fillColor);
return *this;
}
inline Image& Format(int newFormat) {
::ImageFormat(this, newFormat);
return *this;
}
inline Image& AlphaMask(Image alphaMask) {
::ImageAlphaMask(this, alphaMask);
return *this;
}
inline Image& AlphaCrop(float threshold) {
::ImageAlphaCrop(this, threshold);
return *this;
}
inline Image& AlphaPremultiply() {
::ImageAlphaPremultiply(this);
return *this;
}
inline Image& Crop(::Rectangle crop) {
::ImageCrop(this, crop);
return *this;
@@ -101,46 +179,23 @@ namespace raylib {
::ImageResize(this, newWidth, newHeight);
return *this;
}
inline Image& Draw(::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = WHITE) {
::ImageDraw(this, src, srcRec, dstRec, tint);
inline Image& ResizeNN(int newWidth, int newHeight) {
::ImageResizeNN(this, newWidth, newHeight);
return *this;
}
inline Image& DrawRectangle(::Rectangle rec, ::Color color = WHITE) {
::ImageDrawRectangle(this, rec, color);
inline Image& ResizeCanvas(int newWidth, int newHeight, int offsetX, int offsetY, Color color) {
::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
return *this;
}
inline Image& DrawRectangleLines(::Rectangle rec, int thick, ::Color color) {
::ImageDrawRectangleLines(this, rec, thick, color);
inline Image& Mipmaps() {
::ImageMipmaps(this);
return *this;
}
inline Image& ClearBackground(::Color color = WHITE) {
::ImageClearBackground(this, color);
inline Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
return *this;
}
inline Image& DrawPixel(::Vector2 position, ::Color color) {
::ImageDrawPixel(this, position, color);
return *this;
}
inline Image& DrawCircle(::Vector2 center, int radius, ::Color color) {
::ImageDrawCircle(this, center, radius, color);
return *this;
}
inline Image& DrawLineEx(::Vector2 start, ::Vector2 end, ::Color color) {
::ImageDrawLineEx(this, start, end, color);
return *this;
}
inline Image& DrawText(::Vector2 position, const std::string& text, int fontSize, ::Color color = WHITE){
::ImageDrawText(this, position, text.c_str(), fontSize, color);
return *this;
}
inline Image& DrawText(::Vector2 position, ::Font font, const std::string& text, float fontSize, float spacing, ::Color color = WHITE){
::ImageDrawTextEx(this, position, font, text.c_str(), fontSize, spacing, color);
return *this;
}
inline Image& FlipVertical() {
::ImageFlipVertical(this);
return *this;
@@ -183,6 +238,78 @@ namespace raylib {
return *this;
}
inline ::Color* ExtractPalette(int maxPaletteSize, int *extractCount) {
return ::ImageExtractPalette(*this, maxPaletteSize, extractCount);
}
inline Rectangle GetAlphaBorder(float threshold) {
return ::GetImageAlphaBorder(*this, threshold);
}
inline Image& ClearBackground(::Color color = WHITE) {
::ImageClearBackground(this, color);
return *this;
}
inline Image& DrawPixel(int posX, int posY, ::Color color) {
::ImageDrawPixel(this, posX, posY, color);
return *this;
}
inline Image& DrawPixel(::Vector2 position, ::Color color) {
::ImageDrawPixelV(this, position, color);
return *this;
}
inline Image& DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, ::Color color) {
::ImageDrawLine(this, startPosX, startPosY, endPosX, endPosY, color);
return *this;
}
inline Image& DrawLine(::Vector2 start, ::Vector2 end, ::Color color) {
::ImageDrawLineV(this, start, end, color);
return *this;
}
inline Image& DrawCircle(int centerX, int centerY, int radius, ::Color color) {
::ImageDrawCircle(this, centerX, centerY, radius, color);
return *this;
}
inline Image& DrawCircle(::Vector2 center, int radius, ::Color color) {
::ImageDrawCircleV(this, center, radius, color);
return *this;
}
inline Image& DrawRectangle(int posX, int posY, int width, int height, ::Color color = WHITE) {
::ImageDrawRectangle(this, posX, posY, width, height, color);
return *this;
}
inline Image& DrawRectangle(Vector2 position, Vector2 size, ::Color color = WHITE) {
::ImageDrawRectangleV(this, position, size, color);
return *this;
}
inline Image& DrawRectangle(::Rectangle rec, ::Color color = WHITE) {
::ImageDrawRectangleRec(this, rec, color);
return *this;
}
inline Image& DrawRectangleLines(::Rectangle rec, int thick, ::Color color) {
::ImageDrawRectangleLines(this, rec, thick, color);
return *this;
}
inline Image& Draw(::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = WHITE) {
::ImageDraw(this, src, srcRec, dstRec, tint);
return *this;
}
inline Image& DrawText(::Vector2 position, const std::string& text, int fontSize, ::Color color = WHITE){
::ImageDrawText(this, position, text.c_str(), fontSize, color);
return *this;
}
inline Image& DrawText(::Vector2 position, ::Font font, const std::string& text, float fontSize, float spacing, ::Color color = WHITE){
::ImageDrawTextEx(this, position, font, text.c_str(), fontSize, spacing, color);
return *this;
}
inline ::Color* GetImageData() {
return ::GetImageData(*this);
}

73
include/raylib/Mouse.hpp Normal file
View File

@@ -0,0 +1,73 @@
#ifndef RAYLIB_CPP_MOUSE_HPP_
#define RAYLIB_CPP_MOUSE_HPP_
#ifdef __cplusplus
extern "C"{
#endif
#include "raylib.h"
#ifdef __cplusplus
}
#endif
#include "Vector2.hpp"
namespace raylib {
class Mouse {
public:
inline bool IsButtonPressed(int button) {
return ::IsMouseButtonPressed(button);
}
inline bool IsButtonDown(int button) {
return ::IsMouseButtonDown(button);
}
inline bool IsButtonReleased(int button) {
return ::IsMouseButtonReleased(button);
}
inline bool IsButtonUp(int button) {
return ::IsMouseButtonUp(button);
}
inline int GetX() {
return ::GetMouseX();
}
inline int GetY() {
return ::GetMouseY();
}
inline Mouse& SetX(int x) {
::SetMouseOffset(x, GetY());
return *this;
}
inline Mouse& SetY(int y) {
::SetMouseOffset(GetX(), y);
return *this;
}
inline Vector2 GetPosition() {
return ::GetMousePosition();
}
inline Mouse& SetPosition(int x, int y) {
::SetMousePosition(x, y);
return *this;
}
inline Mouse& SetOffset(int offsetX, int offsetY) {
::SetMouseOffset(offsetX, offsetY);
return *this;
}
inline Mouse& SetScale(float scaleX, float scaleY) {
::SetMouseScale(scaleX, scaleY);
return *this;
}
inline int GetWheelMove() {
return ::GetMouseWheelMove();
}
inline int GetTouchX() {
return ::GetTouchX();
}
inline int GetTouchY() {
return ::GetTouchY();
}
inline Vector2 GetTouchPosition(int index) {
return ::GetTouchPosition(index);
}
};
}
#endif

View File

@@ -58,11 +58,43 @@ namespace raylib {
}
void LoadFromImage(::Image& image) {
set(LoadTextureFromImage(image));
set(::LoadTextureFromImage(image));
}
void LoadTextureCubemap(::Image& image, int layoutType) {
set(::LoadTextureCubemap(image, layoutType));
}
void Load(const std::string& fileName) {
set(LoadTexture(fileName.c_str()));
set(::LoadTexture(fileName.c_str()));
}
inline void Unload() {
::UnloadTexture(*this);
}
inline Texture2D& Update(const void *pixels) {
::UpdateTexture(*this, pixels);
return *this;
}
inline Image GetTextureData() {
return ::GetTextureData(*this);
}
inline Texture2D& GenMipmaps() {
::GenTextureMipmaps(this);
return *this;
}
inline Texture2D& SetFilter(int filterMode) {
::SetTextureFilter(*this, filterMode);
return *this;
}
inline Texture2D& SetWrap(int wrapMode) {
::SetTextureWrap(*this, wrapMode);
return *this;
}
inline Texture2D& Draw(int posX, int posY, ::Color tint = WHITE) {
@@ -101,14 +133,14 @@ namespace raylib {
return *this;
}
inline void Unload() {
::UnloadTexture(*this);
}
inline Texture2D& SetMaterialTexture(Material *material, int mapType) {
::SetMaterialTexture(material, mapType, *this);
return *this;
}
static int GetPixelDataSize(int width, int height, int format) {
return ::GetPixelDataSize(width, height, format);
}
};
// Alias the Texture2D as Texture.

View File

@@ -39,19 +39,6 @@ namespace raylib {
inline static bool IsReady() {
return ::IsWindowReady();
};
inline Window& BeginDrawing() {
::BeginDrawing();
return *this;
}
inline Window& EndDrawing() {
::EndDrawing();
return *this;
}
inline bool IsFullscreen() {
return ::IsWindowFullscreen();
}
inline bool IsMinimized() {
return ::IsWindowMinimized();
}
@@ -61,6 +48,10 @@ namespace raylib {
inline bool IsHidden() {
return ::IsWindowHidden();
}
inline bool IsFullscreen() {
return ::IsWindowFullscreen();
}
inline Window& ToggleFullscreen() {
::ToggleFullscreen();
return *this;
@@ -100,6 +91,40 @@ namespace raylib {
inline void* GetHandle() {
return ::GetWindowHandle();
}
inline Window& BeginDrawing() {
::BeginDrawing();
return *this;
}
inline Window& EndDrawing() {
::EndDrawing();
return *this;
}
inline int GetScreenWidth() {
return ::GetScreenWidth();
}
inline int GetScreenHeight() {
return ::GetScreenHeight();
}
inline Vector2 GetWindowPosition() {
return ::GetWindowPosition();
}
std::string GetMonitorName(int monitor) {
return std::string(GetMonitorName(monitor));
}
std::string GetClipboardText() {
return std::string(GetClipboardText());
}
inline Window& SetClipboardText(const std::string& text) {
::SetClipboardText(text.c_str());
return *this;
}
};
}

View File

@@ -13,6 +13,7 @@
#include "Material.hpp"
#include "Mesh.hpp"
#include "ModelAnimation.hpp"
#include "Mouse.hpp"
#include "Model.hpp"
#include "Music.hpp"
#include "RayHitInfo.hpp"