globalVar.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #ifndef __GLOBALVAR_H_
  3. #define __GLOBALVAR_H_
  4. #include "optype.h"
  5. #define SAFE_CLOSE(h) \
  6. if (h) \
  7. CloseHandle(h); \
  8. h = NULL;
  9. template <class Type>
  10. void SAFE_DELETE(Type *&ptr)
  11. {
  12. delete ptr;
  13. ptr = nullptr;
  14. }
  15. #define SAFE_DELETE_ARRAY(ptr) \
  16. if (ptr) \
  17. delete[] ptr; \
  18. ptr = nullptr
  19. #define SAFE_RELEASE(obj) \
  20. if (obj) \
  21. obj->Release(); \
  22. obj = nullptr
  23. //#define _sto_wstring(s) boost::locale::conv::to_utf<wchar_t>(s, "GBK")
  24. //#define _wsto_string(s) boost::locale::conv::from_utf(s,"GBK")
  25. #define DLL_API extern "C" _declspec(dllexport)
  26. //normal windows,gdi;,dx;opengl;
  27. enum RENDER_TYPE
  28. {
  29. NORMAL = 0,
  30. GDI = 1,
  31. DX = 2,
  32. OPENGL = 3
  33. };
  34. #define MAKE_RENDER(type, flag) ((type << 16) | flag)
  35. #define GET_RENDER_TYPE(t) (t >> 16)
  36. #define GET_RENDER_FLAG(t) (t & 0xffff)
  37. constexpr int RDT_NORMAL = MAKE_RENDER(NORMAL, 0);
  38. constexpr int RDT_GDI = MAKE_RENDER(GDI, 0);
  39. constexpr int RDT_GDI2 = MAKE_RENDER(GDI, 1);
  40. constexpr int RDT_GDI_DX2 = MAKE_RENDER(GDI, 2);
  41. constexpr int RDT_DX_DEFAULT = MAKE_RENDER(DX, 0);
  42. constexpr int RDT_DX_D3D9 = MAKE_RENDER(DX, 1);
  43. constexpr int RDT_DX_D3D10 = MAKE_RENDER(DX, 2);
  44. constexpr int RDT_DX_D3D11 = MAKE_RENDER(DX, 3);
  45. constexpr int RDT_GL_DEFAULT = MAKE_RENDER(OPENGL, 0);
  46. constexpr int RDT_GL_STD = MAKE_RENDER(OPENGL, 1);
  47. constexpr int RDT_GL_NOX = MAKE_RENDER(OPENGL, 2);
  48. constexpr int RDT_GL_ES = MAKE_RENDER(OPENGL, 3);
  49. constexpr int RDT_GL_FI = MAKE_RENDER(OPENGL, 4); //glFinish
  50. enum INPUT_TYPE
  51. {
  52. IN_NORMAL = 0,
  53. IN_WINDOWS = 1,
  54. IN_DX = 2
  55. };
  56. //define Image byte format
  57. constexpr int IBF_R8G8B8A8 = 0;
  58. constexpr int IBF_B8G8R8A8 = 1;
  59. constexpr int IBF_R8G8B8 = 2;
  60. //const size_t MAX_IMAGE_WIDTH = 1<<11;
  61. //const size_t SHARED_MEMORY_SIZE = 1080 * 1928 * 4;
  62. constexpr auto SHARED_RES_NAME_FORMAT = L"op_mutex_%d";
  63. constexpr auto MUTEX_NAME_FORMAT = L"op_shared_mem_%d";
  64. #ifndef _M_X64
  65. #define OP64 0
  66. #else
  67. #define OP64 1
  68. #endif
  69. #define _TOSTRING(x) #x
  70. #define MAKE_OP_VERSION(a, b, c, d) _TOSTRING(a##.##b##.##c##.##d)
  71. #define OP_VERSION MAKE_OP_VERSION(0, 4, 0, 0)
  72. //模块句柄
  73. //extern HINSTANCE gInstance;
  74. //是否显示错误信息
  75. //extern int gShowError;
  76. //op 路径
  77. //extern wstring m_opPath;
  78. //extern wstring g_op_name;
  79. #endif