Merge branch 'master' into shader_matrix
This commit is contained in:
commit
5bd6c59f2a
48 changed files with 14912 additions and 1682 deletions
|
|
@ -46,7 +46,7 @@ Here it is a list with the ones I'm aware of:
|
||||||
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
|
| raylib-ruby | 2.6 | [Ruby](https://www.ruby-lang.org/en/) | https://github.com/a0/raylib-ruby |
|
||||||
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
|
| raylib-mruby | 2.5-dev | [mruby](https://github.com/mruby/mruby) | https://github.com/lihaochen910/raylib-mruby |
|
||||||
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
|
| raylib-py | 2.0 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py |
|
||||||
| raylib-python-cffi | 3.5 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
|
| raylib-python-cffi | 3.7 | [Python](https://www.python.org/) | https://github.com/electronstudio/raylib-python-cffi |
|
||||||
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
| raylib-py-ctbg | 2.6 | [Python](https://www.python.org/) | https://github.com/overdev/raylib-py-ctbg |
|
||||||
| jaylib | 3.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
|
| jaylib | 3.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/electronstudio/jaylib/ |
|
||||||
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
|
| raylib-java | 2.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | https://github.com/XoanaIO/raylib-java |
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
|
||||||
set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE)
|
set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE)
|
||||||
unset(WAS_SHARED)
|
unset(WAS_SHARED)
|
||||||
|
|
||||||
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw_objlib>)
|
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw>)
|
||||||
include_directories(BEFORE SYSTEM external/glfw/include)
|
include_directories(BEFORE SYSTEM external/glfw/include)
|
||||||
else()
|
else()
|
||||||
MESSAGE(STATUS "Using external GLFW")
|
MESSAGE(STATUS "Using external GLFW")
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ int main(void)
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
|
InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
|
||||||
|
|
||||||
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for line ending char '\0'
|
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for null terminator char '\0'
|
||||||
int letterCount = 0;
|
int letterCount = 0;
|
||||||
|
|
||||||
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
|
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
|
||||||
|
|
@ -56,6 +56,7 @@ int main(void)
|
||||||
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
|
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
|
||||||
{
|
{
|
||||||
name[letterCount] = (char)key;
|
name[letterCount] = (char)key;
|
||||||
|
name[letterCount+1] = '\0'; // Add null terminator at the end of the string.
|
||||||
letterCount++;
|
letterCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,13 @@ All data is separated into parts, usually as strings. The following types are us
|
||||||
|
|
||||||
Check `raylib_parser.c` for details about those structs.
|
Check `raylib_parser.c` for details about those structs.
|
||||||
|
|
||||||
|
## Command Line Arguments
|
||||||
|
|
||||||
|
The parser can take a few options...
|
||||||
|
|
||||||
|
- `--help` Displays help information about the parser
|
||||||
|
- `--json` Outputs the header information in JSON format
|
||||||
|
|
||||||
## Constraints
|
## Constraints
|
||||||
|
|
||||||
This parser is specifically designed to work with raylib.h, so, it has some constraints:
|
This parser is specifically designed to work with raylib.h, so, it has some constraints:
|
||||||
|
|
|
||||||
6668
parser/raylib_api.json
Normal file
6668
parser/raylib_api.json
Normal file
File diff suppressed because it is too large
Load diff
3568
parser/raylib_api.txt
Normal file
3568
parser/raylib_api.txt
Normal file
File diff suppressed because it is too large
Load diff
2509
parser/raylib_api.xml
Normal file
2509
parser/raylib_api.xml
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,35 +1,35 @@
|
||||||
/**********************************************************************************************
|
/**********************************************************************************************
|
||||||
|
|
||||||
raylib parser - raylib header parser
|
raylib API parser
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
- struct FunctionInfo
|
- struct FunctionInfo
|
||||||
- struct StructInfo
|
- struct StructInfo
|
||||||
- struct EnumInfo
|
- struct EnumInfo
|
||||||
|
|
||||||
CONSTRAINTS:
|
CONSTRAINTS:
|
||||||
|
|
||||||
This parser is specifically designed to work with raylib.h, so, it has some constraints:
|
This parser is specifically designed to work with raylib.h, so, it has some constraints:
|
||||||
|
|
||||||
- Functions are expected as a single line with the following structure:
|
- Functions are expected as a single line with the following structure:
|
||||||
|
|
||||||
<retType> <name>(<paramType[0]> <paramName[0]>, <paramType[1]> <paramName[1]>); <desc>
|
<retType> <name>(<paramType[0]> <paramName[0]>, <paramType[1]> <paramName[1]>); <desc>
|
||||||
|
|
||||||
Be careful with functions broken into several lines, it breaks the process!
|
Be careful with functions broken into several lines, it breaks the process!
|
||||||
|
|
||||||
- Structures are expected as several lines with the following form:
|
- Structures are expected as several lines with the following form:
|
||||||
|
|
||||||
<desc>
|
<desc>
|
||||||
typedef struct <name> {
|
typedef struct <name> {
|
||||||
<fieldType[0]> <fieldName[0]>; <fieldDesc[0]>
|
<fieldType[0]> <fieldName[0]>; <fieldDesc[0]>
|
||||||
<fieldType[1]> <fieldName[1]>; <fieldDesc[1]>
|
<fieldType[1]> <fieldName[1]>; <fieldDesc[1]>
|
||||||
<fieldType[2]> <fieldName[2]>; <fieldDesc[2]>
|
<fieldType[2]> <fieldName[2]>; <fieldDesc[2]>
|
||||||
} <name>;
|
} <name>;
|
||||||
|
|
||||||
- Enums are expected as several lines with the following form:
|
- Enums are expected as several lines with the following form:
|
||||||
|
|
||||||
<desc>
|
<desc>
|
||||||
typedef enum {
|
typedef enum {
|
||||||
<valueName[0]> = <valueInteger[0]>, <valueDesc[0]>
|
<valueName[0]> = <valueInteger[0]>, <valueDesc[0]>
|
||||||
|
|
@ -37,14 +37,16 @@
|
||||||
<valueName[2]>, <valueDesc[2]>
|
<valueName[2]>, <valueDesc[2]>
|
||||||
<valueName[3]> <valueDesc[3]>
|
<valueName[3]> <valueDesc[3]>
|
||||||
} <name>;
|
} <name>;
|
||||||
|
|
||||||
NOTE: Multiple options are supported:
|
NOTE: Multiple options are supported for enums:
|
||||||
- If value is not provided, (<valueInteger[i -1]> + 1) is assigned
|
- If value is not provided, (<valueInteger[i -1]> + 1) is assigned
|
||||||
- Value description can be provided or not
|
- Value description can be provided or not
|
||||||
|
|
||||||
This parser could work with other C header files if mentioned constraints are followed.
|
OTHER NOTES:
|
||||||
|
|
||||||
This parser does not require <string.h> library, all data is parsed directly from char buffers.
|
- This parser could work with other C header files if mentioned constraints are followed.
|
||||||
|
|
||||||
|
- This parser does not require <string.h> library, all data is parsed directly from char buffers.
|
||||||
|
|
||||||
LICENSE: zlib/libpng
|
LICENSE: zlib/libpng
|
||||||
|
|
||||||
|
|
@ -55,6 +57,8 @@
|
||||||
|
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol()
|
#include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol()
|
||||||
#include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose()
|
#include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose()
|
||||||
#include <stdbool.h> // Required for: bool
|
#include <stdbool.h> // Required for: bool
|
||||||
|
|
@ -77,6 +81,7 @@ typedef struct FunctionInfo {
|
||||||
int paramCount; // Number of function parameters
|
int paramCount; // Number of function parameters
|
||||||
char paramType[12][32]; // Parameters type (max: 12 parameters)
|
char paramType[12][32]; // Parameters type (max: 12 parameters)
|
||||||
char paramName[12][32]; // Parameters name (max: 12 parameters)
|
char paramName[12][32]; // Parameters name (max: 12 parameters)
|
||||||
|
char paramDesc[12][8]; // Parameters description (max: 12 parameters)
|
||||||
} FunctionInfo;
|
} FunctionInfo;
|
||||||
|
|
||||||
// Struct info data
|
// Struct info data
|
||||||
|
|
@ -99,45 +104,70 @@ typedef struct EnumInfo {
|
||||||
char valueDesc[128][64]; // Value description (max: 128 values)
|
char valueDesc[128][64]; // Value description (max: 128 values)
|
||||||
} EnumInfo;
|
} EnumInfo;
|
||||||
|
|
||||||
|
// Output format for parsed data
|
||||||
|
typedef enum { DEFAULT = 0, JSON, XML } OutputFormat;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
static int funcCount = 0;
|
||||||
|
static int structCount = 0;
|
||||||
|
static int enumCount = 0;
|
||||||
|
static FunctionInfo *funcs = NULL;
|
||||||
|
static StructInfo *structs = NULL;
|
||||||
|
static EnumInfo *enums = NULL;
|
||||||
|
|
||||||
|
// Command line variables
|
||||||
|
static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI)
|
||||||
|
static char outFileName[512] = { 0 }; // Output file name (required for file save/export)
|
||||||
|
static int outputFormat = DEFAULT;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
char *LoadFileText(const char *fileName, int *length);
|
static void ShowCommandLineInfo(void); // Show command line usage info
|
||||||
char **GetTextLines(const char *buffer, int length, int *linesCount);
|
static void ProcessCommandLine(int argc, char *argv[]); // Process command line input
|
||||||
void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name);
|
|
||||||
bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
|
|
||||||
void MemoryCopy(void *dest, const void *src, unsigned int count);
|
|
||||||
|
|
||||||
// Main entry point
|
static char *LoadFileText(const char *fileName, int *length);
|
||||||
int main()
|
static char **GetTextLines(const char *buffer, int length, int *linesCount);
|
||||||
|
static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name);
|
||||||
|
static unsigned int TextLength(const char *text); // Get text length in bytes, check for \0 character
|
||||||
|
static bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
|
||||||
|
static void MemoryCopy(void *dest, const void *src, unsigned int count);
|
||||||
|
static char* CharReplace(char* text, char search, char replace);
|
||||||
|
|
||||||
|
static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
if (argc > 1) ProcessCommandLine(argc, argv);
|
||||||
|
|
||||||
|
if (inFileName[0] == '\0') MemoryCopy(inFileName, "../src/raylib.h\0", 16);
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
char *buffer = LoadFileText("../src/raylib.h", &length);
|
char *buffer = LoadFileText(inFileName, &length);
|
||||||
|
|
||||||
// Preprocess buffer to get separate lines
|
// Preprocess buffer to get separate lines
|
||||||
// NOTE: GetTextLines() also removes leading spaces/tabs
|
// NOTE: GetTextLines() also removes leading spaces/tabs
|
||||||
int linesCount = 0;
|
int linesCount = 0;
|
||||||
char **lines = GetTextLines(buffer, length, &linesCount);
|
char **lines = GetTextLines(buffer, length, &linesCount);
|
||||||
|
|
||||||
// Print buffer lines
|
|
||||||
//for (int i = 0; i < linesCount; i++) printf("_%s_\n", lines[i]);
|
|
||||||
|
|
||||||
// Function lines pointers, selected from buffer "lines"
|
// Function lines pointers, selected from buffer "lines"
|
||||||
int funcCount = 0;
|
|
||||||
char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *));
|
char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *));
|
||||||
|
|
||||||
// Structs data (multiple lines), selected from "buffer"
|
// Structs data (multiple lines), selected from "buffer"
|
||||||
int structCount = 0;
|
|
||||||
char **structLines = (char **)malloc(MAX_STRUCTS_TO_PARSE*sizeof(char *));
|
char **structLines = (char **)malloc(MAX_STRUCTS_TO_PARSE*sizeof(char *));
|
||||||
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char));
|
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char));
|
||||||
|
|
||||||
// Enums lines pointers, selected from buffer "lines"
|
// Enums lines pointers, selected from buffer "lines"
|
||||||
int enumCount = 0;
|
|
||||||
int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int));
|
int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int));
|
||||||
|
|
||||||
// Prepare required lines for parsing
|
// Prepare required lines for parsing
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Read function lines
|
// Read function lines
|
||||||
for (int i = 0; i < linesCount; i++)
|
for (int i = 0; i < linesCount; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -149,9 +179,6 @@ int main()
|
||||||
funcCount++;
|
funcCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print function lines
|
|
||||||
//for (int i = 0; i < funcCount; i++) printf("%s\n", funcLines[i]);
|
|
||||||
|
|
||||||
// Read structs data (multiple lines, read directly from buffer)
|
// Read structs data (multiple lines, read directly from buffer)
|
||||||
// TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition
|
// TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition
|
||||||
|
|
@ -163,9 +190,9 @@ int main()
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
bool validStruct = false;
|
bool validStruct = false;
|
||||||
|
|
||||||
// WARNING: Typedefs between types: typedef Vector4 Quaternion;
|
// WARNING: Typedefs between types: typedef Vector4 Quaternion;
|
||||||
|
|
||||||
for (int c = 0; c < 128; c++)
|
for (int c = 0; c < 128; c++)
|
||||||
{
|
{
|
||||||
if (buffer[i + c] == '{')
|
if (buffer[i + c] == '{')
|
||||||
|
|
@ -175,13 +202,13 @@ int main()
|
||||||
}
|
}
|
||||||
else if (buffer[i + c] == ';')
|
else if (buffer[i + c] == ';')
|
||||||
{
|
{
|
||||||
// Not valid struct:
|
// Not valid struct:
|
||||||
// i.e typedef struct rAudioBuffer rAudioBuffer; -> Typedef and forward declaration
|
// i.e typedef struct rAudioBuffer rAudioBuffer; -> Typedef and forward declaration
|
||||||
i += c;
|
i += c;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validStruct)
|
if (validStruct)
|
||||||
{
|
{
|
||||||
while (buffer[i + j] != '}')
|
while (buffer[i + j] != '}')
|
||||||
|
|
@ -207,7 +234,7 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read enum lines
|
// Read enum lines
|
||||||
for (int i = 0; i < linesCount; i++)
|
for (int i = 0; i < linesCount; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -220,17 +247,17 @@ int main()
|
||||||
enumCount++;
|
enumCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point we have all raylib structs, enums, functions lines data to start parsing
|
// At this point we have all raylib structs, enums, functions lines data to start parsing
|
||||||
|
|
||||||
free(buffer); // Unload text buffer
|
free(buffer); // Unload text buffer
|
||||||
|
|
||||||
// Parsing raylib data
|
// Parsing raylib data
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Structs info data
|
// Structs info data
|
||||||
StructInfo *structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo));
|
structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo));
|
||||||
|
|
||||||
for (int i = 0; i < structCount; i++)
|
for (int i = 0; i < structCount; i++)
|
||||||
{
|
{
|
||||||
int structLineOffset = 0;
|
int structLineOffset = 0;
|
||||||
|
|
@ -238,52 +265,52 @@ int main()
|
||||||
// Get struct name: typedef struct name {
|
// Get struct name: typedef struct name {
|
||||||
for (int c = 15; c < 64 + 15; c++)
|
for (int c = 15; c < 64 + 15; c++)
|
||||||
{
|
{
|
||||||
if (structLines[i][c] == '{')
|
if (structLines[i][c] == '{')
|
||||||
{
|
{
|
||||||
structLineOffset = c + 2;
|
structLineOffset = c + 2;
|
||||||
|
|
||||||
MemoryCopy(structs[i].name, &structLines[i][15], c - 15 - 1);
|
MemoryCopy(structs[i].name, &structLines[i][15], c - 15 - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get struct fields and count them -> fields finish with ;
|
// Get struct fields and count them -> fields finish with ;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (structLines[i][structLineOffset + j] != '}')
|
while (structLines[i][structLineOffset + j] != '}')
|
||||||
{
|
{
|
||||||
// WARNING: Some structs have empty spaces and comments -> OK, processed
|
// WARNING: Some structs have empty spaces and comments -> OK, processed
|
||||||
|
|
||||||
int fieldStart = 0;
|
int fieldStart = 0;
|
||||||
if ((structLines[i][structLineOffset + j] != ' ') && (structLines[i][structLineOffset + j] != '\n')) fieldStart = structLineOffset + j;
|
if ((structLines[i][structLineOffset + j] != ' ') && (structLines[i][structLineOffset + j] != '\n')) fieldStart = structLineOffset + j;
|
||||||
|
|
||||||
if (fieldStart != 0)
|
if (fieldStart != 0)
|
||||||
{
|
{
|
||||||
// Scan one field line
|
// Scan one field line
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int fieldEndPos = 0;
|
int fieldEndPos = 0;
|
||||||
char fieldLine[256] = { 0 };
|
char fieldLine[256] = { 0 };
|
||||||
|
|
||||||
while (structLines[i][structLineOffset + j] != '\n')
|
while (structLines[i][structLineOffset + j] != '\n')
|
||||||
{
|
{
|
||||||
if (structLines[i][structLineOffset + j] == ';') fieldEndPos = c;
|
if (structLines[i][structLineOffset + j] == ';') fieldEndPos = c;
|
||||||
fieldLine[c] = structLines[i][structLineOffset + j];
|
fieldLine[c] = structLines[i][structLineOffset + j];
|
||||||
c++; j++;
|
c++; j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldLine[0] != '/') // Field line is not a comment
|
if (fieldLine[0] != '/') // Field line is not a comment
|
||||||
{
|
{
|
||||||
//printf("Struct field: %s_\n", fieldLine); // OK!
|
//printf("Struct field: %s_\n", fieldLine); // OK!
|
||||||
|
|
||||||
// Get struct field type and name
|
// Get struct field type and name
|
||||||
GetDataTypeAndName(fieldLine, fieldEndPos, structs[i].fieldType[structs[i].fieldCount], structs[i].fieldName[structs[i].fieldCount]);
|
GetDataTypeAndName(fieldLine, fieldEndPos, structs[i].fieldType[structs[i].fieldCount], structs[i].fieldName[structs[i].fieldCount]);
|
||||||
|
|
||||||
// Get the field description
|
// Get the field description
|
||||||
// We start skipping spaces in front of description comment
|
// We start skipping spaces in front of description comment
|
||||||
int descStart = fieldEndPos;
|
int descStart = fieldEndPos;
|
||||||
while ((fieldLine[descStart] != '/') && (fieldLine[descStart] != '\0')) descStart++;
|
while ((fieldLine[descStart] != '/') && (fieldLine[descStart] != '\0')) descStart++;
|
||||||
|
|
||||||
int k = 0;
|
int k = 0;
|
||||||
while ((fieldLine[descStart + k] != '\0') && (fieldLine[descStart + k] != '\n'))
|
while ((fieldLine[descStart + k] != '\0') && (fieldLine[descStart + k] != '\n'))
|
||||||
{
|
{
|
||||||
structs[i].fieldDesc[structs[i].fieldCount][k] = fieldLine[descStart + k];
|
structs[i].fieldDesc[structs[i].fieldCount][k] = fieldLine[descStart + k];
|
||||||
k++;
|
k++;
|
||||||
|
|
@ -297,17 +324,17 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) free(structLines[i]);
|
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) free(structLines[i]);
|
||||||
free(structLines);
|
free(structLines);
|
||||||
|
|
||||||
// Enum info data
|
// Enum info data
|
||||||
EnumInfo *enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo));
|
enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo));
|
||||||
|
|
||||||
for (int i = 0; i < enumCount; i++)
|
for (int i = 0; i < enumCount; i++)
|
||||||
{
|
{
|
||||||
// TODO: Get enum description from lines[enumLines[i] - 1]
|
// TODO: Get enum description from lines[enumLines[i] - 1]
|
||||||
|
|
||||||
for (int j = 1; j < 256; j++) // Maximum number of lines following enum first line
|
for (int j = 1; j < 256; j++) // Maximum number of lines following enum first line
|
||||||
{
|
{
|
||||||
char *linePtr = lines[enumLines[i] + j];
|
char *linePtr = lines[enumLines[i] + j];
|
||||||
|
|
@ -320,20 +347,20 @@ int main()
|
||||||
//ENUM_VALUE_NAME = 99
|
//ENUM_VALUE_NAME = 99
|
||||||
//ENUM_VALUE_NAME = 99,
|
//ENUM_VALUE_NAME = 99,
|
||||||
//ENUM_VALUE_NAME = 0x00000040, // Value description
|
//ENUM_VALUE_NAME = 0x00000040, // Value description
|
||||||
|
|
||||||
// We start reading the value name
|
// We start reading the value name
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while ((linePtr[c] != ',') &&
|
while ((linePtr[c] != ',') &&
|
||||||
(linePtr[c] != ' ') &&
|
(linePtr[c] != ' ') &&
|
||||||
(linePtr[c] != '=') &&
|
(linePtr[c] != '=') &&
|
||||||
(linePtr[c] != '\0')) { enums[i].valueName[enums[i].valueCount][c] = linePtr[c]; c++; }
|
(linePtr[c] != '\0')) { enums[i].valueName[enums[i].valueCount][c] = linePtr[c]; c++; }
|
||||||
|
|
||||||
// After the name we can have:
|
// After the name we can have:
|
||||||
// '=' -> value is provided
|
// '=' -> value is provided
|
||||||
// ',' -> value is equal to previous + 1, there could be a description if not '\0'
|
// ',' -> value is equal to previous + 1, there could be a description if not '\0'
|
||||||
// ' ' -> value is equal to previous + 1, there could be a description if not '\0'
|
// ' ' -> value is equal to previous + 1, there could be a description if not '\0'
|
||||||
// '\0' -> value is equal to previous + 1
|
// '\0' -> value is equal to previous + 1
|
||||||
|
|
||||||
// Let's start checking if the line is not finished
|
// Let's start checking if the line is not finished
|
||||||
if ((linePtr[c] != ',') && (linePtr[c] != '\0'))
|
if ((linePtr[c] != ',') && (linePtr[c] != '\0'))
|
||||||
{
|
{
|
||||||
|
|
@ -341,7 +368,7 @@ int main()
|
||||||
// '=' -> value is provided
|
// '=' -> value is provided
|
||||||
// ' ' -> value is equal to previous + 1, there could be a description if not '\0'
|
// ' ' -> value is equal to previous + 1, there could be a description if not '\0'
|
||||||
bool foundValue = false;
|
bool foundValue = false;
|
||||||
while (linePtr[c] != '\0')
|
while (linePtr[c] != '\0')
|
||||||
{
|
{
|
||||||
if (linePtr[c] == '=') { foundValue = true; break; }
|
if (linePtr[c] == '=') { foundValue = true; break; }
|
||||||
c++;
|
c++;
|
||||||
|
|
@ -351,64 +378,64 @@ int main()
|
||||||
{
|
{
|
||||||
if (linePtr[c + 1] == ' ') c += 2;
|
if (linePtr[c + 1] == ' ') c += 2;
|
||||||
else c++;
|
else c++;
|
||||||
|
|
||||||
// Parse integer value
|
// Parse integer value
|
||||||
int n = 0;
|
int n = 0;
|
||||||
char integer[16] = { 0 };
|
char integer[16] = { 0 };
|
||||||
|
|
||||||
while ((linePtr[c] != ',') && (linePtr[c] != ' ') && (linePtr[c] != '\0'))
|
while ((linePtr[c] != ',') && (linePtr[c] != ' ') && (linePtr[c] != '\0'))
|
||||||
{
|
{
|
||||||
integer[n] = linePtr[c];
|
integer[n] = linePtr[c];
|
||||||
c++; n++;
|
c++; n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (integer[1] == 'x') enums[i].valueInteger[enums[i].valueCount] = (int)strtol(integer, NULL, 16);
|
if (integer[1] == 'x') enums[i].valueInteger[enums[i].valueCount] = (int)strtol(integer, NULL, 16);
|
||||||
else enums[i].valueInteger[enums[i].valueCount] = atoi(integer);
|
else enums[i].valueInteger[enums[i].valueCount] = atoi(integer);
|
||||||
}
|
}
|
||||||
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
||||||
|
|
||||||
// TODO: Parse value description if any
|
// TODO: Parse value description if any
|
||||||
}
|
}
|
||||||
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
||||||
|
|
||||||
enums[i].valueCount++;
|
enums[i].valueCount++;
|
||||||
}
|
}
|
||||||
else if (linePtr[0] == '}')
|
else if (linePtr[0] == '}')
|
||||||
{
|
{
|
||||||
// Get enum name from typedef
|
// Get enum name from typedef
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while (linePtr[2 + c] != ';') { enums[i].name[c] = linePtr[2 + c]; c++; }
|
while (linePtr[2 + c] != ';') { enums[i].name[c] = linePtr[2 + c]; c++; }
|
||||||
|
|
||||||
break; // Enum ended, break for() loop
|
break; // Enum ended, break for() loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions info data
|
// Functions info data
|
||||||
FunctionInfo *funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo));
|
funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo));
|
||||||
|
|
||||||
for (int i = 0; i < funcCount; i++)
|
for (int i = 0; i < funcCount; i++)
|
||||||
{
|
{
|
||||||
int funcParamsStart = 0;
|
int funcParamsStart = 0;
|
||||||
int funcEnd = 0;
|
int funcEnd = 0;
|
||||||
|
|
||||||
// Get return type and function name from func line
|
// Get return type and function name from func line
|
||||||
for (int c = 0; (c < MAX_LINE_LENGTH) && (funcLines[i][c] != '\n'); c++)
|
for (int c = 0; (c < MAX_LINE_LENGTH) && (funcLines[i][c] != '\n'); c++)
|
||||||
{
|
{
|
||||||
if (funcLines[i][c] == '(') // Starts function parameters
|
if (funcLines[i][c] == '(') // Starts function parameters
|
||||||
{
|
{
|
||||||
funcParamsStart = c + 1;
|
funcParamsStart = c + 1;
|
||||||
|
|
||||||
// At this point we have function return type and function name
|
// At this point we have function return type and function name
|
||||||
char funcRetTypeName[128] = { 0 };
|
char funcRetTypeName[128] = { 0 };
|
||||||
int funcRetTypeNameLen = c - 6; // Substract "RLAPI "
|
int funcRetTypeNameLen = c - 6; // Substract "RLAPI "
|
||||||
MemoryCopy(funcRetTypeName, &funcLines[i][6], funcRetTypeNameLen);
|
MemoryCopy(funcRetTypeName, &funcLines[i][6], funcRetTypeNameLen);
|
||||||
|
|
||||||
GetDataTypeAndName(funcRetTypeName, funcRetTypeNameLen, funcs[i].retType, funcs[i].name);
|
GetDataTypeAndName(funcRetTypeName, funcRetTypeNameLen, funcs[i].retType, funcs[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get parameters from func line
|
// Get parameters from func line
|
||||||
for (int c = funcParamsStart; c < MAX_LINE_LENGTH; c++)
|
for (int c = funcParamsStart; c < MAX_LINE_LENGTH; c++)
|
||||||
{
|
{
|
||||||
|
|
@ -418,9 +445,9 @@ int main()
|
||||||
char funcParamTypeName[128] = { 0 };
|
char funcParamTypeName[128] = { 0 };
|
||||||
int funcParamTypeNameLen = c - funcParamsStart;
|
int funcParamTypeNameLen = c - funcParamsStart;
|
||||||
MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen);
|
MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen);
|
||||||
|
|
||||||
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
||||||
|
|
||||||
funcParamsStart = c + 1;
|
funcParamsStart = c + 1;
|
||||||
if (funcLines[i][c + 1] == ' ') funcParamsStart += 1;
|
if (funcLines[i][c + 1] == ' ') funcParamsStart += 1;
|
||||||
funcs[i].paramCount++; // Move to next parameter
|
funcs[i].paramCount++; // Move to next parameter
|
||||||
|
|
@ -428,72 +455,54 @@ int main()
|
||||||
else if (funcLines[i][c] == ')')
|
else if (funcLines[i][c] == ')')
|
||||||
{
|
{
|
||||||
funcEnd = c + 2;
|
funcEnd = c + 2;
|
||||||
|
|
||||||
// Check if previous word is void
|
// Check if previous word is void
|
||||||
if ((funcLines[i][c - 4] == 'v') && (funcLines[i][c - 3] == 'o') && (funcLines[i][c - 2] == 'i') && (funcLines[i][c - 1] == 'd')) break;
|
if ((funcLines[i][c - 4] == 'v') && (funcLines[i][c - 3] == 'o') && (funcLines[i][c - 2] == 'i') && (funcLines[i][c - 1] == 'd')) break;
|
||||||
|
|
||||||
// Get parameter type + name, extract info
|
// Get parameter type + name, extract info
|
||||||
char funcParamTypeName[128] = { 0 };
|
char funcParamTypeName[128] = { 0 };
|
||||||
int funcParamTypeNameLen = c - funcParamsStart;
|
int funcParamTypeNameLen = c - funcParamsStart;
|
||||||
MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen);
|
MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen);
|
||||||
|
|
||||||
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
||||||
|
|
||||||
funcs[i].paramCount++; // Move to next parameter
|
funcs[i].paramCount++; // Move to next parameter
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get function description
|
// Get function description
|
||||||
for (int c = funcEnd; c < MAX_LINE_LENGTH; c++)
|
for (int c = funcEnd; c < MAX_LINE_LENGTH; c++)
|
||||||
{
|
{
|
||||||
if (funcLines[i][c] == '/')
|
if (funcLines[i][c] == '/')
|
||||||
{
|
{
|
||||||
MemoryCopy(funcs[i].desc, &funcLines[i][c], 127); // WARNING: Size could be too long for funcLines[i][c]?
|
MemoryCopy(funcs[i].desc, &funcLines[i][c], 127); // WARNING: Size could be too long for funcLines[i][c]?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < linesCount; i++) free(lines[i]);
|
//for (int i = 0; i < linesCount; i++) free(lines[i]);
|
||||||
free(lines);
|
free(lines);
|
||||||
free(funcLines);
|
free(funcLines);
|
||||||
|
|
||||||
// At this point, all raylib data has been parsed!
|
// At this point, all raylib data has been parsed!
|
||||||
//-----------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------
|
||||||
// structs[] -> We have all the structs decomposed into pieces for further analysis
|
// structs[] -> We have all the structs decomposed into pieces for further analysis
|
||||||
// enums[] -> We have all the enums decomposed into pieces for further analysis
|
// enums[] -> We have all the enums decomposed into pieces for further analysis
|
||||||
// funcs[] -> We have all the functions decomposed into pieces for further analysis
|
// funcs[] -> We have all the functions decomposed into pieces for further analysis
|
||||||
|
|
||||||
// Print structs info
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print enums info
|
// Process input file to output
|
||||||
printf("\nEnums found: %i\n\n", enumCount);
|
if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15);
|
||||||
for (int i = 0; i < enumCount; i++)
|
|
||||||
{
|
printf("\nInput file: %s", inFileName);
|
||||||
printf("Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount);
|
printf("\nOutput file: %s", outFileName);
|
||||||
//printf("Description: %s\n", enums[i].desc);
|
if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
|
||||||
for (int e = 0; e < enums[i].valueCount; e++) printf(" Value %s: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]);
|
else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
|
||||||
}
|
else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
|
||||||
|
|
||||||
// Print function info
|
ExportParsedData(outFileName, outputFormat);
|
||||||
printf("\nFunctions found: %i\n\n", funcCount);
|
|
||||||
for (int i = 0; i < funcCount; i++)
|
|
||||||
{
|
|
||||||
printf("Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount);
|
|
||||||
printf(" Description: %s\n", funcs[i].desc);
|
|
||||||
printf(" Return type: %s\n", funcs[i].retType);
|
|
||||||
for (int p = 0; p < funcs[i].paramCount; p++) printf(" Param %i: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]);
|
|
||||||
if (funcs[i].paramCount == 0) printf(" No input parameters\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(funcs);
|
free(funcs);
|
||||||
free(structs);
|
free(structs);
|
||||||
free(enums);
|
free(enums);
|
||||||
|
|
@ -502,10 +511,84 @@ int main()
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition
|
// Module Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
// Show command line usage info
|
||||||
|
static void ShowCommandLineInfo(void)
|
||||||
|
{
|
||||||
|
printf("\n//////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("// raylib API parser //\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("// more info and bugs-report: github.com/raysan5/raylib/parser //\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("// Copyright (c) 2021 Ramon Santamaria (@raysan5) //\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("//////////////////////////////////////////////////////////////////////////////////\n\n");
|
||||||
|
|
||||||
|
printf("USAGE:\n\n");
|
||||||
|
printf(" > raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]\n");
|
||||||
|
|
||||||
|
printf("\nOPTIONS:\n\n");
|
||||||
|
printf(" -h, --help : Show tool version and command line usage help\n\n");
|
||||||
|
printf(" -i, --input <filename.h> : Define input header file to parse.\n");
|
||||||
|
printf(" NOTE: If not specified, defaults to: raylib.h\n\n");
|
||||||
|
printf(" -o, --output <filename.ext> : Define output file and format.\n");
|
||||||
|
printf(" Supported extensions: .txt, .json, .xml, .h\n");
|
||||||
|
printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n");
|
||||||
|
printf(" -f, --format <type> : Define output format for parser data.\n");
|
||||||
|
printf(" Supported types: DEFAULT, JSON, XML\n\n");
|
||||||
|
|
||||||
|
printf("\nEXAMPLES:\n\n");
|
||||||
|
printf(" > raylib_parser --input raylib.h --output api.json\n");
|
||||||
|
printf(" Process <raylib.h> to generate <api.json>\n\n");
|
||||||
|
printf(" > raylib_parser --output raylib_data.info --format XML\n");
|
||||||
|
printf(" Process <raylib.h> to generate <raylib_data.info> as XML text data\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process command line arguments
|
||||||
|
static void ProcessCommandLine(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (IsTextEqual(argv[i], "-h", 2) || IsTextEqual(argv[i], "--help", 6))
|
||||||
|
{
|
||||||
|
// Show info
|
||||||
|
ShowCommandLineInfo();
|
||||||
|
}
|
||||||
|
else if (IsTextEqual(argv[i], "-i", 2) || IsTextEqual(argv[i], "--input", 7))
|
||||||
|
{
|
||||||
|
// Check for valid argument and valid file extension
|
||||||
|
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
|
||||||
|
{
|
||||||
|
MemoryCopy(inFileName, argv[i + 1], TextLength(argv[i + 1])); // Read input filename
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else printf("WARNING: No input file provided\n");
|
||||||
|
}
|
||||||
|
else if (IsTextEqual(argv[i], "-o", 2) || IsTextEqual(argv[i], "--output", 8))
|
||||||
|
{
|
||||||
|
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
|
||||||
|
{
|
||||||
|
MemoryCopy(outFileName, argv[i + 1], TextLength(argv[i + 1])); // Read output filename
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else printf("WARNING: No output file provided\n");
|
||||||
|
}
|
||||||
|
else if (IsTextEqual(argv[i], "-f", 2) || IsTextEqual(argv[i], "--format", 8))
|
||||||
|
{
|
||||||
|
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
|
||||||
|
{
|
||||||
|
if (IsTextEqual(argv[i + 1], "DEFAULT\0", 8)) outputFormat = DEFAULT;
|
||||||
|
else if (IsTextEqual(argv[i + 1], "JSON\0", 5)) outputFormat = JSON;
|
||||||
|
else if (IsTextEqual(argv[i + 1], "XML\0", 4)) outputFormat = XML;
|
||||||
|
}
|
||||||
|
else printf("WARNING: No format parameters provided\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load text data from file, returns a '\0' terminated string
|
// Load text data from file, returns a '\0' terminated string
|
||||||
// NOTE: text chars array should be freed manually
|
// NOTE: text chars array should be freed manually
|
||||||
char *LoadFileText(const char *fileName, int *length)
|
static char *LoadFileText(const char *fileName, int *length)
|
||||||
{
|
{
|
||||||
char *text = NULL;
|
char *text = NULL;
|
||||||
|
|
||||||
|
|
@ -524,14 +607,17 @@ char *LoadFileText(const char *fileName, int *length)
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
*length = size;
|
|
||||||
|
|
||||||
text = (char *)calloc((size + 1), sizeof(char));
|
text = (char *)calloc((size + 1), sizeof(char));
|
||||||
unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
|
unsigned int count = (unsigned int)fread(text, sizeof(char), size, file);
|
||||||
|
|
||||||
// WARNING: \r\n is converted to \n on reading, so,
|
// WARNING: \r\n is converted to \n on reading, so,
|
||||||
// read bytes count gets reduced by the number of lines
|
// read bytes count gets reduced by the number of lines
|
||||||
if (count < (unsigned int)size) text = realloc(text, count + 1);
|
if (count < (unsigned int)size)
|
||||||
|
{
|
||||||
|
text = realloc(text, count + 1);
|
||||||
|
*length = count;
|
||||||
|
}
|
||||||
|
else *length = size;
|
||||||
|
|
||||||
// Zero-terminate the string
|
// Zero-terminate the string
|
||||||
text[count] = '\0';
|
text[count] = '\0';
|
||||||
|
|
@ -545,51 +631,49 @@ char *LoadFileText(const char *fileName, int *length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all lines from a text buffer (expecting lines ending with '\n')
|
// Get all lines from a text buffer (expecting lines ending with '\n')
|
||||||
char **GetTextLines(const char *buffer, int length, int *linesCount)
|
static char **GetTextLines(const char *buffer, int length, int *linesCount)
|
||||||
{
|
{
|
||||||
//#define MAX_LINE_LENGTH 512
|
|
||||||
|
|
||||||
// Get the number of lines in the text
|
// Get the number of lines in the text
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < length; i++) if (buffer[i] == '\n') count++;
|
for (int i = 0; i < length; i++) if (buffer[i] == '\n') count++;
|
||||||
|
|
||||||
//printf("Number of text lines in buffer: %i\n", count);
|
printf("Number of text lines in buffer: %i\n", count);
|
||||||
|
|
||||||
// Allocate as many pointers as lines
|
// Allocate as many pointers as lines
|
||||||
char **lines = (char **)malloc(count*sizeof(char **));
|
char **lines = (char **)malloc(count*sizeof(char **));
|
||||||
|
|
||||||
char *bufferPtr = (char *)buffer;
|
char *bufferPtr = (char *)buffer;
|
||||||
|
|
||||||
for (int i = 0; (i < count) || (bufferPtr[0] != '\0'); i++)
|
for (int i = 0; (i < count) || (bufferPtr[0] != '\0'); i++)
|
||||||
{
|
{
|
||||||
lines[i] = (char *)calloc(MAX_LINE_LENGTH, sizeof(char));
|
lines[i] = (char *)calloc(MAX_LINE_LENGTH, sizeof(char));
|
||||||
|
|
||||||
// Remove line leading spaces
|
// Remove line leading spaces
|
||||||
// Find last index of space/tab character
|
// Find last index of space/tab character
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while ((bufferPtr[index] == ' ') || (bufferPtr[index] == '\t')) index++;
|
while ((bufferPtr[index] == ' ') || (bufferPtr[index] == '\t')) index++;
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (bufferPtr[index + j] != '\n')
|
while (bufferPtr[index + j] != '\n')
|
||||||
{
|
{
|
||||||
lines[i][j] = bufferPtr[index + j];
|
lines[i][j] = bufferPtr[index + j];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferPtr += (index + j + 1);
|
bufferPtr += (index + j + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
*linesCount = count;
|
*linesCount = count;
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get data type and name from a string containing both
|
// Get data type and name from a string containing both
|
||||||
// NOTE: Useful to parse function parameters and struct fields
|
// NOTE: Useful to parse function parameters and struct fields
|
||||||
void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name)
|
static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name)
|
||||||
{
|
{
|
||||||
for (int k = typeNameLen; k > 0; k--)
|
for (int k = typeNameLen; k > 0; k--)
|
||||||
{
|
{
|
||||||
if (typeName[k] == ' ')
|
if (typeName[k] == ' ' && typeName[k - 1] != ',')
|
||||||
{
|
{
|
||||||
// Function name starts at this point (and ret type finishes at this point)
|
// Function name starts at this point (and ret type finishes at this point)
|
||||||
MemoryCopy(type, typeName, k);
|
MemoryCopy(type, typeName, k);
|
||||||
|
|
@ -605,8 +689,18 @@ void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get text length in bytes, check for \0 character
|
||||||
|
static unsigned int TextLength(const char *text)
|
||||||
|
{
|
||||||
|
unsigned int length = 0;
|
||||||
|
|
||||||
|
if (text != NULL) while (*text++) length++;
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
// Custom memcpy() to avoid <string.h>
|
// Custom memcpy() to avoid <string.h>
|
||||||
void MemoryCopy(void *dest, const void *src, unsigned int count)
|
static void MemoryCopy(void *dest, const void *src, unsigned int count)
|
||||||
{
|
{
|
||||||
char *srcPtr = (char *)src;
|
char *srcPtr = (char *)src;
|
||||||
char *destPtr = (char *)dest;
|
char *destPtr = (char *)dest;
|
||||||
|
|
@ -615,13 +709,13 @@ void MemoryCopy(void *dest, const void *src, unsigned int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare two text strings, requires number of characters to compare
|
// Compare two text strings, requires number of characters to compare
|
||||||
bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
|
static bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (text1[i] != text2[i])
|
if (text1[i] != text2[i])
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
|
|
@ -631,11 +725,20 @@ bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search and replace a character within a string.
|
||||||
|
static char* CharReplace(char* text, char search, char replace)
|
||||||
|
{
|
||||||
|
for (int i = 0; text[i] != '\0'; i++)
|
||||||
|
if (text[i] == search)
|
||||||
|
text[i] = replace;
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Replace text string
|
// Replace text string
|
||||||
// REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations!
|
// REQUIRES: strlen(), strstr(), strncpy(), strcpy() -> TODO: Replace by custom implementations!
|
||||||
// WARNING: Returned buffer must be freed by the user (if return != NULL)
|
// WARNING: Returned buffer must be freed by the user (if return != NULL)
|
||||||
char *TextReplace(char *text, const char *replace, const char *by)
|
static char *TextReplace(char *text, const char *replace, const char *by)
|
||||||
{
|
{
|
||||||
// Sanity checks and initialization
|
// Sanity checks and initialization
|
||||||
if (!text || !replace || !by) return NULL;
|
if (!text || !replace || !by) return NULL;
|
||||||
|
|
@ -681,4 +784,206 @@ char *TextReplace(char *text, const char *replace, const char *by)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Export parsed data in desired format
|
||||||
|
static void ExportParsedData(const char *fileName, int format)
|
||||||
|
{
|
||||||
|
FILE *outFile = fopen(fileName, "wt");
|
||||||
|
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case DEFAULT:
|
||||||
|
{
|
||||||
|
// Print structs info
|
||||||
|
fprintf(outFile, "\nStructures found: %i\n\n", structCount);
|
||||||
|
for (int i = 0; i < structCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, "Struct %02i: %s (%i fields)\n", i + 1, structs[i].name, structs[i].fieldCount);
|
||||||
|
fprintf(outFile, " Name: %s\n", structs[i].name);
|
||||||
|
fprintf(outFile, " Description: %s\n", structs[i].desc + 3);
|
||||||
|
for (int f = 0; f < structs[i].fieldCount; f++) fprintf(outFile, " Field[%i]: %s %s %s\n", f + 1, structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print enums info
|
||||||
|
fprintf(outFile, "\nEnums found: %i\n\n", enumCount);
|
||||||
|
for (int i = 0; i < enumCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, "Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount);
|
||||||
|
fprintf(outFile, " Name: %s\n", enums[i].name);
|
||||||
|
fprintf(outFile, " Description: %s\n", enums[i].desc + 3);
|
||||||
|
for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print functions info
|
||||||
|
fprintf(outFile, "\nFunctions found: %i\n\n", funcCount);
|
||||||
|
for (int i = 0; i < funcCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount);
|
||||||
|
fprintf(outFile, " Name: %s\n", funcs[i].name);
|
||||||
|
fprintf(outFile, " Return type: %s\n", funcs[i].retType);
|
||||||
|
fprintf(outFile, " Description: %s\n", funcs[i].desc + 3);
|
||||||
|
for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]);
|
||||||
|
if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case JSON:
|
||||||
|
{
|
||||||
|
fprintf(outFile, "{\n");
|
||||||
|
|
||||||
|
// Print structs info
|
||||||
|
fprintf(outFile, " \"structs\": [\n");
|
||||||
|
for (int i = 0; i < structCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].name);
|
||||||
|
fprintf(outFile, " \"description\": \"%s\",\n", structs[i].desc);
|
||||||
|
fprintf(outFile, " \"fields\": [\n");
|
||||||
|
for (int f = 0; f < structs[i].fieldCount; f++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].fieldName[f]),
|
||||||
|
fprintf(outFile, " \"type\": \"%s\",\n", structs[i].fieldType[f]),
|
||||||
|
fprintf(outFile, " \"description\": \"%s\"\n", structs[i].fieldDesc[f] + 3),
|
||||||
|
fprintf(outFile, " }");
|
||||||
|
if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " ]\n");
|
||||||
|
fprintf(outFile, " }");
|
||||||
|
if (i < structCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " ],\n");
|
||||||
|
|
||||||
|
// Print enums info
|
||||||
|
fprintf(outFile, " \"enums\": [\n");
|
||||||
|
for (int i = 0; i < enumCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].name);
|
||||||
|
fprintf(outFile, " \"description\": \"%s\",\n", enums[i].desc + 3);
|
||||||
|
fprintf(outFile, " \"values\": [\n");
|
||||||
|
for (int e = 0; e < enums[i].valueCount; e++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].valueName[e]),
|
||||||
|
fprintf(outFile, " \"value\": %i,\n", enums[i].valueInteger[e]),
|
||||||
|
fprintf(outFile, " \"description\": \"%s\"\n", enums[i].valueDesc[e] + 3),
|
||||||
|
fprintf(outFile, " }");
|
||||||
|
if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " ]\n");
|
||||||
|
fprintf(outFile, " }");
|
||||||
|
if (i < enumCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " ],\n");
|
||||||
|
|
||||||
|
// Print functions info
|
||||||
|
fprintf(outFile, " \"functions\": [\n");
|
||||||
|
for (int i = 0; i < funcCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " {\n");
|
||||||
|
fprintf(outFile, " \"name\": \"%s\",\n", funcs[i].name);
|
||||||
|
fprintf(outFile, " \"description\": \"%s\",\n", CharReplace(funcs[i].desc, '\\', ' ') + 3);
|
||||||
|
fprintf(outFile, " \"returnType\": \"%s\"", funcs[i].retType);
|
||||||
|
|
||||||
|
if (funcs[i].paramCount == 0) fprintf(outFile, "\n");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(outFile, ",\n \"params\": {\n");
|
||||||
|
for (int p = 0; p < funcs[i].paramCount; p++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " \"%s\": \"%s\"", funcs[i].paramName[p], funcs[i].paramType[p]);
|
||||||
|
if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " }");
|
||||||
|
|
||||||
|
if (i < funcCount - 1) fprintf(outFile, ",\n");
|
||||||
|
else fprintf(outFile, "\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " ]\n");
|
||||||
|
fprintf(outFile, "}\n");
|
||||||
|
} break;
|
||||||
|
case XML:
|
||||||
|
{
|
||||||
|
// XML format to export data:
|
||||||
|
/*
|
||||||
|
<?xml version="1.0" encoding="Windows-1252" ?>
|
||||||
|
<raylibAPI>
|
||||||
|
<Structs count="">
|
||||||
|
<Struct name="" fieldCount="" desc="">
|
||||||
|
<Field type="" name="" desc="">
|
||||||
|
<Field type="" name="" desc="">
|
||||||
|
</Struct>
|
||||||
|
<Structs>
|
||||||
|
<Enums count="">
|
||||||
|
<Enum name="" valueCount="" desc="">
|
||||||
|
<Value name="" integer="" desc="">
|
||||||
|
<Value name="" integer="" desc="">
|
||||||
|
</Enum>
|
||||||
|
</Enums>
|
||||||
|
<Functions count="">
|
||||||
|
<Function name="" retType="" paramCount="" desc="">
|
||||||
|
<Param type="" name="" desc="" />
|
||||||
|
<Param type="" name="" desc="" />
|
||||||
|
</Function>
|
||||||
|
</Functions>
|
||||||
|
</raylibAPI>
|
||||||
|
*/
|
||||||
|
|
||||||
|
fprintf(outFile, "<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>\n");
|
||||||
|
fprintf(outFile, "<raylibAPI>\n");
|
||||||
|
|
||||||
|
// Print structs info
|
||||||
|
fprintf(outFile, " <Structs count=\"%i\">\n", structCount);
|
||||||
|
for (int i = 0; i < structCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Struct name=\"%s\" fieldCount=\"%i\" desc=\"%s\">\n", structs[i].name, structs[i].fieldCount, structs[i].desc + 3);
|
||||||
|
for (int f = 0; f < structs[i].fieldCount; f++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Field type=\"%s\" name=\"%s\" desc=\"%s\" />\n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f] + 3);
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Struct>\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Structs>\n");
|
||||||
|
|
||||||
|
// Print enums info
|
||||||
|
fprintf(outFile, " <Enums count=\"%i\">\n", enumCount);
|
||||||
|
for (int i = 0; i < enumCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Enum name=\"%s\" valueCount=\"%i\" desc=\"%s\">\n", enums[i].name, enums[i].valueCount, enums[i].desc + 3);
|
||||||
|
for (int v = 0; v < enums[i].valueCount; v++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Value name=\"%s\" integer=\"%i\" desc=\"%s\" />\n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v] + 3);
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Enum>\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Enums>\n");
|
||||||
|
|
||||||
|
// Print functions info
|
||||||
|
fprintf(outFile, " <Functions count=\"%i\">\n", funcCount);
|
||||||
|
for (int i = 0; i < funcCount; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Function name=\"%s\" retType=\"%s\" paramCount=\"%i\" desc=\"%s\">\n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc + 3);
|
||||||
|
for (int p = 0; p < funcs[i].paramCount; p++)
|
||||||
|
{
|
||||||
|
fprintf(outFile, " <Param type=\"%s\" name=\"%s\" desc=\"%s\" />\n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p] + 3);
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Function>\n");
|
||||||
|
}
|
||||||
|
fprintf(outFile, " </Functions>\n");
|
||||||
|
|
||||||
|
fprintf(outFile, "</raylibAPI>\n");
|
||||||
|
|
||||||
|
} break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(outFile);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ exception to this however, and that is Windows, because Windows
|
||||||
doesn't have a built-in C compiler. On Windows, you'll need to install
|
doesn't have a built-in C compiler. On Windows, you'll need to install
|
||||||
[Visual Studio][visual-studio] or the [build tools][vs-tools]. If you
|
[Visual Studio][visual-studio] or the [build tools][vs-tools]. If you
|
||||||
didn't install them in the default location, write your changes around
|
didn't install them in the default location, write your changes around
|
||||||
line 101 of [`windows-build.bat`](windows-build.bat).
|
line 101 of [`build-windows.bat`](build-windows.bat).
|
||||||
|
|
||||||
## Script customization
|
## Script customization
|
||||||
First of all, the scripts have a few variables at the very top, which
|
First of all, the scripts have a few variables at the very top, which
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@
|
||||||
#define SUPPORT_COMPRESSION_API 1
|
#define SUPPORT_COMPRESSION_API 1
|
||||||
// Support saving binary data automatically to a generated storage.data file. This file is managed internally.
|
// Support saving binary data automatically to a generated storage.data file. This file is managed internally.
|
||||||
#define SUPPORT_DATA_STORAGE 1
|
#define SUPPORT_DATA_STORAGE 1
|
||||||
|
// Support automatic generated events, loading and recording of those events when required
|
||||||
|
#define SUPPORT_EVENTS_AUTOMATION 1
|
||||||
|
|
||||||
// core: Configuration values
|
// core: Configuration values
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
737
src/core.c
737
src/core.c
File diff suppressed because it is too large
Load diff
103
src/external/glfw/CMakeLists.txt
vendored
103
src/external/glfw/CMakeLists.txt
vendored
|
|
@ -41,10 +41,6 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
|
||||||
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
||||||
"MSVC" OFF)
|
"MSVC" OFF)
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
|
||||||
set(_GLFW_BUILD_DLL 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS AND UNIX)
|
if (BUILD_SHARED_LIBS AND UNIX)
|
||||||
# On Unix-like systems, shared libraries can use the soname system.
|
# On Unix-like systems, shared libraries can use the soname system.
|
||||||
set(GLFW_LIB_NAME glfw)
|
set(GLFW_LIB_NAME glfw)
|
||||||
|
|
@ -73,19 +69,8 @@ endif()
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set compiler specific flags
|
# Set compiler specific flags
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (MSVC)
|
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
if (MSVC90)
|
if (${CMAKE_VERSION} VERSION_LESS 3.15)
|
||||||
# Workaround for VS 2008 not shipping with the DirectX 9 SDK
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
|
||||||
if (NOT DINPUT_H_FOUND)
|
|
||||||
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
|
|
||||||
endif()
|
|
||||||
# Workaround for VS 2008 not shipping with stdint.h
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
|
||||||
foreach (flag CMAKE_C_FLAGS
|
foreach (flag CMAKE_C_FLAGS
|
||||||
CMAKE_C_FLAGS_DEBUG
|
CMAKE_C_FLAGS_DEBUG
|
||||||
CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS_RELEASE
|
||||||
|
|
@ -100,41 +85,8 @@ if (MSVC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
else()
|
||||||
endif()
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
|
||||||
if (MINGW)
|
|
||||||
# Workaround for legacy MinGW not providing XInput and DirectInput
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
|
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
|
||||||
check_include_file(xinput.h XINPUT_H_FOUND)
|
|
||||||
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Enable link-time exploit mitigation features enabled by default on MSVC
|
|
||||||
include(CheckCCompilerFlag)
|
|
||||||
|
|
||||||
# Compatibility with data execution prevention (DEP)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
|
||||||
if (_GLFW_HAS_DEP)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compatibility with address space layout randomization (ASLR)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
|
||||||
if (_GLFW_HAS_ASLR)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compatibility with 64-bit address space layout randomization (ASLR)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
|
||||||
if (_GLFW_HAS_64ASLR)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -203,11 +155,8 @@ if (_GLFW_X11)
|
||||||
|
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "x11")
|
|
||||||
|
|
||||||
# Set up library and include paths
|
# Set up library and include paths
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
|
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
|
||||||
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
|
|
||||||
|
|
||||||
# Check for XRandR (modern resolution switching and gamma control)
|
# Check for XRandR (modern resolution switching and gamma control)
|
||||||
if (NOT X11_Xrandr_INCLUDE_PATH)
|
if (NOT X11_Xrandr_INCLUDE_PATH)
|
||||||
|
|
@ -233,37 +182,29 @@ if (_GLFW_X11)
|
||||||
if (NOT X11_Xi_INCLUDE_PATH)
|
if (NOT X11_Xi_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for X Shape (custom window input shape)
|
# Check for X Shape (custom window input shape)
|
||||||
if (NOT X11_Xshape_INCLUDE_PATH)
|
if (NOT X11_Xshape_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
|
|
||||||
"${X11_Xinerama_INCLUDE_PATH}"
|
|
||||||
"${X11_Xkb_INCLUDE_PATH}"
|
|
||||||
"${X11_Xcursor_INCLUDE_PATH}"
|
|
||||||
"${X11_Xi_INCLUDE_PATH}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Use Wayland for window creation
|
# Use Wayland for window creation
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (_GLFW_WAYLAND)
|
if (_GLFW_WAYLAND)
|
||||||
find_package(ECM REQUIRED NO_MODULE)
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
|
|
||||||
|
|
||||||
find_package(Wayland REQUIRED Client Cursor Egl)
|
include(FindPkgConfig)
|
||||||
find_package(WaylandScanner REQUIRED)
|
pkg_check_modules(Wayland REQUIRED
|
||||||
find_package(WaylandProtocols 1.15 REQUIRED)
|
wayland-client>=0.2.7
|
||||||
|
wayland-cursor>=0.2.7
|
||||||
|
wayland-egl>=0.2.7
|
||||||
|
xkbcommon)
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-egl")
|
list(APPEND glfw_PKG_DEPS "wayland-client")
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
||||||
list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
|
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
|
||||||
|
|
||||||
find_package(XKBCommon REQUIRED)
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
|
|
||||||
|
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
|
|
@ -279,14 +220,6 @@ if (_GLFW_WAYLAND)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use OSMesa for offscreen context creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_OSMESA)
|
|
||||||
find_package(OSMesa REQUIRED)
|
|
||||||
list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Use Cocoa for window creation and NSOpenGL for context creation
|
# Use Cocoa for window creation and NSOpenGL for context creation
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
|
@ -312,12 +245,10 @@ endif()
|
||||||
# Export GLFW library dependencies
|
# Export GLFW library dependencies
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
foreach(arg ${glfw_PKG_DEPS})
|
foreach(arg ${glfw_PKG_DEPS})
|
||||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL
|
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
||||||
"GLFW pkg-config Requires.private")
|
|
||||||
endforeach()
|
endforeach()
|
||||||
foreach(arg ${glfw_PKG_LIBS})
|
foreach(arg ${glfw_PKG_LIBS})
|
||||||
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL
|
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
|
||||||
"GLFW pkg-config Libs.private")
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
|
@ -336,9 +267,7 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake
|
||||||
VERSION ${GLFW_VERSION}
|
VERSION ${GLFW_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion)
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
|
configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY)
|
||||||
|
|
||||||
configure_file(CMake/glfw3.pc.in CMake/glfw3.pc @ONLY)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Add subdirectories
|
# Add subdirectories
|
||||||
|
|
|
||||||
38
src/external/glfw/README.md
vendored
38
src/external/glfw/README.md
vendored
|
|
@ -99,7 +99,7 @@ located in the `deps/` directory.
|
||||||
functions
|
functions
|
||||||
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
||||||
examples
|
examples
|
||||||
- [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
|
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
||||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||||
|
|
||||||
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
||||||
|
|
@ -127,7 +127,10 @@ information on what to include when reporting a bug.
|
||||||
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
||||||
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
||||||
values to select ANGLE backend (#1380)
|
values to select ANGLE backend (#1380)
|
||||||
|
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
||||||
|
surface extension (#1793)
|
||||||
- Made joystick subsystem initialize at first use (#1284,#1646)
|
- Made joystick subsystem initialize at first use (#1284,#1646)
|
||||||
|
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
|
||||||
- Updated the minimum required CMake version to 3.1
|
- Updated the minimum required CMake version to 3.1
|
||||||
- Disabled tests and examples by default when built as a CMake subdirectory
|
- Disabled tests and examples by default when built as a CMake subdirectory
|
||||||
- Bugfix: The CMake config-file package used an absolute path and was not
|
- Bugfix: The CMake config-file package used an absolute path and was not
|
||||||
|
|
@ -137,6 +140,7 @@ information on what to include when reporting a bug.
|
||||||
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
||||||
- Bugfix: Some extension loader headers did not prevent default OpenGL header
|
- Bugfix: Some extension loader headers did not prevent default OpenGL header
|
||||||
inclusion (#1695)
|
inclusion (#1695)
|
||||||
|
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
|
||||||
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
||||||
to the window menu
|
to the window menu
|
||||||
- [Win32] Added a version info resource to the GLFW DLL
|
- [Win32] Added a version info resource to the GLFW DLL
|
||||||
|
|
@ -158,10 +162,20 @@ information on what to include when reporting a bug.
|
||||||
- [Win32] Bugfix: Monitor functions could return invalid values after
|
- [Win32] Bugfix: Monitor functions could return invalid values after
|
||||||
configuration change (#1761)
|
configuration change (#1761)
|
||||||
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
|
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
|
||||||
|
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
|
||||||
|
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
|
||||||
|
(#1582)
|
||||||
|
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
|
||||||
|
Windows 10 version 1703 (#1511)
|
||||||
|
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
||||||
|
later (#1783,#1796)
|
||||||
|
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||||
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
||||||
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
||||||
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
||||||
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
||||||
|
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
|
||||||
|
(#1786)
|
||||||
- [Cocoa] Removed dependency on the CoreVideo framework
|
- [Cocoa] Removed dependency on the CoreVideo framework
|
||||||
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
||||||
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
||||||
|
|
@ -174,6 +188,12 @@ information on what to include when reporting a bug.
|
||||||
(#1635)
|
(#1635)
|
||||||
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
|
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
|
||||||
could leak memory
|
could leak memory
|
||||||
|
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
|
||||||
|
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
|
||||||
|
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
|
||||||
|
regained focus (#1648,#1802)
|
||||||
|
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
||||||
|
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
||||||
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
||||||
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||||
(#1462,#1528)
|
(#1462,#1528)
|
||||||
|
|
@ -199,6 +219,8 @@ information on what to include when reporting a bug.
|
||||||
combinaitons (#1598)
|
combinaitons (#1598)
|
||||||
- [X11] Bugfix: Keys pressed simultaneously with others were not always
|
- [X11] Bugfix: Keys pressed simultaneously with others were not always
|
||||||
reported (#1112,#1415,#1472,#1616)
|
reported (#1112,#1415,#1472,#1616)
|
||||||
|
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
||||||
|
(#1863)
|
||||||
- [Wayland] Removed support for `wl_shell` (#1443)
|
- [Wayland] Removed support for `wl_shell` (#1443)
|
||||||
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||||
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
||||||
|
|
@ -206,6 +228,9 @@ information on what to include when reporting a bug.
|
||||||
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
||||||
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
||||||
(#1463)
|
(#1463)
|
||||||
|
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
|
||||||
|
(#1798)
|
||||||
|
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
|
||||||
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
||||||
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
||||||
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||||
|
|
@ -240,13 +265,16 @@ GLFW exists because people around the world donated their time and lent their
|
||||||
skills.
|
skills.
|
||||||
|
|
||||||
- Bobyshev Alexander
|
- Bobyshev Alexander
|
||||||
|
- Laurent Aphecetche
|
||||||
- Matt Arsenault
|
- Matt Arsenault
|
||||||
|
- ashishgamedev
|
||||||
- David Avedissian
|
- David Avedissian
|
||||||
- Keith Bauer
|
- Keith Bauer
|
||||||
- John Bartholomew
|
- John Bartholomew
|
||||||
- Coşku Baş
|
- Coşku Baş
|
||||||
- Niklas Behrens
|
- Niklas Behrens
|
||||||
- Andrew Belt
|
- Andrew Belt
|
||||||
|
- Nevyn Bengtsson
|
||||||
- Niklas Bergström
|
- Niklas Bergström
|
||||||
- Denis Bernard
|
- Denis Bernard
|
||||||
- Doug Binks
|
- Doug Binks
|
||||||
|
|
@ -268,6 +296,7 @@ skills.
|
||||||
- Andrew Corrigan
|
- Andrew Corrigan
|
||||||
- Bailey Cosier
|
- Bailey Cosier
|
||||||
- Noel Cower
|
- Noel Cower
|
||||||
|
- CuriouserThing
|
||||||
- Jason Daly
|
- Jason Daly
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
|
|
@ -294,6 +323,7 @@ skills.
|
||||||
- Eloi Marín Gratacós
|
- Eloi Marín Gratacós
|
||||||
- Stefan Gustavson
|
- Stefan Gustavson
|
||||||
- Jonathan Hale
|
- Jonathan Hale
|
||||||
|
- hdf89shfdfs
|
||||||
- Sylvain Hellegouarch
|
- Sylvain Hellegouarch
|
||||||
- Matthew Henry
|
- Matthew Henry
|
||||||
- heromyth
|
- heromyth
|
||||||
|
|
@ -318,11 +348,13 @@ skills.
|
||||||
- Konstantin Käfer
|
- Konstantin Käfer
|
||||||
- Eric Larson
|
- Eric Larson
|
||||||
- Francis Lecavalier
|
- Francis Lecavalier
|
||||||
|
- Jong Won Lee
|
||||||
- Robin Leffmann
|
- Robin Leffmann
|
||||||
- Glenn Lewis
|
- Glenn Lewis
|
||||||
- Shane Liesegang
|
- Shane Liesegang
|
||||||
- Anders Lindqvist
|
- Anders Lindqvist
|
||||||
- Leon Linhart
|
- Leon Linhart
|
||||||
|
- Marco Lizza
|
||||||
- Eyal Lotem
|
- Eyal Lotem
|
||||||
- Aaron Loucks
|
- Aaron Loucks
|
||||||
- Luflosi
|
- Luflosi
|
||||||
|
|
@ -428,6 +460,9 @@ skills.
|
||||||
- Waris
|
- Waris
|
||||||
- Jay Weisskopf
|
- Jay Weisskopf
|
||||||
- Frank Wille
|
- Frank Wille
|
||||||
|
- Andy Williams
|
||||||
|
- Joel Winarske
|
||||||
|
- Richard A. Wilkes
|
||||||
- Tatsuya Yatagawa
|
- Tatsuya Yatagawa
|
||||||
- Ryogo Yoshimura
|
- Ryogo Yoshimura
|
||||||
- Lukas Zanner
|
- Lukas Zanner
|
||||||
|
|
@ -436,6 +471,7 @@ skills.
|
||||||
- Santi Zupancic
|
- Santi Zupancic
|
||||||
- Jonas Ådahl
|
- Jonas Ådahl
|
||||||
- Lasse Öörni
|
- Lasse Öörni
|
||||||
|
- Leonard König
|
||||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||||
reports, patches, feedback, testing and encouragement
|
reports, patches, feedback, testing and encouragement
|
||||||
|
|
||||||
|
|
|
||||||
45
src/external/glfw/include/GLFW/glfw3.h
vendored
45
src/external/glfw/include/GLFW/glfw3.h
vendored
|
|
@ -276,23 +276,24 @@ extern "C" {
|
||||||
|
|
||||||
/*! @name GLFW version macros
|
/*! @name GLFW version macros
|
||||||
* @{ */
|
* @{ */
|
||||||
/*! @brief The major version number of the GLFW library.
|
/*! @brief The major version number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when the API is changed in non-compatible ways.
|
* The major version number of the GLFW header. This is incremented when the
|
||||||
|
* API is changed in non-compatible ways.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_MAJOR 3
|
#define GLFW_VERSION_MAJOR 3
|
||||||
/*! @brief The minor version number of the GLFW library.
|
/*! @brief The minor version number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when features are added to the API but it remains
|
* The minor version number of the GLFW header. This is incremented when
|
||||||
* backward-compatible.
|
* features are added to the API but it remains backward-compatible.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_MINOR 4
|
#define GLFW_VERSION_MINOR 4
|
||||||
/*! @brief The revision number of the GLFW library.
|
/*! @brief The revision number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when a bug fix release is made that does not contain any
|
* The revision number of the GLFW header. This is incremented when a bug fix
|
||||||
* API changes.
|
* release is made that does not contain any API changes.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_REVISION 0
|
#define GLFW_VERSION_REVISION 0
|
||||||
|
|
@ -977,9 +978,10 @@ extern "C" {
|
||||||
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
|
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
|
||||||
*/
|
*/
|
||||||
#define GLFW_REFRESH_RATE 0x0002100F
|
#define GLFW_REFRESH_RATE 0x0002100F
|
||||||
/*! @brief Framebuffer double buffering hint.
|
/*! @brief Framebuffer double buffering hint and attribute.
|
||||||
*
|
*
|
||||||
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
|
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
|
||||||
|
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
|
||||||
*/
|
*/
|
||||||
#define GLFW_DOUBLEBUFFER 0x00021010
|
#define GLFW_DOUBLEBUFFER 0x00021010
|
||||||
|
|
||||||
|
|
@ -1250,6 +1252,11 @@ extern "C" {
|
||||||
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
|
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
|
||||||
*/
|
*/
|
||||||
#define GLFW_COCOA_MENUBAR 0x00051002
|
#define GLFW_COCOA_MENUBAR 0x00051002
|
||||||
|
/*! @brief X11 specific init hint.
|
||||||
|
*
|
||||||
|
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
|
||||||
|
*/
|
||||||
|
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_DONT_CARE -1
|
#define GLFW_DONT_CARE -1
|
||||||
|
|
@ -2417,8 +2424,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
||||||
*
|
*
|
||||||
* This function returns an array of all video modes supported by the specified
|
* This function returns an array of all video modes supported by the specified
|
||||||
* monitor. The returned array is sorted in ascending order, first by color
|
* monitor. The returned array is sorted in ascending order, first by color
|
||||||
* bit depth (the sum of all channel depths) and then by resolution area (the
|
* bit depth (the sum of all channel depths), then by resolution area (the
|
||||||
* product of width and height).
|
* product of width and height), then resolution width and finally by refresh
|
||||||
|
* rate.
|
||||||
*
|
*
|
||||||
* @param[in] monitor The monitor to query.
|
* @param[in] monitor The monitor to query.
|
||||||
* @param[out] count Where to store the number of video modes in the returned
|
* @param[out] count Where to store the number of video modes in the returned
|
||||||
|
|
@ -5865,9 +5873,8 @@ GLFWAPI int glfwVulkanSupported(void);
|
||||||
* returned array, as it is an error to specify an extension more than once in
|
* returned array, as it is an error to specify an extension more than once in
|
||||||
* the `VkInstanceCreateInfo` struct.
|
* the `VkInstanceCreateInfo` struct.
|
||||||
*
|
*
|
||||||
* @remark @macos This function currently supports either the
|
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
|
||||||
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
|
* the newer `VK_EXT_metal_surface` extensions.
|
||||||
* extension.
|
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||||
* should not free it yourself. It is guaranteed to be valid only until the
|
* should not free it yourself. It is guaranteed to be valid only until the
|
||||||
|
|
@ -5950,7 +5957,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
|
||||||
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
||||||
* `VK_MVK_macos_surface` extension does not provide
|
* `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
|
||||||
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
||||||
*
|
*
|
||||||
* @thread_safety This function may be called from any thread. For
|
* @thread_safety This function may be called from any thread. For
|
||||||
|
|
@ -6013,6 +6020,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
||||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||||
* the window content view, which is required for MoltenVK to function.
|
* the window content view, which is required for MoltenVK to function.
|
||||||
*
|
*
|
||||||
|
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
|
||||||
|
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
|
||||||
|
* extension by setting the
|
||||||
|
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
||||||
|
* hint.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. For
|
* @thread_safety This function may be called from any thread. For
|
||||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
5
src/external/glfw/include/GLFW/glfw3native.h
vendored
5
src/external/glfw/include/GLFW/glfw3native.h
vendored
|
|
@ -83,8 +83,8 @@ extern "C" {
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
// example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
// but windows.h assumes no one will define APIENTRY before it does
|
||||||
#if defined(GLFW_APIENTRY_DEFINED)
|
#if defined(GLFW_APIENTRY_DEFINED)
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
#undef GLFW_APIENTRY_DEFINED
|
||||||
|
|
@ -96,7 +96,6 @@ extern "C" {
|
||||||
typedef PVOID HANDLE;
|
typedef PVOID HANDLE;
|
||||||
typedef HANDLE HWND;
|
typedef HANDLE HWND;
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
#if defined(__OBJC__)
|
#if defined(__OBJC__)
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
300
src/external/glfw/src/CMakeLists.txt
vendored
300
src/external/glfw/src/CMakeLists.txt
vendored
|
|
@ -1,149 +1,192 @@
|
||||||
|
|
||||||
set(common_HEADERS internal.h mappings.h
|
add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||||
"${GLFW_BINARY_DIR}/src/glfw_config.h"
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
|
||||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
internal.h mappings.h context.c init.c input.c monitor.c
|
||||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
|
vulkan.c window.c)
|
||||||
set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
|
|
||||||
|
|
||||||
if (_GLFW_COCOA)
|
if (_GLFW_COCOA)
|
||||||
set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
|
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
||||||
posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)
|
nsgl_context.h egl_context.h osmesa_context.h
|
||||||
set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m
|
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c
|
cocoa_window.m cocoa_time.c posix_thread.c
|
||||||
nsgl_context.m egl_context.c osmesa_context.c)
|
nsgl_context.m egl_context.c osmesa_context.c)
|
||||||
elseif (_GLFW_WIN32)
|
elseif (_GLFW_WIN32)
|
||||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h
|
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
|
||||||
wgl_context.h egl_context.h osmesa_context.h)
|
egl_context.h osmesa_context.h win32_init.c
|
||||||
set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_joystick.c
|
win32_joystick.c win32_monitor.c win32_time.c
|
||||||
win32_monitor.c win32_time.c win32_thread.c win32_window.c
|
win32_thread.c win32_window.c wgl_context.c
|
||||||
wgl_context.c egl_context.c osmesa_context.c)
|
egl_context.c osmesa_context.c)
|
||||||
elseif (_GLFW_X11)
|
elseif (_GLFW_X11)
|
||||||
set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h
|
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h
|
||||||
posix_thread.h glx_context.h egl_context.h osmesa_context.h)
|
posix_thread.h glx_context.h egl_context.h
|
||||||
set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c
|
osmesa_context.h x11_init.c x11_monitor.c
|
||||||
xkb_unicode.c posix_time.c posix_thread.c glx_context.c
|
x11_window.c xkb_unicode.c posix_time.c
|
||||||
egl_context.c osmesa_context.c)
|
posix_thread.c glx_context.c egl_context.c
|
||||||
|
osmesa_context.c)
|
||||||
elseif (_GLFW_WAYLAND)
|
elseif (_GLFW_WAYLAND)
|
||||||
set(glfw_HEADERS ${common_HEADERS} wl_platform.h
|
target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
|
||||||
posix_time.h posix_thread.h xkb_unicode.h egl_context.h
|
xkb_unicode.h egl_context.h osmesa_context.h
|
||||||
osmesa_context.h)
|
wl_init.c wl_monitor.c wl_window.c posix_time.c
|
||||||
set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c
|
posix_thread.c xkb_unicode.c egl_context.c
|
||||||
posix_time.c posix_thread.c xkb_unicode.c
|
osmesa_context.c)
|
||||||
egl_context.c osmesa_context.c)
|
|
||||||
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
|
|
||||||
BASENAME xdg-shell)
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
|
||||||
BASENAME xdg-decoration)
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
|
|
||||||
BASENAME viewporter)
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
|
||||||
BASENAME relative-pointer-unstable-v1)
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
|
||||||
BASENAME pointer-constraints-unstable-v1)
|
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
|
||||||
BASENAME idle-inhibit-unstable-v1)
|
|
||||||
elseif (_GLFW_OSMESA)
|
elseif (_GLFW_OSMESA)
|
||||||
set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h
|
target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
|
||||||
posix_time.h posix_thread.h osmesa_context.h)
|
posix_thread.h osmesa_context.h null_init.c
|
||||||
set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c
|
null_monitor.c null_window.c null_joystick.c
|
||||||
null_joystick.c posix_time.c posix_thread.c osmesa_context.c)
|
posix_time.c posix_thread.c osmesa_context.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
||||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
|
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
|
||||||
set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
|
|
||||||
else()
|
else()
|
||||||
set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h)
|
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
|
||||||
set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (_GLFW_WAYLAND)
|
||||||
# For some reason, CMake doesn't know about .m
|
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||||
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
|
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
||||||
|
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
|
||||||
|
|
||||||
|
macro(wayland_generate protocol_file output_file)
|
||||||
|
add_custom_command(OUTPUT "${output_file}.h"
|
||||||
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
|
||||||
|
DEPENDS "${protocol_file}"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${output_file}.c"
|
||||||
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
|
||||||
|
DEPENDS "${protocol_file}"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
|
if (WIN32 AND BUILD_SHARED_LIBS)
|
||||||
# for all source files that VS will build
|
configure_file(glfw.rc.in glfw.rc @ONLY)
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(windows_SOURCES ${glfw_SOURCES})
|
|
||||||
else()
|
|
||||||
set(windows_SOURCES ${common_SOURCES})
|
|
||||||
endif()
|
|
||||||
set_source_files_properties(${windows_SOURCES} PROPERTIES
|
|
||||||
COMPILE_FLAGS -Wdeclaration-after-statement)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS})
|
configure_file(glfw_config.h.in glfw_config.h @ONLY)
|
||||||
add_library(glfw $<TARGET_OBJECTS:glfw_objlib>)
|
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
|
||||||
set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES
|
set_target_properties(glfw PROPERTIES
|
||||||
OUTPUT_NAME ${GLFW_LIB_NAME}
|
OUTPUT_NAME ${GLFW_LIB_NAME}
|
||||||
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
|
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
|
||||||
SOVERSION ${GLFW_VERSION_MAJOR}
|
SOVERSION ${GLFW_VERSION_MAJOR}
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
C_STANDARD 99
|
||||||
|
C_EXTENSIONS OFF
|
||||||
|
DEFINE_SYMBOL _GLFW_BUILD_DLL
|
||||||
FOLDER "GLFW3")
|
FOLDER "GLFW3")
|
||||||
|
|
||||||
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
|
|
||||||
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
|
|
||||||
|
|
||||||
set_target_properties(glfw_objlib PROPERTIES C_STANDARD 99)
|
|
||||||
else()
|
|
||||||
# Remove this fallback when removing support for CMake version less than 3.1
|
|
||||||
target_compile_options(glfw_objlib PRIVATE
|
|
||||||
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
|
|
||||||
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
|
|
||||||
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H)
|
|
||||||
target_include_directories(glfw_objlib PUBLIC
|
|
||||||
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
|
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
|
|
||||||
target_include_directories(glfw PUBLIC
|
target_include_directories(glfw PUBLIC
|
||||||
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(glfw_objlib PRIVATE
|
target_include_directories(glfw PRIVATE
|
||||||
"${GLFW_SOURCE_DIR}/src"
|
"${GLFW_SOURCE_DIR}/src"
|
||||||
"${GLFW_BINARY_DIR}/src"
|
"${GLFW_BINARY_DIR}/src"
|
||||||
${glfw_INCLUDE_DIRS})
|
${glfw_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
|
||||||
|
|
||||||
|
# Workaround for CMake not knowing about .m files before version 3.16
|
||||||
|
if ("${CMAKE_VERSION}" VERSION_LESS "3.16" AND APPLE)
|
||||||
|
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
|
cocoa_window.m nsgl_context.m PROPERTIES
|
||||||
|
LANGUAGE C)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
|
||||||
|
# source files that VS will build (Clang ignores this because we set -std=c99)
|
||||||
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
|
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
||||||
|
window.c win32_init.c win32_joystick.c
|
||||||
|
win32_monitor.c win32_time.c win32_thread.c
|
||||||
|
win32_window.c wgl_context.c egl_context.c
|
||||||
|
osmesa_context.c PROPERTIES
|
||||||
|
COMPILE_FLAGS -Wdeclaration-after-statement)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Enable a reasonable set of warnings
|
||||||
|
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
||||||
|
if (MSVC)
|
||||||
|
target_compile_options(glfw PRIVATE "/W3")
|
||||||
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
|
||||||
|
target_compile_options(glfw PRIVATE "-Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (_GLFW_WIN32)
|
||||||
|
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
||||||
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
||||||
# win32_platform.h. We define them here until a saner solution can be found
|
# win32_platform.h. We define them here until a saner solution can be found
|
||||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||||
target_compile_definitions(glfw_objlib PRIVATE
|
if (MINGW)
|
||||||
"$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>")
|
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
|
# Workaround for legacy MinGW not providing XInput and DirectInput
|
||||||
target_compile_options(glfw_objlib PRIVATE
|
if (MINGW)
|
||||||
"$<$<C_COMPILER_ID:AppleClang>:-Wall>"
|
include(CheckIncludeFile)
|
||||||
"$<$<C_COMPILER_ID:Clang>:-Wall>"
|
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||||
"$<$<C_COMPILER_ID:GNU>:-Wall>")
|
check_include_file(xinput.h XINPUT_H_FOUND)
|
||||||
|
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
||||||
|
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Workaround for VS 2008 not shipping with stdint.h
|
||||||
|
if (MSVC90)
|
||||||
|
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for the DirectX 9 SDK as it is not included with VS 2008
|
||||||
|
if (MSVC90)
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||||
|
if (NOT DINPUT_H_FOUND)
|
||||||
|
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Remove the dependency on the shared version of libgcc
|
# Remove the dependency on the shared version of libgcc
|
||||||
# NOTE: MinGW-w64 has the correct default but MinGW needs this
|
# NOTE: MinGW-w64 has the correct default but MinGW needs this
|
||||||
target_link_options(glfw PRIVATE "-static-libgcc")
|
target_link_libraries(glfw PRIVATE "-static-libgcc")
|
||||||
|
|
||||||
# Remove the lib prefix on the DLL (but not the import library)
|
# Remove the lib prefix on the DLL (but not the import library)
|
||||||
set_target_properties(glfw PROPERTIES PREFIX "")
|
set_target_properties(glfw PROPERTIES PREFIX "")
|
||||||
|
|
@ -155,33 +198,48 @@ if (BUILD_SHARED_LIBS)
|
||||||
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
|
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL)
|
target_compile_definitions(glfw INTERFACE GLFW_DLL)
|
||||||
elseif (APPLE)
|
endif()
|
||||||
# Add -fno-common to work around a bug in Apple's GCC
|
|
||||||
target_compile_options(glfw_objlib PRIVATE "-fno-common")
|
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES
|
if (MINGW)
|
||||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
|
# Enable link-time exploit mitigation features enabled by default on MSVC
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
|
||||||
|
# Compatibility with data execution prevention (DEP)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
||||||
|
if (_GLFW_HAS_DEP)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compatibility with address space layout randomization (ASLR)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
||||||
|
if (_GLFW_HAS_ASLR)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compatibility with 64-bit address space layout randomization (ASLR)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
||||||
|
if (_GLFW_HAS_64ASLR)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Clear flags again to avoid breaking later tests
|
||||||
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
# Hide symbols not explicitly tagged for export from the shared library
|
# Hide symbols not explicitly tagged for export from the shared library
|
||||||
target_compile_options(glfw_objlib PRIVATE "-fvisibility=hidden")
|
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
target_compile_definitions(glfw_objlib PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (GLFW_INSTALL)
|
if (GLFW_INSTALL)
|
||||||
install(TARGETS glfw
|
install(TARGETS glfw
|
||||||
EXPORT glfwTargets
|
EXPORT glfwTargets
|
||||||
RUNTIME DESTINATION "bin"
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
9
src/external/glfw/src/cocoa_init.m
vendored
9
src/external/glfw/src/cocoa_init.m
vendored
|
|
@ -251,7 +251,7 @@ static void createKeyTables(void)
|
||||||
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
|
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
|
||||||
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
|
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
|
||||||
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
|
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
|
||||||
_glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
|
_glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
|
||||||
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
|
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
|
||||||
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
|
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
|
||||||
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
|
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
|
||||||
|
|
@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void)
|
||||||
{
|
{
|
||||||
if (_glfw.hints.init.ns.menubar)
|
if (_glfw.hints.init.ns.menubar)
|
||||||
{
|
{
|
||||||
// In case we are unbundled, make us a proper UI application
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
// Menu bar setup must go between sharedApplication and finishLaunching
|
// Menu bar setup must go between sharedApplication and finishLaunching
|
||||||
// in order to properly emulate the behavior of NSApplicationMain
|
// in order to properly emulate the behavior of NSApplicationMain
|
||||||
|
|
||||||
|
|
@ -557,6 +554,10 @@ int _glfwPlatformInit(void)
|
||||||
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
|
||||||
|
// In case we are unbundled, make us a proper UI application
|
||||||
|
if (_glfw.hints.init.ns.menubar)
|
||||||
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
|
|
|
||||||
89
src/external/glfw/src/cocoa_monitor.m
vendored
89
src/external/glfw/src/cocoa_monitor.m
vendored
|
|
@ -39,8 +39,21 @@
|
||||||
|
|
||||||
// Get the name of the specified display, or NULL
|
// Get the name of the specified display, or NULL
|
||||||
//
|
//
|
||||||
static char* getDisplayName(CGDirectDisplayID displayID)
|
static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
{
|
{
|
||||||
|
// IOKit doesn't work on Apple Silicon anymore
|
||||||
|
// Luckily, 10.15 introduced -[NSScreen localizedName].
|
||||||
|
// Use it if available, and fall back to IOKit otherwise.
|
||||||
|
if (screen)
|
||||||
|
{
|
||||||
|
if ([screen respondsToSelector:@selector(localizedName)])
|
||||||
|
{
|
||||||
|
NSString* name = [screen valueForKey:@"localizedName"];
|
||||||
|
if (name)
|
||||||
|
return _glfw_strdup([name UTF8String]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
io_iterator_t it;
|
io_iterator_t it;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
CFDictionaryRef info;
|
CFDictionaryRef info;
|
||||||
|
|
@ -50,7 +63,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
||||||
&it) != 0)
|
&it) != 0)
|
||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((service = IOIteratorNext(it)) != 0)
|
while ((service = IOIteratorNext(it)) != 0)
|
||||||
|
|
@ -88,7 +101,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa: Failed to find service port for display");
|
"Cocoa: Failed to find service port for display");
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFDictionaryRef names =
|
CFDictionaryRef names =
|
||||||
|
|
@ -101,7 +114,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFIndex size =
|
const CFIndex size =
|
||||||
|
|
@ -209,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds and caches the NSScreen corresponding to the specified monitor
|
|
||||||
//
|
|
||||||
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
|
||||||
{
|
|
||||||
if (monitor->ns.screen)
|
|
||||||
return GLFW_TRUE;
|
|
||||||
|
|
||||||
for (NSScreen* screen in [NSScreen screens])
|
|
||||||
{
|
|
||||||
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
|
|
||||||
|
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
|
||||||
// display replacement on machines with automatic graphics
|
|
||||||
// switching
|
|
||||||
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
|
|
||||||
{
|
|
||||||
monitor->ns.screen = screen;
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the display refresh rate queried from the I/O registry
|
// Returns the display refresh rate queried from the I/O registry
|
||||||
//
|
//
|
||||||
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||||
|
|
@ -334,27 +322,46 @@ void _glfwPollMonitorsNS(void)
|
||||||
if (CGDisplayIsAsleep(displays[i]))
|
if (CGDisplayIsAsleep(displays[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
||||||
|
NSScreen* screen = nil;
|
||||||
|
|
||||||
|
for (screen in [NSScreen screens])
|
||||||
|
{
|
||||||
|
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
|
||||||
|
|
||||||
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
|
// 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
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
// display replacement on machines with automatic graphics
|
// display replacement on machines with automatic graphics
|
||||||
// switching
|
// switching
|
||||||
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
uint32_t j;
|
||||||
for (uint32_t j = 0; j < disconnectedCount; j++)
|
for (j = 0; j < disconnectedCount; j++)
|
||||||
{
|
{
|
||||||
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
||||||
{
|
{
|
||||||
|
disconnected[j]->ns.screen = screen;
|
||||||
disconnected[j] = NULL;
|
disconnected[j] = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j < disconnectedCount)
|
||||||
|
continue;
|
||||||
|
|
||||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||||
char* name = getDisplayName(displays[i]);
|
char* name = getMonitorName(displays[i], screen);
|
||||||
if (!name)
|
if (!name)
|
||||||
name = _glfw_strdup("Unknown");
|
continue;
|
||||||
|
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
||||||
monitor->ns.displayID = displays[i];
|
monitor->ns.displayID = displays[i];
|
||||||
monitor->ns.unitNumber = unitNumber;
|
monitor->ns.unitNumber = unitNumber;
|
||||||
|
monitor->ns.screen = screen;
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
|
|
@ -463,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query content scale without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect points = [monitor->ns.screen frame];
|
const NSRect points = [monitor->ns.screen frame];
|
||||||
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
||||||
|
|
@ -483,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query workarea without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
||||||
|
|
||||||
|
|
@ -527,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip duplicate modes
|
// Skip duplicate modes
|
||||||
if (i < *count)
|
if (j < *count)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
|
|
||||||
66
src/external/glfw/src/cocoa_window.m
vendored
66
src/external/glfw/src/cocoa_window.m
vendored
|
|
@ -1635,14 +1635,21 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||||
SEL cursorSelector = NULL;
|
SEL cursorSelector = NULL;
|
||||||
|
|
||||||
// HACK: Try to use a private message
|
// HACK: Try to use a private message
|
||||||
if (shape == GLFW_RESIZE_EW_CURSOR)
|
switch (shape)
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
|
{
|
||||||
else if (shape == GLFW_RESIZE_NS_CURSOR)
|
case GLFW_RESIZE_EW_CURSOR:
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
|
cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
|
||||||
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
|
break;
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
|
case GLFW_RESIZE_NS_CURSOR:
|
||||||
else if (shape == GLFW_RESIZE_NESW_CURSOR)
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
|
break;
|
||||||
|
case GLFW_RESIZE_NWSE_CURSOR:
|
||||||
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
|
||||||
|
break;
|
||||||
|
case GLFW_RESIZE_NESW_CURSOR:
|
||||||
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
|
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
|
||||||
{
|
{
|
||||||
|
|
@ -1653,22 +1660,33 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||||
|
|
||||||
if (!cursor->ns.object)
|
if (!cursor->ns.object)
|
||||||
{
|
{
|
||||||
if (shape == GLFW_ARROW_CURSOR)
|
switch (shape)
|
||||||
cursor->ns.object = [NSCursor arrowCursor];
|
{
|
||||||
else if (shape == GLFW_IBEAM_CURSOR)
|
case GLFW_ARROW_CURSOR:
|
||||||
cursor->ns.object = [NSCursor IBeamCursor];
|
cursor->ns.object = [NSCursor arrowCursor];
|
||||||
else if (shape == GLFW_CROSSHAIR_CURSOR)
|
break;
|
||||||
cursor->ns.object = [NSCursor crosshairCursor];
|
case GLFW_IBEAM_CURSOR:
|
||||||
else if (shape == GLFW_POINTING_HAND_CURSOR)
|
cursor->ns.object = [NSCursor IBeamCursor];
|
||||||
cursor->ns.object = [NSCursor pointingHandCursor];
|
break;
|
||||||
else if (shape == GLFW_RESIZE_EW_CURSOR)
|
case GLFW_CROSSHAIR_CURSOR:
|
||||||
cursor->ns.object = [NSCursor resizeLeftRightCursor];
|
cursor->ns.object = [NSCursor crosshairCursor];
|
||||||
else if (shape == GLFW_RESIZE_NS_CURSOR)
|
break;
|
||||||
cursor->ns.object = [NSCursor resizeUpDownCursor];
|
case GLFW_POINTING_HAND_CURSOR:
|
||||||
else if (shape == GLFW_RESIZE_ALL_CURSOR)
|
cursor->ns.object = [NSCursor pointingHandCursor];
|
||||||
cursor->ns.object = [NSCursor closedHandCursor];
|
break;
|
||||||
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
|
case GLFW_RESIZE_EW_CURSOR:
|
||||||
cursor->ns.object = [NSCursor operationNotAllowedCursor];
|
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)
|
if (!cursor->ns.object)
|
||||||
|
|
|
||||||
10
src/external/glfw/src/context.c
vendored
10
src/external/glfw/src/context.c
vendored
|
|
@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desired->doublebuffer != current->doublebuffer)
|
|
||||||
{
|
|
||||||
// Double buffering is a hard constraint
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count number of missing buffers
|
// Count number of missing buffers
|
||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
|
|
@ -570,7 +564,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||||
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
||||||
window->context.getProcAddress("glClear");
|
window->context.getProcAddress("glClear");
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
window->context.swapBuffers(window);
|
|
||||||
|
if (window->doublebuffer)
|
||||||
|
window->context.swapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue