Merge branch 'master' into shader_matrix

This commit is contained in:
Jeffery Myers 2021-06-15 12:28:41 -07:00
commit 5bd6c59f2a
48 changed files with 14911 additions and 1681 deletions

View File

@ -46,7 +46,7 @@ Here it is a list with the ones I'm aware of:
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby | | raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby | | raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py | | raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
| raylib-python-cffi | 3.5 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi | | raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg | | raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
| jaylib | 3.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ | | jaylib | 3.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java | | raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |

View File

@ -26,7 +26,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE) set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE)
unset(WAS_SHARED) unset(WAS_SHARED)
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw_objlib>) list(APPEND raylib_sources $<TARGET_OBJECTS:glfw>)
include_directories(BEFORE SYSTEM external/glfw/include) include_directories(BEFORE SYSTEM external/glfw/include)
else() else()
MESSAGE(STATUS "Using external GLFW") MESSAGE(STATUS "Using external GLFW")

View File

@ -22,7 +22,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [text] example - input box"); InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for line ending char '\0' char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for null terminator char '\0'
int letterCount = 0; int letterCount = 0;
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 }; Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
@ -56,6 +56,7 @@ int main(void)
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS)) if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
{ {
name[letterCount] = (char)key; name[letterCount] = (char)key;
name[letterCount+1] = '\0'; // Add null terminator at the end of the string.
letterCount++; letterCount++;
} }

View File

@ -9,6 +9,13 @@ All data is separated into parts, usually as strings. The following types are us
Check `raylib_parser.c` for details about those structs. Check `raylib_parser.c` for details about those structs.
## Command Line Arguments
The parser can take a few options...
- `--help` Displays help information about the parser
- `--json` Outputs the header information in JSON format
## Constraints ## Constraints
This parser is specifically designed to work with raylib.h, so, it has some constraints: This parser is specifically designed to work with raylib.h, so, it has some constraints:

6668
parser/raylib_api.json Normal file

File diff suppressed because it is too large Load Diff

3568
parser/raylib_api.txt Normal file

File diff suppressed because it is too large Load Diff

2509
parser/raylib_api.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/********************************************************************************************** /**********************************************************************************************
raylib parser - raylib header parser raylib API parser
This parser scans raylib.h to get information about structs, enums and functions. This parser scans raylib.h to get API information about structs, enums and functions.
All data is separated into parts, usually as strings. The following types are used for data: All data is divided into pieces, usually as strings. The following types are used for data:
- struct FunctionInfo - struct FunctionInfo
- struct StructInfo - struct StructInfo
@ -38,13 +38,15 @@
<valueName[3]> <valueDesc[3]> <valueName[3]> <valueDesc[3]>
} <name>; } <name>;
NOTE: Multiple options are supported: NOTE: Multiple options are supported for enums:
- If value is not provided, (<valueInteger[i -1]> + 1) is assigned - If value is not provided, (<valueInteger[i -1]> + 1) is assigned
- Value description can be provided or not - Value description can be provided or not
This parser could work with other C header files if mentioned constraints are followed. OTHER NOTES:
This parser does not require <string.h> library, all data is parsed directly from char buffers. - This parser could work with other C header files if mentioned constraints are followed.
- This parser does not require <string.h> library, all data is parsed directly from char buffers.
LICENSE: zlib/libpng LICENSE: zlib/libpng
@ -55,6 +57,8 @@
**********************************************************************************************/ **********************************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol() #include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol()
#include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose() #include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose()
#include <stdbool.h> // Required for: bool #include <stdbool.h> // Required for: bool
@ -77,6 +81,7 @@ typedef struct FunctionInfo {
int paramCount; // Number of function parameters int paramCount; // Number of function parameters
char paramType[12][32]; // Parameters type (max: 12 parameters) char paramType[12][32]; // Parameters type (max: 12 parameters)
char paramName[12][32]; // Parameters name (max: 12 parameters) char paramName[12][32]; // Parameters name (max: 12 parameters)
char paramDesc[12][8]; // Parameters description (max: 12 parameters)
} FunctionInfo; } FunctionInfo;
// Struct info data // Struct info data
@ -99,40 +104,65 @@ typedef struct EnumInfo {
char valueDesc[128][64]; // Value description (max: 128 values) char valueDesc[128][64]; // Value description (max: 128 values)
} EnumInfo; } EnumInfo;
// Output format for parsed data
typedef enum { DEFAULT = 0, JSON, XML } OutputFormat;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static int funcCount = 0;
static int structCount = 0;
static int enumCount = 0;
static FunctionInfo *funcs = NULL;
static StructInfo *structs = NULL;
static EnumInfo *enums = NULL;
// Command line variables
static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI)
static char outFileName[512] = { 0 }; // Output file name (required for file save/export)
static int outputFormat = DEFAULT;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
char *LoadFileText(const char *fileName, int *length); static void ShowCommandLineInfo(void); // Show command line usage info
char **GetTextLines(const char *buffer, int length, int *linesCount); static void ProcessCommandLine(int argc, char *argv[]); // Process command line input
void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name);
bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
void MemoryCopy(void *dest, const void *src, unsigned int count);
// Main entry point static char *LoadFileText(const char *fileName, int *length);
int main() static char **GetTextLines(const char *buffer, int length, int *linesCount);
static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name);
static unsigned int TextLength(const char *text); // Get text length in bytes, check for \0 character
static bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
static void MemoryCopy(void *dest, const void *src, unsigned int count);
static char* CharReplace(char* text, char search, char replace);
static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(int argc, char* argv[])
{ {
if (argc > 1) ProcessCommandLine(argc, argv);
if (inFileName[0] == '\0') MemoryCopy(inFileName, "../src/raylib.h\0", 16);
int length = 0; int length = 0;
char *buffer = LoadFileText("../src/raylib.h", &length); char *buffer = LoadFileText(inFileName, &length);
// Preprocess buffer to get separate lines // Preprocess buffer to get separate lines
// NOTE: GetTextLines() also removes leading spaces/tabs // NOTE: GetTextLines() also removes leading spaces/tabs
int linesCount = 0; int linesCount = 0;
char **lines = GetTextLines(buffer, length, &linesCount); char **lines = GetTextLines(buffer, length, &linesCount);
// Print buffer lines
//for (int i = 0; i < linesCount; i++) printf("_%s_\n", lines[i]);
// Function lines pointers, selected from buffer "lines" // Function lines pointers, selected from buffer "lines"
int funcCount = 0;
char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *)); char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *));
// Structs data (multiple lines), selected from "buffer" // Structs data (multiple lines), selected from "buffer"
int structCount = 0;
char **structLines = (char **)malloc(MAX_STRUCTS_TO_PARSE*sizeof(char *)); char **structLines = (char **)malloc(MAX_STRUCTS_TO_PARSE*sizeof(char *));
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char)); for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char));
// Enums lines pointers, selected from buffer "lines" // Enums lines pointers, selected from buffer "lines"
int enumCount = 0;
int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int));
// Prepare required lines for parsing // Prepare required lines for parsing
@ -150,9 +180,6 @@ int main()
} }
} }
// Print function lines
//for (int i = 0; i < funcCount; i++) printf("%s\n", funcLines[i]);
// Read structs data (multiple lines, read directly from buffer) // Read structs data (multiple lines, read directly from buffer)
// TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition // TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
@ -229,7 +256,7 @@ int main()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
// Structs info data // Structs info data
StructInfo *structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo)); structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo));
for (int i = 0; i < structCount; i++) for (int i = 0; i < structCount; i++)
{ {
@ -302,7 +329,7 @@ int main()
free(structLines); free(structLines);
// Enum info data // Enum info data
EnumInfo *enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo)); enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo));
for (int i = 0; i < enumCount; i++) for (int i = 0; i < enumCount; i++)
{ {
@ -385,7 +412,7 @@ int main()
} }
// Functions info data // Functions info data
FunctionInfo *funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo)); funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo));
for (int i = 0; i < funcCount; i++) for (int i = 0; i < funcCount; i++)
{ {
@ -455,7 +482,7 @@ int main()
} }
} }
for (int i = 0; i < linesCount; i++) free(lines[i]); //for (int i = 0; i < linesCount; i++) free(lines[i]);
free(lines); free(lines);
free(funcLines); free(funcLines);
@ -465,34 +492,16 @@ int main()
// enums[] -> We have all the enums decomposed into pieces for further analysis // enums[] -> We have all the enums decomposed into pieces for further analysis
// funcs[] -> We have all the functions decomposed into pieces for further analysis // funcs[] -> We have all the functions decomposed into pieces for further analysis
// Print structs info // Process input file to output
printf("\nStructures found: %i\n\n", structCount); if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15);
for (int i = 0; i < structCount; i++)
{
printf("Struct %02i: %s (%i fields)\n", i + 1, structs[i].name, structs[i].fieldCount);
//printf("Description: %s\n", structs[i].desc);
for (int f = 0; f < structs[i].fieldCount; f++) printf(" Fields %i: %s %s %s\n", f + 1, structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]);
}
// Print enums info printf("\nInput file: %s", inFileName);
printf("\nEnums found: %i\n\n", enumCount); printf("\nOutput file: %s", outFileName);
for (int i = 0; i < enumCount; i++) if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
{ else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
printf("Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount); else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
//printf("Description: %s\n", enums[i].desc);
for (int e = 0; e < enums[i].valueCount; e++) printf(" Value %s: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]);
}
// Print function info ExportParsedData(outFileName, outputFormat);
printf("\nFunctions found: %i\n\n", funcCount);
for (int i = 0; i < funcCount; i++)
{
printf("Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount);
printf(" Description: %s\n", funcs[i].desc);
printf(" Return type: %s\n", funcs[i].retType);
for (int p = 0; p < funcs[i].paramCount; p++) printf(" Param %i: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]);
if (funcs[i].paramCount == 0) printf(" No input parameters\n");
}
free(funcs); free(funcs);
free(structs); free(structs);
@ -502,10 +511,84 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Show command line usage info
static void ShowCommandLineInfo(void)
{
printf("\n//////////////////////////////////////////////////////////////////////////////////\n");
printf("// //\n");
printf("// raylib API parser //\n");
printf("// //\n");
printf("// more info and bugs-report: github.com/raysan5/raylib/parser //\n");
printf("// //\n");
printf("// Copyright (c) 2021 Ramon Santamaria (@raysan5) //\n");
printf("// //\n");
printf("//////////////////////////////////////////////////////////////////////////////////\n\n");
printf("USAGE:\n\n");
printf(" > raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]\n");
printf("\nOPTIONS:\n\n");
printf(" -h, --help : Show tool version and command line usage help\n\n");
printf(" -i, --input <filename.h> : Define input header file to parse.\n");
printf(" NOTE: If not specified, defaults to: raylib.h\n\n");
printf(" -o, --output <filename.ext> : Define output file and format.\n");
printf(" Supported extensions: .txt, .json, .xml, .h\n");
printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n");
printf(" -f, --format <type> : Define output format for parser data.\n");
printf(" Supported types: DEFAULT, JSON, XML\n\n");
printf("\nEXAMPLES:\n\n");
printf(" > raylib_parser --input raylib.h --output api.json\n");
printf(" Process <raylib.h> to generate <api.json>\n\n");
printf(" > raylib_parser --output raylib_data.info --format XML\n");
printf(" Process <raylib.h> to generate <raylib_data.info> as XML text data\n\n");
}
// Process command line arguments
static void ProcessCommandLine(int argc, char *argv[])
{
for (int i = 1; i < argc; i++)
{
if (IsTextEqual(argv[i], "-h", 2) || IsTextEqual(argv[i], "--help", 6))
{
// Show info
ShowCommandLineInfo();
}
else if (IsTextEqual(argv[i], "-i", 2) || IsTextEqual(argv[i], "--input", 7))
{
// Check for valid argument and valid file extension
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
{
MemoryCopy(inFileName, argv[i + 1], TextLength(argv[i + 1])); // Read input filename
i++;
}
else printf("WARNING: No input file provided\n");
}
else if (IsTextEqual(argv[i], "-o", 2) || IsTextEqual(argv[i], "--output", 8))
{
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
{
MemoryCopy(outFileName, argv[i + 1], TextLength(argv[i + 1])); // Read output filename
i++;
}
else printf("WARNING: No output file provided\n");
}
else if (IsTextEqual(argv[i], "-f", 2) || IsTextEqual(argv[i], "--format", 8))
{
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
{
if (IsTextEqual(argv[i + 1], "DEFAULT\0", 8)) outputFormat = DEFAULT;
else if (IsTextEqual(argv[i + 1], "JSON\0", 5)) outputFormat = JSON;
else if (IsTextEqual(argv[i + 1], "XML\0", 4)) outputFormat = XML;
}
else printf("WARNING: No format parameters provided\n");
}
}
}
// Load text data from file, returns a '\0' terminated string // Load text data from file, returns a '\0' terminated string
// NOTE: text chars array should be freed manually // NOTE: text chars array should be freed manually
char *LoadFileText(const char *fileName, int *length) static char *LoadFileText(const char *fileName, int *length)
{ {
char *text = NULL; char *text = NULL;
@ -524,14 +607,17 @@ char *LoadFileText(const char *fileName, int *length)
if (size > 0) if (size > 0)
{ {
*length = size;
text = (char *)calloc((size + 1), sizeof(char)); text = (char *)calloc((size + 1), sizeof(char));
unsigned int count = (unsigned int)fread(text, sizeof(char), size, file); unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
// WARNING: \r\n is converted to \n on reading, so, // WARNING: \r\n is converted to \n on reading, so,
// read bytes count gets reduced by the number of lines // read bytes count gets reduced by the number of lines
if (count < (unsigned int)size) text = realloc(text, count + 1); if (count < (unsigned int)size)
{
text = realloc(text, count + 1);
*length = count;
}
else *length = size;
// Zero-terminate the string // Zero-terminate the string
text[count] = '\0'; text[count] = '\0';
@ -545,15 +631,13 @@ char *LoadFileText(const char *fileName, int *length)
} }
// Get all lines from a text buffer (expecting lines ending with '\n') // Get all lines from a text buffer (expecting lines ending with '\n')
char **GetTextLines(const char *buffer, int length, int *linesCount) static char **GetTextLines(const char *buffer, int length, int *linesCount)
{ {
//#define MAX_LINE_LENGTH 512
// Get the number of lines in the text // Get the number of lines in the text
int count = 0; int count = 0;
for (int i = 0; i < length; i++) if (buffer[i] == '\n') count++; for (int i = 0; i < length; i++) if (buffer[i] == '\n') count++;
//printf("Number of text lines in buffer: %i\n", count); printf("Number of text lines in buffer: %i\n", count);
// Allocate as many pointers as lines // Allocate as many pointers as lines
char **lines = (char **)malloc(count*sizeof(char **)); char **lines = (char **)malloc(count*sizeof(char **));
@ -585,11 +669,11 @@ char **GetTextLines(const char *buffer, int length, int *linesCount)
// Get data type and name from a string containing both // Get data type and name from a string containing both
// NOTE: Useful to parse function parameters and struct fields // NOTE: Useful to parse function parameters and struct fields
void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name) static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name)
{ {
for (int k = typeNameLen; k > 0; k--) for (int k = typeNameLen; k > 0; k--)
{ {
if (typeName[k] == ' ') if (typeName[k] == ' ' && typeName[k - 1] != ',')
{ {
// Function name starts at this point (and ret type finishes at this point) // Function name starts at this point (and ret type finishes at this point)
MemoryCopy(type, typeName, k); MemoryCopy(type, typeName, k);
@ -605,8 +689,18 @@ void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char
} }
} }
// Get text length in bytes, check for \0 character
static unsigned int TextLength(const char *text)
{
unsigned int length = 0;
if (text != NULL) while (*text++) length++;
return length;
}
// Custom memcpy() to avoid <string.h> // Custom memcpy() to avoid <string.h>
void MemoryCopy(void *dest, const void *src, unsigned int count) static void MemoryCopy(void *dest, const void *src, unsigned int count)
{ {
char *srcPtr = (char *)src; char *srcPtr = (char *)src;
char *destPtr = (char *)dest; char *destPtr = (char *)dest;
@ -615,7 +709,7 @@ void MemoryCopy(void *dest, const void *src, unsigned int count)
} }
// Compare two text strings, requires number of characters to compare // Compare two text strings, requires number of characters to compare
bool IsTextEqual(const char *text1, const char *text2, unsigned int count) static bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
{ {
bool result = true; bool result = true;
@ -631,11 +725,20 @@ bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
return result; return result;
} }
// Search and replace a character within a string.
static char* CharReplace(char* text, char search, char replace)
{
for (int i = 0; text[i] != '\0'; i++)
if (text[i] == search)
text[i] = replace;
return text;
}
/* /*
// Replace text string // Replace text string
// REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations! // REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations!
// WARNING: Returned buffer must be freed by the user (if return != NULL) // WARNING: Returned buffer must be freed by the user (if return != NULL)
char *TextReplace(char *text, const char *replace, const char *by) static char *TextReplace(char *text, const char *replace, const char *by)
{ {
// Sanity checks and initialization // Sanity checks and initialization
if (!text || !replace || !by) return NULL; if (!text || !replace || !by) return NULL;
@ -682,3 +785,205 @@ char *TextReplace(char *text, const char *replace, const char *by)
return result; return result;
} }
*/ */
// Export parsed data in desired format
static void ExportParsedData(const char *fileName, int format)
{
FILE *outFile = fopen(fileName, "wt");
switch (format)
{
case DEFAULT:
{
// Print structs info
fprintf(outFile, "\nStructures found: %i\n\n", structCount);
for (int i = 0; i < structCount; i++)
{
fprintf(outFile, "Struct %02i: %s (%i fields)\n", i + 1, structs[i].name, structs[i].fieldCount);
fprintf(outFile, " Name: %s\n", structs[i].name);
fprintf(outFile, " Description: %s\n", structs[i].desc + 3);
for (int f = 0; f < structs[i].fieldCount; f++) fprintf(outFile, " Field[%i]: %s %s %s\n", f + 1, structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]);
}
// Print enums info
fprintf(outFile, "\nEnums found: %i\n\n", enumCount);
for (int i = 0; i < enumCount; i++)
{
fprintf(outFile, "Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount);
fprintf(outFile, " Name: %s\n", enums[i].name);
fprintf(outFile, " Description: %s\n", enums[i].desc + 3);
for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]);
}
// Print functions info
fprintf(outFile, "\nFunctions found: %i\n\n", funcCount);
for (int i = 0; i < funcCount; i++)
{
fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount);
fprintf(outFile, " Name: %s\n", funcs[i].name);
fprintf(outFile, " Return type: %s\n", funcs[i].retType);
fprintf(outFile, " Description: %s\n", funcs[i].desc + 3);
for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]);
if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
}
} break;
case JSON:
{
fprintf(outFile, "{\n");
// Print structs info
fprintf(outFile, " \"structs\": [\n");
for (int i = 0; i < structCount; i++)
{
fprintf(outFile, " {\n");
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].name);
fprintf(outFile, " \"description\": \"%s\",\n", structs[i].desc);
fprintf(outFile, " \"fields\": [\n");
for (int f = 0; f < structs[i].fieldCount; f++)
{
fprintf(outFile, " {\n");
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].fieldName[f]),
fprintf(outFile, " \"type\": \"%s\",\n", structs[i].fieldType[f]),
fprintf(outFile, " \"description\": \"%s\"\n", structs[i].fieldDesc[f] + 3),
fprintf(outFile, " }");
if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " ]\n");
fprintf(outFile, " }");
if (i < structCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " ],\n");
// Print enums info
fprintf(outFile, " \"enums\": [\n");
for (int i = 0; i < enumCount; i++)
{
fprintf(outFile, " {\n");
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].name);
fprintf(outFile, " \"description\": \"%s\",\n", enums[i].desc + 3);
fprintf(outFile, " \"values\": [\n");
for (int e = 0; e < enums[i].valueCount; e++)
{
fprintf(outFile, " {\n");
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].valueName[e]),
fprintf(outFile, " \"value\": %i,\n", enums[i].valueInteger[e]),
fprintf(outFile, " \"description\": \"%s\"\n", enums[i].valueDesc[e] + 3),
fprintf(outFile, " }");
if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " ]\n");
fprintf(outFile, " }");
if (i < enumCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " ],\n");
// Print functions info
fprintf(outFile, " \"functions\": [\n");
for (int i = 0; i < funcCount; i++)
{
fprintf(outFile, " {\n");
fprintf(outFile, " \"name\": \"%s\",\n", funcs[i].name);
fprintf(outFile, " \"description\": \"%s\",\n", CharReplace(funcs[i].desc, '\\', ' ') + 3);
fprintf(outFile, " \"returnType\": \"%s\"", funcs[i].retType);
if (funcs[i].paramCount == 0) fprintf(outFile, "\n");
else
{
fprintf(outFile, ",\n \"params\": {\n");
for (int p = 0; p < funcs[i].paramCount; p++)
{
fprintf(outFile, " \"%s\": \"%s\"", funcs[i].paramName[p], funcs[i].paramType[p]);
if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " }\n");
}
fprintf(outFile, " }");
if (i < funcCount - 1) fprintf(outFile, ",\n");
else fprintf(outFile, "\n");
}
fprintf(outFile, " ]\n");
fprintf(outFile, "}\n");
} break;
case XML:
{
// XML format to export data:
/*
<?xml version="1.0" encoding="Windows-1252" ?>
<raylibAPI>
<Structs count="">
<Struct name="" fieldCount="" desc="">
<Field type="" name="" desc="">
<Field type="" name="" desc="">
</Struct>
<Structs>
<Enums count="">
<Enum name="" valueCount="" desc="">
<Value name="" integer="" desc="">
<Value name="" integer="" desc="">
</Enum>
</Enums>
<Functions count="">
<Function name="" retType="" paramCount="" desc="">
<Param type="" name="" desc="" />
<Param type="" name="" desc="" />
</Function>
</Functions>
</raylibAPI>
*/
fprintf(outFile, "<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>\n");
fprintf(outFile, "<raylibAPI>\n");
// Print structs info
fprintf(outFile, " <Structs count=\"%i\">\n", structCount);
for (int i = 0; i < structCount; i++)
{
fprintf(outFile, " <Struct name=\"%s\" fieldCount=\"%i\" desc=\"%s\">\n", structs[i].name, structs[i].fieldCount, structs[i].desc + 3);
for (int f = 0; f < structs[i].fieldCount; f++)
{
fprintf(outFile, " <Field type=\"%s\" name=\"%s\" desc=\"%s\" />\n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f] + 3);
}
fprintf(outFile, " </Struct>\n");
}
fprintf(outFile, " </Structs>\n");
// Print enums info
fprintf(outFile, " <Enums count=\"%i\">\n", enumCount);
for (int i = 0; i < enumCount; i++)
{
fprintf(outFile, " <Enum name=\"%s\" valueCount=\"%i\" desc=\"%s\">\n", enums[i].name, enums[i].valueCount, enums[i].desc + 3);
for (int v = 0; v < enums[i].valueCount; v++)
{
fprintf(outFile, " <Value name=\"%s\" integer=\"%i\" desc=\"%s\" />\n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v] + 3);
}
fprintf(outFile, " </Enum>\n");
}
fprintf(outFile, " </Enums>\n");
// Print functions info
fprintf(outFile, " <Functions count=\"%i\">\n", funcCount);
for (int i = 0; i < funcCount; i++)
{
fprintf(outFile, " <Function name=\"%s\" retType=\"%s\" paramCount=\"%i\" desc=\"%s\">\n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc + 3);
for (int p = 0; p < funcs[i].paramCount; p++)
{
fprintf(outFile, " <Param type=\"%s\" name=\"%s\" desc=\"%s\" />\n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p] + 3);
}
fprintf(outFile, " </Function>\n");
}
fprintf(outFile, " </Functions>\n");
fprintf(outFile, "</raylibAPI>\n");
} break;
default: break;
}
fclose(outFile);
}

View File

@ -6,7 +6,7 @@ exception to this however, and that is Windows, because Windows
doesn't have a built-in C compiler. On Windows, you'll need to install doesn't have a built-in C compiler. On Windows, you'll need to install
[Visual Studio][visual-studio] or the [build tools][vs-tools]. If you [Visual Studio][visual-studio] or the [build tools][vs-tools]. If you
didn't install them in the default location, write your changes around didn't install them in the default location, write your changes around
line 101 of [`windows-build.bat`](windows-build.bat). line 101 of [`build-windows.bat`](build-windows.bat).
## Script customization ## Script customization
First of all, the scripts have a few variables at the very top, which First of all, the scripts have a few variables at the very top, which

View File

@ -55,6 +55,8 @@
#define SUPPORT_COMPRESSION_API 1 #define SUPPORT_COMPRESSION_API 1
// Support saving binary data automatically to a generated storage.data file. This file is managed internally. // Support saving binary data automatically to a generated storage.data file. This file is managed internally.
#define SUPPORT_DATA_STORAGE 1 #define SUPPORT_DATA_STORAGE 1
// Support automatic generated events, loading and recording of those events when required
#define SUPPORT_EVENTS_AUTOMATION 1
// core: Configuration values // core: Configuration values
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -41,10 +41,6 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
"MSVC" OFF) "MSVC" OFF)
if (BUILD_SHARED_LIBS)
set(_GLFW_BUILD_DLL 1)
endif()
if (BUILD_SHARED_LIBS AND UNIX) if (BUILD_SHARED_LIBS AND UNIX)
# On Unix-like systems, shared libraries can use the soname system. # On Unix-like systems, shared libraries can use the soname system.
set(GLFW_LIB_NAME glfw) set(GLFW_LIB_NAME glfw)
@ -73,19 +69,8 @@ endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set compiler specific flags # Set compiler specific flags
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (MSVC) if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (MSVC90) if (${CMAKE_VERSION} VERSION_LESS 3.15)
# Workaround for VS 2008 not shipping with the DirectX 9 SDK
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
# Workaround for VS 2008 not shipping with stdint.h
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
foreach (flag CMAKE_C_FLAGS foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE
@ -100,41 +85,8 @@ if (MSVC)
endif() endif()
endforeach() endforeach()
endif() else()
endif() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (MINGW)
# Workaround for legacy MinGW not providing XInput and DirectInput
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
# Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag)
# Compatibility with data execution prevention (DEP)
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
# Compatibility with address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
# Compatibility with 64-bit address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
endif() endif()
endif() endif()
@ -203,11 +155,8 @@ if (_GLFW_X11)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
list(APPEND glfw_PKG_DEPS "x11")
# Set up library and include paths # Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
# Check for XRandR (modern resolution switching and gamma control) # Check for XRandR (modern resolution switching and gamma control)
if (NOT X11_Xrandr_INCLUDE_PATH) if (NOT X11_Xrandr_INCLUDE_PATH)
@ -238,32 +187,24 @@ if (_GLFW_X11)
if (NOT X11_Xshape_INCLUDE_PATH) if (NOT X11_Xshape_INCLUDE_PATH)
message(FATAL_ERROR "X Shape headers not found; install libxext development package") message(FATAL_ERROR "X Shape headers not found; install libxext development package")
endif() endif()
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
"${X11_Xinerama_INCLUDE_PATH}"
"${X11_Xkb_INCLUDE_PATH}"
"${X11_Xcursor_INCLUDE_PATH}"
"${X11_Xi_INCLUDE_PATH}")
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Use Wayland for window creation # Use Wayland for window creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_WAYLAND) if (_GLFW_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
find_package(Wayland REQUIRED Client Cursor Egl) include(FindPkgConfig)
find_package(WaylandScanner REQUIRED) pkg_check_modules(Wayland REQUIRED
find_package(WaylandProtocols 1.15 REQUIRED) wayland-client>=0.2.7
wayland-cursor>=0.2.7
wayland-egl>=0.2.7
xkbcommon)
list(APPEND glfw_PKG_DEPS "wayland-egl") list(APPEND glfw_PKG_DEPS "wayland-client")
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}") list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
find_package(XKBCommon REQUIRED)
list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
include(CheckIncludeFiles) include(CheckIncludeFiles)
include(CheckFunctionExists) include(CheckFunctionExists)
@ -279,14 +220,6 @@ if (_GLFW_WAYLAND)
endif() endif()
endif() endif()
#--------------------------------------------------------------------
# Use OSMesa for offscreen context creation
#--------------------------------------------------------------------
if (_GLFW_OSMESA)
find_package(OSMesa REQUIRED)
list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Use Cocoa for window creation and NSOpenGL for context creation # Use Cocoa for window creation and NSOpenGL for context creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -312,12 +245,10 @@ endif()
# Export GLFW library dependencies # Export GLFW library dependencies
#-------------------------------------------------------------------- #--------------------------------------------------------------------
foreach(arg ${glfw_PKG_DEPS}) foreach(arg ${glfw_PKG_DEPS})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
"GLFW pkg-config Requires.private")
endforeach() endforeach()
foreach(arg ${glfw_PKG_LIBS}) foreach(arg ${glfw_PKG_LIBS})
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
"GLFW pkg-config Libs.private")
endforeach() endforeach()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -336,9 +267,7 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake
VERSION ${GLFW_VERSION} VERSION ${GLFW_VERSION}
COMPATIBILITY SameMajorVersion) COMPATIBILITY SameMajorVersion)
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY) configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY)
configure_file(CMake/glfw3.pc.in CMake/glfw3.pc @ONLY)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Add subdirectories # Add subdirectories

View File

@ -99,7 +99,7 @@ located in the `deps/` directory.
functions functions
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in - [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
examples examples
- [Nuklear](https://github.com/vurtun/nuklear) for test and example UI - [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
@ -127,7 +127,10 @@ information on what to include when reporting a bug.
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692) - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*` - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
values to select ANGLE backend (#1380) values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
surface extension (#1793)
- Made joystick subsystem initialize at first use (#1284,#1646) - Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1 - Updated the minimum required CMake version to 3.1
- Disabled tests and examples by default when built as a CMake subdirectory - Disabled tests and examples by default when built as a CMake subdirectory
- Bugfix: The CMake config-file package used an absolute path and was not - Bugfix: The CMake config-file package used an absolute path and was not
@ -137,6 +140,7 @@ information on what to include when reporting a bug.
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583) - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- Bugfix: Some extension loader headers did not prevent default OpenGL header - Bugfix: Some extension loader headers did not prevent default OpenGL header
inclusion (#1695) inclusion (#1695)
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu to the window menu
- [Win32] Added a version info resource to the GLFW DLL - [Win32] Added a version info resource to the GLFW DLL
@ -158,10 +162,20 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: Monitor functions could return invalid values after - [Win32] Bugfix: Monitor functions could return invalid values after
configuration change (#1761) configuration change (#1761)
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
(#1582)
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
Windows 10 version 1703 (#1511)
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
later (#1783,#1796)
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169) - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
(#1786)
- [Cocoa] Removed dependency on the CoreVideo framework - [Cocoa] Removed dependency on the CoreVideo framework
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll - [Cocoa] Bugfix: Window remained on screen after destruction until event poll
@ -174,6 +188,12 @@ information on what to include when reporting a bug.
(#1635) (#1635)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory could leak memory
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
regained focus (#1648,#1802)
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed - [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528) (#1462,#1528)
@ -199,6 +219,8 @@ information on what to include when reporting a bug.
combinaitons (#1598) combinaitons (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always - [X11] Bugfix: Keys pressed simultaneously with others were not always
reported (#1112,#1415,#1472,#1616) reported (#1112,#1415,#1472,#1616)
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
(#1863)
- [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
@ -206,6 +228,9 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
(#1463) (#1463)
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
(#1798)
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
@ -240,13 +265,16 @@ GLFW exists because people around the world donated their time and lent their
skills. skills.
- Bobyshev Alexander - Bobyshev Alexander
- Laurent Aphecetche
- Matt Arsenault - Matt Arsenault
- ashishgamedev
- David Avedissian - David Avedissian
- Keith Bauer - Keith Bauer
- John Bartholomew - John Bartholomew
- Coşku Baş - Coşku Baş
- Niklas Behrens - Niklas Behrens
- Andrew Belt - Andrew Belt
- Nevyn Bengtsson
- Niklas Bergström - Niklas Bergström
- Denis Bernard - Denis Bernard
- Doug Binks - Doug Binks
@ -268,6 +296,7 @@ skills.
- Andrew Corrigan - Andrew Corrigan
- Bailey Cosier - Bailey Cosier
- Noel Cower - Noel Cower
- CuriouserThing
- Jason Daly - Jason Daly
- Jarrod Davis - Jarrod Davis
- Olivier Delannoy - Olivier Delannoy
@ -294,6 +323,7 @@ skills.
- Eloi Marín Gratacós - Eloi Marín Gratacós
- Stefan Gustavson - Stefan Gustavson
- Jonathan Hale - Jonathan Hale
- hdf89shfdfs
- Sylvain Hellegouarch - Sylvain Hellegouarch
- Matthew Henry - Matthew Henry
- heromyth - heromyth
@ -318,11 +348,13 @@ skills.
- Konstantin Käfer - Konstantin Käfer
- Eric Larson - Eric Larson
- Francis Lecavalier - Francis Lecavalier
- Jong Won Lee
- Robin Leffmann - Robin Leffmann
- Glenn Lewis - Glenn Lewis
- Shane Liesegang - Shane Liesegang
- Anders Lindqvist - Anders Lindqvist
- Leon Linhart - Leon Linhart
- Marco Lizza
- Eyal Lotem - Eyal Lotem
- Aaron Loucks - Aaron Loucks
- Luflosi - Luflosi
@ -428,6 +460,9 @@ skills.
- Waris - Waris
- Jay Weisskopf - Jay Weisskopf
- Frank Wille - Frank Wille
- Andy Williams
- Joel Winarske
- Richard A. Wilkes
- Tatsuya Yatagawa - Tatsuya Yatagawa
- Ryogo Yoshimura - Ryogo Yoshimura
- Lukas Zanner - Lukas Zanner
@ -436,6 +471,7 @@ skills.
- Santi Zupancic - Santi Zupancic
- Jonas Ådahl - Jonas Ådahl
- Lasse Öörni - Lasse Öörni
- Leonard König
- All the unmentioned and anonymous contributors in the GLFW community, for bug - All the unmentioned and anonymous contributors in the GLFW community, for bug
reports, patches, feedback, testing and encouragement reports, patches, feedback, testing and encouragement

View File

@ -276,23 +276,24 @@ extern "C" {
/*! @name GLFW version macros /*! @name GLFW version macros
* @{ */ * @{ */
/*! @brief The major version number of the GLFW library. /*! @brief The major version number of the GLFW header.
* *
* This is incremented when the API is changed in non-compatible ways. * The major version number of the GLFW header. This is incremented when the
* API is changed in non-compatible ways.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_MAJOR 3 #define GLFW_VERSION_MAJOR 3
/*! @brief The minor version number of the GLFW library. /*! @brief The minor version number of the GLFW header.
* *
* This is incremented when features are added to the API but it remains * The minor version number of the GLFW header. This is incremented when
* backward-compatible. * features are added to the API but it remains backward-compatible.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_MINOR 4 #define GLFW_VERSION_MINOR 4
/*! @brief The revision number of the GLFW library. /*! @brief The revision number of the GLFW header.
* *
* This is incremented when a bug fix release is made that does not contain any * The revision number of the GLFW header. This is incremented when a bug fix
* API changes. * release is made that does not contain any API changes.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_REVISION 0 #define GLFW_VERSION_REVISION 0
@ -977,9 +978,10 @@ extern "C" {
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE). * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
*/ */
#define GLFW_REFRESH_RATE 0x0002100F #define GLFW_REFRESH_RATE 0x0002100F
/*! @brief Framebuffer double buffering hint. /*! @brief Framebuffer double buffering hint and attribute.
* *
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER). * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
*/ */
#define GLFW_DOUBLEBUFFER 0x00021010 #define GLFW_DOUBLEBUFFER 0x00021010
@ -1250,6 +1252,11 @@ extern "C" {
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint). * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
*/ */
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002
/*! @brief X11 specific init hint.
*
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
*/
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @} */ /*! @} */
#define GLFW_DONT_CARE -1 #define GLFW_DONT_CARE -1
@ -2417,8 +2424,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
* *
* This function returns an array of all video modes supported by the specified * This function returns an array of all video modes supported by the specified
* monitor. The returned array is sorted in ascending order, first by color * monitor. The returned array is sorted in ascending order, first by color
* bit depth (the sum of all channel depths) and then by resolution area (the * bit depth (the sum of all channel depths), then by resolution area (the
* product of width and height). * product of width and height), then resolution width and finally by refresh
* rate.
* *
* @param[in] monitor The monitor to query. * @param[in] monitor The monitor to query.
* @param[out] count Where to store the number of video modes in the returned * @param[out] count Where to store the number of video modes in the returned
@ -5865,9 +5873,8 @@ GLFWAPI int glfwVulkanSupported(void);
* returned array, as it is an error to specify an extension more than once in * returned array, as it is an error to specify an extension more than once in
* the `VkInstanceCreateInfo` struct. * the `VkInstanceCreateInfo` struct.
* *
* @remark @macos This function currently supports either the * @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface` * the newer `VK_EXT_metal_surface` extensions.
* extension.
* *
* @pointer_lifetime The returned array is allocated and freed by GLFW. You * @pointer_lifetime The returned array is allocated and freed by GLFW. You
* should not free it yourself. It is guaranteed to be valid only until the * should not free it yourself. It is guaranteed to be valid only until the
@ -5950,7 +5957,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
* *
* @remark @macos This function currently always returns `GLFW_TRUE`, as the * @remark @macos This function currently always returns `GLFW_TRUE`, as the
* `VK_MVK_macos_surface` extension does not provide * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
* a `vkGetPhysicalDevice*PresentationSupport` type function. * a `vkGetPhysicalDevice*PresentationSupport` type function.
* *
* @thread_safety This function may be called from any thread. For * @thread_safety This function may be called from any thread. For
@ -6013,6 +6020,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* @remark @macos This function creates and sets a `CAMetalLayer` instance for * @remark @macos This function creates and sets a `CAMetalLayer` instance for
* the window content view, which is required for MoltenVK to function. * the window content view, which is required for MoltenVK to function.
* *
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
* extension by setting the
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
* hint.
*
* @thread_safety This function may be called from any thread. For * @thread_safety This function may be called from any thread. For
* synchronization details of Vulkan objects, see the Vulkan specification. * synchronization details of Vulkan objects, see the Vulkan specification.
* *

View File

@ -83,8 +83,8 @@ extern "C" {
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL) #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output // example to allow applications to correctly declare a GL_KHR_debug callback)
// callback) but windows.h assumes no one will define APIENTRY before it does // but windows.h assumes no one will define APIENTRY before it does
#if defined(GLFW_APIENTRY_DEFINED) #if defined(GLFW_APIENTRY_DEFINED)
#undef APIENTRY #undef APIENTRY
#undef GLFW_APIENTRY_DEFINED #undef GLFW_APIENTRY_DEFINED
@ -96,7 +96,6 @@ extern "C" {
typedef PVOID HANDLE; typedef PVOID HANDLE;
typedef HANDLE HWND; typedef HANDLE HWND;
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL) #elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
#include <ApplicationServices/ApplicationServices.h>
#if defined(__OBJC__) #if defined(__OBJC__)
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#else #else

View File

@ -1,149 +1,192 @@
set(common_HEADERS internal.h mappings.h add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
"${GLFW_BINARY_DIR}/src/glfw_config.h" "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" internal.h mappings.h context.c init.c input.c monitor.c
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h") vulkan.c window.c)
set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
if (_GLFW_COCOA) if (_GLFW_COCOA)
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
posix_thread.h nsgl_context.h egl_context.h osmesa_context.h) nsgl_context.h egl_context.h osmesa_context.h
set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c cocoa_window.m cocoa_time.c posix_thread.c
nsgl_context.m egl_context.c osmesa_context.c) nsgl_context.m egl_context.c osmesa_context.c)
elseif (_GLFW_WIN32) elseif (_GLFW_WIN32)
set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
wgl_context.h egl_context.h osmesa_context.h) egl_context.h osmesa_context.h win32_init.c
set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_joystick.c win32_joystick.c win32_monitor.c win32_time.c
win32_monitor.c win32_time.c win32_thread.c win32_window.c win32_thread.c win32_window.c wgl_context.c
wgl_context.c egl_context.c osmesa_context.c) egl_context.c osmesa_context.c)
elseif (_GLFW_X11) elseif (_GLFW_X11)
set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h
posix_thread.h glx_context.h egl_context.h osmesa_context.h) posix_thread.h glx_context.h egl_context.h
set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c osmesa_context.h x11_init.c x11_monitor.c
xkb_unicode.c posix_time.c posix_thread.c glx_context.c x11_window.c xkb_unicode.c posix_time.c
egl_context.c osmesa_context.c) posix_thread.c glx_context.c egl_context.c
osmesa_context.c)
elseif (_GLFW_WAYLAND) elseif (_GLFW_WAYLAND)
set(glfw_HEADERS ${common_HEADERS} wl_platform.h target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
posix_time.h posix_thread.h xkb_unicode.h egl_context.h xkb_unicode.h egl_context.h osmesa_context.h
osmesa_context.h) wl_init.c wl_monitor.c wl_window.c posix_time.c
set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c posix_thread.c xkb_unicode.c egl_context.c
posix_time.c posix_thread.c xkb_unicode.c osmesa_context.c)
egl_context.c osmesa_context.c)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
BASENAME xdg-shell)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
BASENAME xdg-decoration)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
BASENAME viewporter)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
BASENAME relative-pointer-unstable-v1)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
BASENAME pointer-constraints-unstable-v1)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
BASENAME idle-inhibit-unstable-v1)
elseif (_GLFW_OSMESA) elseif (_GLFW_OSMESA)
set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
posix_time.h posix_thread.h osmesa_context.h) posix_thread.h osmesa_context.h null_init.c
set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c null_monitor.c null_window.c null_joystick.c
null_joystick.c posix_time.c posix_thread.c osmesa_context.c) posix_time.c posix_thread.c osmesa_context.c)
endif() endif()
if (_GLFW_X11 OR _GLFW_WAYLAND) if (_GLFW_X11 OR _GLFW_WAYLAND)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h) target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
else() else()
set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h) target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c)
endif() endif()
endif() endif()
if (APPLE) if (_GLFW_WAYLAND)
# For some reason, CMake doesn't know about .m find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
macro(wayland_generate protocol_file output_file)
add_custom_command(OUTPUT "${output_file}.h"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
DEPENDS "${protocol_file}"
VERBATIM)
add_custom_command(OUTPUT "${output_file}.c"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
DEPENDS "${protocol_file}"
VERBATIM)
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c")
endmacro()
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
"${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
endif() endif()
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept if (WIN32 AND BUILD_SHARED_LIBS)
# for all source files that VS will build configure_file(glfw.rc.in glfw.rc @ONLY)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
if (WIN32)
set(windows_SOURCES ${glfw_SOURCES})
else()
set(windows_SOURCES ${common_SOURCES})
endif()
set_source_files_properties(${windows_SOURCES} PROPERTIES
COMPILE_FLAGS -Wdeclaration-after-statement)
endif() endif()
add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS}) configure_file(glfw_config.h.in glfw_config.h @ONLY)
add_library(glfw $<TARGET_OBJECTS:glfw_objlib>) target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON) target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
set_target_properties(glfw PROPERTIES set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME} OUTPUT_NAME ${GLFW_LIB_NAME}
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
SOVERSION ${GLFW_VERSION_MAJOR} SOVERSION ${GLFW_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON
C_STANDARD 99
C_EXTENSIONS OFF
DEFINE_SYMBOL _GLFW_BUILD_DLL
FOLDER "GLFW3") FOLDER "GLFW3")
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
set_target_properties(glfw_objlib PROPERTIES C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
target_compile_options(glfw_objlib PRIVATE
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
endif()
target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H)
target_include_directories(glfw_objlib PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
target_include_directories(glfw PUBLIC target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(glfw_objlib PRIVATE target_include_directories(glfw PRIVATE
"${GLFW_SOURCE_DIR}/src" "${GLFW_SOURCE_DIR}/src"
"${GLFW_BINARY_DIR}/src" "${GLFW_BINARY_DIR}/src"
${glfw_INCLUDE_DIRS}) ${glfw_INCLUDE_DIRS})
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
# Workaround for CMake not knowing about .m files before version 3.16
if ("${CMAKE_VERSION}" VERSION_LESS "3.16" AND APPLE)
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m nsgl_context.m PROPERTIES
LANGUAGE C)
endif()
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
# source files that VS will build (Clang ignores this because we set -std=c99)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
window.c win32_init.c win32_joystick.c
win32_monitor.c win32_time.c win32_thread.c
win32_window.c wgl_context.c egl_context.c
osmesa_context.c PROPERTIES
COMPILE_FLAGS -Wdeclaration-after-statement)
endif()
# Enable a reasonable set of warnings
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
if (MSVC)
target_compile_options(glfw PRIVATE "/W3")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(glfw PRIVATE "-Wall")
endif()
if (_GLFW_WIN32)
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
endif()
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before # HACK: When building on MinGW, WINVER and UNICODE need to be defined before
# the inclusion of stddef.h (by glfw3.h), which is itself included before # the inclusion of stddef.h (by glfw3.h), which is itself included before
# win32_platform.h. We define them here until a saner solution can be found # win32_platform.h. We define them here until a saner solution can be found
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
target_compile_definitions(glfw_objlib PRIVATE if (MINGW)
"$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>") target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif()
# Enable a reasonable set of warnings (no, -Wextra is not reasonable) # Workaround for legacy MinGW not providing XInput and DirectInput
target_compile_options(glfw_objlib PRIVATE if (MINGW)
"$<$<C_COMPILER_ID:AppleClang>:-Wall>" include(CheckIncludeFile)
"$<$<C_COMPILER_ID:Clang>:-Wall>" check_include_file(dinput.h DINPUT_H_FOUND)
"$<$<C_COMPILER_ID:GNU>:-Wall>") check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
endif()
# Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# Workaround for VS 2008 not shipping with stdint.h
if (MSVC90)
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
# Check for the DirectX 9 SDK as it is not included with VS 2008
if (MSVC90)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
endif()
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
if (WIN32) if (WIN32)
if (MINGW) if (MINGW)
# Remove the dependency on the shared version of libgcc # Remove the dependency on the shared version of libgcc
# NOTE: MinGW-w64 has the correct default but MinGW needs this # NOTE: MinGW-w64 has the correct default but MinGW needs this
target_link_options(glfw PRIVATE "-static-libgcc") target_link_libraries(glfw PRIVATE "-static-libgcc")
# Remove the lib prefix on the DLL (but not the import library) # Remove the lib prefix on the DLL (but not the import library)
set_target_properties(glfw PROPERTIES PREFIX "") set_target_properties(glfw PROPERTIES PREFIX "")
@ -155,33 +198,48 @@ if (BUILD_SHARED_LIBS)
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
endif() endif()
target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL) target_compile_definitions(glfw INTERFACE GLFW_DLL)
elseif (APPLE) endif()
# Add -fno-common to work around a bug in Apple's GCC
target_compile_options(glfw_objlib PRIVATE "-fno-common")
set_target_properties(glfw PROPERTIES if (MINGW)
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") # Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag)
# Compatibility with data execution prevention (DEP)
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP)
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
endif()
# Compatibility with address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
endif()
# Compatibility with 64-bit address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
endif()
# Clear flags again to avoid breaking later tests
set(CMAKE_REQUIRED_FLAGS)
endif() endif()
if (UNIX) if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library # Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw_objlib PRIVATE "-fvisibility=hidden") target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif() endif()
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
else()
target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
endif()
if (MSVC)
target_compile_definitions(glfw_objlib PRIVATE _CRT_SECURE_NO_WARNINGS)
endif() endif()
if (GLFW_INSTALL) if (GLFW_INSTALL)
install(TARGETS glfw install(TARGETS glfw
EXPORT glfwTargets EXPORT glfwTargets
RUNTIME DESTINATION "bin" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif() endif()

View File

@ -251,7 +251,7 @@ static void createKeyTables(void)
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10; _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11; _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12; _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
_glfw.ns.keycodes[0x69] = GLFW_KEY_F13; _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14; _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15; _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16; _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void)
{ {
if (_glfw.hints.init.ns.menubar) if (_glfw.hints.init.ns.menubar)
{ {
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// Menu bar setup must go between sharedApplication and finishLaunching // Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain // in order to properly emulate the behavior of NSApplicationMain
@ -557,6 +554,10 @@ int _glfwPlatformInit(void)
if (![[NSRunningApplication currentApplication] isFinishedLaunching]) if (![[NSRunningApplication currentApplication] isFinishedLaunching])
[NSApp run]; [NSApp run];
// In case we are unbundled, make us a proper UI application
if (_glfw.hints.init.ns.menubar)
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
return GLFW_TRUE; return GLFW_TRUE;
} // autoreleasepool } // autoreleasepool

View File

@ -39,8 +39,21 @@
// Get the name of the specified display, or NULL // Get the name of the specified display, or NULL
// //
static char* getDisplayName(CGDirectDisplayID displayID) static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
{ {
// IOKit doesn't work on Apple Silicon anymore
// Luckily, 10.15 introduced -[NSScreen localizedName].
// Use it if available, and fall back to IOKit otherwise.
if (screen)
{
if ([screen respondsToSelector:@selector(localizedName)])
{
NSString* name = [screen valueForKey:@"localizedName"];
if (name)
return _glfw_strdup([name UTF8String]);
}
}
io_iterator_t it; io_iterator_t it;
io_service_t service; io_service_t service;
CFDictionaryRef info; CFDictionaryRef info;
@ -50,7 +63,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
&it) != 0) &it) != 0)
{ {
// This may happen if a desktop Mac is running headless // This may happen if a desktop Mac is running headless
return NULL; return _glfw_strdup("Display");
} }
while ((service = IOIteratorNext(it)) != 0) while ((service = IOIteratorNext(it)) != 0)
@ -88,7 +101,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find service port for display"); "Cocoa: Failed to find service port for display");
return NULL; return _glfw_strdup("Display");
} }
CFDictionaryRef names = CFDictionaryRef names =
@ -101,7 +114,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{ {
// This may happen if a desktop Mac is running headless // This may happen if a desktop Mac is running headless
CFRelease(info); CFRelease(info);
return NULL; return _glfw_strdup("Display");
} }
const CFIndex size = const CFIndex size =
@ -209,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
} }
} }
// Finds and caches the NSScreen corresponding to the specified monitor
//
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
{
if (monitor->ns.screen)
return GLFW_TRUE;
for (NSScreen* screen in [NSScreen screens])
{
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
{
monitor->ns.screen = screen;
return GLFW_TRUE;
}
}
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
return GLFW_FALSE;
}
// Returns the display refresh rate queried from the I/O registry // Returns the display refresh rate queried from the I/O registry
// //
static double getFallbackRefreshRate(CGDirectDisplayID displayID) static double getFallbackRefreshRate(CGDirectDisplayID displayID)
@ -334,27 +322,46 @@ void _glfwPollMonitorsNS(void)
if (CGDisplayIsAsleep(displays[i])) if (CGDisplayIsAsleep(displays[i]))
continue; continue;
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
NSScreen* screen = nil;
for (screen in [NSScreen screens])
{
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around // HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics // display replacement on machines with automatic graphics
// switching // switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
for (uint32_t j = 0; j < disconnectedCount; j++) break;
}
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
uint32_t j;
for (j = 0; j < disconnectedCount; j++)
{ {
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{ {
disconnected[j]->ns.screen = screen;
disconnected[j] = NULL; disconnected[j] = NULL;
break; break;
} }
} }
if (j < disconnectedCount)
continue;
const CGSize size = CGDisplayScreenSize(displays[i]); const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]); char* name = getMonitorName(displays[i], screen);
if (!name) if (!name)
name = _glfw_strdup("Unknown"); continue;
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i]; monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber; monitor->ns.unitNumber = unitNumber;
monitor->ns.screen = screen;
free(name); free(name);
@ -463,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
{ {
@autoreleasepool { @autoreleasepool {
if (!refreshMonitorScreen(monitor)) if (!monitor->ns.screen)
return; {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query content scale without screen");
}
const NSRect points = [monitor->ns.screen frame]; const NSRect points = [monitor->ns.screen frame];
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points]; const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
@ -483,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
{ {
@autoreleasepool { @autoreleasepool {
if (!refreshMonitorScreen(monitor)) if (!monitor->ns.screen)
return; {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query workarea without screen");
}
const NSRect frameRect = [monitor->ns.screen visibleFrame]; const NSRect frameRect = [monitor->ns.screen visibleFrame];
@ -527,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
} }
// Skip duplicate modes // Skip duplicate modes
if (i < *count) if (j < *count)
continue; continue;
(*count)++; (*count)++;

View File

@ -1635,14 +1635,21 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
SEL cursorSelector = NULL; SEL cursorSelector = NULL;
// HACK: Try to use a private message // HACK: Try to use a private message
if (shape == GLFW_RESIZE_EW_CURSOR) switch (shape)
{
case GLFW_RESIZE_EW_CURSOR:
cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
else if (shape == GLFW_RESIZE_NS_CURSOR) break;
case GLFW_RESIZE_NS_CURSOR:
cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
else if (shape == GLFW_RESIZE_NWSE_CURSOR) break;
case GLFW_RESIZE_NWSE_CURSOR:
cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
else if (shape == GLFW_RESIZE_NESW_CURSOR) break;
case GLFW_RESIZE_NESW_CURSOR:
cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
break;
}
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
{ {
@ -1653,22 +1660,33 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
if (!cursor->ns.object) if (!cursor->ns.object)
{ {
if (shape == GLFW_ARROW_CURSOR) switch (shape)
{
case GLFW_ARROW_CURSOR:
cursor->ns.object = [NSCursor arrowCursor]; cursor->ns.object = [NSCursor arrowCursor];
else if (shape == GLFW_IBEAM_CURSOR) break;
case GLFW_IBEAM_CURSOR:
cursor->ns.object = [NSCursor IBeamCursor]; cursor->ns.object = [NSCursor IBeamCursor];
else if (shape == GLFW_CROSSHAIR_CURSOR) break;
case GLFW_CROSSHAIR_CURSOR:
cursor->ns.object = [NSCursor crosshairCursor]; cursor->ns.object = [NSCursor crosshairCursor];
else if (shape == GLFW_POINTING_HAND_CURSOR) break;
case GLFW_POINTING_HAND_CURSOR:
cursor->ns.object = [NSCursor pointingHandCursor]; cursor->ns.object = [NSCursor pointingHandCursor];
else if (shape == GLFW_RESIZE_EW_CURSOR) break;
case GLFW_RESIZE_EW_CURSOR:
cursor->ns.object = [NSCursor resizeLeftRightCursor]; cursor->ns.object = [NSCursor resizeLeftRightCursor];
else if (shape == GLFW_RESIZE_NS_CURSOR) break;
case GLFW_RESIZE_NS_CURSOR:
cursor->ns.object = [NSCursor resizeUpDownCursor]; cursor->ns.object = [NSCursor resizeUpDownCursor];
else if (shape == GLFW_RESIZE_ALL_CURSOR) break;
case GLFW_RESIZE_ALL_CURSOR:
cursor->ns.object = [NSCursor closedHandCursor]; cursor->ns.object = [NSCursor closedHandCursor];
else if (shape == GLFW_NOT_ALLOWED_CURSOR) break;
case GLFW_NOT_ALLOWED_CURSOR:
cursor->ns.object = [NSCursor operationNotAllowedCursor]; cursor->ns.object = [NSCursor operationNotAllowedCursor];
break;
}
} }
if (!cursor->ns.object) if (!cursor->ns.object)

View File

@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (desired->doublebuffer != current->doublebuffer)
{
// Double buffering is a hard constraint
continue;
}
// Count number of missing buffers // Count number of missing buffers
{ {
missing = 0; missing = 0;
@ -570,6 +564,8 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC) PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear"); window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
if (window->doublebuffer)
window->context.swapBuffers(window); window->context.swapBuffers(window);
} }

View File

@ -173,7 +173,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE); u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES); u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE; u->doublebuffer = desired->doublebuffer;
u->handle = (uintptr_t) n; u->handle = (uintptr_t) n;
usableCount++; usableCount++;
@ -643,6 +643,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
} }
if (!fbconfig->doublebuffer)
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
setAttrib(EGL_NONE, EGL_NONE); setAttrib(EGL_NONE, EGL_NONE);
native = _glfwPlatformGetEGLNativeWindow(window); native = _glfwPlatformGetEGLNativeWindow(window);

View File

@ -64,6 +64,8 @@
#define EGL_OPENGL_ES_API 0x30a0 #define EGL_OPENGL_ES_API 0x30a0
#define EGL_OPENGL_API 0x30a2 #define EGL_OPENGL_API 0x30a2
#define EGL_NONE 0x3038 #define EGL_NONE 0x3038
#define EGL_RENDER_BUFFER 0x3086
#define EGL_SINGLE_BUFFER 0x3085
#define EGL_EXTENSIONS 0x3055 #define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e #define EGL_NATIVE_VISUAL_ID 0x302e

View File

@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
continue;
if (desired->transparent) if (desired->transparent)
{ {
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n); XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
if (getGLXFBConfigAttrib(n, GLX_STEREO)) if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
u->doublebuffer = GLFW_TRUE;
if (_glfw.glx.ARB_multisample) if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES); u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);

View File

@ -57,7 +57,10 @@ static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // macOS menu bar GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir GLFW_TRUE // macOS bundle chdir
} },
{
GLFW_TRUE, // X11 XCB Vulkan surface
},
}; };
// Terminate the library // Terminate the library
@ -298,6 +301,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_COCOA_MENUBAR: case GLFW_COCOA_MENUBAR:
_glfwInitHints.ns.menubar = value; _glfwInitHints.ns.menubar = value;
return; return;
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
} }
_glfwInputError(GLFW_INVALID_ENUM, _glfwInputError(GLFW_INVALID_ENUM,

View File

@ -446,7 +446,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
js->present = GLFW_TRUE; js->present = GLFW_TRUE;
js->name = _glfw_strdup(name);
js->axes = calloc(axisCount, sizeof(float)); js->axes = calloc(axisCount, sizeof(float));
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1); js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = calloc(hatCount, 1); js->hats = calloc(hatCount, 1);
@ -454,6 +453,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js->buttonCount = buttonCount; js->buttonCount = buttonCount;
js->hatCount = hatCount; js->hatCount = hatCount;
strncpy(js->name, name, sizeof(js->name) - 1);
strncpy(js->guid, guid, sizeof(js->guid) - 1); strncpy(js->guid, guid, sizeof(js->guid) - 1);
js->mapping = findValidMapping(js); js->mapping = findValidMapping(js);
@ -464,7 +464,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
// //
void _glfwFreeJoystick(_GLFWjoystick* js) void _glfwFreeJoystick(_GLFWjoystick* js)
{ {
free(js->name);
free(js->axes); free(js->axes);
free(js->buttons); free(js->buttons);
free(js->hats); free(js->hats);

View File

@ -248,6 +248,9 @@ struct _GLFWinitconfig
GLFWbool menubar; GLFWbool menubar;
GLFWbool chdir; GLFWbool chdir;
} ns; } ns;
struct {
GLFWbool xcbVulkanSurface;
} x11;
}; };
// Window configuration // Window configuration
@ -384,6 +387,7 @@ struct _GLFWwindow
GLFWbool mousePassthrough; GLFWbool mousePassthrough;
GLFWbool shouldClose; GLFWbool shouldClose;
void* userPointer; void* userPointer;
GLFWbool doublebuffer;
GLFWvidmode videoMode; GLFWvidmode videoMode;
_GLFWmonitor* monitor; _GLFWmonitor* monitor;
_GLFWcursor* cursor; _GLFWcursor* cursor;
@ -432,7 +436,7 @@ struct _GLFWwindow
// //
struct _GLFWmonitor struct _GLFWmonitor
{ {
char* name; char name[128];
void* userPointer; void* userPointer;
// Physical dimensions in millimeters. // Physical dimensions in millimeters.
@ -493,7 +497,7 @@ struct _GLFWjoystick
int buttonCount; int buttonCount;
unsigned char* hats; unsigned char* hats;
int hatCount; int hatCount;
char* name; char name[128];
void* userPointer; void* userPointer;
char guid[33]; char guid[33];
_GLFWmapping* mapping; _GLFWmapping* mapping;

File diff suppressed because it is too large Load Diff

View File

@ -170,8 +170,7 @@ _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
monitor->widthMM = widthMM; monitor->widthMM = widthMM;
monitor->heightMM = heightMM; monitor->heightMM = heightMM;
if (name) strncpy(monitor->name, name, sizeof(monitor->name) - 1);
monitor->name = _glfw_strdup(name);
return monitor; return monitor;
} }
@ -189,7 +188,6 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
_glfwFreeGammaArrays(&monitor->currentRamp); _glfwFreeGammaArrays(&monitor->currentRamp);
free(monitor->modes); free(monitor->modes);
free(monitor->name);
free(monitor); free(monitor);
} }

View File

@ -165,6 +165,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue; continue;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue;
u->redBits = findAttribValue(WGL_RED_BITS_ARB); u->redBits = findAttribValue(WGL_RED_BITS_ARB);
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB); u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB); u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
@ -182,8 +185,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_STEREO_ARB)) if (findAttribValue(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
u->doublebuffer = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample) if (_glfw.wgl.ARB_multisample)
u->samples = findAttribValue(WGL_SAMPLES_ARB); u->samples = findAttribValue(WGL_SAMPLES_ARB);
@ -239,6 +240,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.iPixelType != PFD_TYPE_RGBA) if (pfd.iPixelType != PFD_TYPE_RGBA)
continue; continue;
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
continue;
u->redBits = pfd.cRedBits; u->redBits = pfd.cRedBits;
u->greenBits = pfd.cGreenBits; u->greenBits = pfd.cGreenBits;
u->blueBits = pfd.cBlueBits; u->blueBits = pfd.cBlueBits;
@ -256,8 +260,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.dwFlags & PFD_STEREO) if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
u->doublebuffer = GLFW_TRUE;
} }
u->handle = pixelFormat; u->handle = pixelFormat;

View File

@ -39,6 +39,10 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID =
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) #if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
#if defined(_GLFW_BUILD_DLL)
#warning "These symbols must be exported by the executable and have no effect in a DLL"
#endif
// Executables (but not DLLs) exporting this symbol with this value will be // Executables (but not DLLs) exporting this symbol with this value will be
// automatically directed to the high-performance GPU on Nvidia Optimus systems // automatically directed to the high-performance GPU on Nvidia Optimus systems
// with up-to-date drivers // with up-to-date drivers
@ -614,7 +618,9 @@ void _glfwPlatformTerminate(void)
const char* _glfwPlatformGetVersionString(void) const char* _glfwPlatformGetVersionString(void)
{ {
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa" return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
#if defined(__MINGW32__) #if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64"
#elif defined(__MINGW32__)
" MinGW" " MinGW"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
" VisualC" " VisualC"

View File

@ -39,8 +39,8 @@
#endif #endif
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output // example to allow applications to correctly declare a GL_KHR_debug callback)
// callback) but windows.h assumes no one will define APIENTRY before it does // but windows.h assumes no one will define APIENTRY before it does
#undef APIENTRY #undef APIENTRY
// GLFW on Windows is Unicode only and does not work in MBCS mode // GLFW on Windows is Unicode only and does not work in MBCS mode
@ -314,6 +314,9 @@ typedef struct _GLFWwindowWin32
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
GLFWbool keymenu; GLFWbool keymenu;
// Cached size used to filter out duplicate events
int width, height;
// The last received cursor position, regardless of source // The last received cursor position, regardless of source
int lastCursorPosX, lastCursorPosY; int lastCursorPosX, lastCursorPosY;
// The last recevied high surrogate when decoding pairs of UTF-16 messages // The last recevied high surrogate when decoding pairs of UTF-16 messages

View File

@ -501,7 +501,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_NCCREATE: case WM_NCCREATE:
{ {
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
{
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
// On per-monitor DPI aware V1 systems, only enable
// non-client scaling for windows that scale the client area
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
// area static when the non-client area is scaled
if (wndconfig && wndconfig->scaleToMonitor)
EnableNonClientDpiScaling(hWnd); EnableNonClientDpiScaling(hWnd);
}
break; break;
} }
@ -961,6 +971,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_SIZE: case WM_SIZE:
{ {
const int width = LOWORD(lParam);
const int height = HIWORD(lParam);
const GLFWbool iconified = wParam == SIZE_MINIMIZED; const GLFWbool iconified = wParam == SIZE_MINIMIZED;
const GLFWbool maximized = wParam == SIZE_MAXIMIZED || const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
(window->win32.maximized && (window->win32.maximized &&
@ -975,8 +987,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->win32.maximized != maximized) if (window->win32.maximized != maximized)
_glfwInputWindowMaximize(window, maximized); _glfwInputWindowMaximize(window, maximized);
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); if (width != window->win32.width || height != window->win32.height)
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); {
window->win32.width = width;
window->win32.height = height;
_glfwInputFramebufferSize(window, width, height);
_glfwInputWindowSize(window, width, height);
}
if (window->monitor && window->win32.iconified != iconified) if (window->monitor && window->win32.iconified != iconified)
{ {
@ -1130,9 +1148,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
// Only apply the suggested size if the OS is new enough to have // Resize windowed mode windows that either permit rescaling or that
// sent a WM_GETDPISCALEDSIZE before this // need it to compensate for non-client area scaling
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) if (!window->monitor &&
(window->win32.scaleToMonitor ||
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
{ {
RECT* suggested = (RECT*) lParam; RECT* suggested = (RECT*) lParam;
SetWindowPos(window->win32.handle, HWND_TOP, SetWindowPos(window->win32.handle, HWND_TOP,
@ -1247,7 +1267,7 @@ static int createNativeWindow(_GLFWwindow* window,
NULL, // No parent window NULL, // No parent window
NULL, // No window menu NULL, // No window menu
GetModuleHandleW(NULL), GetModuleHandleW(NULL),
NULL); (LPVOID) wndconfig);
free(wideTitle); free(wideTitle);
@ -1315,6 +1335,8 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.transparent = GLFW_TRUE; window->win32.transparent = GLFW_TRUE;
} }
_glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height);
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -2113,28 +2135,39 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
int id = 0; int id = 0;
if (shape == GLFW_ARROW_CURSOR) switch (shape)
id = OCR_NORMAL;
else if (shape == GLFW_IBEAM_CURSOR)
id = OCR_IBEAM;
else if (shape == GLFW_CROSSHAIR_CURSOR)
id = OCR_CROSS;
else if (shape == GLFW_POINTING_HAND_CURSOR)
id = OCR_HAND;
else if (shape == GLFW_RESIZE_EW_CURSOR)
id = OCR_SIZEWE;
else if (shape == GLFW_RESIZE_NS_CURSOR)
id = OCR_SIZENS;
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
id = OCR_SIZENWSE;
else if (shape == GLFW_RESIZE_NESW_CURSOR)
id = OCR_SIZENESW;
else if (shape == GLFW_RESIZE_ALL_CURSOR)
id = OCR_SIZEALL;
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
id = OCR_NO;
else
{ {
case GLFW_ARROW_CURSOR:
id = OCR_NORMAL;
break;
case GLFW_IBEAM_CURSOR:
id = OCR_IBEAM;
break;
case GLFW_CROSSHAIR_CURSOR:
id = OCR_CROSS;
break;
case GLFW_POINTING_HAND_CURSOR:
id = OCR_HAND;
break;
case GLFW_RESIZE_EW_CURSOR:
id = OCR_SIZEWE;
break;
case GLFW_RESIZE_NS_CURSOR:
id = OCR_SIZENS;
break;
case GLFW_RESIZE_NWSE_CURSOR:
id = OCR_SIZENWSE;
break;
case GLFW_RESIZE_NESW_CURSOR:
id = OCR_SIZENESW;
break;
case GLFW_RESIZE_ALL_CURSOR:
id = OCR_SIZEALL;
break;
case GLFW_NOT_ALLOWED_CURSOR:
id = OCR_NO;
break;
default:
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor"); _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
return GLFW_FALSE; return GLFW_FALSE;
} }

View File

@ -206,6 +206,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->mousePassthrough = wndconfig.mousePassthrough; window->mousePassthrough = wndconfig.mousePassthrough;
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
window->doublebuffer = fbconfig.doublebuffer;
window->minwidth = GLFW_DONT_CARE; window->minwidth = GLFW_DONT_CARE;
window->minheight = GLFW_DONT_CARE; window->minheight = GLFW_DONT_CARE;
window->maxwidth = GLFW_DONT_CARE; window->maxwidth = GLFW_DONT_CARE;
@ -841,6 +843,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->floating; return window->floating;
case GLFW_AUTO_ICONIFY: case GLFW_AUTO_ICONIFY:
return window->autoIconify; return window->autoIconify;
case GLFW_DOUBLEBUFFER:
return window->doublebuffer;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:
return window->context.client; return window->context.client;
case GLFW_CONTEXT_CREATION_API: case GLFW_CONTEXT_CREATION_API:
@ -882,27 +886,18 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->autoIconify = value; window->autoIconify = value;
else if (attrib == GLFW_RESIZABLE) else if (attrib == GLFW_RESIZABLE)
{ {
if (window->resizable == value)
return;
window->resizable = value; window->resizable = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowResizable(window, value); _glfwPlatformSetWindowResizable(window, value);
} }
else if (attrib == GLFW_DECORATED) else if (attrib == GLFW_DECORATED)
{ {
if (window->decorated == value)
return;
window->decorated = value; window->decorated = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowDecorated(window, value); _glfwPlatformSetWindowDecorated(window, value);
} }
else if (attrib == GLFW_FLOATING) else if (attrib == GLFW_FLOATING)
{ {
if (window->floating == value)
return;
window->floating = value; window->floating = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowFloating(window, value); _glfwPlatformSetWindowFloating(window, value);
@ -911,9 +906,6 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->focusOnShow = value; window->focusOnShow = value;
else if (attrib == GLFW_MOUSE_PASSTHROUGH) else if (attrib == GLFW_MOUSE_PASSTHROUGH)
{ {
if (window->mousePassthrough == value)
return;
window->mousePassthrough = value; window->mousePassthrough = value;
_glfwPlatformSetWindowMousePassthrough(window, value); _glfwPlatformSetWindowMousePassthrough(window, value);
} }

View File

@ -1038,8 +1038,6 @@ int _glfwPlatformInit(void)
char *cursorSizeEnd; char *cursorSizeEnd;
long cursorSizeLong; long cursorSizeLong;
int cursorSize; int cursorSize;
int i;
_GLFWmonitor* monitor;
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
if (!_glfw.wl.cursor.handle) if (!_glfw.wl.cursor.handle)
@ -1148,17 +1146,6 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events // Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display); wl_display_roundtrip(_glfw.wl.display);
for (i = 0; i < _glfw.monitorCount; ++i)
{
monitor = _glfw.monitors[i];
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
monitor->widthMM = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f);
monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f);
}
}
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();
_glfw.wl.timerfd = -1; _glfw.wl.timerfd = -1;

View File

@ -47,15 +47,13 @@ static void outputHandleGeometry(void* data,
int32_t transform) int32_t transform)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
char name[1024];
monitor->wl.x = x; monitor->wl.x = x;
monitor->wl.y = y; monitor->wl.y = y;
monitor->widthMM = physicalWidth; monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight; monitor->heightMM = physicalHeight;
snprintf(name, sizeof(name), "%s %s", make, model); snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
monitor->name = _glfw_strdup(name);
} }
static void outputHandleMode(void* data, static void outputHandleMode(void* data,
@ -88,6 +86,14 @@ static void outputHandleDone(void* data, struct wl_output* output)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode];
monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
}
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
} }
@ -125,7 +131,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
} }
// The actual name of this output will be set in the geometry handler. // The actual name of this output will be set in the geometry handler.
monitor = _glfwAllocMonitor(NULL, 0, 0); monitor = _glfwAllocMonitor("", 0, 0);
output = wl_registry_bind(_glfw.wl.registry, output = wl_registry_bind(_glfw.wl.registry,
name, name,

View File

@ -246,10 +246,10 @@ static void createDecorations(_GLFWwindow* window)
static void destroyDecoration(_GLFWdecorationWayland* decoration) static void destroyDecoration(_GLFWdecorationWayland* decoration)
{ {
if (decoration->surface)
wl_surface_destroy(decoration->surface);
if (decoration->subsurface) if (decoration->subsurface)
wl_subsurface_destroy(decoration->subsurface); wl_subsurface_destroy(decoration->subsurface);
if (decoration->surface)
wl_surface_destroy(decoration->surface);
if (decoration->viewport) if (decoration->viewport)
wp_viewport_destroy(decoration->viewport); wp_viewport_destroy(decoration->viewport);
decoration->surface = NULL; decoration->surface = NULL;
@ -1242,26 +1242,39 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
const char* name = NULL; const char* name = NULL;
// Try the XDG names first // Try the XDG names first
if (shape == GLFW_ARROW_CURSOR) switch (shape)
{
case GLFW_ARROW_CURSOR:
name = "default"; name = "default";
else if (shape == GLFW_IBEAM_CURSOR) break;
case GLFW_IBEAM_CURSOR:
name = "text"; name = "text";
else if (shape == GLFW_CROSSHAIR_CURSOR) break;
case GLFW_CROSSHAIR_CURSOR:
name = "crosshair"; name = "crosshair";
else if (shape == GLFW_POINTING_HAND_CURSOR) break;
case GLFW_POINTING_HAND_CURSOR:
name = "pointer"; name = "pointer";
else if (shape == GLFW_RESIZE_EW_CURSOR) break;
case GLFW_RESIZE_EW_CURSOR:
name = "ew-resize"; name = "ew-resize";
else if (shape == GLFW_RESIZE_NS_CURSOR) break;
case GLFW_RESIZE_NS_CURSOR:
name = "ns-resize"; name = "ns-resize";
else if (shape == GLFW_RESIZE_NWSE_CURSOR) break;
case GLFW_RESIZE_NWSE_CURSOR:
name = "nwse-resize"; name = "nwse-resize";
else if (shape == GLFW_RESIZE_NESW_CURSOR) break;
case GLFW_RESIZE_NESW_CURSOR:
name = "nesw-resize"; name = "nesw-resize";
else if (shape == GLFW_RESIZE_ALL_CURSOR) break;
case GLFW_RESIZE_ALL_CURSOR:
name = "all-scroll"; name = "all-scroll";
else if (shape == GLFW_NOT_ALLOWED_CURSOR) break;
case GLFW_NOT_ALLOWED_CURSOR:
name = "not-allowed"; name = "not-allowed";
break;
}
cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
@ -1274,22 +1287,23 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
if (!cursor->wl.cursor) if (!cursor->wl.cursor)
{ {
// Fall back to the core X11 names // Fall back to the core X11 names
if (shape == GLFW_ARROW_CURSOR) switch (shape)
name = "left_ptr";
else if (shape == GLFW_IBEAM_CURSOR)
name = "xterm";
else if (shape == GLFW_CROSSHAIR_CURSOR)
name = "crosshair";
else if (shape == GLFW_POINTING_HAND_CURSOR)
name = "hand2";
else if (shape == GLFW_RESIZE_EW_CURSOR)
name = "sb_h_double_arrow";
else if (shape == GLFW_RESIZE_NS_CURSOR)
name = "sb_v_double_arrow";
else if (shape == GLFW_RESIZE_ALL_CURSOR)
name = "fleur";
else
{ {
case GLFW_ARROW_CURSOR:
name = "left_ptr";
case GLFW_IBEAM_CURSOR:
name = "xterm";
case GLFW_CROSSHAIR_CURSOR:
name = "crosshair";
case GLFW_POINTING_HAND_CURSOR:
name = "hand2";
case GLFW_RESIZE_EW_CURSOR:
name = "sb_h_double_arrow";
case GLFW_RESIZE_NS_CURSOR:
name = "sb_v_double_arrow";
case GLFW_RESIZE_ALL_CURSOR:
name = "fleur";
default:
_glfwInputError(GLFW_CURSOR_UNAVAILABLE, _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
"Wayland: Standard cursor shape unavailable"); "Wayland: Standard cursor shape unavailable");
return GLFW_FALSE; return GLFW_FALSE;

View File

@ -813,11 +813,15 @@ static GLFWbool initExtensions(void)
XkbGroupStateMask, XkbGroupStateMask); XkbGroupStateMask, XkbGroupStateMask);
} }
if (_glfw.hints.init.x11.xcbVulkanSurface)
{
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
#else #else
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
#endif #endif
}
if (_glfw.x11.x11xcb.handle) if (_glfw.x11.x11xcb.handle)
{ {
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection) _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)

View File

@ -2485,7 +2485,11 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
} }
if (window->monitor) if (window->monitor)
{
_glfwPlatformSetWindowDecorated(window, window->decorated);
_glfwPlatformSetWindowFloating(window, window->floating);
releaseMonitor(window); releaseMonitor(window);
}
_glfwInputWindowMonitor(window, monitor); _glfwInputWindowMonitor(window, monitor);
updateNormalHints(window, width, height); updateNormalHints(window, width, height);
@ -2935,26 +2939,39 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
const int size = XcursorGetDefaultSize(_glfw.x11.display); const int size = XcursorGetDefaultSize(_glfw.x11.display);
const char* name = NULL; const char* name = NULL;
if (shape == GLFW_ARROW_CURSOR) switch (shape)
{
case GLFW_ARROW_CURSOR:
name = "default"; name = "default";
else if (shape == GLFW_IBEAM_CURSOR) break;
case GLFW_IBEAM_CURSOR:
name = "text"; name = "text";
else if (shape == GLFW_CROSSHAIR_CURSOR) break;
case GLFW_CROSSHAIR_CURSOR:
name = "crosshair"; name = "crosshair";
else if (shape == GLFW_POINTING_HAND_CURSOR) break;
case GLFW_POINTING_HAND_CURSOR:
name = "pointer"; name = "pointer";
else if (shape == GLFW_RESIZE_EW_CURSOR) break;
case GLFW_RESIZE_EW_CURSOR:
name = "ew-resize"; name = "ew-resize";
else if (shape == GLFW_RESIZE_NS_CURSOR) break;
case GLFW_RESIZE_NS_CURSOR:
name = "ns-resize"; name = "ns-resize";
else if (shape == GLFW_RESIZE_NWSE_CURSOR) break;
case GLFW_RESIZE_NWSE_CURSOR:
name = "nwse-resize"; name = "nwse-resize";
else if (shape == GLFW_RESIZE_NESW_CURSOR) break;
case GLFW_RESIZE_NESW_CURSOR:
name = "nesw-resize"; name = "nesw-resize";
else if (shape == GLFW_RESIZE_ALL_CURSOR) break;
case GLFW_RESIZE_ALL_CURSOR:
name = "all-scroll"; name = "all-scroll";
else if (shape == GLFW_NOT_ALLOWED_CURSOR) break;
case GLFW_NOT_ALLOWED_CURSOR:
name = "not-allowed"; name = "not-allowed";
break;
}
XcursorImage* image = XcursorLibraryLoadImage(name, theme, size); XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
if (image) if (image)
@ -2969,22 +2986,30 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
unsigned int native = 0; unsigned int native = 0;
if (shape == GLFW_ARROW_CURSOR) switch (shape)
native = XC_left_ptr;
else if (shape == GLFW_IBEAM_CURSOR)
native = XC_xterm;
else if (shape == GLFW_CROSSHAIR_CURSOR)
native = XC_crosshair;
else if (shape == GLFW_POINTING_HAND_CURSOR)
native = XC_hand2;
else if (shape == GLFW_RESIZE_EW_CURSOR)
native = XC_sb_h_double_arrow;
else if (shape == GLFW_RESIZE_NS_CURSOR)
native = XC_sb_v_double_arrow;
else if (shape == GLFW_RESIZE_ALL_CURSOR)
native = XC_fleur;
else
{ {
case GLFW_ARROW_CURSOR:
native = XC_left_ptr;
break;
case GLFW_IBEAM_CURSOR:
native = XC_xterm;
break;
case GLFW_CROSSHAIR_CURSOR:
native = XC_crosshair;
break;
case GLFW_POINTING_HAND_CURSOR:
native = XC_hand2;
break;
case GLFW_RESIZE_EW_CURSOR:
native = XC_sb_h_double_arrow;
break;
case GLFW_RESIZE_NS_CURSOR:
native = XC_sb_v_double_arrow;
break;
case GLFW_RESIZE_ALL_CURSOR:
native = XC_fleur;
break;
default:
_glfwInputError(GLFW_CURSOR_UNAVAILABLE, _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
"X11: Standard cursor shape unavailable"); "X11: Standard cursor shape unavailable");
return GLFW_FALSE; return GLFW_FALSE;

View File

@ -490,7 +490,7 @@ float GetGesturePinchAngle(void)
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(GESTURES_STANDALONE) #if defined(GESTURES_STANDALONE)
// Returns angle from two-points vector with X-axis // Get angle from two-points vector with X-axis
static float Vector2Angle(Vector2 v1, Vector2 v2) static float Vector2Angle(Vector2 v1, Vector2 v2)
{ {
float angle = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI); float angle = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI);

View File

@ -117,11 +117,11 @@ static ModelAnimation *LoadIQMModelAnimations(const char *fileName, int *animCou
#if defined(SUPPORT_FILEFORMAT_GLTF) #if defined(SUPPORT_FILEFORMAT_GLTF)
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount); // Load GLTF animation data static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount); // Load GLTF animation data
static void LoadGLTFModelIndices(Model* model, cgltf_accessor* indexAccessor, int primitiveIndex); static void LoadGLTFModelIndices(Model *model, cgltf_accessor *indexAccessor, int primitiveIndex);
static void BindGLTFPrimitiveToBones(Model* model, const cgltf_data* data, int primitiveIndex); static void BindGLTFPrimitiveToBones(Model *model, const cgltf_data *data, int primitiveIndex);
static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor, const cgltf_data* data, int primitiveIndex); static void LoadGLTFBoneAttribute(Model *model, cgltf_accessor *jointsAccessor, const cgltf_data *data, int primitiveIndex);
static void LoadGLTFMaterial(Model* model, const char* fileName, const cgltf_data* data); static void LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_data *data);
static void InitGLTFBones(Model* model, const cgltf_data* data); static void InitGLTFBones(Model *model, const cgltf_data *data);
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -2919,7 +2919,7 @@ void DrawBoundingBox(BoundingBox box, Color color)
DrawCubeWires(center, size.x, size.y, size.z, color); DrawCubeWires(center, size.x, size.y, size.z, color);
} }
// Detect collision between two spheres // Check collision between two spheres
bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2) bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2)
{ {
bool collision = false; bool collision = false;
@ -2942,7 +2942,7 @@ bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, floa
return collision; return collision;
} }
// Detect collision between two boxes // Check collision between two boxes
// NOTE: Boxes are defined by two points minimum and maximum // NOTE: Boxes are defined by two points minimum and maximum
bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2) bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
{ {
@ -2958,7 +2958,7 @@ bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
return collision; return collision;
} }
// Detect collision between box and sphere // Check collision between box and sphere
bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius) bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius)
{ {
bool collision = false; bool collision = false;
@ -3773,7 +3773,7 @@ static Model LoadIQM(const char *fileName)
} }
// Load IQM animation data // Load IQM animation data
static ModelAnimation* LoadIQMModelAnimations(const char* fileName, int* animCount) static ModelAnimation* LoadIQMModelAnimations(const char *fileName, int *animCount)
{ {
#define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number #define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
#define IQM_VERSION 2 // only IQM version 2 supported #define IQM_VERSION 2 // only IQM version 2 supported
@ -4574,7 +4574,7 @@ static void LoadGLTFBoneAttribute(Model *model, cgltf_accessor *jointsAccessor,
else if (jointsAccessor->component_type == cgltf_component_type_r_8u) else if (jointsAccessor->component_type == cgltf_component_type_r_8u)
{ {
model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int)); model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int));
unsigned char* bones = RL_MALLOC(jointsAccessor->count*4*sizeof(unsigned char)); unsigned char *bones = RL_MALLOC(jointsAccessor->count*4*sizeof(unsigned char));
for (unsigned int a = 0; a < jointsAccessor->count; a++) for (unsigned int a = 0; a < jointsAccessor->count; a++)
{ {

View File

@ -1311,7 +1311,7 @@ Music LoadMusicStream(const char *fileName)
} }
// extension including period ".mod" // extension including period ".mod"
Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize) Music LoadMusicStreamFromMemory(const char *fileType, unsigned char *data, int dataSize)
{ {
Music music = { 0 }; Music music = { 0 };
bool musicLoaded = false; bool musicLoaded = false;
@ -1325,7 +1325,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
{ {
drwav *ctxWav = RL_CALLOC(1, sizeof(drwav)); drwav *ctxWav = RL_CALLOC(1, sizeof(drwav));
bool success = drwav_init_memory(ctxWav, (const void*)data, dataSize, NULL); bool success = drwav_init_memory(ctxWav, (const void *)data, dataSize, NULL);
music.ctxType = MUSIC_AUDIO_WAV; music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav; music.ctxData = ctxWav;
@ -1383,7 +1383,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
// Open ogg audio stream // Open ogg audio stream
music.ctxType = MUSIC_AUDIO_OGG; music.ctxType = MUSIC_AUDIO_OGG;
//music.ctxData = stb_vorbis_open_filename(fileName, NULL, NULL); //music.ctxData = stb_vorbis_open_filename(fileName, NULL, NULL);
music.ctxData = stb_vorbis_open_memory((const unsigned char*)data, dataSize, NULL, NULL); music.ctxData = stb_vorbis_open_memory((const unsigned char *)data, dataSize, NULL, NULL);
if (music.ctxData != NULL) if (music.ctxData != NULL)
{ {
@ -1403,7 +1403,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
else if (TextIsEqual(fileExtLower, ".xm")) else if (TextIsEqual(fileExtLower, ".xm"))
{ {
jar_xm_context_t *ctxXm = NULL; jar_xm_context_t *ctxXm = NULL;
int result = jar_xm_create_context_safe(&ctxXm, (const char*)data, dataSize, AUDIO.System.device.sampleRate); int result = jar_xm_create_context_safe(&ctxXm, (const char *)data, dataSize, AUDIO.System.device.sampleRate);
if (result == 0) // XM AUDIO.System.context created successfully if (result == 0) // XM AUDIO.System.context created successfully
{ {
music.ctxType = MUSIC_MODULE_XM; music.ctxType = MUSIC_MODULE_XM;
@ -1660,17 +1660,17 @@ void UpdateMusicStream(Music music)
{ {
case ma_format_f32: case ma_format_f32:
// NOTE: Internally this function considers 2 channels generation, so samplesCount/2 // NOTE: Internally this function considers 2 channels generation, so samplesCount/2
jar_xm_generate_samples((jar_xm_context_t*)music.ctxData, (float*)pcm, samplesCount/2); jar_xm_generate_samples((jar_xm_context_t*)music.ctxData, (float *)pcm, samplesCount/2);
break; break;
case ma_format_s16: case ma_format_s16:
// NOTE: Internally this function considers 2 channels generation, so samplesCount/2 // NOTE: Internally this function considers 2 channels generation, so samplesCount/2
jar_xm_generate_samples_16bit((jar_xm_context_t*)music.ctxData, (short*)pcm, samplesCount/2); jar_xm_generate_samples_16bit((jar_xm_context_t*)music.ctxData, (short *)pcm, samplesCount/2);
break; break;
case ma_format_u8: case ma_format_u8:
// NOTE: Internally this function considers 2 channels generation, so samplesCount/2 // NOTE: Internally this function considers 2 channels generation, so samplesCount/2
jar_xm_generate_samples_8bit((jar_xm_context_t*)music.ctxData, (char*)pcm, samplesCount/2); jar_xm_generate_samples_8bit((jar_xm_context_t*)music.ctxData, (char *)pcm, samplesCount/2);
break; break;
} }
@ -1786,7 +1786,7 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
unsigned int periodSize = AUDIO.System.device.playback.internalPeriodSizeInFrames; unsigned int periodSize = AUDIO.System.device.playback.internalPeriodSizeInFrames;
// If the buffer is not set, compute one that would give us a buffer good enough for a decent frame rate // If the buffer is not set, compute one that would give us a buffer good enough for a decent frame rate
unsigned int subBufferSize = (AUDIO.Buffer.defaultSize == 0)? AUDIO.Buffer.defaultSize : AUDIO.System.device.sampleRate/30; unsigned int subBufferSize = (AUDIO.Buffer.defaultSize == 0)? AUDIO.System.device.sampleRate/30 : AUDIO.Buffer.defaultSize;
if (subBufferSize < periodSize) subBufferSize = periodSize; if (subBufferSize < periodSize) subBufferSize = periodSize;

View File

@ -646,7 +646,6 @@ typedef enum {
MOUSE_BUTTON_EXTRA = 4, MOUSE_BUTTON_EXTRA = 4,
MOUSE_BUTTON_FORWARD = 5, MOUSE_BUTTON_FORWARD = 5,
MOUSE_BUTTON_BACK = 6, MOUSE_BUTTON_BACK = 6,
MOUSE_BUTTON_MAX = 7
} MouseButton; } MouseButton;
// Mouse cursor // Mouse cursor
@ -717,17 +716,17 @@ typedef enum {
// Material map index // Material map index
typedef enum { typedef enum {
MATERIAL_MAP_ALBEDO = 0, // MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)
MATERIAL_MAP_METALNESS = 1, // MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR)
MATERIAL_MAP_NORMAL = 2, MATERIAL_MAP_NORMAL, // Normal material
MATERIAL_MAP_ROUGHNESS = 3, MATERIAL_MAP_ROUGHNESS, // Roughness material
MATERIAL_MAP_OCCLUSION, MATERIAL_MAP_OCCLUSION, // Ambient occlusion material
MATERIAL_MAP_EMISSION, MATERIAL_MAP_EMISSION, // Emission material
MATERIAL_MAP_HEIGHT, MATERIAL_MAP_HEIGHT, // Heightmap material
MATERIAL_MAP_BRDG, MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_PREFILTER // NOTE: Uses GL_TEXTURE_CUBE_MAP MATERIAL_MAP_BRDG // Brdg material
} MaterialMapIndex; } MaterialMapIndex;
#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO #define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO
@ -735,32 +734,32 @@ typedef enum {
// Shader location index // Shader location index
typedef enum { typedef enum {
SHADER_LOC_VERTEX_POSITION = 0, SHADER_LOC_VERTEX_POSITION = 0, // Shader location point: position
SHADER_LOC_VERTEX_TEXCOORD01, SHADER_LOC_VERTEX_TEXCOORD01, // Shader location point: texcoord01
SHADER_LOC_VERTEX_TEXCOORD02, SHADER_LOC_VERTEX_TEXCOORD02, // Shader location point: texcoord02
SHADER_LOC_VERTEX_NORMAL, SHADER_LOC_VERTEX_NORMAL, // Shader location point: normal
SHADER_LOC_VERTEX_TANGENT, SHADER_LOC_VERTEX_TANGENT, // Shader location point: tangent
SHADER_LOC_VERTEX_COLOR, SHADER_LOC_VERTEX_COLOR, // Shader location point: color
SHADER_LOC_MATRIX_MVP, SHADER_LOC_MATRIX_MVP, // Shader location point: model-view-projection matrix
SHADER_LOC_MATRIX_VIEW, SHADER_LOC_MATRIX_VIEW, // Shader location point: view matrix
SHADER_LOC_MATRIX_PROJECTION, SHADER_LOC_MATRIX_PROJECTION, // Shader location point: projection matrix
SHADER_LOC_MATRIX_MODEL, SHADER_LOC_MATRIX_MODEL, // Shader location point: model matrix
SHADER_LOC_MATRIX_NORMAL, SHADER_LOC_MATRIX_NORMAL, // Shader location point: normal matrix
SHADER_LOC_VECTOR_VIEW, SHADER_LOC_VECTOR_VIEW, // Shader location point: view vector
SHADER_LOC_COLOR_DIFFUSE, SHADER_LOC_COLOR_DIFFUSE, // Shader location point: diffuse color
SHADER_LOC_COLOR_SPECULAR, SHADER_LOC_COLOR_SPECULAR, // Shader location point: specular color
SHADER_LOC_COLOR_AMBIENT, SHADER_LOC_COLOR_AMBIENT, // Shader location point: ambient color
SHADER_LOC_MAP_ALBEDO, // SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO, // Shader location point: albedo texture (same as: SHADER_LOC_MAP_DIFFUSE)
SHADER_LOC_MAP_METALNESS, // SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS, // Shader location point: metalness texture (same as: SHADER_LOC_MAP_SPECULAR)
SHADER_LOC_MAP_NORMAL, SHADER_LOC_MAP_NORMAL, // Shader location point: normal texture
SHADER_LOC_MAP_ROUGHNESS, SHADER_LOC_MAP_ROUGHNESS, // Shader location point: roughness texture
SHADER_LOC_MAP_OCCLUSION, SHADER_LOC_MAP_OCCLUSION, // Shader location point: occlusion texture
SHADER_LOC_MAP_EMISSION, SHADER_LOC_MAP_EMISSION, // Shader location point: emission texture
SHADER_LOC_MAP_HEIGHT, SHADER_LOC_MAP_HEIGHT, // Shader location point: height texture
SHADER_LOC_MAP_CUBEMAP, SHADER_LOC_MAP_CUBEMAP, // Shader location point: cubemap texture_cube_map
SHADER_LOC_MAP_IRRADIANCE, SHADER_LOC_MAP_IRRADIANCE, // Shader location point: irradiance texture_cube_map
SHADER_LOC_MAP_PREFILTER, SHADER_LOC_MAP_PREFILTER, // Shader location point: prefilter texture_cube_map
SHADER_LOC_MAP_BRDF SHADER_LOC_MAP_BRDF // Shader location point: brdf texture
} ShaderLocationIndex; } ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO #define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
@ -768,19 +767,27 @@ typedef enum {
// Shader uniform data type // Shader uniform data type
typedef enum { typedef enum {
SHADER_UNIFORM_FLOAT = 0, SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
SHADER_UNIFORM_VEC2, SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
SHADER_UNIFORM_VEC3, SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)
SHADER_UNIFORM_VEC4, SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)
SHADER_UNIFORM_INT, SHADER_UNIFORM_INT, // Shader uniform type: int
SHADER_UNIFORM_IVEC2, SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)
SHADER_UNIFORM_IVEC3, SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)
SHADER_UNIFORM_IVEC4, SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)
SHADER_UNIFORM_SAMPLER2D, SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d
SHADER_UNIFORM_MAT3, SHADER_UNIFORM_MAT3, // Shader uniform type: mat3 (9 float)
SHADER_UNIFORM_MAT4 SHADER_UNIFORM_MAT4 // Shader uniform type: mat4 (16 float)
} ShaderUniformDataType; } ShaderUniformDataType;
// Shader attribute data types
typedef enum {
SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float
SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float)
SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float)
SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)
} ShaderAttributeDataType;
// Pixel formats // Pixel formats
// NOTE: Support depends on OpenGL version and platform // NOTE: Support depends on OpenGL version and platform
typedef enum { typedef enum {
@ -857,32 +864,32 @@ typedef enum {
// Gestures // Gestures
// NOTE: It could be used as flags to enable only some gestures // NOTE: It could be used as flags to enable only some gestures
typedef enum { typedef enum {
GESTURE_NONE = 0, GESTURE_NONE = 0, // No gesture
GESTURE_TAP = 1, GESTURE_TAP = 1, // Tap gesture
GESTURE_DOUBLETAP = 2, GESTURE_DOUBLETAP = 2, // Double tap gesture
GESTURE_HOLD = 4, GESTURE_HOLD = 4, // Hold gesture
GESTURE_DRAG = 8, GESTURE_DRAG = 8, // Drag gesture
GESTURE_SWIPE_RIGHT = 16, GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture
GESTURE_SWIPE_LEFT = 32, GESTURE_SWIPE_LEFT = 32, // Swipe left gesture
GESTURE_SWIPE_UP = 64, GESTURE_SWIPE_UP = 64, // Swipe up gesture
GESTURE_SWIPE_DOWN = 128, GESTURE_SWIPE_DOWN = 128, // Swipe down gesture
GESTURE_PINCH_IN = 256, GESTURE_PINCH_IN = 256, // Pinch in gesture
GESTURE_PINCH_OUT = 512 GESTURE_PINCH_OUT = 512 // Pinch out gesture
} Gesture; } Gesture;
// Camera system modes // Camera system modes
typedef enum { typedef enum {
CAMERA_CUSTOM = 0, CAMERA_CUSTOM = 0, // Custom camera
CAMERA_FREE, CAMERA_FREE, // Free camera
CAMERA_ORBITAL, CAMERA_ORBITAL, // Orbital camera
CAMERA_FIRST_PERSON, CAMERA_FIRST_PERSON, // First person camera
CAMERA_THIRD_PERSON CAMERA_THIRD_PERSON // Third person camera
} CameraMode; } CameraMode;
// Camera projection // Camera projection
typedef enum { typedef enum {
CAMERA_PERSPECTIVE = 0, CAMERA_PERSPECTIVE = 0, // Perspective projection
CAMERA_ORTHOGRAPHIC CAMERA_ORTHOGRAPHIC // Orthographic projection
} CameraProjection; } CameraProjection;
// N-patch layout // N-patch layout
@ -999,22 +1006,22 @@ RLAPI void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
// Screen-space-related functions // Screen-space-related functions
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position
RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Returns size position for a 3d world space position RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position
RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position
RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
// Timing-related functions // Timing-related functions
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum) RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
RLAPI int GetFPS(void); // Returns current FPS RLAPI int GetFPS(void); // Get current FPS
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn (delta time) RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)
RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow() RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()
// Misc. functions // Misc. functions
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format) RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
@ -1070,45 +1077,45 @@ RLAPI void OpenURL(const char *url); // Open URL wi
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Input-related functions: keyboard // Input-related functions: keyboard
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed RLAPI bool IsKeyDown(int key); // Check if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once RLAPI bool IsKeyReleased(int key); // Check if a key has been released once
RLAPI bool IsKeyUp(int key); // Detect if a key is NOT being pressed RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued
RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued
// Input-related functions: gamepads // Input-related functions: gamepads
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available) RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once
RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed
RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once
RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed
RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
// Input-related functions: mouse // Input-related functions: mouse
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed RLAPI bool IsMouseButtonDown(int button); // Check if a mouse button is being pressed
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once RLAPI bool IsMouseButtonReleased(int button); // Check if a mouse button has been released once
RLAPI bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed RLAPI bool IsMouseButtonUp(int button); // Check if a mouse button is NOT being pressed
RLAPI int GetMouseX(void); // Returns mouse position X RLAPI int GetMouseX(void); // Get mouse position X
RLAPI int GetMouseY(void); // Returns mouse position Y RLAPI int GetMouseY(void); // Get mouse position Y
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY RLAPI Vector2 GetMousePosition(void); // Get mouse position XY
RLAPI void SetMousePosition(int x, int y); // Set mouse position XY RLAPI void SetMousePosition(int x, int y); // Set mouse position XY
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
RLAPI float GetMouseWheelMove(void); // Returns mouse wheel movement Y RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement Y
RLAPI void SetMouseCursor(int cursor); // Set mouse cursor RLAPI void SetMouseCursor(int cursor); // Set mouse cursor
// Input-related functions: touch // Input-related functions: touch
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size) RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
RLAPI int GetTouchY(void); // Returns touch position Y 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); // Returns touch position XY for a touch point index (relative to screen size) RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: gestures) // Gestures and Touch Handling Functions (Module: gestures)
@ -1294,14 +1301,14 @@ RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle
RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint); // Draw a textured polygon RLAPI void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint); // Draw a textured polygon
// Color/pixel related functions // Color/pixel related functions
RLAPI Color Fade(Color color, float alpha); // Returns color with alpha applied, alpha goes from 0.0f to 1.0f RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color
RLAPI Vector4 ColorNormalize(Color color); // Returns Color normalized as float [0..1] RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
RLAPI Color ColorFromNormalized(Vector4 normalized); // Returns Color from normalized values [0..1] RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color, hue [0..360], saturation/value [0..1] RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Returns a Color from HSV values, hue [0..360], saturation/value [0..1] RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
RLAPI Color ColorAlpha(Color color, float alpha); // Returns color with alpha applied, alpha goes from 0.0f to 1.0f RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Returns src alpha-blended into dst color with tint RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint
RLAPI Color GetColor(int hexValue); // Get Color structure from hexadecimal value RLAPI Color GetColor(int hexValue); // Get Color structure from hexadecimal value
RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format
RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer
@ -1357,7 +1364,7 @@ RLAPI char *TextToUtf8(int *codepoints, int length); // Encode
// UTF8 text strings management functions // UTF8 text strings management functions
RLAPI int *GetCodepoints(const char *text, int *count); // Get all codepoints in a string, codepoints count returned by parameters RLAPI int *GetCodepoints(const char *text, int *count); // Get all codepoints in a string, codepoints count returned by parameters
RLAPI int GetCodepointsCount(const char *text); // Get total number of characters (codepoints) in a UTF8 encoded string RLAPI int GetCodepointsCount(const char *text); // Get total number of characters (codepoints) in a UTF8 encoded string
RLAPI int GetNextCodepoint(const char *text, int *bytesProcessed); // Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure RLAPI int GetNextCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure
RLAPI const char *CodepointToUtf8(int codepoint, int *byteLength); // Encode codepoint into utf8 text (char array length returned as parameter) RLAPI const char *CodepointToUtf8(int codepoint, int *byteLength); // Encode codepoint into utf8 text (char array length returned as parameter)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -1444,9 +1451,9 @@ RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source,
RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation
// Collision detection functions // Collision detection functions
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Detect collision between two spheres RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere
RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere
RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box
RLAPI RayCollision GetRayCollisionModel(Ray ray, Model model); // Get collision info between ray and model RLAPI RayCollision GetRayCollisionModel(Ray ray, Model model); // Get collision info between ray and model
@ -1494,7 +1501,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
// Music management functions // Music management functions
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize); // Load music stream from data RLAPI Music LoadMusicStreamFromMemory(const char *fileType, unsigned char *data, int dataSize); // Load music stream from data
RLAPI void UnloadMusicStream(Music music); // Unload music stream RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing

View File

@ -65,7 +65,7 @@
#define RMDEF static inline // Functions may be inlined, no external out-of-line definition #define RMDEF static inline // Functions may be inlined, no external out-of-line definition
#else #else
#if defined(__TINYC__) #if defined(__TINYC__)
#define RMDEF static inline // plain inline not supported by tinycc (See issue #435) #define RMDEF static inline // WARNING: Plain inline not supported by tinycc (See issue #435)
#else #else
#define RMDEF inline // Functions may be inlined or external definition used #define RMDEF inline // Functions may be inlined or external definition used
#endif #endif
@ -86,12 +86,12 @@
#define RAD2DEG (180.0f/PI) #define RAD2DEG (180.0f/PI)
#endif #endif
// Return float vector for Matrix // Get float vector for Matrix
#ifndef MatrixToFloat #ifndef MatrixToFloat
#define MatrixToFloat(mat) (MatrixToFloatV(mat).v) #define MatrixToFloat(mat) (MatrixToFloatV(mat).v)
#endif #endif
// Return float vector for Vector3 // Get float vector for Vector3
#ifndef Vector3ToFloat #ifndef Vector3ToFloat
#define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v) #define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v)
#endif #endif
@ -559,7 +559,7 @@ RMDEF Vector3 Vector3Reflect(Vector3 v, Vector3 normal)
return result; return result;
} }
// Return min value for each pair of components // Get min value for each pair of components
RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2) RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2)
{ {
Vector3 result = { 0 }; Vector3 result = { 0 };
@ -571,7 +571,7 @@ RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2)
return result; return result;
} }
// Return max value for each pair of components // Get max value for each pair of components
RMDEF Vector3 Vector3Max(Vector3 v1, Vector3 v2) RMDEF Vector3 Vector3Max(Vector3 v1, Vector3 v2)
{ {
Vector3 result = { 0 }; Vector3 result = { 0 };
@ -609,7 +609,7 @@ RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
return result; return result;
} }
// Returns Vector3 as float array // Get Vector3 as float array
RMDEF float3 Vector3ToFloatV(Vector3 v) RMDEF float3 Vector3ToFloatV(Vector3 v)
{ {
float3 buffer = { 0 }; float3 buffer = { 0 };
@ -644,7 +644,7 @@ RMDEF float MatrixDeterminant(Matrix mat)
return result; return result;
} }
// Returns the trace of the matrix (sum of the values along the diagonal) // Get the trace of the matrix (sum of the values along the diagonal)
RMDEF float MatrixTrace(Matrix mat) RMDEF float MatrixTrace(Matrix mat)
{ {
float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15); float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15);
@ -750,7 +750,7 @@ RMDEF Matrix MatrixNormalize(Matrix mat)
return result; return result;
} }
// Returns identity matrix // Get identity matrix
RMDEF Matrix MatrixIdentity(void) RMDEF Matrix MatrixIdentity(void)
{ {
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
@ -811,7 +811,7 @@ RMDEF Matrix MatrixSubtract(Matrix left, Matrix right)
return result; return result;
} }
// Returns two matrix multiplication // Get two matrix multiplication
// NOTE: When multiplying matrices... the order matters! // NOTE: When multiplying matrices... the order matters!
RMDEF Matrix MatrixMultiply(Matrix left, Matrix right) RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
{ {
@ -837,7 +837,7 @@ RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
return result; return result;
} }
// Returns translation matrix // Get translation matrix
RMDEF Matrix MatrixTranslate(float x, float y, float z) RMDEF Matrix MatrixTranslate(float x, float y, float z)
{ {
Matrix result = { 1.0f, 0.0f, 0.0f, x, Matrix result = { 1.0f, 0.0f, 0.0f, x,
@ -893,7 +893,7 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
return result; return result;
} }
// Returns x-rotation matrix (angle in radians) // Get x-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateX(float angle) RMDEF Matrix MatrixRotateX(float angle)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
@ -909,7 +909,7 @@ RMDEF Matrix MatrixRotateX(float angle)
return result; return result;
} }
// Returns y-rotation matrix (angle in radians) // Get y-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateY(float angle) RMDEF Matrix MatrixRotateY(float angle)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
@ -925,7 +925,7 @@ RMDEF Matrix MatrixRotateY(float angle)
return result; return result;
} }
// Returns z-rotation matrix (angle in radians) // Get z-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateZ(float angle) RMDEF Matrix MatrixRotateZ(float angle)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
@ -942,7 +942,7 @@ RMDEF Matrix MatrixRotateZ(float angle)
} }
// Returns xyz-rotation matrix (angles in radians) // Get xyz-rotation matrix (angles in radians)
RMDEF Matrix MatrixRotateXYZ(Vector3 ang) RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
@ -969,7 +969,7 @@ RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
return result; return result;
} }
// Returns zyx-rotation matrix (angles in radians) // Get zyx-rotation matrix (angles in radians)
RMDEF Matrix MatrixRotateZYX(Vector3 ang) RMDEF Matrix MatrixRotateZYX(Vector3 ang)
{ {
Matrix result = { 0 }; Matrix result = { 0 };
@ -1004,7 +1004,7 @@ RMDEF Matrix MatrixRotateZYX(Vector3 ang)
return result; return result;
} }
// Returns scaling matrix // Get scaling matrix
RMDEF Matrix MatrixScale(float x, float y, float z) RMDEF Matrix MatrixScale(float x, float y, float z)
{ {
Matrix result = { x, 0.0f, 0.0f, 0.0f, Matrix result = { x, 0.0f, 0.0f, 0.0f,
@ -1015,7 +1015,7 @@ RMDEF Matrix MatrixScale(float x, float y, float z)
return result; return result;
} }
// Returns perspective projection matrix // Get perspective projection matrix
RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far) RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)
{ {
Matrix result = { 0 }; Matrix result = { 0 };
@ -1047,7 +1047,7 @@ RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top,
return result; return result;
} }
// Returns perspective projection matrix // Get perspective projection matrix
// NOTE: Angle should be provided in radians // NOTE: Angle should be provided in radians
RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double far) RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
{ {
@ -1058,7 +1058,7 @@ RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double f
return result; return result;
} }
// Returns orthographic projection matrix // Get orthographic projection matrix
RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far) RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
{ {
Matrix result = { 0 }; Matrix result = { 0 };
@ -1087,7 +1087,7 @@ RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, d
return result; return result;
} }
// Returns camera look-at matrix (view matrix) // Get camera look-at matrix (view matrix)
RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up) RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
{ {
Matrix result = { 0 }; Matrix result = { 0 };
@ -1118,7 +1118,7 @@ RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
return result; return result;
} }
// Returns float array of matrix data // Get float array of matrix data
RMDEF float16 MatrixToFloatV(Matrix mat) RMDEF float16 MatrixToFloatV(Matrix mat)
{ {
float16 buffer = { 0 }; float16 buffer = { 0 };
@ -1175,7 +1175,7 @@ RMDEF Quaternion QuaternionSubtractValue(Quaternion q, float sub)
return result; return result;
} }
// Returns identity quaternion // Get identity quaternion
RMDEF Quaternion QuaternionIdentity(void) RMDEF Quaternion QuaternionIdentity(void)
{ {
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
@ -1351,7 +1351,7 @@ RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
return result; return result;
} }
// Returns a quaternion for a given rotation matrix // Get a quaternion for a given rotation matrix
RMDEF Quaternion QuaternionFromMatrix(Matrix mat) RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
{ {
Quaternion result = { 0 }; Quaternion result = { 0 };
@ -1385,7 +1385,7 @@ RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
return result; return result;
} }
// Returns a matrix for a given quaternion // Get a matrix for a given quaternion
RMDEF Matrix QuaternionToMatrix(Quaternion q) RMDEF Matrix QuaternionToMatrix(Quaternion q)
{ {
Matrix result = MatrixIdentity(); Matrix result = MatrixIdentity();
@ -1415,7 +1415,7 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
return result; return result;
} }
// Returns rotation quaternion for an angle and axis // Get rotation quaternion for an angle and axis
// NOTE: angle must be provided in radians // NOTE: angle must be provided in radians
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
{ {
@ -1440,7 +1440,7 @@ RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
return result; return result;
} }
// Returns the rotation angle and axis for a given quaternion // Get the rotation angle and axis for a given quaternion
RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle) RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
{ {
if (fabs(q.w) > 1.0f) q = QuaternionNormalize(q); if (fabs(q.w) > 1.0f) q = QuaternionNormalize(q);
@ -1466,7 +1466,7 @@ RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle
*outAngle = resAngle; *outAngle = resAngle;
} }
// Returns the quaternion equivalent to Euler angles // Get the quaternion equivalent to Euler angles
// NOTE: Rotation order is ZYX // NOTE: Rotation order is ZYX
RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll) RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
{ {
@ -1487,7 +1487,7 @@ RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
return q; return q;
} }
// Return the Euler angles equivalent to quaternion (roll, pitch, yaw) // Get the Euler angles equivalent to quaternion (roll, pitch, yaw)
// NOTE: Angles are returned in a Vector3 struct in degrees // NOTE: Angles are returned in a Vector3 struct in degrees
RMDEF Vector3 QuaternionToEuler(Quaternion q) RMDEF Vector3 QuaternionToEuler(Quaternion q)
{ {

View File

@ -291,26 +291,18 @@ typedef struct RenderBatch {
float currentDepth; // Current depth value for next draw float currentDepth; // Current depth value for next draw
} RenderBatch; } RenderBatch;
// Shader attribute data types
typedef enum {
SHADER_ATTRIB_FLOAT = 0,
SHADER_ATTRIB_VEC2,
SHADER_ATTRIB_VEC3,
SHADER_ATTRIB_VEC4
} ShaderAttributeDataType;
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
#ifndef __cplusplus #ifndef __cplusplus
// Boolean type // Boolean type
typedef enum { false, true } bool; typedef enum { false, true } bool;
#endif #endif
// Color type, RGBA (32bit) // Color, 4 components, R8G8B8A8 (32bit)
typedef struct Color { typedef struct Color {
unsigned char r; unsigned char r; // Color red value
unsigned char g; unsigned char g; // Color green value
unsigned char b; unsigned char b; // Color blue value
unsigned char a; unsigned char a; // Color alpha value
} Color; } Color;
// Texture type // Texture type
@ -345,7 +337,7 @@ typedef enum {
// Texture formats (support depends on OpenGL version) // Texture formats (support depends on OpenGL version)
typedef enum { typedef enum {
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp
PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
@ -399,49 +391,57 @@ typedef enum {
// Shader location point type // Shader location point type
typedef enum { typedef enum {
SHADER_LOC_VERTEX_POSITION = 0, SHADER_LOC_VERTEX_POSITION = 0, // Shader location point: position
SHADER_LOC_VERTEX_TEXCOORD01, SHADER_LOC_VERTEX_TEXCOORD01, // Shader location point: texcoord01
SHADER_LOC_VERTEX_TEXCOORD02, SHADER_LOC_VERTEX_TEXCOORD02, // Shader location point: texcoord02
SHADER_LOC_VERTEX_NORMAL, SHADER_LOC_VERTEX_NORMAL, // Shader location point: normal
SHADER_LOC_VERTEX_TANGENT, SHADER_LOC_VERTEX_TANGENT, // Shader location point: tangent
SHADER_LOC_VERTEX_COLOR, SHADER_LOC_VERTEX_COLOR, // Shader location point: color
SHADER_LOC_MATRIX_MVP, SHADER_LOC_MATRIX_MVP, // Shader location point: model-view-projection matrix
SHADER_LOC_MATRIX_MODEL, SHADER_LOC_MATRIX_VIEW, // Shader location point: view matrix
SHADER_LOC_MATRIX_VIEW, SHADER_LOC_MATRIX_PROJECTION, // Shader location point: projection matrix
SHADER_LOC_MATRIX_NORMAL, SHADER_LOC_MATRIX_MODEL, // Shader location point: model matrix
SHADER_LOC_MATRIX_PROJECTION, SHADER_LOC_MATRIX_NORMAL, // Shader location point: normal matrix
SHADER_LOC_VECTOR_VIEW, SHADER_LOC_VECTOR_VIEW, // Shader location point: view vector
SHADER_LOC_COLOR_DIFFUSE, SHADER_LOC_COLOR_DIFFUSE, // Shader location point: diffuse color
SHADER_LOC_COLOR_SPECULAR, SHADER_LOC_COLOR_SPECULAR, // Shader location point: specular color
SHADER_LOC_COLOR_AMBIENT, SHADER_LOC_COLOR_AMBIENT, // Shader location point: ambient color
SHADER_LOC_MAP_ALBEDO, // SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO, // Shader location point: albedo texture (same as: SHADER_LOC_MAP_DIFFUSE)
SHADER_LOC_MAP_METALNESS, // SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS, // Shader location point: metalness texture (same as: SHADER_LOC_MAP_SPECULAR)
SHADER_LOC_MAP_NORMAL, SHADER_LOC_MAP_NORMAL, // Shader location point: normal texture
SHADER_LOC_MAP_ROUGHNESS, SHADER_LOC_MAP_ROUGHNESS, // Shader location point: roughness texture
SHADER_LOC_MAP_OCCLUSION, SHADER_LOC_MAP_OCCLUSION, // Shader location point: occlusion texture
SHADER_LOC_MAP_EMISSION, SHADER_LOC_MAP_EMISSION, // Shader location point: emission texture
SHADER_LOC_MAP_HEIGHT, SHADER_LOC_MAP_HEIGHT, // Shader location point: height texture
SHADER_LOC_MAP_CUBEMAP, SHADER_LOC_MAP_CUBEMAP, // Shader location point: cubemap texture_cube_map
SHADER_LOC_MAP_IRRADIANCE, SHADER_LOC_MAP_IRRADIANCE, // Shader location point: irradiance texture_cube_map
SHADER_LOC_MAP_PREFILTER, SHADER_LOC_MAP_PREFILTER, // Shader location point: prefilter texture_cube_map
SHADER_LOC_MAP_BRDF SHADER_LOC_MAP_BRDF // Shader location point: brdf texture
} ShaderLocationIndex; } ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO #define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS #define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS
// Shader uniform data types // Shader uniform data type
typedef enum { typedef enum {
SHADER_UNIFORM_FLOAT = 0, SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
SHADER_UNIFORM_VEC2, SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
SHADER_UNIFORM_VEC3, SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)
SHADER_UNIFORM_VEC4, SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)
SHADER_UNIFORM_INT, SHADER_UNIFORM_INT, // Shader uniform type: int
SHADER_UNIFORM_IVEC2, SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)
SHADER_UNIFORM_IVEC3, SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)
SHADER_UNIFORM_IVEC4, SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)
SHADER_UNIFORM_SAMPLER2D SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d
} ShaderUniformDataType; } ShaderUniformDataType;
// Shader attribute data types
typedef enum {
SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float
SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float)
SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float)
SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)
} ShaderAttributeDataType;
#endif #endif
#if defined(__cplusplus) #if defined(__cplusplus)
@ -546,7 +546,7 @@ RLAPI void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation);
RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states) RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
RLAPI void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures) RLAPI void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required) RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required)
RLAPI int rlGetVersion(void); // Returns current OpenGL version RLAPI int rlGetVersion(void); // Get current OpenGL version
RLAPI int rlGetFramebufferWidth(void); // Get default framebuffer width RLAPI int rlGetFramebufferWidth(void); // Get default framebuffer width
RLAPI int rlGetFramebufferHeight(void); // Get default framebuffer height RLAPI int rlGetFramebufferHeight(void); // Get default framebuffer height
@ -1892,7 +1892,7 @@ void rlLoadExtensions(void *loader)
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
} }
// Returns current OpenGL version // Get current OpenGL version
int rlGetVersion(void) int rlGetVersion(void)
{ {
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
@ -3471,7 +3471,7 @@ void rlSetShader(Shader shader)
// Matrix state management // Matrix state management
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
// Return internal modelview matrix // Get internal modelview matrix
Matrix rlGetMatrixModelview(void) Matrix rlGetMatrixModelview(void)
{ {
Matrix matrix = MatrixIdentity(); Matrix matrix = MatrixIdentity();
@ -3500,7 +3500,7 @@ Matrix rlGetMatrixModelview(void)
return matrix; return matrix;
} }
// Return internal projection matrix // Get internal projection matrix
Matrix rlGetMatrixProjection(void) Matrix rlGetMatrixProjection(void)
{ {
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)

View File

@ -122,15 +122,19 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
// Draw a line defining thickness // Draw a line defining thickness
void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
{ {
Vector2 delta = {endPos.x-startPos.x, endPos.y-startPos.y}; Vector2 delta = { endPos.x - startPos.x, endPos.y - startPos.y };
float length = sqrtf(delta.x*delta.x + delta.y*delta.y); float length = sqrtf(delta.x*delta.x + delta.y*delta.y);
if (length > 0 && thick > 0) if ((length > 0) && (thick > 0))
{ {
float scale = thick/(2*length); float scale = thick/(2*length);
Vector2 radius = {-scale*delta.y, scale*delta.x}; Vector2 radius = { -scale*delta.y, scale*delta.x };
Vector2 strip[] = {{startPos.x-radius.x, startPos.y-radius.y}, {startPos.x+radius.x, startPos.y+radius.y}, Vector2 strip[4] = {
{endPos.x-radius.x, endPos.y-radius.y}, {endPos.x+radius.x, endPos.y+radius.y}}; { startPos.x - radius.x, startPos.y - radius.y },
{ startPos.x + radius.x, startPos.y + radius.y },
{ endPos.x - radius.x, endPos.y - radius.y },
{ endPos.x + radius.x, endPos.y + radius.y }
};
DrawTriangleStrip(strip, 4, color); DrawTriangleStrip(strip, 4, color);
} }

View File

@ -1123,7 +1123,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
return vec; return vec;
} }
// Returns index position for a unicode character on spritefont // Get index position for a unicode character on spritefont
int GetGlyphIndex(Font font, int codepoint) int GetGlyphIndex(Font font, int codepoint)
{ {
#ifndef GLYPH_NOTFOUND_CHAR_FALLBACK #ifndef GLYPH_NOTFOUND_CHAR_FALLBACK
@ -1586,7 +1586,7 @@ int *GetCodepoints(const char *text, int *count)
return codepoints; return codepoints;
} }
// Returns total number of characters(codepoints) in a UTF8 encoded text, until '\0' is found // Get total number of characters(codepoints) in a UTF8 encoded text, until '\0' is found
// NOTE: If an invalid UTF8 sequence is encountered a '?'(0x3f) codepoint is counted instead // NOTE: If an invalid UTF8 sequence is encountered a '?'(0x3f) codepoint is counted instead
int GetCodepointsCount(const char *text) int GetCodepointsCount(const char *text)
{ {
@ -1608,7 +1608,7 @@ int GetCodepointsCount(const char *text)
} }
#endif // SUPPORT_TEXT_MANIPULATION #endif // SUPPORT_TEXT_MANIPULATION
// Returns next codepoint in a UTF8 encoded text, scanning until '\0' is found // Get next codepoint in a UTF8 encoded text, scanning until '\0' is found
// When a invalid UTF8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned // When a invalid UTF8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
// Total number of bytes processed are returned as a parameter // Total number of bytes processed are returned as a parameter
// NOTE: the standard says U+FFFD should be returned in case of errors // NOTE: the standard says U+FFFD should be returned in case of errors

View File

@ -2646,7 +2646,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
// [x] Optimize ColorAlphaBlend() for faster operations (maybe avoiding divs?) // [x] Optimize ColorAlphaBlend() for faster operations (maybe avoiding divs?)
// [x] Consider fast path: no alpha blending required cases (src has no alpha) // [x] Consider fast path: no alpha blending required cases (src has no alpha)
// [x] Consider fast path: same src/dst format with no alpha -> direct line copy // [x] Consider fast path: same src/dst format with no alpha -> direct line copy
// [-] GetPixelColor(): Return Vector4 instead of Color, easier for ColorAlphaBlend() // [-] GetPixelColor(): Get Vector4 instead of Color, easier for ColorAlphaBlend()
Color colSrc, colDst, blend; Color colSrc, colDst, blend;
bool blendRequired = true; bool blendRequired = true;
@ -3553,7 +3553,7 @@ void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2
rlSetTexture(0); rlSetTexture(0);
} }
// Returns color with alpha applied, alpha goes from 0.0f to 1.0f // Get color with alpha applied, alpha goes from 0.0f to 1.0f
Color Fade(Color color, float alpha) Color Fade(Color color, float alpha)
{ {
if (alpha < 0.0f) alpha = 0.0f; if (alpha < 0.0f) alpha = 0.0f;
@ -3562,13 +3562,13 @@ Color Fade(Color color, float alpha)
return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)}; return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)};
} }
// Returns hexadecimal value for a Color // Get hexadecimal value for a Color
int ColorToInt(Color color) int ColorToInt(Color color)
{ {
return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a); return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
} }
// Returns color normalized as float [0..1] // Get color normalized as float [0..1]
Vector4 ColorNormalize(Color color) Vector4 ColorNormalize(Color color)
{ {
Vector4 result; Vector4 result;
@ -3581,7 +3581,7 @@ Vector4 ColorNormalize(Color color)
return result; return result;
} }
// Returns color from normalized values [0..1] // Get color from normalized values [0..1]
Color ColorFromNormalized(Vector4 normalized) Color ColorFromNormalized(Vector4 normalized)
{ {
Color result; Color result;
@ -3594,7 +3594,7 @@ Color ColorFromNormalized(Vector4 normalized)
return result; return result;
} }
// Returns HSV values for a Color // Get HSV values for a Color
// NOTE: Hue is returned as degrees [0..360] // NOTE: Hue is returned as degrees [0..360]
Vector3 ColorToHSV(Color color) Vector3 ColorToHSV(Color color)
{ {
@ -3646,7 +3646,7 @@ Vector3 ColorToHSV(Color color)
return hsv; return hsv;
} }
// Returns a Color from HSV values // Get a Color from HSV values
// Implementation reference: https://en.wikipedia.org/wiki/HSL_and_HSV#Alternative_HSV_conversion // Implementation reference: https://en.wikipedia.org/wiki/HSL_and_HSV#Alternative_HSV_conversion
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors // NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
// Hue is provided in degrees: [0..360] // Hue is provided in degrees: [0..360]
@ -3682,7 +3682,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
return color; return color;
} }
// Returns color with alpha applied, alpha goes from 0.0f to 1.0f // Get color with alpha applied, alpha goes from 0.0f to 1.0f
Color ColorAlpha(Color color, float alpha) Color ColorAlpha(Color color, float alpha)
{ {
if (alpha < 0.0f) alpha = 0.0f; if (alpha < 0.0f) alpha = 0.0f;
@ -3691,7 +3691,7 @@ Color ColorAlpha(Color color, float alpha)
return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)}; return (Color){color.r, color.g, color.b, (unsigned char)(255.0f*alpha)};
} }
// Returns src alpha-blended into dst color with tint // Get src alpha-blended into dst color with tint
Color ColorAlphaBlend(Color dst, Color src, Color tint) Color ColorAlphaBlend(Color dst, Color src, Color tint)
{ {
Color out = WHITE; Color out = WHITE;
@ -3746,7 +3746,7 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint)
return out; return out;
} }
// Returns a Color struct from hexadecimal value // Get a Color struct from hexadecimal value
Color GetColor(int hexValue) Color GetColor(int hexValue)
{ {
Color color; Color color;

View File

@ -393,7 +393,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
if (asset != NULL) if (asset != NULL)
{ {
// Return pointer to file in the assets // Get pointer to file in the assets
return funopen(asset, android_read, android_write, android_seek, android_close); return funopen(asset, android_read, android_write, android_seek, android_close);
} }
else else