4 #ifndef RAYLIB_CPP_INCLUDE_FUNCTIONS_HPP_
5 #define RAYLIB_CPP_INCLUDE_FUNCTIONS_HPP_
10 #include "./raylib.hpp"
16 #define RLCPPAPI static
24 RLCPPAPI
inline void InitWindow(
int width,
int height,
const std::string& title =
"raylib") {
39 return ::GetMonitorName(monitor);
53 return ::GetClipboardText();
67 return ::GetGamepadName(gamepad);
75 std::string output(text);
76 ::UnloadFileText(text);
83 RLCPPAPI
inline bool SaveFileText(
const std::string& fileName,
const std::string& text) {
84 return ::SaveFileText(fileName.c_str(),
const_cast<char*
>(text.c_str()));
90 RLCPPAPI
inline bool FileExists(
const std::string& fileName) {
91 return ::FileExists(fileName.c_str());
98 return ::DirectoryExists(dirPath.c_str());
104 RLCPPAPI
inline bool IsFileExtension(
const std::string& fileName,
const std::string& ext) {
105 return ::IsFileExtension(fileName.c_str(), ext.c_str());
112 return ::GetFileExtension(fileName.c_str());
118 RLCPPAPI
inline std::string
GetFileName(
const std::string& filePath) {
119 return ::GetFileName(filePath.c_str());
126 return ::GetFileNameWithoutExt(filePath.c_str());
133 return ::GetDirectoryPath(filePath.c_str());
140 return ::GetPrevDirectoryPath(dirPath.c_str());
147 return ::GetWorkingDirectory();
155 std::vector<std::string> output(files.paths, files.paths + files.count);
156 ::UnloadDirectoryFiles(files);
164 return ::ChangeDirectory(dir.c_str());
171 if (!::IsFileDropped()) {
172 return std::vector<std::string>();
175 std::vector<std::string> output(files.paths, files.paths + files.count);
176 ::UnloadDroppedFiles(files);
184 return ::GetFileModTime(fileName.c_str());
190 RLCPPAPI
inline void OpenURL(
const std::string& url) {
191 return ::OpenURL(url.c_str());
205 RLCPPAPI inline ::Image
LoadImage(
const std::string& fileName) {
206 return ::LoadImage(fileName.c_str());
213 int width,
int height,
214 int format,
int headerSize) {
215 return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize);
221 RLCPPAPI inline ::Image
LoadImageAnim(
const std::string& fileName,
int *frames) {
222 return ::LoadImageAnim(fileName.c_str(), frames);
229 const unsigned char *fileData,
231 return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize);
238 return ::ExportImage(image, fileName.c_str());
245 return ::ExportImageAsCode(image, fileName.c_str());
251 RLCPPAPI
inline void DrawText(
const std::string& text,
int posX,
int posY,
int fontSize, ::
Color color) {
252 ::DrawText(text.c_str(), posX, posY, fontSize, color);
259 float fontSize,
float spacing, ::
Color tint) {
260 ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, tint);
267 Vector2 origin,
float rotation,
float fontSize,
float spacing, ::
Color tint) {
268 ::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, tint);
274 RLCPPAPI inline ::Font
LoadFont(
const std::string& fileName) {
275 return ::LoadFont(fileName.c_str());
281 RLCPPAPI inline ::Font
LoadFontEx(
const std::string& fileName,
int fontSize,
int *fontChars,
int charsCount) {
282 return ::LoadFontEx(fileName.c_str(), fontSize, fontChars, charsCount);
288 RLCPPAPI
inline int MeasureText(
const std::string& text,
int fontSize) {
289 return ::MeasureText(text.c_str(), fontSize);
295 RLCPPAPI
inline bool TextIsEqual(
const std::string& text1,
const std::string& text2) {
296 return ::TextIsEqual(text1.c_str(), text2.c_str());
302 RLCPPAPI
inline unsigned int TextLength(
const std::string& text) {
303 return ::TextLength(text.c_str());
309 RLAPI
inline std::string
TextSubtext(
const std::string& text,
int position,
int length) {
310 return ::TextSubtext(text.c_str(), position, length);
316 RLAPI
inline std::string
TextReplace(
const std::string& text,
const std::string& replace,
const std::string& by) {
317 const char* input = text.c_str();
318 char* output =
::TextReplace(
const_cast<char*
>(input), replace.c_str(), by.c_str());
319 if (output != NULL) {
320 std::string stringOutput(output);
330 RLAPI
inline std::string
TextInsert(
const std::string& text,
const std::string& insert,
int position) {
331 char* output =
::TextInsert(text.c_str(), insert.c_str(), position);
332 if (output != NULL) {
333 std::string stringOutput(output);
343 RLAPI
inline std::vector<std::string>
TextSplit(
const std::string& text,
char delimiter) {
345 const char** split =
::TextSplit(text.c_str(), delimiter, &count);
346 return std::vector<std::string>(split, split + count);
352 RLAPI
inline int TextFindIndex(
const std::string& text,
const std::string& find) {
353 return ::TextFindIndex(text.c_str(), find.c_str());
360 return ::TextToUpper(text.c_str());
367 return ::TextToLower(text.c_str());
374 return ::TextToPascal(text.c_str());
381 return ::TextToInteger(text.c_str());
Camera type, defines a camera position/orientation in 3d space.
Font type, includes texture and charSet array data.
Image type, bpp always RGBA (32bit)
All raylib-cpp classes and functions appear in the raylib namespace.
static bool ExportImageAsCode(const Image &image, const std::string &fileName)
Export image as code file (.h) defining an array of bytes.
RLAPI std::string TextToUpper(const std::string &text)
Get upper case version of provided string.
static bool DirectoryExists(const std::string &dirPath)
Check if directory path exists.
RLAPI std::string TextToLower(const std::string &text)
Get lower case version of provided string.
static inline ::Image LoadImage(const std::string &fileName)
Load an image.
RLAPI int TextFindIndex(const std::string &text, const std::string &find)
Find first text occurrence within a string.
static std::string GetWorkingDirectory()
Get current working directory.
static unsigned int TextLength(const std::string &text)
Check if two text string are equal.
static std::string GetGamepadName(int gamepad)
Get gamepad internal name id.
static inline ::Font LoadFontEx(const std::string &fileName, int fontSize, int *fontChars, int charsCount)
Load font from file (filename must include file extension)
static inline ::Font LoadFont(const std::string &fileName)
Load font from file (filename must include file extension)
static bool ExportImage(const Image &image, const std::string &fileName)
Export image data to file.
static void DrawText(const std::string &text, int posX, int posY, int fontSize, ::Color color)
Draw text (using default font)
RLAPI std::string TextSubtext(const std::string &text, int position, int length)
Get text length, checks for '\0' ending.
RLAPI std::string TextToPascal(const std::string &text)
Get Pascal case notation version of provided string.
static bool SaveFileText(const std::string &fileName, const std::string &text)
Save text data to file (write)
static bool IsFileExtension(const std::string &fileName, const std::string &ext)
Check file extension (including point: .png, .wav)
static std::vector< std::string > LoadDirectoryFiles(const std::string &dirPath)
Get filenames in a directory path.
RLAPI int TextToInteger(const std::string &text)
Get integer value from text (negative values not supported)
static std::string GetFileName(const std::string &filePath)
Get pointer to filename for a path string.
static inline ::Image LoadImageFromMemory(const std::string &fileType, const unsigned char *fileData, int dataSize)
Load image from memory buffer, fileType refers to extension like "png".
static std::string GetMonitorName(int monitor=0)
Get the human-readable, UTF-8 encoded name of the primary monitor.
static int MeasureText(const std::string &text, int fontSize)
Measure string width for default font.
RLAPI std::string TextReplace(const std::string &text, const std::string &replace, const std::string &by)
Replace text string.
static void TakeScreenshot(const std::string &fileName)
Takes a screenshot of current screen (saved a .png)
static void SetClipboardText(const std::string &text)
Set clipboard text content.
RLAPI std::string TextInsert(const std::string &text, const std::string &insert, int position)
Insert text in a position.
static void SetWindowTitle(const std::string &title)
Set title for window.
static bool FileExists(const std::string &fileName)
Check if file exists.
static void InitWindow(int width, int height, const std::string &title="raylib")
Initialize window and OpenGL context.
RLAPI std::vector< std::string > TextSplit(const std::string &text, char delimiter)
Split text into multiple strings.
static inline ::Image LoadImageAnim(const std::string &fileName, int *frames)
Load animated image data.
static std::string LoadFileText(const std::string &fileName)
Load text data from file (read)
static long GetFileModTime(const std::string &fileName)
Get file modification time (last write time)
static std::string GetFileExtension(const std::string &fileName)
Get pointer to extension for a filename string (including point: ".png")
static void UpdateCamera(const ::Camera &camera)
Update camera depending on selected mode.
static void OpenURL(const std::string &url)
Open URL with default system browser (if available)
static std::vector< std::string > LoadDroppedFiles()
Get dropped files names.
static std::string GetFileNameWithoutExt(const std::string &filePath)
Get filename string without extension.
static inline ::Image LoadImageRaw(const std::string &fileName, int width, int height, int format, int headerSize)
Load an image from RAW file data.
static void DrawTextPro(const Font &font, const std::string &text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint)
Draw text using Font and pro parameters (rotation)
static std::string GetPrevDirectoryPath(const std::string &dirPath)
Get previous directory path for a given path.
static void DrawTextEx(const Font &font, const std::string &text, Vector2 position, float fontSize, float spacing, ::Color tint)
Draw text using font and additional parameters.
static bool ChangeDirectory(const std::string &dir)
Change working directory, return true on success.
static std::string GetDirectoryPath(const std::string &filePath)
Get full path for a given fileName with path.
static bool TextIsEqual(const std::string &text1, const std::string &text2)
Check if two text string are equal.
static std::string GetClipboardText()
Get clipboard text content.