Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改 initgraph 的定义,使代码更清晰 #36

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/ege.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,15 @@ enum music_state_flag {
};

enum initmode_flag {
INIT_DEFAULT = 0x0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了之后跟之前的行为就不一样了... 会不会引起疑问...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能得在release note 里面单独提一下

INIT_NOBORDER = 0x1,
INIT_CHILD = 0x2,
INIT_TOPMOST = 0x4,
INIT_RENDERMANUAL = 0x8,
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 {
Expand Down Expand Up @@ -581,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

Expand Down Expand Up @@ -657,14 +647,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Ϊ�ޱ߿򴰿ڣ�xy�dz�ʼ��������
int EGEAPI getinitmode();
void EGEAPI initgraph(int Width, int Height, int Flag); // ��ʼ��ͼ�λ���
// Debug ������Ĭ�ϲ���ʾ LOGO��Release ģʽ��Ĭ����ʾ��
#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) {
wysaid marked this conversation as resolved.
Show resolved Hide resolved
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); //���贰�ڳߴ�
Expand Down Expand Up @@ -715,8 +717,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Ϊ�ޱ߿򴰿ڣ�xy�dz�ʼ��������
int EGEAPI attachHWND(HWND hWnd);

// ���ݺ�
#define RGBtoGRAY rgb2gray
Expand Down
18 changes: 8 additions & 10 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -1257,8 +1257,6 @@ initgraph(int *gdriver, int *gmode, char *path) {
}

//��ʼ������
if (g_initoption == -1)
setinitmode();
setmode(*gdriver, *gmode);
init_img_page(pg);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down