# Rewrite 5
- Move Libraries Source into pd directory and give them all their own CMakeLists.txt - Partial rewrite core (color, autogenerated vec), lithium (now uses UNIQUE PTR for Commands), UI7 - Use MenuV2 as new standart in UI7 - Implementz ViewPort Pre alpha to UI7 - Add Line Drawing to DrawList (not Working) - Implement a Complete new drievrs API (static Drivers) - NO SUPPORT FOR SHARED LIBRARY BUILDS IN VERSION 5 YET - Add Tools to Autogenerate Headers and Stuff
This commit is contained in:
		
							
								
								
									
										31
									
								
								backends/desktop/CMakeLists.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										31
									
								
								backends/desktop/CMakeLists.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -1,27 +1,16 @@ | ||||
| cmake_minimum_required(VERSION 3.22) | ||||
|  | ||||
| if(WIN32) | ||||
| set(EXTRA_LIBS ws2_32) | ||||
| else() | ||||
| set(EXTRA_LIBS) | ||||
| endif() | ||||
| project(pd-desktop LANGUAGES CXX VERSION 0.5.0) | ||||
|  | ||||
| add_subdirectory(glfw) | ||||
| add_subdirectory(glad) | ||||
| add_subdirectory(glfw) | ||||
|  | ||||
| # if(PD_BUILD_SHARED) | ||||
| # add_library(pd-backend-desktop SHARED | ||||
| # source/li_backend_gl2.cpp | ||||
| # source/pd_hid_glfw.cpp) | ||||
| # target_compile_definitions(pd-backend-desktop PUBLIC | ||||
| #     -DPD_BKND_DESKTOP_BUILD_SHARED=1) | ||||
| # else() | ||||
| add_library(pd-backend-desktop STATIC | ||||
| source/li_backend_gl2.cpp | ||||
| source/pd_hid_glfw.cpp) | ||||
| #endif() | ||||
| set(SRC | ||||
|     source/bknd-gfx.cpp | ||||
|     source/bknd-hid.cpp | ||||
|     source/pd-desktop.cpp | ||||
| ) | ||||
|  | ||||
| target_compile_definitions(pd-backend-desktop PUBLIC | ||||
|      -DPD_BKND_DESKTOP_STATIC=1) | ||||
| target_include_directories(pd-backend-desktop PUBLIC include) | ||||
| target_link_libraries(pd-backend-desktop PUBLIC glad glfw palladium ${EXTRA_LIBS}) | ||||
| pd_add_lib(pd-desktop SRC_FILES ${SRC}) | ||||
| target_include_directories(pd-desktop PUBLIC include) | ||||
| target_link_libraries(pd-desktop PUBLIC palladium glad glfw) | ||||
|   | ||||
							
								
								
									
										0
									
								
								backends/desktop/glad/CMakeLists.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								backends/desktop/glad/CMakeLists.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										622
									
								
								backends/desktop/glad/include/KHR/khrplatform.h
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										622
									
								
								backends/desktop/glad/include/KHR/khrplatform.h
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -1,311 +1,311 @@ | ||||
| #ifndef __khrplatform_h_ | ||||
| #define __khrplatform_h_ | ||||
|  | ||||
| /* | ||||
| ** Copyright (c) 2008-2018 The Khronos Group Inc. | ||||
| ** | ||||
| ** Permission is hereby granted, free of charge, to any person obtaining a | ||||
| ** copy of this software and/or associated documentation files (the | ||||
| ** "Materials"), to deal in the Materials without restriction, including | ||||
| ** without limitation the rights to use, copy, modify, merge, publish, | ||||
| ** distribute, sublicense, and/or sell copies of the Materials, and to | ||||
| ** permit persons to whom the Materials are furnished to do so, subject to | ||||
| ** the following conditions: | ||||
| ** | ||||
| ** The above copyright notice and this permission notice shall be included | ||||
| ** in all copies or substantial portions of the Materials. | ||||
| ** | ||||
| ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||||
| ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||||
| ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||||
| ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||||
| ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. | ||||
| */ | ||||
|  | ||||
| /* Khronos platform-specific types and definitions. | ||||
|  * | ||||
|  * The master copy of khrplatform.h is maintained in the Khronos EGL | ||||
|  * Registry repository at https://github.com/KhronosGroup/EGL-Registry | ||||
|  * The last semantic modification to khrplatform.h was at commit ID: | ||||
|  *      67a3e0864c2d75ea5287b9f3d2eb74a745936692 | ||||
|  * | ||||
|  * Adopters may modify this file to suit their platform. Adopters are | ||||
|  * encouraged to submit platform specific modifications to the Khronos | ||||
|  * group so that they can be included in future versions of this file. | ||||
|  * Please submit changes by filing pull requests or issues on | ||||
|  * the EGL Registry repository linked above. | ||||
|  * | ||||
|  * | ||||
|  * See the Implementer's Guidelines for information about where this file | ||||
|  * should be located on your system and for more details of its use: | ||||
|  *    http://www.khronos.org/registry/implementers_guide.pdf | ||||
|  * | ||||
|  * This file should be included as | ||||
|  *        #include <KHR/khrplatform.h> | ||||
|  * by Khronos client API header files that use its types and defines. | ||||
|  * | ||||
|  * The types in khrplatform.h should only be used to define API-specific types. | ||||
|  * | ||||
|  * Types defined in khrplatform.h: | ||||
|  *    khronos_int8_t              signed   8  bit | ||||
|  *    khronos_uint8_t             unsigned 8  bit | ||||
|  *    khronos_int16_t             signed   16 bit | ||||
|  *    khronos_uint16_t            unsigned 16 bit | ||||
|  *    khronos_int32_t             signed   32 bit | ||||
|  *    khronos_uint32_t            unsigned 32 bit | ||||
|  *    khronos_int64_t             signed   64 bit | ||||
|  *    khronos_uint64_t            unsigned 64 bit | ||||
|  *    khronos_intptr_t            signed   same number of bits as a pointer | ||||
|  *    khronos_uintptr_t           unsigned same number of bits as a pointer | ||||
|  *    khronos_ssize_t             signed   size | ||||
|  *    khronos_usize_t             unsigned size | ||||
|  *    khronos_float_t             signed   32 bit floating point | ||||
|  *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds | ||||
|  *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in | ||||
|  *                                         nanoseconds | ||||
|  *    khronos_stime_nanoseconds_t signed time interval in nanoseconds | ||||
|  *    khronos_boolean_enum_t      enumerated boolean type. This should | ||||
|  *      only be used as a base type when a client API's boolean type is | ||||
|  *      an enum. Client APIs which use an integer or other type for | ||||
|  *      booleans cannot use this as the base type for their boolean. | ||||
|  * | ||||
|  * Tokens defined in khrplatform.h: | ||||
|  * | ||||
|  *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. | ||||
|  * | ||||
|  *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. | ||||
|  *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. | ||||
|  * | ||||
|  * Calling convention macros defined in this file: | ||||
|  *    KHRONOS_APICALL | ||||
|  *    KHRONOS_APIENTRY | ||||
|  *    KHRONOS_APIATTRIBUTES | ||||
|  * | ||||
|  * These may be used in function prototypes as: | ||||
|  * | ||||
|  *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname( | ||||
|  *                                  int arg1, | ||||
|  *                                  int arg2) KHRONOS_APIATTRIBUTES; | ||||
|  */ | ||||
|  | ||||
| #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) | ||||
| #   define KHRONOS_STATIC 1 | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APICALL | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This precedes the return type of the function in the function prototype. | ||||
|  */ | ||||
| #if defined(KHRONOS_STATIC) | ||||
|     /* If the preprocessor constant KHRONOS_STATIC is defined, make the | ||||
|      * header compatible with static linking. */ | ||||
| #   define KHRONOS_APICALL | ||||
| #elif defined(_WIN32) | ||||
| #   define KHRONOS_APICALL __declspec(dllimport) | ||||
| #elif defined (__SYMBIAN32__) | ||||
| #   define KHRONOS_APICALL IMPORT_C | ||||
| #elif defined(__ANDROID__) | ||||
| #   define KHRONOS_APICALL __attribute__((visibility("default"))) | ||||
| #else | ||||
| #   define KHRONOS_APICALL | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APIENTRY | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This follows the return type of the function  and precedes the function | ||||
|  * name in the function prototype. | ||||
|  */ | ||||
| #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) | ||||
|     /* Win32 but not WinCE */ | ||||
| #   define KHRONOS_APIENTRY __stdcall | ||||
| #else | ||||
| #   define KHRONOS_APIENTRY | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APIATTRIBUTES | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This follows the closing parenthesis of the function prototype arguments. | ||||
|  */ | ||||
| #if defined (__ARMCC_2__) | ||||
| #define KHRONOS_APIATTRIBUTES __softfp | ||||
| #else | ||||
| #define KHRONOS_APIATTRIBUTES | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * basic type definitions | ||||
|  *-----------------------------------------------------------------------*/ | ||||
| #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Using <stdint.h> | ||||
|  */ | ||||
| #include <stdint.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
| /* | ||||
|  * To support platform where unsigned long cannot be used interchangeably with | ||||
|  * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. | ||||
|  * Ideally, we could just use (u)intptr_t everywhere, but this could result in | ||||
|  * ABI breakage if khronos_uintptr_t is changed from unsigned long to | ||||
|  * unsigned long long or similar (this results in different C++ name mangling). | ||||
|  * To avoid changes for existing platforms, we restrict usage of intptr_t to | ||||
|  * platforms where the size of a pointer is larger than the size of long. | ||||
|  */ | ||||
| #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) | ||||
| #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ | ||||
| #define KHRONOS_USE_INTPTR_T | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| #elif defined(__VMS ) || defined(__sgi) | ||||
|  | ||||
| /* | ||||
|  * Using <inttypes.h> | ||||
|  */ | ||||
| #include <inttypes.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) | ||||
|  | ||||
| /* | ||||
|  * Win32 | ||||
|  */ | ||||
| typedef __int32                 khronos_int32_t; | ||||
| typedef unsigned __int32        khronos_uint32_t; | ||||
| typedef __int64                 khronos_int64_t; | ||||
| typedef unsigned __int64        khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif defined(__sun__) || defined(__digital__) | ||||
|  | ||||
| /* | ||||
|  * Sun or Digital | ||||
|  */ | ||||
| typedef int                     khronos_int32_t; | ||||
| typedef unsigned int            khronos_uint32_t; | ||||
| #if defined(__arch64__) || defined(_LP64) | ||||
| typedef long int                khronos_int64_t; | ||||
| typedef unsigned long int       khronos_uint64_t; | ||||
| #else | ||||
| typedef long long int           khronos_int64_t; | ||||
| typedef unsigned long long int  khronos_uint64_t; | ||||
| #endif /* __arch64__ */ | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif 0 | ||||
|  | ||||
| /* | ||||
|  * Hypothetical platform with no float or int64 support | ||||
|  */ | ||||
| typedef int                     khronos_int32_t; | ||||
| typedef unsigned int            khronos_uint32_t; | ||||
| #define KHRONOS_SUPPORT_INT64   0 | ||||
| #define KHRONOS_SUPPORT_FLOAT   0 | ||||
|  | ||||
| #else | ||||
|  | ||||
| /* | ||||
|  * Generic fallback | ||||
|  */ | ||||
| #include <stdint.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Types that are (so far) the same on all platforms | ||||
|  */ | ||||
| typedef signed   char          khronos_int8_t; | ||||
| typedef unsigned char          khronos_uint8_t; | ||||
| typedef signed   short int     khronos_int16_t; | ||||
| typedef unsigned short int     khronos_uint16_t; | ||||
|  | ||||
| /* | ||||
|  * Types that differ between LLP64 and LP64 architectures - in LLP64, | ||||
|  * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears | ||||
|  * to be the only LLP64 architecture in current use. | ||||
|  */ | ||||
| #ifdef KHRONOS_USE_INTPTR_T | ||||
| typedef intptr_t               khronos_intptr_t; | ||||
| typedef uintptr_t              khronos_uintptr_t; | ||||
| #elif defined(_WIN64) | ||||
| typedef signed   long long int khronos_intptr_t; | ||||
| typedef unsigned long long int khronos_uintptr_t; | ||||
| #else | ||||
| typedef signed   long  int     khronos_intptr_t; | ||||
| typedef unsigned long  int     khronos_uintptr_t; | ||||
| #endif | ||||
|  | ||||
| #if defined(_WIN64) | ||||
| typedef signed   long long int khronos_ssize_t; | ||||
| typedef unsigned long long int khronos_usize_t; | ||||
| #else | ||||
| typedef signed   long  int     khronos_ssize_t; | ||||
| typedef unsigned long  int     khronos_usize_t; | ||||
| #endif | ||||
|  | ||||
| #if KHRONOS_SUPPORT_FLOAT | ||||
| /* | ||||
|  * Float type | ||||
|  */ | ||||
| typedef          float         khronos_float_t; | ||||
| #endif | ||||
|  | ||||
| #if KHRONOS_SUPPORT_INT64 | ||||
| /* Time types | ||||
|  * | ||||
|  * These types can be used to represent a time interval in nanoseconds or | ||||
|  * an absolute Unadjusted System Time.  Unadjusted System Time is the number | ||||
|  * of nanoseconds since some arbitrary system event (e.g. since the last | ||||
|  * time the system booted).  The Unadjusted System Time is an unsigned | ||||
|  * 64 bit value that wraps back to 0 every 584 years.  Time intervals | ||||
|  * may be either signed or unsigned. | ||||
|  */ | ||||
| typedef khronos_uint64_t       khronos_utime_nanoseconds_t; | ||||
| typedef khronos_int64_t        khronos_stime_nanoseconds_t; | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|  * Dummy value used to pad enum types to 32 bits. | ||||
|  */ | ||||
| #ifndef KHRONOS_MAX_ENUM | ||||
| #define KHRONOS_MAX_ENUM 0x7FFFFFFF | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|  * Enumerated boolean type | ||||
|  * | ||||
|  * Values other than zero should be considered to be true.  Therefore | ||||
|  * comparisons should not be made against KHRONOS_TRUE. | ||||
|  */ | ||||
| typedef enum { | ||||
|     KHRONOS_FALSE = 0, | ||||
|     KHRONOS_TRUE  = 1, | ||||
|     KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM | ||||
| } khronos_boolean_enum_t; | ||||
|  | ||||
| #endif /* __khrplatform_h_ */ | ||||
| #ifndef __khrplatform_h_ | ||||
| #define __khrplatform_h_ | ||||
|  | ||||
| /* | ||||
| ** Copyright (c) 2008-2018 The Khronos Group Inc. | ||||
| ** | ||||
| ** Permission is hereby granted, free of charge, to any person obtaining a | ||||
| ** copy of this software and/or associated documentation files (the | ||||
| ** "Materials"), to deal in the Materials without restriction, including | ||||
| ** without limitation the rights to use, copy, modify, merge, publish, | ||||
| ** distribute, sublicense, and/or sell copies of the Materials, and to | ||||
| ** permit persons to whom the Materials are furnished to do so, subject to | ||||
| ** the following conditions: | ||||
| ** | ||||
| ** The above copyright notice and this permission notice shall be included | ||||
| ** in all copies or substantial portions of the Materials. | ||||
| ** | ||||
| ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||||
| ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||||
| ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||||
| ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||||
| ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. | ||||
| */ | ||||
|  | ||||
| /* Khronos platform-specific types and definitions. | ||||
|  * | ||||
|  * The master copy of khrplatform.h is maintained in the Khronos EGL | ||||
|  * Registry repository at https://github.com/KhronosGroup/EGL-Registry | ||||
|  * The last semantic modification to khrplatform.h was at commit ID: | ||||
|  *      67a3e0864c2d75ea5287b9f3d2eb74a745936692 | ||||
|  * | ||||
|  * Adopters may modify this file to suit their platform. Adopters are | ||||
|  * encouraged to submit platform specific modifications to the Khronos | ||||
|  * group so that they can be included in future versions of this file. | ||||
|  * Please submit changes by filing pull requests or issues on | ||||
|  * the EGL Registry repository linked above. | ||||
|  * | ||||
|  * | ||||
|  * See the Implementer's Guidelines for information about where this file | ||||
|  * should be located on your system and for more details of its use: | ||||
|  *    http://www.khronos.org/registry/implementers_guide.pdf | ||||
|  * | ||||
|  * This file should be included as | ||||
|  *        #include <KHR/khrplatform.h> | ||||
|  * by Khronos client API header files that use its types and defines. | ||||
|  * | ||||
|  * The types in khrplatform.h should only be used to define API-specific types. | ||||
|  * | ||||
|  * Types defined in khrplatform.h: | ||||
|  *    khronos_int8_t              signed   8  bit | ||||
|  *    khronos_uint8_t             unsigned 8  bit | ||||
|  *    khronos_int16_t             signed   16 bit | ||||
|  *    khronos_uint16_t            unsigned 16 bit | ||||
|  *    khronos_int32_t             signed   32 bit | ||||
|  *    khronos_uint32_t            unsigned 32 bit | ||||
|  *    khronos_int64_t             signed   64 bit | ||||
|  *    khronos_uint64_t            unsigned 64 bit | ||||
|  *    khronos_intptr_t            signed   same number of bits as a pointer | ||||
|  *    khronos_uintptr_t           unsigned same number of bits as a pointer | ||||
|  *    khronos_ssize_t             signed   size | ||||
|  *    khronos_usize_t             unsigned size | ||||
|  *    khronos_float_t             signed   32 bit floating point | ||||
|  *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds | ||||
|  *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in | ||||
|  *                                         nanoseconds | ||||
|  *    khronos_stime_nanoseconds_t signed time interval in nanoseconds | ||||
|  *    khronos_boolean_enum_t      enumerated boolean type. This should | ||||
|  *      only be used as a base type when a client API's boolean type is | ||||
|  *      an enum. Client APIs which use an integer or other type for | ||||
|  *      booleans cannot use this as the base type for their boolean. | ||||
|  * | ||||
|  * Tokens defined in khrplatform.h: | ||||
|  * | ||||
|  *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. | ||||
|  * | ||||
|  *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. | ||||
|  *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. | ||||
|  * | ||||
|  * Calling convention macros defined in this file: | ||||
|  *    KHRONOS_APICALL | ||||
|  *    KHRONOS_APIENTRY | ||||
|  *    KHRONOS_APIATTRIBUTES | ||||
|  * | ||||
|  * These may be used in function prototypes as: | ||||
|  * | ||||
|  *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname( | ||||
|  *                                  int arg1, | ||||
|  *                                  int arg2) KHRONOS_APIATTRIBUTES; | ||||
|  */ | ||||
|  | ||||
| #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) | ||||
| #   define KHRONOS_STATIC 1 | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APICALL | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This precedes the return type of the function in the function prototype. | ||||
|  */ | ||||
| #if defined(KHRONOS_STATIC) | ||||
|     /* If the preprocessor constant KHRONOS_STATIC is defined, make the | ||||
|      * header compatible with static linking. */ | ||||
| #   define KHRONOS_APICALL | ||||
| #elif defined(_WIN32) | ||||
| #   define KHRONOS_APICALL __declspec(dllimport) | ||||
| #elif defined (__SYMBIAN32__) | ||||
| #   define KHRONOS_APICALL IMPORT_C | ||||
| #elif defined(__ANDROID__) | ||||
| #   define KHRONOS_APICALL __attribute__((visibility("default"))) | ||||
| #else | ||||
| #   define KHRONOS_APICALL | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APIENTRY | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This follows the return type of the function  and precedes the function | ||||
|  * name in the function prototype. | ||||
|  */ | ||||
| #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) | ||||
|     /* Win32 but not WinCE */ | ||||
| #   define KHRONOS_APIENTRY __stdcall | ||||
| #else | ||||
| #   define KHRONOS_APIENTRY | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * Definition of KHRONOS_APIATTRIBUTES | ||||
|  *------------------------------------------------------------------------- | ||||
|  * This follows the closing parenthesis of the function prototype arguments. | ||||
|  */ | ||||
| #if defined (__ARMCC_2__) | ||||
| #define KHRONOS_APIATTRIBUTES __softfp | ||||
| #else | ||||
| #define KHRONOS_APIATTRIBUTES | ||||
| #endif | ||||
|  | ||||
| /*------------------------------------------------------------------------- | ||||
|  * basic type definitions | ||||
|  *-----------------------------------------------------------------------*/ | ||||
| #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Using <stdint.h> | ||||
|  */ | ||||
| #include <stdint.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
| /* | ||||
|  * To support platform where unsigned long cannot be used interchangeably with | ||||
|  * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. | ||||
|  * Ideally, we could just use (u)intptr_t everywhere, but this could result in | ||||
|  * ABI breakage if khronos_uintptr_t is changed from unsigned long to | ||||
|  * unsigned long long or similar (this results in different C++ name mangling). | ||||
|  * To avoid changes for existing platforms, we restrict usage of intptr_t to | ||||
|  * platforms where the size of a pointer is larger than the size of long. | ||||
|  */ | ||||
| #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) | ||||
| #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ | ||||
| #define KHRONOS_USE_INTPTR_T | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| #elif defined(__VMS ) || defined(__sgi) | ||||
|  | ||||
| /* | ||||
|  * Using <inttypes.h> | ||||
|  */ | ||||
| #include <inttypes.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) | ||||
|  | ||||
| /* | ||||
|  * Win32 | ||||
|  */ | ||||
| typedef __int32                 khronos_int32_t; | ||||
| typedef unsigned __int32        khronos_uint32_t; | ||||
| typedef __int64                 khronos_int64_t; | ||||
| typedef unsigned __int64        khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif defined(__sun__) || defined(__digital__) | ||||
|  | ||||
| /* | ||||
|  * Sun or Digital | ||||
|  */ | ||||
| typedef int                     khronos_int32_t; | ||||
| typedef unsigned int            khronos_uint32_t; | ||||
| #if defined(__arch64__) || defined(_LP64) | ||||
| typedef long int                khronos_int64_t; | ||||
| typedef unsigned long int       khronos_uint64_t; | ||||
| #else | ||||
| typedef long long int           khronos_int64_t; | ||||
| typedef unsigned long long int  khronos_uint64_t; | ||||
| #endif /* __arch64__ */ | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #elif 0 | ||||
|  | ||||
| /* | ||||
|  * Hypothetical platform with no float or int64 support | ||||
|  */ | ||||
| typedef int                     khronos_int32_t; | ||||
| typedef unsigned int            khronos_uint32_t; | ||||
| #define KHRONOS_SUPPORT_INT64   0 | ||||
| #define KHRONOS_SUPPORT_FLOAT   0 | ||||
|  | ||||
| #else | ||||
|  | ||||
| /* | ||||
|  * Generic fallback | ||||
|  */ | ||||
| #include <stdint.h> | ||||
| typedef int32_t                 khronos_int32_t; | ||||
| typedef uint32_t                khronos_uint32_t; | ||||
| typedef int64_t                 khronos_int64_t; | ||||
| typedef uint64_t                khronos_uint64_t; | ||||
| #define KHRONOS_SUPPORT_INT64   1 | ||||
| #define KHRONOS_SUPPORT_FLOAT   1 | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Types that are (so far) the same on all platforms | ||||
|  */ | ||||
| typedef signed   char          khronos_int8_t; | ||||
| typedef unsigned char          khronos_uint8_t; | ||||
| typedef signed   short int     khronos_int16_t; | ||||
| typedef unsigned short int     khronos_uint16_t; | ||||
|  | ||||
| /* | ||||
|  * Types that differ between LLP64 and LP64 architectures - in LLP64, | ||||
|  * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears | ||||
|  * to be the only LLP64 architecture in current use. | ||||
|  */ | ||||
| #ifdef KHRONOS_USE_INTPTR_T | ||||
| typedef intptr_t               khronos_intptr_t; | ||||
| typedef uintptr_t              khronos_uintptr_t; | ||||
| #elif defined(_WIN64) | ||||
| typedef signed   long long int khronos_intptr_t; | ||||
| typedef unsigned long long int khronos_uintptr_t; | ||||
| #else | ||||
| typedef signed   long  int     khronos_intptr_t; | ||||
| typedef unsigned long  int     khronos_uintptr_t; | ||||
| #endif | ||||
|  | ||||
| #if defined(_WIN64) | ||||
| typedef signed   long long int khronos_ssize_t; | ||||
| typedef unsigned long long int khronos_usize_t; | ||||
| #else | ||||
| typedef signed   long  int     khronos_ssize_t; | ||||
| typedef unsigned long  int     khronos_usize_t; | ||||
| #endif | ||||
|  | ||||
| #if KHRONOS_SUPPORT_FLOAT | ||||
| /* | ||||
|  * Float type | ||||
|  */ | ||||
| typedef          float         khronos_float_t; | ||||
| #endif | ||||
|  | ||||
| #if KHRONOS_SUPPORT_INT64 | ||||
| /* Time types | ||||
|  * | ||||
|  * These types can be used to represent a time interval in nanoseconds or | ||||
|  * an absolute Unadjusted System Time.  Unadjusted System Time is the number | ||||
|  * of nanoseconds since some arbitrary system event (e.g. since the last | ||||
|  * time the system booted).  The Unadjusted System Time is an unsigned | ||||
|  * 64 bit value that wraps back to 0 every 584 years.  Time intervals | ||||
|  * may be either signed or unsigned. | ||||
|  */ | ||||
| typedef khronos_uint64_t       khronos_utime_nanoseconds_t; | ||||
| typedef khronos_int64_t        khronos_stime_nanoseconds_t; | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|  * Dummy value used to pad enum types to 32 bits. | ||||
|  */ | ||||
| #ifndef KHRONOS_MAX_ENUM | ||||
| #define KHRONOS_MAX_ENUM 0x7FFFFFFF | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|  * Enumerated boolean type | ||||
|  * | ||||
|  * Values other than zero should be considered to be true.  Therefore | ||||
|  * comparisons should not be made against KHRONOS_TRUE. | ||||
|  */ | ||||
| typedef enum { | ||||
|     KHRONOS_FALSE = 0, | ||||
|     KHRONOS_TRUE  = 1, | ||||
|     KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM | ||||
| } khronos_boolean_enum_t; | ||||
|  | ||||
| #endif /* __khrplatform_h_ */ | ||||
|   | ||||
							
								
								
									
										10338
									
								
								backends/desktop/glad/include/glad/glad.h
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										10338
									
								
								backends/desktop/glad/include/glad/glad.h
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										5064
									
								
								backends/desktop/glad/source/glad.c
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										5064
									
								
								backends/desktop/glad/source/glad.c
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,46 +0,0 @@ | ||||
| #include <glad/glad.h> | ||||
|  | ||||
| /** SEPARATOR */ | ||||
| #include <GLFW/glfw3.h> | ||||
| /** SEPARATOR */ | ||||
| #include <pd/core/core.hpp> | ||||
| #include <pd/lithium/backend.hpp> | ||||
| #include <pd_p_bknd_api.hpp> | ||||
|  | ||||
| namespace PD { | ||||
| namespace LI { | ||||
| class PD_BKND_DESKTOP_API Backend_GL2 : public PD::LI::Backend { | ||||
|  public: | ||||
|   Backend_GL2() : LI::Backend("OpenGL2") {} | ||||
|   ~Backend_GL2() {} | ||||
|  | ||||
|   PD_SMART_CTOR(Backend_GL2) | ||||
|  | ||||
|   void Init() override; | ||||
|   void Deinit() override; | ||||
|   void NewFrame() override; | ||||
|   void BindTexture(PD::LI::TexAddress addr) override; | ||||
|   void RenderDrawData(const PD::Vec<PD::LI::Command::Ref>& Commands) override; | ||||
|   PD::LI::Texture::Ref LoadTexture( | ||||
|       const std::vector<PD::u8>& pixels, int w, int h, | ||||
|       PD::LI::Texture::Type type = PD::LI::Texture::Type::RGBA32, | ||||
|       PD::LI::Texture::Filter filter = | ||||
|           PD::LI::Texture::Filter::LINEAR) override; | ||||
|  | ||||
|  private: | ||||
|   PD::Vec<PD::LI::Vertex> VertexBuffer; | ||||
|   PD::Vec<PD::u16> IndexBuffer; | ||||
|   size_t CurrentVertex = 0; | ||||
|   size_t CurrentIndex = 0; | ||||
|   GLuint Shader; | ||||
|   GLuint pLocProjection; | ||||
|   GLuint pLocTex; | ||||
|   Mat4 Projection; | ||||
|   GLuint VBO, IBO; | ||||
|   // For Stats | ||||
|   PD::u32 num_vtx = 0; | ||||
|   PD::u32 num_idx = 0; | ||||
| }; | ||||
|  | ||||
| }  // namespace LI | ||||
| }  // namespace PD | ||||
							
								
								
									
										38
									
								
								backends/desktop/include/pd_p_bknd_api.hpp → backends/desktop/include/pd-desktop.hpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										38
									
								
								backends/desktop/include/pd_p_bknd_api.hpp → backends/desktop/include/pd-desktop.hpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -22,37 +22,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
| */ | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
| #include <pd-desktop/bknd-gfx.hpp> | ||||
| #include <pd-desktop/bknd-hid.hpp> | ||||
| 
 | ||||
| #ifdef PD_BKND_DESKTOP_STATIC | ||||
| #if defined(__3DS__)  // 3ds Specific
 | ||||
| #error "Desktop backend is not supported on the 3ds!" | ||||
| #endif | ||||
| #define PD_BKND_DESKTOP_API | ||||
| #else | ||||
| #ifdef _WIN32  // Windows (MSVC Tested)
 | ||||
| #ifdef PD_BKND_DESKTOP_BUILD_SHARED | ||||
| #define PD_BKND_DESKTOP_API __declspec(dllexport) | ||||
| #else | ||||
| #define PD_BKND_DESKTOP_API __declspec(dllimport) | ||||
| #endif | ||||
| #elif defined(__APPLE__)  // macOS (untested yet)
 | ||||
| #ifdef PD_BKND_DESKTOP_BUILD_SHARED | ||||
| #define PD_BKND_DESKTOP_API __attribute__((visibility("default"))) | ||||
| #else | ||||
| #define PD_BKND_DESKTOP_API | ||||
| #endif | ||||
| #elif defined(__linux__)  // Linux (untested yet)
 | ||||
| #ifdef PD_BKND_DESKTOP_BUILD_SHARED | ||||
| #define PD_BKND_DESKTOP_API __attribute__((visibility("default"))) | ||||
| #else | ||||
| #define PD_BKND_DESKTOP_API | ||||
| #endif | ||||
| #elif defined(__3DS__)  // 3ds Specific
 | ||||
| #error "Desktop backend is not supported on the 3ds!" | ||||
| #else | ||||
| #define PD_BKND_DESKTOP_API | ||||
| #endif | ||||
| #endif | ||||
| namespace PD { | ||||
| void Init(void* data = nullptr); | ||||
| } | ||||
							
								
								
									
										70
									
								
								backends/desktop/include/pd-desktop/bknd-gfx.hpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										70
									
								
								backends/desktop/include/pd-desktop/bknd-gfx.hpp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| #pragma once | ||||
|  | ||||
| /* | ||||
| MIT License | ||||
|  | ||||
| Copyright (c) 2024 - 2025 tobid7 | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #include <glad/glad.h> | ||||
|  | ||||
| /** SEPARATOR */ | ||||
| #include <GLFW/glfw3.h> | ||||
| /** SEPARATOR */ | ||||
|  | ||||
| #include <pd/lithium/lithium.hpp> | ||||
|  | ||||
| namespace PD { | ||||
| namespace Li { | ||||
| class GfxGL2 : public GfxDriver { | ||||
|  public: | ||||
|   GfxGL2() : GfxDriver("OpenGL2") {} | ||||
|   ~GfxGL2() = default; | ||||
|  | ||||
|   PD_SHARED(GfxGL2); | ||||
|  | ||||
|   void Init() override; | ||||
|   void Deinit() override; | ||||
|   void NewFrame() override; | ||||
|   void BindTex(PD::Li::TexAddress addr) override; | ||||
|   void RenderDrawData( | ||||
|       const std::vector<PD::Li::Command::Ref>& Commands) override; | ||||
|   PD::Li::Texture::Ref LoadTex( | ||||
|       const std::vector<PD::u8>& pixels, int w, int h, | ||||
|       PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32, | ||||
|       PD::Li::Texture::Filter filter = | ||||
|           PD::Li::Texture::Filter::LINEAR) override; | ||||
|  | ||||
|   PD::Vec<Vertex> VertexBuffer; | ||||
|   PD::Vec<PD::u16> IndexBuffer; | ||||
|   size_t CurrentVertex = 0; | ||||
|   size_t CurrentIndex = 0; | ||||
|   GLuint Shader; | ||||
|   GLuint pLocProjection; | ||||
|   GLuint pLocTex; | ||||
|   Mat4 Projection; | ||||
|   GLuint VBO, IBO; | ||||
|   // Stats oder so IDNK zu lange her | ||||
|   PD::u32 NumVtx; | ||||
|   PD::u32 NumIdx; | ||||
| }; | ||||
| }  // namespace Li | ||||
| }  // namespace PD | ||||
							
								
								
									
										19
									
								
								backends/desktop/include/pd_hid_glfw.hpp → backends/desktop/include/pd-desktop/bknd-hid.hpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										19
									
								
								backends/desktop/include/pd_hid_glfw.hpp → backends/desktop/include/pd-desktop/bknd-hid.hpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -2,7 +2,8 @@ | ||||
| 
 | ||||
| /*
 | ||||
| MIT License | ||||
| Copyright (c) 2024 - 2025 René Amthor (tobid7) | ||||
| 
 | ||||
| Copyright (c) 2024 - 2025 tobid7 | ||||
| 
 | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| @@ -25,25 +26,19 @@ SOFTWARE. | ||||
| 
 | ||||
| #include <GLFW/glfw3.h> | ||||
| 
 | ||||
| #include <pd/core/hid_driver.hpp> | ||||
| #include <pd_p_bknd_api.hpp> | ||||
| #include <pd/drivers/drivers.hpp> | ||||
| 
 | ||||
| namespace PD { | ||||
| class PD_BKND_DESKTOP_API HidGLFW : public Hid { | ||||
| class HidGLFW : public HidDriver { | ||||
|  public: | ||||
|   /**
 | ||||
|    * Constructor to setup Key binds | ||||
|    */ | ||||
|   HidGLFW(GLFWwindow* win); | ||||
|   ~HidGLFW() = default; | ||||
|   PD_SMART_CTOR(HidGLFW) | ||||
| 
 | ||||
|   /**
 | ||||
|    * Overrideing the Update Function for Input Checking etc | ||||
|    */ | ||||
|   PD_SHARED(HidGLFW); | ||||
| 
 | ||||
|   void Update() override; | ||||
| 
 | ||||
|  private: | ||||
|   /** Data section */ | ||||
|   GLFWwindow* Window; | ||||
|   int PrevState; | ||||
| }; | ||||
| @@ -1,132 +0,0 @@ | ||||
| #pragma once | ||||
|  | ||||
| /* | ||||
| MIT License | ||||
| Copyright (c) 2024 - 2025 René Amthor (tobid7) | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #ifdef _WIN32 | ||||
| #include <winsock2.h> | ||||
| #include <ws2tcpip.h> | ||||
| #ifdef _MSVC | ||||
| #pragma comment(lib, "ws2_32.lib") | ||||
| #endif | ||||
| #else | ||||
| #include <arpa/inet.h> | ||||
| #include <netinet/in.h> | ||||
| #include <sys/socket.h> | ||||
| #include <unistd.h> | ||||
| #endif | ||||
|  | ||||
| #include <pd/net/backend.hpp> | ||||
| namespace PD { | ||||
| class NetBackendDesktop : public PD::Net::Backend { | ||||
|  public: | ||||
| #ifdef _WIN32 | ||||
|   NetBackendDesktop() : Net::Backend("Desktop (Windows)") { | ||||
| #else | ||||
|   NetBackendDesktop() : Net::Backend("Desktop (Unix)") { | ||||
| #endif | ||||
|   } | ||||
|   ~NetBackendDesktop() = default; | ||||
|   PD_SMART_CTOR(NetBackendDesktop) | ||||
|   bool Init() override { | ||||
| #ifdef _WIN32 | ||||
|     WSADATA wsa_data; | ||||
|     return (WSAStartup(MAKEWORD(2, 2), &wsa_data) == 0); | ||||
| #else | ||||
|     return true; | ||||
| #endif | ||||
|   } | ||||
|   void Deinit() override { | ||||
| #ifdef _WIN32 | ||||
|     WSACleanup(); | ||||
| #endif | ||||
|   } | ||||
|   int NewSocket() override { return socket(AF_INET, SOCK_STREAM, 0); } | ||||
|   void Close(int sock_id) override { | ||||
| #ifdef _WIN32 | ||||
|     closesocket(sock_id); | ||||
| #else | ||||
|     close(sock_id); | ||||
| #endif | ||||
|   } | ||||
|   int GetInvalidRef() const override { | ||||
| #ifdef _WIN32 | ||||
|     return INVALID_SOCKET; | ||||
| #else | ||||
|     return -1; | ||||
| #endif | ||||
|   } | ||||
|  | ||||
|   bool Bind(int sock_id, u16 port) override { | ||||
|     sockaddr_in addr{}; | ||||
|     addr.sin_family = AF_INET; | ||||
|     addr.sin_port = htons(port); | ||||
|     addr.sin_addr.s_addr = INADDR_ANY; | ||||
|     return bind(sock_id, (sockaddr*)&addr, sizeof(addr)) != -1; | ||||
|   } | ||||
|   bool Listen(int sock_id, int backlog = 5) override { | ||||
|     return listen(sock_id, backlog) != -1; | ||||
|   } | ||||
|  | ||||
|   bool WaitForRead(int sock_id, int timeout_ms) override { | ||||
|     fd_set set; | ||||
|     FD_ZERO(&set); | ||||
|     FD_SET(sock_id, &set); | ||||
|  | ||||
|     timeval timeout{}; | ||||
|     timeout.tv_sec = timeout_ms / 1000; | ||||
|     timeout.tv_usec = (timeout_ms % 1000) * 1000; | ||||
|  | ||||
|     int result = select(sock_id + 1, &set, nullptr, nullptr, &timeout); | ||||
|     return (result > 0 && FD_ISSET(sock_id, &set)); | ||||
|   } | ||||
|  | ||||
|   bool Accept(int sock_id, Net::Socket::Ref client) override { | ||||
|     int client_soc = accept(sock_id, nullptr, nullptr); | ||||
|     if (client_soc == GetInvalidRef()) { | ||||
|       return false; | ||||
|     } | ||||
|     client->pSocket = client_soc; | ||||
|     return true; | ||||
|   } | ||||
|   bool Connect(int sock_id, const std::string& ip, u16 port) override { | ||||
|     sockaddr_in addr{}; | ||||
|     addr.sin_family = AF_INET; | ||||
|     addr.sin_port = htons(port); | ||||
|     inet_pton(AF_INET, ip.c_str(), &addr.sin_addr); | ||||
|     return connect(sock_id, (sockaddr*)&addr, sizeof(addr)) != -1; | ||||
|   } | ||||
|   int Send(int sock_id, const std::string& data) override { | ||||
|     return send(sock_id, data.c_str(), static_cast<int>(data.size()), 0); | ||||
|   } | ||||
|   int Receive(int sock_id, std::string& data, int size = 1024) override { | ||||
|     char* tmp = new char[size]; | ||||
|     int res = recv(sock_id, tmp, size, 0); | ||||
|     if (res > 0) { | ||||
|       data.assign(tmp, res); | ||||
|     } | ||||
|     delete[] tmp; | ||||
|     return res; | ||||
|   } | ||||
| }; | ||||
| }  // namespace PD | ||||
							
								
								
									
										114
									
								
								backends/desktop/source/li_backend_gl2.cpp → backends/desktop/source/bknd-gfx.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										114
									
								
								backends/desktop/source/li_backend_gl2.cpp → backends/desktop/source/bknd-gfx.cpp
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -1,5 +1,31 @@ | ||||
| #include <li_backend_gl2.hpp> | ||||
| /*
 | ||||
| MIT License | ||||
| 
 | ||||
| Copyright (c) 2024 - 2025 tobid7 | ||||
| 
 | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
| 
 | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
| 
 | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| #include <pd-desktop/bknd-gfx.hpp> | ||||
| 
 | ||||
| namespace PD { | ||||
| namespace Li { | ||||
| const char* vertex_shader = R"( | ||||
|   #version 120 | ||||
|    | ||||
| @@ -35,8 +61,7 @@ const char* frag_shader = R"( | ||||
|   } | ||||
|   )"; | ||||
| 
 | ||||
| GLuint compileShader(const std::string& source, | ||||
|                                          GLenum type) { | ||||
| GLuint compileShader(const std::string& source, GLenum type) { | ||||
|   GLuint shader = glCreateShader(type); | ||||
|   const char* src = source.c_str(); | ||||
|   glShaderSource(shader, 1, &src, nullptr); | ||||
| @@ -53,9 +78,8 @@ GLuint compileShader(const std::string& source, | ||||
|   return shader; | ||||
| } | ||||
| 
 | ||||
| GLuint | ||||
| createShaderProgram(const std::string& vertexShaderSource, | ||||
|                     const std::string& fragmentShaderSource) { | ||||
| GLuint createShaderProgram(const std::string& vertexShaderSource, | ||||
|                            const std::string& fragmentShaderSource) { | ||||
|   GLuint vertexShader = compileShader(vertexShaderSource, GL_VERTEX_SHADER); | ||||
|   GLuint fragmentShader = | ||||
|       compileShader(fragmentShaderSource, GL_FRAGMENT_SHADER); | ||||
| @@ -79,9 +103,9 @@ createShaderProgram(const std::string& vertexShaderSource, | ||||
|   return shaderProgram; | ||||
| } | ||||
| 
 | ||||
| namespace PD { | ||||
| namespace LI { | ||||
| PD_BKND_DESKTOP_API void Backend_GL2::Init() { | ||||
| /** Actual Backend */ | ||||
| 
 | ||||
| void GfxGL2::Init() { | ||||
|   VertexBuffer.Resize(4 * 8192); | ||||
|   IndexBuffer.Resize(6 * 8192); | ||||
|   Shader = createShaderProgram(vertex_shader, frag_shader); | ||||
| @@ -93,17 +117,17 @@ PD_BKND_DESKTOP_API void Backend_GL2::Init() { | ||||
|   GLint _pos = glGetAttribLocation(Shader, "pos"); | ||||
|   GLint _uv = glGetAttribLocation(Shader, "uv"); | ||||
|   GLint _color = glGetAttribLocation(Shader, "color"); | ||||
|   glVertexAttribPointer(_pos, 2, GL_FLOAT, GL_FALSE, sizeof(PD::LI::Vertex), | ||||
|                         (void*)offsetof(PD::LI::Vertex, Pos)); | ||||
|   glVertexAttribPointer(_pos, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex), | ||||
|                         (void*)offsetof(PD::Li::Vertex, Pos)); | ||||
|   glEnableVertexAttribArray(_pos); | ||||
| 
 | ||||
|   glVertexAttribPointer(_uv, 2, GL_FLOAT, GL_FALSE, sizeof(PD::LI::Vertex), | ||||
|                         (void*)offsetof(PD::LI::Vertex, UV)); | ||||
|   glVertexAttribPointer(_uv, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex), | ||||
|                         (void*)offsetof(PD::Li::Vertex, UV)); | ||||
|   glEnableVertexAttribArray(_uv); | ||||
| 
 | ||||
|   glVertexAttribPointer(_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, | ||||
|                         sizeof(PD::LI::Vertex), | ||||
|                         (void*)offsetof(PD::LI::Vertex, Color)); | ||||
|                         sizeof(PD::Li::Vertex), | ||||
|                         (void*)offsetof(PD::Li::Vertex, Color)); | ||||
|   glEnableVertexAttribArray(_color); | ||||
| 
 | ||||
|   glGenBuffers(1, &IBO); | ||||
| @@ -116,12 +140,12 @@ PD_BKND_DESKTOP_API void Backend_GL2::Init() { | ||||
|   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | ||||
| } | ||||
| 
 | ||||
| PD_BKND_DESKTOP_API void Backend_GL2::Deinit() { | ||||
| void GfxGL2::Deinit() { | ||||
|   glDeleteBuffers(1, &VBO); | ||||
|   glDeleteBuffers(1, &IBO); | ||||
| } | ||||
| 
 | ||||
| PD_BKND_DESKTOP_API void Backend_GL2::NewFrame() { | ||||
| void GfxGL2::NewFrame() { | ||||
|   glViewport(0, 0, ViewPort.x, ViewPort.y); | ||||
|   glClearColor(ClearColor.x, ClearColor.y, ClearColor.z, ClearColor.w); | ||||
|   glClear(GL_COLOR_BUFFER_BIT); | ||||
| @@ -132,57 +156,56 @@ PD_BKND_DESKTOP_API void Backend_GL2::NewFrame() { | ||||
|   CurrentIndex = 0; | ||||
|   CurrentVertex = 0; | ||||
|   FrameCounter++; | ||||
|   VertexCounter = num_vtx; | ||||
|   IndexCounter = num_idx; | ||||
|   num_vtx = 0; | ||||
|   num_idx = 0; | ||||
|   VertexCounter = NumVtx; | ||||
|   IndexCounter = NumIdx; | ||||
|   NumVtx = 0; | ||||
|   NumIdx = 0; | ||||
| } | ||||
| 
 | ||||
| PD_BKND_DESKTOP_API void Backend_GL2::BindTexture(PD::LI::TexAddress addr) { | ||||
| void GfxGL2::BindTex(PD::Li::TexAddress addr) { | ||||
|   // Actually not using the Address as Address
 | ||||
|   glActiveTexture(GL_TEXTURE0); | ||||
|   glBindTexture(GL_TEXTURE_2D, (GLuint)addr); | ||||
|   glUniform1i(pLocTex, 0); | ||||
| } | ||||
| 
 | ||||
| PD_BKND_DESKTOP_API void Backend_GL2::RenderDrawData( | ||||
|     const PD::Vec<PD::LI::Command::Ref>& Commands) { | ||||
| void GfxGL2::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) { | ||||
|   glUseProgram(Shader); | ||||
|   size_t index = 0; | ||||
|   while (index < Commands.Size()) { | ||||
|     PD::LI::Texture::Ref Tex = Commands[index]->Tex; | ||||
|   while (index < Commands.size()) { | ||||
|     PD::Li::Texture::Ref Tex = Commands[index]->Tex; | ||||
|     if (!Tex) { | ||||
|       index++; | ||||
|       continue; | ||||
|     } | ||||
|     size_t StartIndex = CurrentIndex; | ||||
|     bool ScissorEnabled = Commands[index]->ScissorEnabled; | ||||
|     bool ScissorOn = Commands[index]->ScissorOn; | ||||
|     ivec4 ScissorRect = Commands[index]->ScissorRect; | ||||
| 
 | ||||
|     while (index < Commands.Size() && Commands[index]->Tex == Tex && | ||||
|            Commands[index]->ScissorEnabled == ScissorEnabled && | ||||
|     while (index < Commands.size() && Commands[index]->Tex == Tex && | ||||
|            Commands[index]->ScissorOn == ScissorOn && | ||||
|            Commands[index]->ScissorRect == ScissorRect) { | ||||
|       auto c = Commands[index]; | ||||
|       auto c = Commands[index].get(); | ||||
|       for (size_t i = 0; i < c->IndexBuffer.Size(); i++) { | ||||
|         num_idx++; | ||||
|         NumIdx++; | ||||
|         IndexBuffer[CurrentIndex++] = CurrentVertex + c->IndexBuffer.At(i); | ||||
|       } | ||||
|       for (size_t i = 0; i < c->VertexBuffer.Size(); i++) { | ||||
|         num_vtx++; | ||||
|         NumVtx++; | ||||
|         VertexBuffer[CurrentVertex++] = c->VertexBuffer.At(i); | ||||
|       } | ||||
|       index++; | ||||
|     } | ||||
|     if (ScissorEnabled) { | ||||
|     if (ScissorOn) { | ||||
|       glScissor(ScissorRect.x, ViewPort.y - (ScissorRect.y + ScissorRect.w), | ||||
|                 ScissorRect.z, ScissorRect.w); | ||||
|       glEnable(GL_SCISSOR_TEST); | ||||
|     } else { | ||||
|       glDisable(GL_SCISSOR_TEST); | ||||
|     } | ||||
|     BindTexture(Tex->Address); | ||||
|     BindTex(Tex->Address); | ||||
|     glBindBuffer(GL_ARRAY_BUFFER, VBO); | ||||
|     glBufferData(GL_ARRAY_BUFFER, CurrentVertex * sizeof(PD::LI::Vertex), | ||||
|     glBufferData(GL_ARRAY_BUFFER, CurrentVertex * sizeof(PD::Li::Vertex), | ||||
|                  &VertexBuffer[0], GL_DYNAMIC_DRAW); | ||||
| 
 | ||||
|     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO); | ||||
| @@ -194,37 +217,36 @@ PD_BKND_DESKTOP_API void Backend_GL2::RenderDrawData( | ||||
| 
 | ||||
|     glBindBuffer(GL_ARRAY_BUFFER, 0); | ||||
|     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | ||||
|     BindTexture(0); | ||||
|     BindTex(0); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| PD_BKND_DESKTOP_API PD::LI::Texture::Ref Backend_GL2::LoadTexture( | ||||
|     const std::vector<PD::u8>& pixels, int w, int h, PD::LI::Texture::Type type, | ||||
|     PD::LI::Texture::Filter filter) { | ||||
| PD::Li::Texture::Ref GfxGL2::LoadTex(const std::vector<PD::u8>& pixels, int w, | ||||
|                                      int h, PD::Li::Texture::Type type, | ||||
|                                      PD::Li::Texture::Filter filter) { | ||||
|   GLuint texID; | ||||
|   glGenTextures(1, &texID); | ||||
|   glBindTexture(GL_TEXTURE_2D, texID); | ||||
| 
 | ||||
|   // Set base format (Always using RGBA as base)
 | ||||
|   GLenum fmt = GL_RGBA; | ||||
|   if (type == PD::LI::Texture::Type::RGB24) { | ||||
|   if (type == PD::Li::Texture::Type::RGB24) { | ||||
|     fmt = GL_RGB; | ||||
|   } else if (type == PD::LI::Texture::Type::A8) { | ||||
|   } else if (type == PD::Li::Texture::Type::A8) { | ||||
|     fmt = GL_ALPHA; | ||||
|   } | ||||
|   glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, | ||||
|                pixels.data()); | ||||
|   if (filter == PD::LI::Texture::Filter::LINEAR) { | ||||
|   if (filter == PD::Li::Texture::Filter::LINEAR) { | ||||
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||||
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | ||||
|   } else if (filter == PD::LI::Texture::Filter::NEAREST) { | ||||
|   } else if (filter == PD::Li::Texture::Filter::NEAREST) { | ||||
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||||
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||||
|   } | ||||
|   glBindTexture(GL_TEXTURE_2D, 0); | ||||
|   auto res = PD::LI::Texture::New(texID, PD::ivec2(w, h)); | ||||
|   auto res = PD::Li::Texture::New(texID, PD::ivec2(w, h)); | ||||
|   return res; | ||||
| } | ||||
| 
 | ||||
| }  // namespace LI
 | ||||
| }  // namespace Li
 | ||||
| }  // namespace PD
 | ||||
							
								
								
									
										58
									
								
								backends/desktop/source/bknd-hid.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										58
									
								
								backends/desktop/source/bknd-hid.cpp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| /* | ||||
| MIT License | ||||
|  | ||||
| Copyright (c) 2024 - 2025 tobid7 | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #include <pd-desktop/bknd-hid.hpp> | ||||
|  | ||||
| namespace PD { | ||||
| HidGLFW::HidGLFW(GLFWwindow* win) : HidDriver("HidGLFW") { | ||||
|   Window = win; | ||||
|   pBinds[GLFW_MOUSE_BUTTON_LEFT] = Touch; | ||||
| } | ||||
|  | ||||
| void HidGLFW::Update() { | ||||
|   for (int i = 0; i < 2; i++) { | ||||
|     KeyEvents[i][Event_Down] = 0; | ||||
|     KeyEvents[i][Event_Held] = 0; | ||||
|     KeyEvents[i][Event_Up] = 0; | ||||
|   } | ||||
|   int state = glfwGetMouseButton(Window, GLFW_MOUSE_BUTTON_LEFT); | ||||
|   if (state == GLFW_PRESS) { | ||||
|     if (PrevState == GLFW_RELEASE) { | ||||
|       KeyEvents[0][Event_Down] |= Touch; | ||||
|     } | ||||
|     KeyEvents[0][Event_Held] |= Touch; | ||||
|   } else if (state == GLFW_RELEASE && PrevState == GLFW_PRESS) { | ||||
|     KeyEvents[0][Event_Up] |= Touch; | ||||
|   } | ||||
|  | ||||
|   PrevState = state; | ||||
|   if (pLocked) { | ||||
|     SwapTab(); | ||||
|   } | ||||
|   double x, y; | ||||
|   glfwGetCursorPos(Window, &x, &y); | ||||
|   pMouse[1] = pMouse[0];  // Cycle pMouse pos | ||||
|   pMouse[0] = fvec2(x, y); | ||||
| } | ||||
| }  // namespace PD | ||||
							
								
								
									
										43
									
								
								backends/desktop/source/pd-desktop.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								backends/desktop/source/pd-desktop.cpp
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| /* | ||||
| MIT License | ||||
|  | ||||
| Copyright (c) 2024 - 2025 tobid7 | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #include <palladium> | ||||
| #include <pd-desktop.hpp> | ||||
|  | ||||
| namespace PD { | ||||
| void Init(void* data) { | ||||
|   if (!data) { | ||||
|     std::cout << "[PD-DRIVERS] Error: pd-desktop requires GLFWwindow* " | ||||
|                  "reference as data " | ||||
|                  "input!" | ||||
|               << std::endl; | ||||
|     abort(); | ||||
|   } | ||||
|   // Dekstop Init Stage | ||||
|   // First use default OS Driver | ||||
|   PD::OS::Init(); | ||||
|   PD::Li::Gfx::Init(PD::Li::GfxGL2::New()); | ||||
|   PD::Hid::Init(PD::HidGLFW::New(reinterpret_cast<GLFWwindow*>(data))); | ||||
| } | ||||
| }  // namespace PD | ||||
| @@ -1,33 +0,0 @@ | ||||
| #include <pd_hid_glfw.hpp> | ||||
|  | ||||
| namespace PD { | ||||
| PD_BKND_DESKTOP_API HidGLFW::HidGLFW(GLFWwindow* win) : Hid("GLFW") { | ||||
|   Window = win; | ||||
|   binds[GLFW_MOUSE_BUTTON_LEFT] = Touch; | ||||
| } | ||||
| PD_BKND_DESKTOP_API void HidGLFW::Update() { | ||||
|   for (int i = 0; i < 2; i++) { | ||||
|     key_events[i][Event_Down] = 0; | ||||
|     key_events[i][Event_Held] = 0; | ||||
|     key_events[i][Event_Up] = 0; | ||||
|   } | ||||
|   int state = glfwGetMouseButton(Window, GLFW_MOUSE_BUTTON_LEFT); | ||||
|   if (state == GLFW_PRESS) { | ||||
|     if (PrevState == GLFW_RELEASE) { | ||||
|       key_events[0][Event_Down] |= Touch; | ||||
|     } | ||||
|     key_events[0][Event_Held] |= Touch; | ||||
|   } else if (state == GLFW_RELEASE && PrevState == GLFW_PRESS) { | ||||
|     key_events[0][Event_Up] |= Touch; | ||||
|   } | ||||
|  | ||||
|   PrevState = state; | ||||
|   if (locked) { | ||||
|     SwappyTable(); | ||||
|   } | ||||
|   double x, y; | ||||
|   glfwGetCursorPos(Window, &x, &y); | ||||
|   touch[1] = touch[0];  // Cycle touch pos | ||||
|   touch[0] = fvec2(x, y); | ||||
| } | ||||
| }  // namespace PD | ||||
		Reference in New Issue
	
	Block a user