From 85d841ffc03496ae7fb71e75ae33199c6687f3c2 Mon Sep 17 00:00:00 2001 From: chirsz-ever Date: Sun, 26 Jul 2020 20:24:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20`initgraph`=20?= =?UTF-8?q?=E7=9A=84=E5=AE=9A=E4=B9=89=EF=BC=8C=E4=BD=BF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=9B=B4=E6=B8=85=E6=99=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不带 Flag 参数仅用长宽调用 `initgraph`,则在 Release 配置启动时显示 Logo, 在 Release 时则不显示。 新增函数 `getinitmode`。 将兼容 BGI 的 `initgraph` 重载版本的 `path` 参数类型改为 `const char*`。 --- src/ege.h | 32 +++++++++++++++++++------------- src/graphics.cpp | 18 ++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/ege.h b/src/ege.h index 229d82f9..19e73166 100644 --- a/src/ege.h +++ b/src/ege.h @@ -339,6 +339,7 @@ enum music_state_flag { }; enum initmode_flag { + INIT_DEFAULT = 0x0, INIT_NOBORDER = 0x1, INIT_CHILD = 0x2, INIT_TOPMOST = 0x4, @@ -346,12 +347,7 @@ enum initmode_flag { INIT_NOFORCEEXIT = 0x10, INIT_UNICODE = 0x20, INIT_WITHLOGO = 0x100, -#if defined(_DEBUG) || defined(DEBUG) - INIT_DEFAULT = 0x0, -#else - INIT_DEFAULT = INIT_WITHLOGO, -#endif - INIT_ANIMATION = INIT_DEFAULT | INIT_RENDERMANUAL | INIT_NOFORCEEXIT, + INIT_ANIMATION = INIT_DEFAULT | INIT_RENDERMANUAL | INIT_NOFORCEEXIT, }; enum rendermode_e { @@ -657,14 +653,26 @@ typedef IMAGE *PIMAGE; typedef const IMAGE *PCIMAGE; // ͼغ - -void EGEAPI initgraph(int Width, int Height, int Flag = INIT_DEFAULT); // ʼͼλ -void EGEAPI initgraph(int* gdriver, int* gmode, char* path); // Borland C++ 3.1 أֻʹ 640x480x24bit -void EGEAPI closegraph(); // رͼλ -bool EGEAPI is_run(); // жUIǷ˳ +void EGEAPI setinitmode(int mode, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT); //óʼģʽmode=0Ϊͨ1Ϊޱ߿򴰿ڣxydzʼ +int EGEAPI getinitmode(); +void EGEAPI initgraph(int Width, int Height, int Flag); // ʼͼλ +// Debug Ĭϲʾ LOGORelease ģʽĬʾ +#if !defined(NDEBUG) || defined(DEBUG) || defined(_DEBUG) +inline void EGEAPI initgraph(int Width, int Height) { + initgraph(Width, Height, getinitmode()); +} +#else +inline void EGEAPI initgraph(int Width, int Height) { + initgraph(Width, Height, getinitmode()|INIT_WITHLOGO); +} +#endif +void EGEAPI initgraph(int* gdriver, int* gmode, const char* path); // Borland C++ 3.1 أֻʹ 640x480x24bit +void EGEAPI closegraph(); // رͼλ +bool EGEAPI is_run(); // жUIǷ˳ void EGEAPI setcaption(LPCSTR caption); void EGEAPI setcaption(LPCWSTR caption); void EGEAPI seticon(int icon_id); +int EGEAPI attachHWND(HWND hWnd); void EGEAPI movewindow(int x, int y, bool redraw = true); //ƶ void EGEAPI resizewindow(int width, int height); //贰ڳߴ @@ -715,8 +723,6 @@ EGE_DEPRECATE(setfillstyle) void EGEAPI setbkcolor_f(color_t color, PIMAGE pimg = NULL); // õǰͼɫֻò滭 void EGEAPI setfontbkcolor(color_t color, PIMAGE pimg = NULL); // õǰֱɫ void EGEAPI setbkmode(int iBkMode, PIMAGE pimg = NULL); // ñģʽ(0=OPAQUE, 1=TRANSPARENT) -void EGEAPI setinitmode(int mode = INIT_DEFAULT, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT); //óʼģʽmode=0Ϊͨ1Ϊޱ߿򴰿ڣxydzʼ -int EGEAPI attachHWND(HWND hWnd); // ݺ #define RGBtoGRAY rgb2gray diff --git a/src/graphics.cpp b/src/graphics.cpp index 1def92dd..03f6436d 100755 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -72,7 +72,7 @@ static DWORD g_windowstyle = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEB static DWORD g_windowexstyle = WS_EX_LEFT|WS_EX_LTRREADING; static int g_windowpos_x = CW_USEDEFAULT; static int g_windowpos_y = CW_USEDEFAULT; -static int g_initoption = -1; +static int g_initoption = INIT_DEFAULT; static HWND g_attach_hwnd = 0; static WNDPROC DefWindowProcFunc = NULL; @@ -1239,7 +1239,7 @@ void initicon(void) { } void -initgraph(int *gdriver, int *gmode, char *path) { +initgraph(int *gdriver, int *gmode, const char *path) { struct _graph_setting * pg = &graph_setting; pg->exit_flag = 0; @@ -1257,8 +1257,6 @@ initgraph(int *gdriver, int *gmode, char *path) { } //ʼ - if (g_initoption == -1) - setinitmode(); setmode(*gdriver, *gmode); init_img_page(pg); @@ -1304,12 +1302,8 @@ initgraph(int *gdriver, int *gmode, char *path) { void initgraph(int Width, int Height, int Flag) { int g = TRUECOLORSIZE, m = (Width) | (Height<<16); - - if (g_initoption == -1) - setinitmode(Flag); - - initgraph(&g, &m, (char*)""); - //using flag; + setinitmode(Flag); + initgraph(&g, &m, ""); } void @@ -1412,6 +1406,10 @@ setinitmode(int mode, int x, int y) { g_windowpos_y = y; } +int getinitmode() { + return g_initoption; +} + // ȡǰ汾 #### int getGraphicsVer() { return EGE_VERSION_INT; From f059d4181ee2417421463d216906eebcdaf4e569 Mon Sep 17 00:00:00 2001 From: chirsz-ever Date: Sun, 26 Jul 2020 23:27:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E5=8E=BB=20`INITGRAPH`=20?= =?UTF-8?q?=E5=92=8C=20`INITGRAPH3`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于初始化顺序不确定等问题,还是禁用比较好 --- src/ege.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ege.h b/src/ege.h index 19e73166..bfda92de 100644 --- a/src/ege.h +++ b/src/ege.h @@ -577,12 +577,6 @@ struct msg_createwindow { }; -// ͼʼ -#define INITGRAPH(x, y) struct _initgraph_{_initgraph_(){initgraph(x, y);}\ - ~_initgraph_(){closegraph();}}_g_initgraph_ -#define INITGRAPH3(x, y, f) struct _initgraph_{_initgraph_(){initgraph(x, y, f);}\ - ~_initgraph_(){closegraph();}}_g_initgraph_ - // #define MUSIC_ERROR 0xFFFFFFFF