80 lines
1.4 KiB
Plaintext
Vendored
80 lines
1.4 KiB
Plaintext
Vendored
1、非绘图
|
|
|
|
```C++
|
|
#include <dl.h>
|
|
using namespace dl;
|
|
|
|
void Main()
|
|
{
|
|
Engine::Param& param = dl::Engine::_param;
|
|
// 修改param开启或关闭一些功能
|
|
Engine::Init();
|
|
}
|
|
|
|
int main()
|
|
{
|
|
Main();
|
|
Engine::Release();
|
|
return 0;
|
|
}
|
|
```
|
|
2、绘图
|
|
```C++
|
|
#include <dl.h>
|
|
using namespace dl;
|
|
|
|
void Init()
|
|
{
|
|
// 设置ui标准布局
|
|
g_ui->SetStandardSize({ 1920, 1080 });
|
|
// 注册预设ui
|
|
g_ui->RegisterAll("ui/");
|
|
|
|
// 创建主界面并显示
|
|
g_UIMain = new UIMain;
|
|
g_scene->Add("ui_main", g_UIMain);
|
|
}
|
|
|
|
void Run()
|
|
{
|
|
// 帧函数
|
|
}
|
|
|
|
void Main()
|
|
{
|
|
Engine::Param& param = Engine::_param;
|
|
// 修改param开启或关闭一些功能
|
|
param._setConsoleUtf8 = false;
|
|
Engine::Init();
|
|
// 设置日志文件夹
|
|
g_log->SetLogFile("log/");
|
|
// 设置资源路径
|
|
g_factory->SetPath("image/", "", "binary/", "temp/");
|
|
// 初始化音效系统(可选)
|
|
g_audio->Init("sound/config.json");
|
|
// 设置fps
|
|
g_time->SetFPS(60);
|
|
// 设置初始化函数
|
|
g_system->SetFuncInit(Init);
|
|
// 设置帧函数
|
|
g_system->SetFuncRun(Run);
|
|
// 窗口参数
|
|
ParamWindow p;
|
|
p._size = g_system->GetWorkArea() * 3u / 4u;
|
|
p._strTitle = "dl engine";
|
|
|
|
// 进入游戏循环
|
|
g_system->Start(p);
|
|
}
|
|
|
|
int CALLBACK WinMain(
|
|
__in HINSTANCE hInstance,
|
|
__in HINSTANCE hPrevInstance,
|
|
__in LPSTR lpCmdLine,
|
|
__in int nCmdShow
|
|
)
|
|
{
|
|
Main()
|
|
return 0;
|
|
}
|
|
``` |