mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-24 21:28:27 -04:00
Compare commits
8 Commits
5b1445b381
...
b812c18e6b
| Author | SHA1 | Date | |
|---|---|---|---|
| b812c18e6b | |||
| 6c6a248be8 | |||
| ce6ac7d8c7 | |||
| baa9a4df51 | |||
| 58e03dbc6c | |||
| cfccb83ddd | |||
| b806e3d2ec | |||
| 0725811224 |
15
src/raylib.h
15
src/raylib.h
@ -1154,14 +1154,15 @@ RLAPI long GetFileModTime(const char *fileName); // Get file
|
||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
||||
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)
|
||||
RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)
|
||||
RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string)
|
||||
RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a provided fileName with path (uses static string)
|
||||
RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a provided path (uses static string)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)
|
||||
RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)
|
||||
RLAPI int MakeDirectory(const char *dirPath); // Create directories (including full path requested), returns 0 on success
|
||||
RLAPI int ChangeDirectory(const char *dirPath); // Change working directory, returns 0 on success
|
||||
RLAPI bool IsPathFile(const char *path); // Check if given path points to a file
|
||||
RLAPI bool IsPathDirectory(const char *path); // Check if given path points to a directory
|
||||
RLAPI bool IsPathFile(const char *path); // Check if provided path points to a file
|
||||
RLAPI bool IsPathDirectory(const char *path); // Check if provided path points to a directory
|
||||
RLAPI bool IsPathAbsolute(const char *path); // Check if provided path is an absolute path
|
||||
RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS
|
||||
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths, files and directories, no subdirs scan
|
||||
RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and subdir scan; some filters available: '*.*','FILES*','DIRS*'
|
||||
@ -1240,7 +1241,7 @@ RLAPI void SetMouseCursor(int cursor); // Set mouse curso
|
||||
RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
|
||||
RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index
|
||||
RLAPI int GetTouchPointId(int index); // Get touch point identifier for provided index
|
||||
RLAPI int GetTouchPointCount(void); // Get number of touch points
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -1327,7 +1328,7 @@ RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vecto
|
||||
RLAPI void DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color); // Draw spline segment: Quadratic Bezier, 2 points, 1 control point
|
||||
RLAPI void DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color); // Draw spline segment: Cubic Bezier, 2 points, 2 control points
|
||||
|
||||
// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f]
|
||||
// Spline segment point evaluation functions, for a provided t [0.0f .. 1.0f]
|
||||
RLAPI Vector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t); // Get (evaluate) spline point: Linear
|
||||
RLAPI Vector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: B-Spline
|
||||
RLAPI Vector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: Catmull-Rom
|
||||
@ -1417,7 +1418,7 @@ RLAPI Color GetImageColor(Image image, int x, int y);
|
||||
|
||||
// Image drawing functions
|
||||
// NOTE: Image software-rendering functions (CPU)
|
||||
RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color
|
||||
RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with provided color
|
||||
RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image
|
||||
RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)
|
||||
RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image
|
||||
|
||||
36
src/rcore.c
36
src/rcore.c
@ -1804,7 +1804,6 @@ void UnloadRandomSequence(int *sequence)
|
||||
}
|
||||
|
||||
// Takes a screenshot of current screen
|
||||
// NOTE: Provided fileName should not contain paths, saving to working directory
|
||||
void TakeScreenshot(const char *fileName)
|
||||
{
|
||||
#if SUPPORT_MODULE_RTEXTURES
|
||||
@ -1819,7 +1818,8 @@ void TakeScreenshot(const char *fileName)
|
||||
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||
|
||||
char path[MAX_FILEPATH_LENGTH] = { 0 };
|
||||
snprintf(path, MAX_FILEPATH_LENGTH, "%s", TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
||||
if (!IsPathAbsolute(fileName)) snprintf(path, MAX_FILEPATH_LENGTH, "%s", TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
||||
else snprintf(path, MAX_FILEPATH_LENGTH, "%s", fileName);
|
||||
|
||||
ExportImage(image, path); // WARNING: Module required: rtextures
|
||||
RL_FREE(imgData);
|
||||
@ -2522,7 +2522,7 @@ const char *GetFileNameWithoutExt(const char *filePath)
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// Get directory for a given filePath
|
||||
// Get directory for a provided filePath
|
||||
const char *GetDirectoryPath(const char *filePath)
|
||||
{
|
||||
/*
|
||||
@ -2569,7 +2569,7 @@ const char *GetDirectoryPath(const char *filePath)
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
// Get previous directory path for a given path
|
||||
// Get previous directory path for a provided path
|
||||
const char *GetPrevDirectoryPath(const char *dirPath)
|
||||
{
|
||||
static char prevDirPath[MAX_FILEPATH_LENGTH] = { 0 };
|
||||
@ -2819,7 +2819,7 @@ int ChangeDirectory(const char *dirPath)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if given path point to a file
|
||||
// Check if provided path point to a file
|
||||
bool IsPathFile(const char *path)
|
||||
{
|
||||
bool result = false;
|
||||
@ -2832,7 +2832,7 @@ bool IsPathFile(const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if given path point to a directory
|
||||
// Check if provided path point to a directory
|
||||
bool IsPathDirectory(const char *path)
|
||||
{
|
||||
bool result = false;
|
||||
@ -2842,6 +2842,28 @@ bool IsPathDirectory(const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if provided path is an absolute path
|
||||
bool IsPathAbsolute(const char *path)
|
||||
{
|
||||
int result = false;
|
||||
|
||||
if ((path != NULL) && (path[0] != '\0'))
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
// UNC path (\\server\share)
|
||||
if ((path[0] == '\\') && (path[1] == '\\')) result = true;
|
||||
// Drive letter (e.g. C:\ or D:/)
|
||||
else if (isalpha((unsigned char)path[0]) && (path[1] == ':') &&
|
||||
((path[2] == '\\') || (path[2] == '/'))) result = true;
|
||||
#else
|
||||
// POSIX: must start with /
|
||||
if (path[0] == '/') result = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if fileName is valid for the platform/OS
|
||||
bool IsFileNameValid(const char *fileName)
|
||||
{
|
||||
@ -4214,7 +4236,7 @@ Vector2 GetTouchPosition(int index)
|
||||
return position;
|
||||
}
|
||||
|
||||
// Get touch point identifier for given index
|
||||
// Get touch point identifier for provided index
|
||||
int GetTouchPointId(int index)
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
@ -3793,6 +3793,10 @@ unsigned char *rlReadScreenPixels(int width, int height)
|
||||
{
|
||||
unsigned char *imgData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char));
|
||||
|
||||
// NOTE: Buffer retrieved is GL_FRONT in single-buffered configurations
|
||||
// and GL_BACK in double-buffered configurations, make sure to call it at the end of frame
|
||||
//glReadBuffer(GL_BACK);
|
||||
|
||||
// NOTE: glReadPixels() returns image flipped vertically -> (0,0) is the bottom left corner of the framebuffer
|
||||
// WARNING: Getting alpha channel! Be careful, it can be transparent if not cleared properly!
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, imgData);
|
||||
|
||||
@ -1233,15 +1233,13 @@ Image ImageFromImage(Image image, Rectangle rec)
|
||||
// Security check to avoid program crash
|
||||
if ((image.data == NULL) || (image.width == 0) || (image.height == 0)) return result;
|
||||
|
||||
// Basic rectangle validation: size smaller than image size
|
||||
if ((rec.x >= 0) && (rec.y >= 0) && (rec.width > 0) && (rec.height > 0) &&
|
||||
(((int)rec.x + (int)rec.width) <= image.width) &&
|
||||
(((int)rec.y + (int)rec.height) <= image.height))
|
||||
{
|
||||
|
||||
if (image.format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "IMAGE: Image manipulation not supported for compressed formats");
|
||||
else
|
||||
if (image.format < PIXELFORMAT_COMPRESSED_DXT1_RGB)
|
||||
{
|
||||
// Basic rectangle validation: size smaller than image size
|
||||
if ((rec.x >= 0) && (rec.y >= 0) && (rec.width > 0) && (rec.height > 0) &&
|
||||
(((int)rec.x + (int)rec.width) <= image.width) &&
|
||||
(((int)rec.y + (int)rec.height) <= image.height))
|
||||
{
|
||||
int bytesPerPixel = GetPixelDataSize(1, 1, image.format);
|
||||
|
||||
result.width = (int)rec.width;
|
||||
@ -1252,11 +1250,14 @@ Image ImageFromImage(Image image, Rectangle rec)
|
||||
|
||||
for (int y = 0; y < (int)rec.height; y++)
|
||||
{
|
||||
memcpy(((unsigned char *)result.data) + y*(int)rec.width*bytesPerPixel, ((unsigned char *)image.data) + ((y + (int)rec.y)*image.width + (int)rec.x)*bytesPerPixel, (int)rec.width*bytesPerPixel);
|
||||
memcpy(((unsigned char *)result.data) + y*(int)rec.width*bytesPerPixel,
|
||||
((unsigned char *)image.data) + ((y + (int)rec.y)*image.width + (int)rec.x)*bytesPerPixel,
|
||||
(int)rec.width*bytesPerPixel);
|
||||
}
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "IMAGE: ImageToImage(), rectangle provided not valid");
|
||||
}
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "IMAGE: Rectangle provided for ImageToImage not valid");
|
||||
else TRACELOG(LOG_WARNING, "IMAGE: Image manipulation not supported for compressed formats");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -4603,7 +4603,7 @@
|
||||
},
|
||||
{
|
||||
"name": "GetDirectoryPath",
|
||||
"description": "Get full path for a given fileName with path (uses static string)",
|
||||
"description": "Get full path for a provided fileName with path (uses static string)",
|
||||
"returnType": "const char *",
|
||||
"params": [
|
||||
{
|
||||
@ -4614,7 +4614,7 @@
|
||||
},
|
||||
{
|
||||
"name": "GetPrevDirectoryPath",
|
||||
"description": "Get previous directory path for a given path (uses static string)",
|
||||
"description": "Get previous directory path for a provided path (uses static string)",
|
||||
"returnType": "const char *",
|
||||
"params": [
|
||||
{
|
||||
@ -4657,7 +4657,7 @@
|
||||
},
|
||||
{
|
||||
"name": "IsPathFile",
|
||||
"description": "Check if given path points to a file",
|
||||
"description": "Check if provided path points to a file",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
@ -4668,7 +4668,18 @@
|
||||
},
|
||||
{
|
||||
"name": "IsPathDirectory",
|
||||
"description": "Check if given path points to a directory",
|
||||
"description": "Check if provided path points to a directory",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "path"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "IsPathAbsolute",
|
||||
"description": "Check if provided path is an absolute path",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
@ -5379,7 +5390,7 @@
|
||||
},
|
||||
{
|
||||
"name": "GetTouchPointId",
|
||||
"description": "Get touch point identifier for given index",
|
||||
"description": "Get touch point identifier for provided index",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
@ -8099,7 +8110,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ImageClearBackground",
|
||||
"description": "Clear image background with given color",
|
||||
"description": "Clear image background with provided color",
|
||||
"returnType": "void",
|
||||
"params": [
|
||||
{
|
||||
|
||||
@ -4135,7 +4135,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "GetDirectoryPath",
|
||||
description = "Get full path for a given fileName with path (uses static string)",
|
||||
description = "Get full path for a provided fileName with path (uses static string)",
|
||||
returnType = "const char *",
|
||||
params = {
|
||||
{type = "const char *", name = "filePath"}
|
||||
@ -4143,7 +4143,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "GetPrevDirectoryPath",
|
||||
description = "Get previous directory path for a given path (uses static string)",
|
||||
description = "Get previous directory path for a provided path (uses static string)",
|
||||
returnType = "const char *",
|
||||
params = {
|
||||
{type = "const char *", name = "dirPath"}
|
||||
@ -4177,7 +4177,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "IsPathFile",
|
||||
description = "Check if given path points to a file",
|
||||
description = "Check if provided path points to a file",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "const char *", name = "path"}
|
||||
@ -4185,7 +4185,15 @@ return {
|
||||
},
|
||||
{
|
||||
name = "IsPathDirectory",
|
||||
description = "Check if given path points to a directory",
|
||||
description = "Check if provided path points to a directory",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "const char *", name = "path"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "IsPathAbsolute",
|
||||
description = "Check if provided path is an absolute path",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "const char *", name = "path"}
|
||||
@ -4671,7 +4679,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "GetTouchPointId",
|
||||
description = "Get touch point identifier for given index",
|
||||
description = "Get touch point identifier for provided index",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "int", name = "index"}
|
||||
@ -6071,7 +6079,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "ImageClearBackground",
|
||||
description = "Clear image background with given color",
|
||||
description = "Clear image background with provided color",
|
||||
returnType = "void",
|
||||
params = {
|
||||
{type = "Image *", name = "dst"},
|
||||
|
||||
@ -3001,13 +3001,13 @@
|
||||
((type "const char *") (name "filePath"))))
|
||||
|
||||
((name "GetDirectoryPath")
|
||||
(description "Get full path for a given fileName with path (uses static string)")
|
||||
(description "Get full path for a provided fileName with path (uses static string)")
|
||||
(return-type "const char *")
|
||||
(params
|
||||
((type "const char *") (name "filePath"))))
|
||||
|
||||
((name "GetPrevDirectoryPath")
|
||||
(description "Get previous directory path for a given path (uses static string)")
|
||||
(description "Get previous directory path for a provided path (uses static string)")
|
||||
(return-type "const char *")
|
||||
(params
|
||||
((type "const char *") (name "dirPath"))))
|
||||
@ -3033,13 +3033,19 @@
|
||||
((type "const char *") (name "dirPath"))))
|
||||
|
||||
((name "IsPathFile")
|
||||
(description "Check if given path points to a file")
|
||||
(description "Check if provided path points to a file")
|
||||
(return-type "bool")
|
||||
(params
|
||||
((type "const char *") (name "path"))))
|
||||
|
||||
((name "IsPathDirectory")
|
||||
(description "Check if given path points to a directory")
|
||||
(description "Check if provided path points to a directory")
|
||||
(return-type "bool")
|
||||
(params
|
||||
((type "const char *") (name "path"))))
|
||||
|
||||
((name "IsPathAbsolute")
|
||||
(description "Check if provided path is an absolute path")
|
||||
(return-type "bool")
|
||||
(params
|
||||
((type "const char *") (name "path"))))
|
||||
@ -3414,7 +3420,7 @@
|
||||
((type "int") (name "index"))))
|
||||
|
||||
((name "GetTouchPointId")
|
||||
(description "Get touch point identifier for given index")
|
||||
(description "Get touch point identifier for provided index")
|
||||
(return-type "int")
|
||||
(params
|
||||
((type "int") (name "index"))))
|
||||
@ -4544,7 +4550,7 @@
|
||||
((type "int") (name "y"))))
|
||||
|
||||
((name "ImageClearBackground")
|
||||
(description "Clear image background with given color")
|
||||
(description "Clear image background with provided color")
|
||||
(return-type "void")
|
||||
(params
|
||||
((type "Image *") (name "dst"))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -681,7 +681,7 @@
|
||||
<Param type="unsigned int" name="frames" desc="" />
|
||||
</Callback>
|
||||
</Callbacks>
|
||||
<Functions count="612">
|
||||
<Functions count="613">
|
||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||
<Param type="int" name="width" desc="" />
|
||||
<Param type="int" name="height" desc="" />
|
||||
@ -1099,10 +1099,10 @@
|
||||
<Function name="GetFileNameWithoutExt" retType="const char *" paramCount="1" desc="Get filename string without extension (uses static string)">
|
||||
<Param type="const char *" name="filePath" desc="" />
|
||||
</Function>
|
||||
<Function name="GetDirectoryPath" retType="const char *" paramCount="1" desc="Get full path for a given fileName with path (uses static string)">
|
||||
<Function name="GetDirectoryPath" retType="const char *" paramCount="1" desc="Get full path for a provided fileName with path (uses static string)">
|
||||
<Param type="const char *" name="filePath" desc="" />
|
||||
</Function>
|
||||
<Function name="GetPrevDirectoryPath" retType="const char *" paramCount="1" desc="Get previous directory path for a given path (uses static string)">
|
||||
<Function name="GetPrevDirectoryPath" retType="const char *" paramCount="1" desc="Get previous directory path for a provided path (uses static string)">
|
||||
<Param type="const char *" name="dirPath" desc="" />
|
||||
</Function>
|
||||
<Function name="GetWorkingDirectory" retType="const char *" paramCount="0" desc="Get current working directory (uses static string)">
|
||||
@ -1115,10 +1115,13 @@
|
||||
<Function name="ChangeDirectory" retType="int" paramCount="1" desc="Change working directory, returns 0 on success">
|
||||
<Param type="const char *" name="dirPath" desc="" />
|
||||
</Function>
|
||||
<Function name="IsPathFile" retType="bool" paramCount="1" desc="Check if given path points to a file">
|
||||
<Function name="IsPathFile" retType="bool" paramCount="1" desc="Check if provided path points to a file">
|
||||
<Param type="const char *" name="path" desc="" />
|
||||
</Function>
|
||||
<Function name="IsPathDirectory" retType="bool" paramCount="1" desc="Check if given path points to a directory">
|
||||
<Function name="IsPathDirectory" retType="bool" paramCount="1" desc="Check if provided path points to a directory">
|
||||
<Param type="const char *" name="path" desc="" />
|
||||
</Function>
|
||||
<Function name="IsPathAbsolute" retType="bool" paramCount="1" desc="Check if provided path is an absolute path">
|
||||
<Param type="const char *" name="path" desc="" />
|
||||
</Function>
|
||||
<Function name="IsFileNameValid" retType="bool" paramCount="1" desc="Check if fileName is valid for the platform/OS">
|
||||
@ -1319,7 +1322,7 @@
|
||||
<Function name="GetTouchPosition" retType="Vector2" paramCount="1" desc="Get touch position XY for a touch point index (relative to screen size)">
|
||||
<Param type="int" name="index" desc="" />
|
||||
</Function>
|
||||
<Function name="GetTouchPointId" retType="int" paramCount="1" desc="Get touch point identifier for given index">
|
||||
<Function name="GetTouchPointId" retType="int" paramCount="1" desc="Get touch point identifier for provided index">
|
||||
<Param type="int" name="index" desc="" />
|
||||
</Function>
|
||||
<Function name="GetTouchPointCount" retType="int" paramCount="0" desc="Get number of touch points">
|
||||
@ -2039,7 +2042,7 @@
|
||||
<Param type="int" name="x" desc="" />
|
||||
<Param type="int" name="y" desc="" />
|
||||
</Function>
|
||||
<Function name="ImageClearBackground" retType="void" paramCount="2" desc="Clear image background with given color">
|
||||
<Function name="ImageClearBackground" retType="void" paramCount="2" desc="Clear image background with provided color">
|
||||
<Param type="Image *" name="dst" desc="" />
|
||||
<Param type="Color" name="color" desc="" />
|
||||
</Function>
|
||||
|
||||
Reference in New Issue
Block a user