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-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-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 |
| 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 |

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)
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)
else()
MESSAGE(STATUS "Using external GLFW")

View File

@ -22,7 +22,7 @@ int main(void)
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;
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
@ -56,6 +56,7 @@ int main(void)
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
{
name[letterCount] = (char)key;
name[letterCount+1] = '\0'; // Add null terminator at the end of the string.
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.
## 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
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.
All data is separated into parts, usually as strings. The following types are used for data:
This parser scans raylib.h to get API information about structs, enums and functions.
All data is divided into pieces, usually as strings. The following types are used for data:
- struct FunctionInfo
- struct StructInfo
@ -38,13 +38,15 @@
<valueName[3]> <valueDesc[3]>
} <name>;
NOTE: Multiple options are supported:
NOTE: Multiple options are supported for enums:
- If value is not provided, (<valueInteger[i -1]> + 1) is assigned
- 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
@ -55,6 +57,8 @@
**********************************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol()
#include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose()
#include <stdbool.h> // Required for: bool
@ -77,6 +81,7 @@ typedef struct FunctionInfo {
int paramCount; // Number of function parameters
char paramType[12][32]; // Parameters type (max: 12 parameters)
char paramName[12][32]; // Parameters name (max: 12 parameters)
char paramDesc[12][8]; // Parameters description (max: 12 parameters)
} FunctionInfo;
// Struct info data
@ -99,40 +104,65 @@ typedef struct EnumInfo {
char valueDesc[128][64]; // Value description (max: 128 values)
} 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
//----------------------------------------------------------------------------------
char *LoadFileText(const char *fileName, int *length);
char **GetTextLines(const char *buffer, int length, int *linesCount);
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);
static void ShowCommandLineInfo(void); // Show command line usage info
static void ProcessCommandLine(int argc, char *argv[]); // Process command line input
// Main entry point
int main()
static char *LoadFileText(const char *fileName, int *length);
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;
char *buffer = LoadFileText("../src/raylib.h", &length);
char *buffer = LoadFileText(inFileName, &length);
// Preprocess buffer to get separate lines
// NOTE: GetTextLines() also removes leading spaces/tabs
int linesCount = 0;
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"
int funcCount = 0;
char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *));
// Structs data (multiple lines), selected from "buffer"
int structCount = 0;
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));
// Enums lines pointers, selected from buffer "lines"
int enumCount = 0;
int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int));
// 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)
// TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition
for (int i = 0; i < length; i++)
@ -229,7 +256,7 @@ int main()
//--------------------------------------------------------------------------------------------------
// 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++)
{
@ -302,7 +329,7 @@ int main()
free(structLines);
// 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++)
{
@ -385,7 +412,7 @@ int main()
}
// 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++)
{
@ -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(funcLines);
@ -465,34 +492,16 @@ int main()
// enums[] -> We have all the enums decomposed into pieces for further analysis
// funcs[] -> We have all the functions decomposed into pieces for further analysis
// Print structs info
printf("\nStructures found: %i\n\n", structCount);
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]);
}
// Process input file to output
if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15);
// Print enums info
printf("\nEnums found: %i\n\n", enumCount);
for (int i = 0; i < enumCount; i++)
{
printf("Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount);
//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]);
}
printf("\nInput file: %s", inFileName);
printf("\nOutput file: %s", outFileName);
if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
// Print function info
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");
}
ExportParsedData(outFileName, outputFormat);
free(funcs);
free(structs);
@ -502,10 +511,84 @@ int main()
//----------------------------------------------------------------------------------
// 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
// 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;
@ -524,14 +607,17 @@ char *LoadFileText(const char *fileName, int *length)
if (size > 0)
{
*length = size;
text = (char *)calloc((size + 1), sizeof(char));
unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
// WARNING: \r\n is converted to \n on reading, so,
// 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
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')
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
int count = 0;
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
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
// 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--)
{
if (typeName[k] == ' ')
if (typeName[k] == ' ' && typeName[k - 1] != ',')
{
// Function name starts at this point (and ret type finishes at this point)
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>
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 *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
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;
@ -631,11 +725,20 @@ bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
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
// REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations!
// 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
if (!text || !replace || !by) return NULL;
@ -682,3 +785,205 @@ char *TextReplace(char *text, const char *replace, const char *by)
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
[Visual Studio][visual-studio] or the [build tools][vs-tools]. If you
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
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
// Support saving binary data automatically to a generated storage.data file. This file is managed internally.
#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
//------------------------------------------------------------------------------------

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
"MSVC" OFF)
if (BUILD_SHARED_LIBS)
set(_GLFW_BUILD_DLL 1)
endif()
if (BUILD_SHARED_LIBS AND UNIX)
# On Unix-like systems, shared libraries can use the soname system.
set(GLFW_LIB_NAME glfw)
@ -73,19 +69,8 @@ endif()
#--------------------------------------------------------------------
# Set compiler specific flags
#--------------------------------------------------------------------
if (MSVC)
if (MSVC90)
# 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)
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (${CMAKE_VERSION} VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
@ -100,41 +85,8 @@ if (MSVC)
endif()
endforeach()
endif()
endif()
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}")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
@ -203,11 +155,8 @@ if (_GLFW_X11)
find_package(X11 REQUIRED)
list(APPEND glfw_PKG_DEPS "x11")
# Set up library and include paths
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)
if (NOT X11_Xrandr_INCLUDE_PATH)
@ -238,32 +187,24 @@ if (_GLFW_X11)
if (NOT X11_Xshape_INCLUDE_PATH)
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
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()
#--------------------------------------------------------------------
# Use Wayland for window creation
#--------------------------------------------------------------------
if (_GLFW_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
find_package(Wayland REQUIRED Client Cursor Egl)
find_package(WaylandScanner REQUIRED)
find_package(WaylandProtocols 1.15 REQUIRED)
include(FindPkgConfig)
pkg_check_modules(Wayland 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_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
find_package(XKBCommon REQUIRED)
list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
include(CheckIncludeFiles)
include(CheckFunctionExists)
@ -279,14 +220,6 @@ if (_GLFW_WAYLAND)
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
#--------------------------------------------------------------------
@ -312,12 +245,10 @@ endif()
# Export GLFW library dependencies
#--------------------------------------------------------------------
foreach(arg ${glfw_PKG_DEPS})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL
"GLFW pkg-config Requires.private")
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
endforeach()
foreach(arg ${glfw_PKG_LIBS})
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL
"GLFW pkg-config Libs.private")
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
endforeach()
#--------------------------------------------------------------------
@ -336,9 +267,7 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake
VERSION ${GLFW_VERSION}
COMPATIBILITY SameMajorVersion)
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
configure_file(CMake/glfw3.pc.in CMake/glfw3.pc @ONLY)
configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY)
#--------------------------------------------------------------------
# Add subdirectories

View File

@ -99,7 +99,7 @@ located in the `deps/` directory.
functions
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
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
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_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
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 `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1
- 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
@ -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: Some extension loader headers did not prevent default OpenGL header
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
to the window menu
- [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
configuration change (#1761)
- [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 locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [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] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- [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)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
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: Key names were not updated when the keyboard layout changed
(#1462,#1528)
@ -199,6 +219,8 @@ information on what to include when reporting a bug.
combinaitons (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always
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] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [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: Scrolling offsets were inverted compared to other platforms
(#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
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [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.
- Bobyshev Alexander
- Laurent Aphecetche
- Matt Arsenault
- ashishgamedev
- David Avedissian
- Keith Bauer
- John Bartholomew
- Coşku Baş
- Niklas Behrens
- Andrew Belt
- Nevyn Bengtsson
- Niklas Bergström
- Denis Bernard
- Doug Binks
@ -268,6 +296,7 @@ skills.
- Andrew Corrigan
- Bailey Cosier
- Noel Cower
- CuriouserThing
- Jason Daly
- Jarrod Davis
- Olivier Delannoy
@ -294,6 +323,7 @@ skills.
- Eloi Marín Gratacós
- Stefan Gustavson
- Jonathan Hale
- hdf89shfdfs
- Sylvain Hellegouarch
- Matthew Henry
- heromyth
@ -318,11 +348,13 @@ skills.
- Konstantin Käfer
- Eric Larson
- Francis Lecavalier
- Jong Won Lee
- Robin Leffmann
- Glenn Lewis
- Shane Liesegang
- Anders Lindqvist
- Leon Linhart
- Marco Lizza
- Eyal Lotem
- Aaron Loucks
- Luflosi
@ -428,6 +460,9 @@ skills.
- Waris
- Jay Weisskopf
- Frank Wille
- Andy Williams
- Joel Winarske
- Richard A. Wilkes
- Tatsuya Yatagawa
- Ryogo Yoshimura
- Lukas Zanner
@ -436,6 +471,7 @@ skills.
- Santi Zupancic
- Jonas Ådahl
- Lasse Öörni
- Leonard König
- All the unmentioned and anonymous contributors in the GLFW community, for bug
reports, patches, feedback, testing and encouragement

View File

@ -276,23 +276,24 @@ extern "C" {
/*! @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
*/
#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
* backward-compatible.
* The minor version number of the GLFW header. This is incremented when
* features are added to the API but it remains backward-compatible.
* @ingroup init
*/
#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
* API changes.
* The revision number of the GLFW header. This is incremented when a bug fix
* release is made that does not contain any API changes.
* @ingroup init
*/
#define GLFW_VERSION_REVISION 0
@ -977,9 +978,10 @@ extern "C" {
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
*/
#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
@ -1250,6 +1252,11 @@ extern "C" {
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
*/
#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
@ -2417,8 +2424,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
*
* 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
* bit depth (the sum of all channel depths) and then by resolution area (the
* product of width and height).
* bit depth (the sum of all channel depths), then by resolution area (the
* product of width and height), then resolution width and finally by refresh
* rate.
*
* @param[in] monitor The monitor to query.
* @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
* the `VkInstanceCreateInfo` struct.
*
* @remark @macos This function currently supports either the
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
* extension.
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
* the newer `VK_EXT_metal_surface` extensions.
*
* @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
@ -5950,7 +5957,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @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.
*
* @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
* 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
* 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)
// 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
// callback) but windows.h assumes no one will define APIENTRY before it does
// example to allow applications to correctly declare a GL_KHR_debug callback)
// but windows.h assumes no one will define APIENTRY before it does
#if defined(GLFW_APIENTRY_DEFINED)
#undef APIENTRY
#undef GLFW_APIENTRY_DEFINED
@ -96,7 +96,6 @@ extern "C" {
typedef PVOID HANDLE;
typedef HANDLE HWND;
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
#include <ApplicationServices/ApplicationServices.h>
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#else

View File

@ -1,149 +1,192 @@
set(common_HEADERS internal.h mappings.h
"${GLFW_BINARY_DIR}/src/glfw_config.h"
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
internal.h mappings.h context.c init.c input.c monitor.c
vulkan.c window.c)
if (_GLFW_COCOA)
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)
set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m
cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c
nsgl_context.m egl_context.c osmesa_context.c)
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
nsgl_context.h egl_context.h osmesa_context.h
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m cocoa_time.c posix_thread.c
nsgl_context.m egl_context.c osmesa_context.c)
elseif (_GLFW_WIN32)
set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h
wgl_context.h egl_context.h osmesa_context.h)
set(glfw_SOURCES ${common_SOURCES} 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)
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
egl_context.h osmesa_context.h 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)
elseif (_GLFW_X11)
set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h
posix_thread.h glx_context.h egl_context.h osmesa_context.h)
set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c
xkb_unicode.c posix_time.c posix_thread.c glx_context.c
egl_context.c osmesa_context.c)
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 x11_init.c x11_monitor.c
x11_window.c xkb_unicode.c posix_time.c
posix_thread.c glx_context.c egl_context.c
osmesa_context.c)
elseif (_GLFW_WAYLAND)
set(glfw_HEADERS ${common_HEADERS} wl_platform.h
posix_time.h posix_thread.h xkb_unicode.h egl_context.h
osmesa_context.h)
set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c
posix_time.c posix_thread.c xkb_unicode.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)
target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
xkb_unicode.h egl_context.h osmesa_context.h
wl_init.c wl_monitor.c wl_window.c posix_time.c
posix_thread.c xkb_unicode.c egl_context.c
osmesa_context.c)
elseif (_GLFW_OSMESA)
set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h
posix_time.h posix_thread.h osmesa_context.h)
set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c
null_joystick.c posix_time.c posix_thread.c osmesa_context.c)
target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
posix_thread.h osmesa_context.h null_init.c
null_monitor.c null_window.c null_joystick.c
posix_time.c posix_thread.c osmesa_context.c)
endif()
if (_GLFW_X11 OR _GLFW_WAYLAND)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
else()
set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h)
set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c)
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
endif()
endif()
if (APPLE)
# For some reason, CMake doesn't know about .m
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
if (_GLFW_WAYLAND)
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
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()
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
# for all source files that VS will build
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
"${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)
if (WIN32 AND BUILD_SHARED_LIBS)
configure_file(glfw.rc.in glfw.rc @ONLY)
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
endif()
add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS})
add_library(glfw $<TARGET_OBJECTS:glfw_objlib>)
set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
configure_file(glfw_config.h.in glfw_config.h @ONLY)
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME}
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
SOVERSION ${GLFW_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON
C_STANDARD 99
C_EXTENSIONS OFF
DEFINE_SYMBOL _GLFW_BUILD_DLL
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
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
target_include_directories(glfw_objlib PRIVATE
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(glfw PRIVATE
"${GLFW_SOURCE_DIR}/src"
"${GLFW_BINARY_DIR}/src"
${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
# 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
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
target_compile_definitions(glfw_objlib PRIVATE
"$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>")
if (MINGW)
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif()
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
target_compile_options(glfw_objlib PRIVATE
"$<$<C_COMPILER_ID:AppleClang>:-Wall>"
"$<$<C_COMPILER_ID:Clang>:-Wall>"
"$<$<C_COMPILER_ID:GNU>:-Wall>")
# Workaround for legacy MinGW not providing XInput and DirectInput
if (MINGW)
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)
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 (WIN32)
if (MINGW)
# Remove the dependency on the shared version of libgcc
# 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)
set_target_properties(glfw PROPERTIES PREFIX "")
@ -155,33 +198,48 @@ if (BUILD_SHARED_LIBS)
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
endif()
target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL)
elseif (APPLE)
# Add -fno-common to work around a bug in Apple's GCC
target_compile_options(glfw_objlib PRIVATE "-fno-common")
target_compile_definitions(glfw INTERFACE GLFW_DLL)
endif()
set_target_properties(glfw PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
if (MINGW)
# 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()
if (UNIX)
# 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()
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()
if (GLFW_INSTALL)
install(TARGETS glfw
EXPORT glfwTargets
RUNTIME DESTINATION "bin"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

View File

@ -251,7 +251,7 @@ static void createKeyTables(void)
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
_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[0x71] = GLFW_KEY_F15;
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void)
{
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
// in order to properly emulate the behavior of NSApplicationMain
@ -557,6 +554,10 @@ int _glfwPlatformInit(void)
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
[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;
} // autoreleasepool

View File

@ -39,8 +39,21 @@
// 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_service_t service;
CFDictionaryRef info;
@ -50,7 +63,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
&it) != 0)
{
// This may happen if a desktop Mac is running headless
return NULL;
return _glfw_strdup("Display");
}
while ((service = IOIteratorNext(it)) != 0)
@ -88,7 +101,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find service port for display");
return NULL;
return _glfw_strdup("Display");
}
CFDictionaryRef names =
@ -101,7 +114,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
{
// This may happen if a desktop Mac is running headless
CFRelease(info);
return NULL;
return _glfw_strdup("Display");
}
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
//
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
@ -334,27 +322,46 @@ void _glfwPollMonitorsNS(void)
if (CGDisplayIsAsleep(displays[i]))
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
// display replacement on machines with automatic graphics
// switching
if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
break;
}
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
for (uint32_t j = 0; j < disconnectedCount; j++)
uint32_t j;
for (j = 0; j < disconnectedCount; j++)
{
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{
disconnected[j]->ns.screen = screen;
disconnected[j] = NULL;
break;
}
}
if (j < disconnectedCount)
continue;
const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]);
char* name = getMonitorName(displays[i], screen);
if (!name)
name = _glfw_strdup("Unknown");
continue;
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber;
monitor->ns.screen = screen;
free(name);
@ -463,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
{
@autoreleasepool {
if (!refreshMonitorScreen(monitor))
return;
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query content scale without screen");
}
const NSRect points = [monitor->ns.screen frame];
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
@ -483,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
{
@autoreleasepool {
if (!refreshMonitorScreen(monitor))
return;
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query workarea without screen");
}
const NSRect frameRect = [monitor->ns.screen visibleFrame];
@ -527,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
}
// Skip duplicate modes
if (i < *count)
if (j < *count)
continue;
(*count)++;

View File

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

View File

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

View File

@ -173,7 +173,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE;
u->doublebuffer = desired->doublebuffer;
u->handle = (uintptr_t) n;
usableCount++;
@ -643,6 +643,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
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);
native = _glfwPlatformGetEGLNativeWindow(window);

View File

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

View File

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

View File

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

View File

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

View File

@ -248,6 +248,9 @@ struct _GLFWinitconfig
GLFWbool menubar;
GLFWbool chdir;
} ns;
struct {
GLFWbool xcbVulkanSurface;
} x11;
};
// Window configuration
@ -350,9 +353,9 @@ struct _GLFWcontext
int robustness;
int release;
PFNGLGETSTRINGIPROC GetStringi;
PFNGLGETSTRINGIPROC GetStringi;
PFNGLGETINTEGERVPROC GetIntegerv;
PFNGLGETSTRINGPROC GetString;
PFNGLGETSTRINGPROC GetString;
_GLFWmakecontextcurrentfun makeCurrent;
_GLFWswapbuffersfun swapBuffers;
@ -384,6 +387,7 @@ struct _GLFWwindow
GLFWbool mousePassthrough;
GLFWbool shouldClose;
void* userPointer;
GLFWbool doublebuffer;
GLFWvidmode videoMode;
_GLFWmonitor* monitor;
_GLFWcursor* cursor;
@ -405,23 +409,23 @@ struct _GLFWwindow
_GLFWcontext context;
struct {
GLFWwindowposfun pos;
GLFWwindowsizefun size;
GLFWwindowclosefun close;
GLFWwindowrefreshfun refresh;
GLFWwindowfocusfun focus;
GLFWwindowiconifyfun iconify;
GLFWwindowmaximizefun maximize;
GLFWframebuffersizefun fbsize;
GLFWwindowposfun pos;
GLFWwindowsizefun size;
GLFWwindowclosefun close;
GLFWwindowrefreshfun refresh;
GLFWwindowfocusfun focus;
GLFWwindowiconifyfun iconify;
GLFWwindowmaximizefun maximize;
GLFWframebuffersizefun fbsize;
GLFWwindowcontentscalefun scale;
GLFWmousebuttonfun mouseButton;
GLFWcursorposfun cursorPos;
GLFWcursorenterfun cursorEnter;
GLFWscrollfun scroll;
GLFWkeyfun key;
GLFWcharfun character;
GLFWcharmodsfun charmods;
GLFWdropfun drop;
GLFWmousebuttonfun mouseButton;
GLFWcursorposfun cursorPos;
GLFWcursorenterfun cursorEnter;
GLFWscrollfun scroll;
GLFWkeyfun key;
GLFWcharfun character;
GLFWcharmodsfun charmods;
GLFWdropfun drop;
} callbacks;
// This is defined in the window API's platform.h
@ -432,7 +436,7 @@ struct _GLFWwindow
//
struct _GLFWmonitor
{
char* name;
char name[128];
void* userPointer;
// Physical dimensions in millimeters.
@ -493,7 +497,7 @@ struct _GLFWjoystick
int buttonCount;
unsigned char* hats;
int hatCount;
char* name;
char name[128];
void* userPointer;
char guid[33];
_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->heightMM = heightMM;
if (name)
monitor->name = _glfw_strdup(name);
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
return monitor;
}
@ -189,7 +188,6 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
_glfwFreeGammaArrays(&monitor->currentRamp);
free(monitor->modes);
free(monitor->name);
free(monitor);
}

View File

@ -165,6 +165,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue;
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
@ -182,8 +185,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
u->doublebuffer = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample)
u->samples = findAttribValue(WGL_SAMPLES_ARB);
@ -239,6 +240,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.iPixelType != PFD_TYPE_RGBA)
continue;
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
continue;
u->redBits = pfd.cRedBits;
u->greenBits = pfd.cGreenBits;
u->blueBits = pfd.cBlueBits;
@ -256,8 +260,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE;
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
u->doublebuffer = GLFW_TRUE;
}
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_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
// automatically directed to the high-performance GPU on Nvidia Optimus systems
// with up-to-date drivers
@ -614,7 +618,9 @@ void _glfwPlatformTerminate(void)
const char* _glfwPlatformGetVersionString(void)
{
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
#if defined(__MINGW32__)
#if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64"
#elif defined(__MINGW32__)
" MinGW"
#elif defined(_MSC_VER)
" VisualC"

View File

@ -39,8 +39,8 @@
#endif
// 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
// callback) but windows.h assumes no one will define APIENTRY before it does
// example to allow applications to correctly declare a GL_KHR_debug callback)
// but windows.h assumes no one will define APIENTRY before it does
#undef APIENTRY
// GLFW on Windows is Unicode only and does not work in MBCS mode
@ -314,6 +314,9 @@ typedef struct _GLFWwindowWin32
GLFWbool scaleToMonitor;
GLFWbool keymenu;
// Cached size used to filter out duplicate events
int width, height;
// The last received cursor position, regardless of source
int lastCursorPosX, lastCursorPosY;
// 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:
{
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
EnableNonClientDpiScaling(hWnd);
{
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);
}
break;
}
@ -961,6 +971,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_SIZE:
{
const int width = LOWORD(lParam);
const int height = HIWORD(lParam);
const GLFWbool iconified = wParam == SIZE_MINIMIZED;
const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
(window->win32.maximized &&
@ -975,8 +987,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->win32.maximized != maximized)
_glfwInputWindowMaximize(window, maximized);
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
if (width != window->win32.width || height != window->win32.height)
{
window->win32.width = width;
window->win32.height = height;
_glfwInputFramebufferSize(window, width, height);
_glfwInputWindowSize(window, width, height);
}
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 yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
// Only apply the suggested size if the OS is new enough to have
// sent a WM_GETDPISCALEDSIZE before this
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
// Resize windowed mode windows that either permit rescaling or that
// need it to compensate for non-client area scaling
if (!window->monitor &&
(window->win32.scaleToMonitor ||
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
{
RECT* suggested = (RECT*) lParam;
SetWindowPos(window->win32.handle, HWND_TOP,
@ -1247,7 +1267,7 @@ static int createNativeWindow(_GLFWwindow* window,
NULL, // No parent window
NULL, // No window menu
GetModuleHandleW(NULL),
NULL);
(LPVOID) wndconfig);
free(wideTitle);
@ -1315,6 +1335,8 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.transparent = GLFW_TRUE;
}
_glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height);
return GLFW_TRUE;
}
@ -2113,30 +2135,41 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{
int id = 0;
if (shape == GLFW_ARROW_CURSOR)
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
switch (shape)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
return GLFW_FALSE;
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");
return GLFW_FALSE;
}
cursor->win32.handle = LoadImageW(NULL,

View File

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

View File

@ -1038,8 +1038,6 @@ int _glfwPlatformInit(void)
char *cursorSizeEnd;
long cursorSizeLong;
int cursorSize;
int i;
_GLFWmonitor* monitor;
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
if (!_glfw.wl.cursor.handle)
@ -1148,17 +1146,6 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events
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();
_glfw.wl.timerfd = -1;

View File

@ -47,15 +47,13 @@ static void outputHandleGeometry(void* data,
int32_t transform)
{
struct _GLFWmonitor *monitor = data;
char name[1024];
monitor->wl.x = x;
monitor->wl.y = y;
monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight;
snprintf(name, sizeof(name), "%s %s", make, model);
monitor->name = _glfw_strdup(name);
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
}
static void outputHandleMode(void* data,
@ -88,6 +86,14 @@ static void outputHandleDone(void* data, struct wl_output* output)
{
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);
}
@ -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.
monitor = _glfwAllocMonitor(NULL, 0, 0);
monitor = _glfwAllocMonitor("", 0, 0);
output = wl_registry_bind(_glfw.wl.registry,
name,

View File

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

View File

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

View File

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

View File

@ -490,7 +490,7 @@ float GetGesturePinchAngle(void)
// Module specific Functions Definition
//----------------------------------------------------------------------------------
#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)
{
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)
static Model LoadGLTF(const char *fileName); // Load GLTF mesh 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 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 LoadGLTFMaterial(Model* model, const char* fileName, const cgltf_data* data);
static void InitGLTFBones(Model* model, const cgltf_data* data);
static void LoadGLTFModelIndices(Model *model, cgltf_accessor *indexAccessor, 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 LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_data *data);
static void InitGLTFBones(Model *model, const cgltf_data *data);
#endif
//----------------------------------------------------------------------------------
@ -2824,8 +2824,8 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
// NOTE: Billboard locked on axis-Y
Vector3 up = { 0.0f, 1.0f, 0.0f };
Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2);
Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2);
Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2);
Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2);
Vector3 p1 = Vector3Add(rightScaled, upScaled);
Vector3 p2 = Vector3Subtract(rightScaled, upScaled);
@ -2835,48 +2835,48 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
Vector3 bottomRight = p2;
Vector3 bottomLeft = Vector3Scale(p1, -1);
if (rotation != 0.0f)
{
float sinRotation = sinf(rotation*DEG2RAD);
float cosRotation = cosf(rotation*DEG2RAD);
if (rotation != 0.0f)
{
float sinRotation = sinf(rotation*DEG2RAD);
float cosRotation = cosf(rotation*DEG2RAD);
// NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture
float rotateAboutX = sizeRatio.x*origin.x/2;
float rotateAboutY = sizeRatio.y*origin.y/2;
// NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture
float rotateAboutX = sizeRatio.x*origin.x/2;
float rotateAboutY = sizeRatio.y*origin.y/2;
float xtvalue, ytvalue;
float rotatedX, rotatedY;
float xtvalue, ytvalue;
float rotatedX, rotatedY;
xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane
ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates
xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane
ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates
xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
topRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomRight) - rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomRight) - rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
}
xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX;
ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY;
rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX;
rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY;
bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX));
}
// Translate points to the draw center (position)
topLeft = Vector3Add(topLeft, position);
topRight = Vector3Add(topRight, position);
bottomRight = Vector3Add(bottomRight, position);
bottomLeft = Vector3Add(bottomLeft, position);
topLeft = Vector3Add(topLeft, position);
topRight = Vector3Add(topRight, position);
bottomRight = Vector3Add(bottomRight, position);
bottomLeft = Vector3Add(bottomLeft, position);
rlCheckRenderBatchLimit(4);
@ -2919,7 +2919,7 @@ void DrawBoundingBox(BoundingBox box, Color 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 collision = false;
@ -2942,7 +2942,7 @@ bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, floa
return collision;
}
// Detect collision between two boxes
// Check collision between two boxes
// NOTE: Boxes are defined by two points minimum and maximum
bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
{
@ -2958,7 +2958,7 @@ bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
return collision;
}
// Detect collision between box and sphere
// Check collision between box and sphere
bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius)
{
bool collision = false;
@ -3773,7 +3773,7 @@ static Model LoadIQM(const char *fileName)
}
// 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_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)
{
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++)
{

View File

@ -1311,7 +1311,7 @@ Music LoadMusicStream(const char *fileName)
}
// 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 };
bool musicLoaded = false;
@ -1325,7 +1325,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
{
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.ctxData = ctxWav;
@ -1383,7 +1383,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
// Open ogg audio stream
music.ctxType = MUSIC_AUDIO_OGG;
//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)
{
@ -1403,7 +1403,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int d
else if (TextIsEqual(fileExtLower, ".xm"))
{
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
{
music.ctxType = MUSIC_MODULE_XM;
@ -1660,17 +1660,17 @@ void UpdateMusicStream(Music music)
{
case ma_format_f32:
// 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;
case ma_format_s16:
// 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;
case ma_format_u8:
// 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;
}
@ -1786,7 +1786,7 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
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
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;

View File

@ -646,7 +646,6 @@ typedef enum {
MOUSE_BUTTON_EXTRA = 4,
MOUSE_BUTTON_FORWARD = 5,
MOUSE_BUTTON_BACK = 6,
MOUSE_BUTTON_MAX = 7
} MouseButton;
// Mouse cursor
@ -711,23 +710,23 @@ typedef enum {
GAMEPAD_AXIS_RIGHT_Y = 3,
// Pressure levels for the back triggers
GAMEPAD_AXIS_LEFT_TRIGGER = 4, // [1..-1] (pressure-level)
GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // [1..-1] (pressure-level)
GAMEPAD_AXIS_LEFT_TRIGGER = 4, // [1..-1] (pressure-level)
GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // [1..-1] (pressure-level)
} GamepadAxis;
// Material map index
typedef enum {
MATERIAL_MAP_ALBEDO = 0, // MATERIAL_MAP_DIFFUSE
MATERIAL_MAP_METALNESS = 1, // MATERIAL_MAP_SPECULAR
MATERIAL_MAP_NORMAL = 2,
MATERIAL_MAP_ROUGHNESS = 3,
MATERIAL_MAP_OCCLUSION,
MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
MATERIAL_MAP_BRDG,
MATERIAL_MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP
MATERIAL_MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP
MATERIAL_MAP_PREFILTER // NOTE: Uses GL_TEXTURE_CUBE_MAP
MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)
MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR)
MATERIAL_MAP_NORMAL, // Normal material
MATERIAL_MAP_ROUGHNESS, // Roughness material
MATERIAL_MAP_OCCLUSION, // Ambient occlusion material
MATERIAL_MAP_EMISSION, // Emission material
MATERIAL_MAP_HEIGHT, // Heightmap material
MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP)
MATERIAL_MAP_BRDG // Brdg material
} MaterialMapIndex;
#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO
@ -735,32 +734,32 @@ typedef enum {
// Shader location index
typedef enum {
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO, // SHADER_LOC_MAP_DIFFUSE
SHADER_LOC_MAP_METALNESS, // SHADER_LOC_MAP_SPECULAR
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF
SHADER_LOC_VERTEX_POSITION = 0, // Shader location point: position
SHADER_LOC_VERTEX_TEXCOORD01, // Shader location point: texcoord01
SHADER_LOC_VERTEX_TEXCOORD02, // Shader location point: texcoord02
SHADER_LOC_VERTEX_NORMAL, // Shader location point: normal
SHADER_LOC_VERTEX_TANGENT, // Shader location point: tangent
SHADER_LOC_VERTEX_COLOR, // Shader location point: color
SHADER_LOC_MATRIX_MVP, // Shader location point: model-view-projection matrix
SHADER_LOC_MATRIX_VIEW, // Shader location point: view matrix
SHADER_LOC_MATRIX_PROJECTION, // Shader location point: projection matrix
SHADER_LOC_MATRIX_MODEL, // Shader location point: model matrix
SHADER_LOC_MATRIX_NORMAL, // Shader location point: normal matrix
SHADER_LOC_VECTOR_VIEW, // Shader location point: view vector
SHADER_LOC_COLOR_DIFFUSE, // Shader location point: diffuse color
SHADER_LOC_COLOR_SPECULAR, // Shader location point: specular color
SHADER_LOC_COLOR_AMBIENT, // Shader location point: ambient color
SHADER_LOC_MAP_ALBEDO, // Shader location point: albedo texture (same as: SHADER_LOC_MAP_DIFFUSE)
SHADER_LOC_MAP_METALNESS, // Shader location point: metalness texture (same as: SHADER_LOC_MAP_SPECULAR)
SHADER_LOC_MAP_NORMAL, // Shader location point: normal texture
SHADER_LOC_MAP_ROUGHNESS, // Shader location point: roughness texture
SHADER_LOC_MAP_OCCLUSION, // Shader location point: occlusion texture
SHADER_LOC_MAP_EMISSION, // Shader location point: emission texture
SHADER_LOC_MAP_HEIGHT, // Shader location point: height texture
SHADER_LOC_MAP_CUBEMAP, // Shader location point: cubemap texture_cube_map
SHADER_LOC_MAP_IRRADIANCE, // Shader location point: irradiance texture_cube_map
SHADER_LOC_MAP_PREFILTER, // Shader location point: prefilter texture_cube_map
SHADER_LOC_MAP_BRDF // Shader location point: brdf texture
} ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
@ -768,43 +767,51 @@ typedef enum {
// Shader uniform data type
typedef enum {
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D,
SHADER_UNIFORM_MAT3,
SHADER_UNIFORM_MAT4
SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)
SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)
SHADER_UNIFORM_INT, // Shader uniform type: int
SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)
SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)
SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)
SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d
SHADER_UNIFORM_MAT3, // Shader uniform type: mat3 (9 float)
SHADER_UNIFORM_MAT4 // Shader uniform type: mat4 (16 float)
} 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
// NOTE: Support depends on OpenGL version and platform
typedef enum {
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp
PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp
PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp
PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp
PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp
PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} PixelFormat;
// Texture parameters: filter mode
@ -821,68 +828,68 @@ typedef enum {
// Texture parameters: wrap mode
typedef enum {
TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode
TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode
TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode
TEXTURE_WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode
TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode
TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode
TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode
TEXTURE_WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode
} TextureWrap;
// Cubemap layouts
typedef enum {
CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map)
CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map)
} CubemapLayout;
// Font type, defines generation method
typedef enum {
FONT_DEFAULT = 0, // Default font generation, anti-aliased
FONT_BITMAP, // Bitmap font generation, no anti-aliasing
FONT_SDF // SDF font generation, requires external shader
FONT_DEFAULT = 0, // Default font generation, anti-aliased
FONT_BITMAP, // Bitmap font generation, no anti-aliasing
FONT_SDF // SDF font generation, requires external shader
} FontType;
// Color blending modes (pre-defined)
typedef enum {
BLEND_ALPHA = 0, // Blend textures considering alpha (default)
BLEND_ADDITIVE, // Blend textures adding colors
BLEND_MULTIPLIED, // Blend textures multiplying colors
BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)
BLEND_CUSTOM // Belnd textures using custom src/dst factors (use rlSetBlendMode())
BLEND_ALPHA = 0, // Blend textures considering alpha (default)
BLEND_ADDITIVE, // Blend textures adding colors
BLEND_MULTIPLIED, // Blend textures multiplying colors
BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)
BLEND_CUSTOM // Belnd textures using custom src/dst factors (use rlSetBlendMode())
} BlendMode;
// Gestures
// NOTE: It could be used as flags to enable only some gestures
typedef enum {
GESTURE_NONE = 0,
GESTURE_TAP = 1,
GESTURE_DOUBLETAP = 2,
GESTURE_HOLD = 4,
GESTURE_DRAG = 8,
GESTURE_SWIPE_RIGHT = 16,
GESTURE_SWIPE_LEFT = 32,
GESTURE_SWIPE_UP = 64,
GESTURE_SWIPE_DOWN = 128,
GESTURE_PINCH_IN = 256,
GESTURE_PINCH_OUT = 512
GESTURE_NONE = 0, // No gesture
GESTURE_TAP = 1, // Tap gesture
GESTURE_DOUBLETAP = 2, // Double tap gesture
GESTURE_HOLD = 4, // Hold gesture
GESTURE_DRAG = 8, // Drag gesture
GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture
GESTURE_SWIPE_LEFT = 32, // Swipe left gesture
GESTURE_SWIPE_UP = 64, // Swipe up gesture
GESTURE_SWIPE_DOWN = 128, // Swipe down gesture
GESTURE_PINCH_IN = 256, // Pinch in gesture
GESTURE_PINCH_OUT = 512 // Pinch out gesture
} Gesture;
// Camera system modes
typedef enum {
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
CAMERA_CUSTOM = 0, // Custom camera
CAMERA_FREE, // Free camera
CAMERA_ORBITAL, // Orbital camera
CAMERA_FIRST_PERSON, // First person camera
CAMERA_THIRD_PERSON // Third person camera
} CameraMode;
// Camera projection
typedef enum {
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
CAMERA_PERSPECTIVE = 0, // Perspective projection
CAMERA_ORTHOGRAPHIC // Orthographic projection
} CameraProjection;
// 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)
// Screen-space-related functions
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns 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 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns 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 Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position
RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
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); // Get size position for a 3d 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); // Get the world space position for a 2d camera screen space position
// Timing-related functions
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
RLAPI int GetFPS(void); // Returns current FPS
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn (delta time)
RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow()
RLAPI int GetFPS(void); // Get current FPS
RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)
RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()
// 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 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
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
RLAPI bool IsKeyUp(int key); // Detect if a key is NOT being pressed
RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once
RLAPI bool IsKeyDown(int key); // Check if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Check if a key has been released once
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 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
// 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 const char *GetGamepadName(int gamepad); // Return gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect 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 IsGamepadButtonReleased(int gamepad, int button); // Detect 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 const char *GetGamepadName(int gamepad); // Get gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once
RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed
RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once
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 GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
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)
// Input-related functions: mouse
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
RLAPI bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
RLAPI int GetMouseX(void); // Returns mouse position X
RLAPI int GetMouseY(void); // Returns mouse position Y
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once
RLAPI bool IsMouseButtonDown(int button); // Check if a mouse button is being pressed
RLAPI bool IsMouseButtonReleased(int button); // Check if a mouse button has been released once
RLAPI bool IsMouseButtonUp(int button); // Check if a mouse button is NOT being pressed
RLAPI int GetMouseX(void); // Get mouse position X
RLAPI int GetMouseY(void); // Get mouse position Y
RLAPI Vector2 GetMousePosition(void); // Get 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 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
// Input-related functions: touch
RLAPI int GetTouchX(void); // Returns 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 Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)
RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
//------------------------------------------------------------------------------------
// 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
// 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 int ColorToInt(Color color); // Returns hexadecimal value for a Color
RLAPI Vector4 ColorNormalize(Color color); // Returns Color normalized as float [0..1]
RLAPI Color ColorFromNormalized(Vector4 normalized); // Returns 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 Color ColorFromHSV(float hue, float saturation, float value); // Returns 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 ColorAlphaBlend(Color dst, Color src, Color tint); // Returns src alpha-blended into dst color with tint
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); // Get hexadecimal value for a Color
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [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); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
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); // Get src alpha-blended into dst color with tint
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 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
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 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)
//------------------------------------------------------------------------------------
@ -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
// Collision detection functions
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Detect collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes
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 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
@ -1494,7 +1501,7 @@ RLAPI void UnloadWaveSamples(float *samples); // Unload
// Music management functions
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 PlayMusicStream(Music music); // Start music playing
RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing

View File

@ -42,11 +42,11 @@
#ifndef RAYMATH_H
#define RAYMATH_H
//#define RAYMATH_STANDALONE // NOTE: To use raymath as standalone lib, just uncomment this line
//#define RAYMATH_HEADER_ONLY // NOTE: To compile functions as static inline, uncomment this line
//#define RAYMATH_STANDALONE // NOTE: To use raymath as standalone lib, just uncomment this line
//#define RAYMATH_HEADER_ONLY // NOTE: To compile functions as static inline, uncomment this line
#ifndef RAYMATH_STANDALONE
#include "raylib.h" // Required for structs: Vector3, Matrix
#include "raylib.h" // Required for structs: Vector3, Matrix
#endif
#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_HEADER_ONLY)
@ -55,17 +55,17 @@
#if defined(RAYMATH_IMPLEMENTATION)
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
#define RMDEF __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll).
#define RMDEF __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll).
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
#define RMDEF __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#define RMDEF __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#else
#define RMDEF extern inline // Provide external definition
#endif
#elif defined(RAYMATH_HEADER_ONLY)
#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
#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
#define RMDEF inline // Functions may be inlined or external definition used
#endif
@ -86,12 +86,12 @@
#define RAD2DEG (180.0f/PI)
#endif
// Return float vector for Matrix
// Get float vector for Matrix
#ifndef MatrixToFloat
#define MatrixToFloat(mat) (MatrixToFloatV(mat).v)
#endif
// Return float vector for Vector3
// Get float vector for Vector3
#ifndef Vector3ToFloat
#define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v)
#endif
@ -559,7 +559,7 @@ RMDEF Vector3 Vector3Reflect(Vector3 v, Vector3 normal)
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)
{
Vector3 result = { 0 };
@ -571,7 +571,7 @@ RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2)
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)
{
Vector3 result = { 0 };
@ -609,7 +609,7 @@ RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
return result;
}
// Returns Vector3 as float array
// Get Vector3 as float array
RMDEF float3 Vector3ToFloatV(Vector3 v)
{
float3 buffer = { 0 };
@ -644,7 +644,7 @@ RMDEF float MatrixDeterminant(Matrix mat)
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)
{
float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15);
@ -750,7 +750,7 @@ RMDEF Matrix MatrixNormalize(Matrix mat)
return result;
}
// Returns identity matrix
// Get identity matrix
RMDEF Matrix MatrixIdentity(void)
{
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
@ -811,7 +811,7 @@ RMDEF Matrix MatrixSubtract(Matrix left, Matrix right)
return result;
}
// Returns two matrix multiplication
// Get two matrix multiplication
// NOTE: When multiplying matrices... the order matters!
RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
{
@ -837,7 +837,7 @@ RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
return result;
}
// Returns translation matrix
// Get translation matrix
RMDEF Matrix MatrixTranslate(float x, float y, float z)
{
Matrix result = { 1.0f, 0.0f, 0.0f, x,
@ -893,7 +893,7 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
return result;
}
// Returns x-rotation matrix (angle in radians)
// Get x-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateX(float angle)
{
Matrix result = MatrixIdentity();
@ -909,7 +909,7 @@ RMDEF Matrix MatrixRotateX(float angle)
return result;
}
// Returns y-rotation matrix (angle in radians)
// Get y-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateY(float angle)
{
Matrix result = MatrixIdentity();
@ -925,7 +925,7 @@ RMDEF Matrix MatrixRotateY(float angle)
return result;
}
// Returns z-rotation matrix (angle in radians)
// Get z-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateZ(float angle)
{
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)
{
Matrix result = MatrixIdentity();
@ -969,7 +969,7 @@ RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
return result;
}
// Returns zyx-rotation matrix (angles in radians)
// Get zyx-rotation matrix (angles in radians)
RMDEF Matrix MatrixRotateZYX(Vector3 ang)
{
Matrix result = { 0 };
@ -1004,7 +1004,7 @@ RMDEF Matrix MatrixRotateZYX(Vector3 ang)
return result;
}
// Returns scaling matrix
// Get scaling matrix
RMDEF Matrix MatrixScale(float x, float y, float z)
{
Matrix result = { x, 0.0f, 0.0f, 0.0f,
@ -1015,7 +1015,7 @@ RMDEF Matrix MatrixScale(float x, float y, float z)
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)
{
Matrix result = { 0 };
@ -1047,7 +1047,7 @@ RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top,
return result;
}
// Returns perspective projection matrix
// Get perspective projection matrix
// NOTE: Angle should be provided in radians
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;
}
// Returns orthographic projection matrix
// Get orthographic projection matrix
RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
{
Matrix result = { 0 };
@ -1087,7 +1087,7 @@ RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, d
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)
{
Matrix result = { 0 };
@ -1118,7 +1118,7 @@ RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
return result;
}
// Returns float array of matrix data
// Get float array of matrix data
RMDEF float16 MatrixToFloatV(Matrix mat)
{
float16 buffer = { 0 };
@ -1175,7 +1175,7 @@ RMDEF Quaternion QuaternionSubtractValue(Quaternion q, float sub)
return result;
}
// Returns identity quaternion
// Get identity quaternion
RMDEF Quaternion QuaternionIdentity(void)
{
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
@ -1351,7 +1351,7 @@ RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
return result;
}
// Returns a quaternion for a given rotation matrix
// Get a quaternion for a given rotation matrix
RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
{
Quaternion result = { 0 };
@ -1385,7 +1385,7 @@ RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
return result;
}
// Returns a matrix for a given quaternion
// Get a matrix for a given quaternion
RMDEF Matrix QuaternionToMatrix(Quaternion q)
{
Matrix result = MatrixIdentity();
@ -1415,7 +1415,7 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
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
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
{
@ -1440,7 +1440,7 @@ RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
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)
{
if (fabs(q.w) > 1.0f) q = QuaternionNormalize(q);
@ -1466,7 +1466,7 @@ RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle
*outAngle = resAngle;
}
// Returns the quaternion equivalent to Euler angles
// Get the quaternion equivalent to Euler angles
// NOTE: Rotation order is ZYX
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 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
RMDEF Vector3 QuaternionToEuler(Quaternion q)
{

View File

@ -291,26 +291,18 @@ typedef struct RenderBatch {
float currentDepth; // Current depth value for next draw
} 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)
#ifndef __cplusplus
// Boolean type
typedef enum { false, true } bool;
#endif
// Color type, RGBA (32bit)
// Color, 4 components, R8G8B8A8 (32bit)
typedef struct Color {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
unsigned char r; // Color red value
unsigned char g; // Color green value
unsigned char b; // Color blue value
unsigned char a; // Color alpha value
} Color;
// Texture type
@ -332,20 +324,20 @@ typedef enum {
// Trace log level
// NOTE: Organized by priority level
typedef enum {
LOG_ALL = 0, // Display all logs
LOG_TRACE, // Trace logging, intended for internal use only
LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds
LOG_INFO, // Info logging, used for program execution info
LOG_WARNING, // Warning logging, used on recoverable failures
LOG_ERROR, // Error logging, used on unrecoverable failures
LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE)
LOG_NONE // Disable logging
LOG_ALL = 0, // Display all logs
LOG_TRACE, // Trace logging, intended for internal use only
LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds
LOG_INFO, // Info logging, used for program execution info
LOG_WARNING, // Warning logging, used on recoverable failures
LOG_ERROR, // Error logging, used on unrecoverable failures
LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE)
LOG_NONE // Disable logging
} TraceLogLevel;
// Texture formats (support depends on OpenGL version)
typedef enum {
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_R8G8B8, // 24 bpp
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
@ -399,49 +391,57 @@ typedef enum {
// Shader location point type
typedef enum {
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO, // SHADER_LOC_MAP_DIFFUSE
SHADER_LOC_MAP_METALNESS, // SHADER_LOC_MAP_SPECULAR
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF
SHADER_LOC_VERTEX_POSITION = 0, // Shader location point: position
SHADER_LOC_VERTEX_TEXCOORD01, // Shader location point: texcoord01
SHADER_LOC_VERTEX_TEXCOORD02, // Shader location point: texcoord02
SHADER_LOC_VERTEX_NORMAL, // Shader location point: normal
SHADER_LOC_VERTEX_TANGENT, // Shader location point: tangent
SHADER_LOC_VERTEX_COLOR, // Shader location point: color
SHADER_LOC_MATRIX_MVP, // Shader location point: model-view-projection matrix
SHADER_LOC_MATRIX_VIEW, // Shader location point: view matrix
SHADER_LOC_MATRIX_PROJECTION, // Shader location point: projection matrix
SHADER_LOC_MATRIX_MODEL, // Shader location point: model matrix
SHADER_LOC_MATRIX_NORMAL, // Shader location point: normal matrix
SHADER_LOC_VECTOR_VIEW, // Shader location point: view vector
SHADER_LOC_COLOR_DIFFUSE, // Shader location point: diffuse color
SHADER_LOC_COLOR_SPECULAR, // Shader location point: specular color
SHADER_LOC_COLOR_AMBIENT, // Shader location point: ambient color
SHADER_LOC_MAP_ALBEDO, // Shader location point: albedo texture (same as: SHADER_LOC_MAP_DIFFUSE)
SHADER_LOC_MAP_METALNESS, // Shader location point: metalness texture (same as: SHADER_LOC_MAP_SPECULAR)
SHADER_LOC_MAP_NORMAL, // Shader location point: normal texture
SHADER_LOC_MAP_ROUGHNESS, // Shader location point: roughness texture
SHADER_LOC_MAP_OCCLUSION, // Shader location point: occlusion texture
SHADER_LOC_MAP_EMISSION, // Shader location point: emission texture
SHADER_LOC_MAP_HEIGHT, // Shader location point: height texture
SHADER_LOC_MAP_CUBEMAP, // Shader location point: cubemap texture_cube_map
SHADER_LOC_MAP_IRRADIANCE, // Shader location point: irradiance texture_cube_map
SHADER_LOC_MAP_PREFILTER, // Shader location point: prefilter texture_cube_map
SHADER_LOC_MAP_BRDF // Shader location point: brdf texture
} ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO
#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS
// Shader uniform data types
// Shader uniform data type
typedef enum {
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D
SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float
SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)
SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)
SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)
SHADER_UNIFORM_INT, // Shader uniform type: int
SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)
SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)
SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)
SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d
} 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
#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 rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
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 rlGetFramebufferHeight(void); // Get default framebuffer height
@ -1892,7 +1892,7 @@ void rlLoadExtensions(void *loader)
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
}
// Returns current OpenGL version
// Get current OpenGL version
int rlGetVersion(void)
{
#if defined(GRAPHICS_API_OPENGL_11)
@ -3471,7 +3471,7 @@ void rlSetShader(Shader shader)
// Matrix state management
//-----------------------------------------------------------------------------------------
// Return internal modelview matrix
// Get internal modelview matrix
Matrix rlGetMatrixModelview(void)
{
Matrix matrix = MatrixIdentity();
@ -3500,7 +3500,7 @@ Matrix rlGetMatrixModelview(void)
return matrix;
}
// Return internal projection matrix
// Get internal projection matrix
Matrix rlGetMatrixProjection(void)
{
#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
void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
{
Vector2 delta = {endPos.x-startPos.x, endPos.y-startPos.y};
float length = sqrtf(delta.x*delta.x + delta.y*delta.y);
Vector2 delta = { endPos.x - startPos.x, endPos.y - startPos.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);
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},
{endPos.x-radius.x, endPos.y-radius.y}, {endPos.x+radius.x, endPos.y+radius.y}};
float scale = thick/(2*length);
Vector2 radius = { -scale*delta.y, scale*delta.x };
Vector2 strip[4] = {
{ 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);
}

View File

@ -1123,7 +1123,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
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)
{
#ifndef GLYPH_NOTFOUND_CHAR_FALLBACK
@ -1176,7 +1176,7 @@ const char *TextFormat(const char *text, ...)
// We create an array of buffers so strings don't expire until MAX_TEXTFORMAT_BUFFERS invocations
static char buffers[MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH] = { 0 };
static int index = 0;
static int index = 0;
char *currentBuffer = buffers[index];
memset(currentBuffer, 0, MAX_TEXT_BUFFER_LENGTH); // Clear buffer before using
@ -1586,7 +1586,7 @@ int *GetCodepoints(const char *text, int *count)
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
int GetCodepointsCount(const char *text)
{
@ -1608,7 +1608,7 @@ int GetCodepointsCount(const char *text)
}
#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
// Total number of bytes processed are returned as a parameter
// 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] 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
// [-] GetPixelColor(): Return Vector4 instead of Color, easier for ColorAlphaBlend()
// [-] GetPixelColor(): Get Vector4 instead of Color, easier for ColorAlphaBlend()
Color colSrc, colDst, blend;
bool blendRequired = true;
@ -3553,7 +3553,7 @@ void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2
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)
{
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)};
}
// Returns hexadecimal value for a Color
// Get hexadecimal value for a Color
int ColorToInt(Color color)
{
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 result;
@ -3581,7 +3581,7 @@ Vector4 ColorNormalize(Color color)
return result;
}
// Returns color from normalized values [0..1]
// Get color from normalized values [0..1]
Color ColorFromNormalized(Vector4 normalized)
{
Color result;
@ -3594,7 +3594,7 @@ Color ColorFromNormalized(Vector4 normalized)
return result;
}
// Returns HSV values for a Color
// Get HSV values for a Color
// NOTE: Hue is returned as degrees [0..360]
Vector3 ColorToHSV(Color color)
{
@ -3646,7 +3646,7 @@ Vector3 ColorToHSV(Color color)
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
// NOTE: Color->HSV->Color conversion will not yield exactly the same color due to rounding errors
// Hue is provided in degrees: [0..360]
@ -3682,7 +3682,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
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)
{
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)};
}
// 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 out = WHITE;
@ -3746,7 +3746,7 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint)
return out;
}
// Returns a Color struct from hexadecimal value
// Get a Color struct from hexadecimal value
Color GetColor(int hexValue)
{
Color color;

View File

@ -393,7 +393,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
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);
}
else