#Include Once "windows.bi"
#Include "OurDream2D.bi"



' 框架函数 [用于游戏逻辑处理]
Function FrameFunc() As Integer
	' 处理UI事件
	GUI_OnEven()
	Return -1
End Function



' 渲染函数 [用于渲染画面到屏幕]
Function RenderFunc() As Integer
	' 准备绘制
	Render_BeginScene()
		' 用纯色清除屏幕
		Render_Clear(&H0)
		' 绘制全部UI控件
		GUI_RenderAll()
	' 绘制结束
	Render_EndScene()
	Return -1
End Function



Function Button1_Click() As Integer
	System_OD2DStop()
	End(0)
	Return -1
End Function



' 初始化游戏引擎
If System_CreateOD2D(1,0,-1,-1,-1,0,-1,-1,-1,800,600,32,-1,0,40,NULL,"OurDream2D Test",ExePath & "\Debug.log",-1) Then
	' 设置框架函数回调
	System_SetFrameFunction(@FrameFunc)
	' 设置渲染函数回调
	System_SetRenderFunction(@RenderFunc)
	' 载入字体
	Resource_LoadFont(100,"黑体",10,25,20,0)
	' 创建一个按钮
	GUI_AddButton(100,680,550,780,580,100,&HFFFF0000,"关闭",-1,0,0,&H64FFFFFF,&HFF00FF00,0,0,0,0,0,0,0,0,0,0,-1)
	GUI_SetEvenReceiver(100,2,@Button1_Click,-1)
	' 开始运行
	System_OD2DRun()
	System_OD2DStop()
Else
	MessageBox(0,"OurDream引擎初始化失败！","Error",MB_ICONERROR)
EndIf