CMake 配置
在将 HiEasyX 移动到你的项目根目录后。使用如下代码来连接上 HiEasyX 库:
add_subdirectory(path_to_hiex)
target_link_libraries(your_application HiEasyXLib)
附测试代码:
#include <include/hex.h>
#include <include/impl/EasyX/hex_impl_easyx.h>
int main() {
initgraph(640, 480);
BeginBatchDraw();
HX::HXInitForEasyX();
HX::SetBuffer(GetWorkingImage());
setbkcolor(RGB(180, 180, 180));
HX::WindowProfile windowProfile;
while (true) {
cleardevice();
HX::HXBegin();
ExMessage message{};
while (peekmessage(&message)) {
HX::PushMessage(HX::GetHXMessage(&message));
}
HX::Window(HXStr("Hello World!"), windowProfile);
HX::Text(HXStr("Hello HiEasyX!"));
static int count = 0;
static HX::ButtonProfile buttonProfile;
HX::BeginSameLine();
if (HX::Button(HXStr("Hello Button"), buttonProfile)) {
++count;
}
HX::Text(HXStr("Count : ") + ToHXString(count));
HX::EndSameLine();
HX::End();
HX::Render();
FlushBatchDraw();
Sleep(1);
}
return 0;
}
若无意外,则应得到结果: