@@ -34,10 +34,11 @@ namespace hgl
|
|||||||
std::cout<<(char *)str.c_str()<<std::endl;
|
std::cout<<(char *)str.c_str()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Log(LogLevel ll,const AnsiString &str)
|
// 对于不支持C++20的编译器还得用宏处理一下
|
||||||
{
|
// inline void Log(LogLevel ll,const AnsiString &str)
|
||||||
std::cout<<str.c_str()<<std::endl;
|
// {
|
||||||
}
|
// std::cout<<str.c_str()<<std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
inline void DebugLog(LogLevel ll,const UTF16String &str,const char *filename,int line,const char *funcname)
|
inline void DebugLog(LogLevel ll,const UTF16String &str,const char *filename,int line,const char *funcname)
|
||||||
{
|
{
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#define HGL_COMPILER_Microsoft HGL_MERGE32('M','S','C',' ')
|
#define HGL_COMPILER_Microsoft HGL_MERGE32('M','S','C',' ')
|
||||||
#define HGL_COMPILER_GNU HGL_MERGE32('G','N','U',' ')
|
#define HGL_COMPILER_GNU HGL_MERGE32('G','N','U',' ')
|
||||||
#define HGL_COMPILER_MinGW32 HGL_MERGE32('M','G','3','2')
|
#define HGL_COMPILER_MinGW32 HGL_MERGE32('M','G','3','2')
|
||||||
|
#define HGL_COMPILER_MinGW64 HGL_MERGE32('M','G','6','4')
|
||||||
#define HGL_COMPILER_Intel HGL_MERGE32('I','n','t','e')
|
#define HGL_COMPILER_Intel HGL_MERGE32('I','n','t','e')
|
||||||
#define HGL_COMPILER_IBM HGL_MERGE32('I','B','M',' ')
|
#define HGL_COMPILER_IBM HGL_MERGE32('I','B','M',' ')
|
||||||
#define HGL_COMPILER_DigitalMars HGL_MERGE32('D','i','M','a')
|
#define HGL_COMPILER_DigitalMars HGL_MERGE32('D','i','M','a')
|
||||||
@@ -191,6 +192,8 @@
|
|||||||
#define HGL_COMPILER HGL_COMPILER_PGI
|
#define HGL_COMPILER HGL_COMPILER_PGI
|
||||||
#elif defined(__MINGW32__)
|
#elif defined(__MINGW32__)
|
||||||
#define HGL_COMPILER HGL_COMPILER_MinGW32
|
#define HGL_COMPILER HGL_COMPILER_MinGW32
|
||||||
|
#elif defined(__MINGW64__)
|
||||||
|
#define HGL_COMPILER HGL_COMPILER_MinGW64
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define HGL_COMPILER HGL_COMPILER_GNU
|
#define HGL_COMPILER HGL_COMPILER_GNU
|
||||||
#else
|
#else
|
||||||
@@ -221,7 +224,9 @@
|
|||||||
#include<hgl/platform/compiler/Intel.h>
|
#include<hgl/platform/compiler/Intel.h>
|
||||||
#elif HGL_COMPILER == HGL_COMPILER_IBM
|
#elif HGL_COMPILER == HGL_COMPILER_IBM
|
||||||
#include<hgl/platform/compiler/IBM.h>
|
#include<hgl/platform/compiler/IBM.h>
|
||||||
#elif HGL_COMPILER == HGL_COMPILER_MINGW32
|
#elif HGL_COMPILER == HGL_COMPILER_MinGW32
|
||||||
|
#include<hgl/platform/compiler/GNU.h>
|
||||||
|
#elif HGL_COMPILER == HGL_COMPILER_MinGW64
|
||||||
#include<hgl/platform/compiler/GNU.h>
|
#include<hgl/platform/compiler/GNU.h>
|
||||||
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
#elif HGL_COMPILER == HGL_COMPILER_GNU
|
||||||
#include<hgl/platform/compiler/GNU.h>
|
#include<hgl/platform/compiler/GNU.h>
|
||||||
|
@@ -72,6 +72,14 @@
|
|||||||
|
|
||||||
#endif//__GNUC__
|
#endif//__GNUC__
|
||||||
|
|
||||||
|
// 假设 GCC 从 11 开始正式支持 char8_t( 这个我手头没有 11 ,不确定 )
|
||||||
|
#if __GNUC__ >= 11
|
||||||
|
using u8char = char8_t;
|
||||||
|
#else
|
||||||
|
using u8char = char;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存
|
#define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_"
|
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_"
|
||||||
|
@@ -4,13 +4,15 @@
|
|||||||
#define HGL_COMPILER_NAME OS_TEXT("Microsoft C/C++")
|
#define HGL_COMPILER_NAME OS_TEXT("Microsoft C/C++")
|
||||||
#define HGL_LIB_COMPILER_NAME OS_TEXT("MSC")
|
#define HGL_LIB_COMPILER_NAME OS_TEXT("MSC")
|
||||||
|
|
||||||
#if _MSC_VER < 1910 //Visual C++ 2017
|
#if _MSC_VER < 1900 //Visual C++ 2017
|
||||||
#error Please upgrade your compiler or development tools to Microsoft C/C++ 19.1 (Visual C++ 2017) or later.
|
#error Please upgrade your compiler or development tools to Microsoft C/C++ 19.1 (Visual C++ 2017) or later.
|
||||||
#else
|
#else
|
||||||
#if _MSC_VER >= 1920
|
#if _MSC_VER >= 1920
|
||||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.2") //Visual C++ 2019
|
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.2") //Visual C++ 2019
|
||||||
#elif _MSC_VER >= 1910
|
#elif _MSC_VER >= 1910
|
||||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.1") //Visual C++ 2017
|
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.1") //Visual C++ 2017
|
||||||
|
#elif _MSC_VER >= 1900
|
||||||
|
#define HGL_LIB_COMPILER_VERSION OS_TEXT("19.0") //Visual C++ 2015
|
||||||
#else
|
#else
|
||||||
#define HGL_LIB_COMPILER_VERSION OS_TEXT("Unknow")
|
#define HGL_LIB_COMPILER_VERSION OS_TEXT("Unknow")
|
||||||
#endif//_MSC_VER
|
#endif//_MSC_VER
|
||||||
|
@@ -51,33 +51,36 @@ using os_char =wchar_t;
|
|||||||
#define HGL_GL_WINDOW_INCLUDE_FILE <hgl/platform/WinOpenGL.h> //指定OpenGL窗口引用头文件
|
#define HGL_GL_WINDOW_INCLUDE_FILE <hgl/platform/WinOpenGL.h> //指定OpenGL窗口引用头文件
|
||||||
#define HGL_GL_WINDOW_CLASS WinGLWindow //指定OpenGL窗口类名称
|
#define HGL_GL_WINDOW_CLASS WinGLWindow //指定OpenGL窗口类名称
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
#if HGL_COMPILER == HGL_COMPILER_Microsoft
|
|
||||||
#define hgl_malloc(size) _aligned_malloc(size,HGL_MEM_ALIGN)
|
|
||||||
#define hgl_realloc(ptr,size) _aligned_realloc(ptr,size,HGL_MEM_ALIGN)
|
|
||||||
#define hgl_free _aligned_free
|
|
||||||
|
|
||||||
template<typename T>
|
// == 目前MINGW和MSVC在以下接口上应该能保持一致了
|
||||||
inline T *hgl_aligned_malloc(size_t n)
|
|
||||||
{
|
#define hgl_malloc(size) _aligned_malloc(size,HGL_MEM_ALIGN)
|
||||||
return (T *)_aligned_malloc(n*sizeof(T),alignof(T));
|
#define hgl_realloc(ptr,size) _aligned_realloc(ptr,size,HGL_MEM_ALIGN)
|
||||||
}
|
#define hgl_free _aligned_free
|
||||||
#else
|
|
||||||
#define hgl_malloc(size) memalign(HGL_MEM_ALIGN,size)
|
template<typename T>
|
||||||
#define hgl_realloc(ptr,size) realloc(ptr,size)
|
inline T *hgl_aligned_malloc(size_t n)
|
||||||
#define hgl_free free
|
{
|
||||||
#endif//
|
return (T *)_aligned_malloc(n*sizeof(T),alignof(T));
|
||||||
|
}
|
||||||
|
|
||||||
#define OS_EXTERNAL_H <winbase.h>
|
#define OS_EXTERNAL_H <winbase.h>
|
||||||
using ExternalModulePointer =HMODULE;
|
using ExternalModulePointer =HMODULE;
|
||||||
#define pi_get GetProcAddress
|
#define pi_get GetProcAddress
|
||||||
#define pi_close FreeLibrary
|
#define pi_close FreeLibrary
|
||||||
|
|
||||||
#define struct_stat64 struct _stat64
|
#ifdef HGL_64_BITS
|
||||||
|
#define struct_stat64 struct _stat64
|
||||||
|
#define hgl_lstat64 _wstat64
|
||||||
|
#endif
|
||||||
|
#if HGL_32_BITS
|
||||||
|
#define struct_stat64 struct _stati64
|
||||||
|
#define hgl_lstat64 _wstat32i64
|
||||||
|
#endif
|
||||||
//#define hgl_stat64 _stat64
|
//#define hgl_stat64 _stat64
|
||||||
#define hgl_lseek64 _lseeki64
|
#define hgl_lseek64 _lseeki64
|
||||||
#define hgl_tell64(fp) _telli64(fp)
|
#define hgl_tell64(fp) _telli64(fp)
|
||||||
#define hgl_fstat64 _fstati64
|
#define hgl_fstat64 _fstati64
|
||||||
#define hgl_lstat64 _wstat64
|
|
||||||
#define hgl_read64 _read
|
#define hgl_read64 _read
|
||||||
#define hgl_write64 _write
|
#define hgl_write64 _write
|
||||||
|
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef HGL_LIST_CPP
|
#ifndef HGL_LIST_CPP
|
||||||
#define HGL_LIST_CPP
|
#define HGL_LIST_CPP
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
// 代码中的部分memcpy可替换为memmove,但这样会引起CodeGuard/Valgrind之类的内存调试器报错
|
// 代码中的部分memcpy可替换为memmove,但这样会引起CodeGuard/Valgrind之类的内存调试器报错
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -41,8 +45,11 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(!items||count<=0)
|
if(!items||count<=0)
|
||||||
return(false);
|
return(false);
|
||||||
|
#ifdef _WIN32
|
||||||
|
memcpy(&ti,items+(rand()%count),sizeof(T));
|
||||||
|
#else
|
||||||
memcpy(&ti,items+(lrand48()%count),sizeof(T));
|
memcpy(&ti,items+(lrand48()%count),sizeof(T));
|
||||||
|
#endif
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,16 +32,16 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(fp)
|
if(fp)
|
||||||
{
|
{
|
||||||
void *func=pi_get(fp,name);
|
void *func=(void*)pi_get(fp,name);
|
||||||
|
|
||||||
if(!func)
|
if(!func)
|
||||||
LOG_ERROR("don't find "+AnsiString(name));
|
LOG_ERROR("don't find "+UTF8String(name));
|
||||||
|
|
||||||
return(func);
|
return(func);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_ERROR("Get func <"+AnsiString(name)+"> error: no load module!");
|
LOG_ERROR("Get func <"+UTF8String(name)+"> error: no load module!");
|
||||||
|
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(fp)
|
if(fp)
|
||||||
{
|
{
|
||||||
void *func=pi_get(fp,name);
|
void *func=(void*)pi_get(fp,name);
|
||||||
|
|
||||||
if(func)return(func);
|
if(func)return(func);
|
||||||
|
|
||||||
@@ -60,12 +60,12 @@ namespace hgl
|
|||||||
_name[0]='_';
|
_name[0]='_';
|
||||||
strcpy(_name+1,HGL_MAX_PATH-1,name);
|
strcpy(_name+1,HGL_MAX_PATH-1,name);
|
||||||
|
|
||||||
func=pi_get(fp,_name);
|
func=(void*)pi_get(fp,_name);
|
||||||
|
|
||||||
if(func)return(func);
|
if(func)return(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user