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



Dim Shared As Single x,y



' 框架函数 [用于游戏逻辑处理]
Function FrameFunc() As Integer
	InputWin32_GetMousePos(x,y)
	Return -1
End Function



' 渲染函数 [用于渲染画面到屏幕]
Function RenderFunc() As Integer
	' 准备绘制
	Render_BeginScene()
		' 用纯色清除屏幕
		Render_Clear(&H0)
		' 打印鼠标坐标
		Render_RenderFont("x : " & x & "    y : " & y,2,2,&HFF00FF00,0,100)
		' 打印键盘状态
		Dim i As Integer
		For i = 1 To 26
			If InputWin32_GetTheKeyState(64+i) Then
				Render_RenderFont(Chr(64+i),2+i*20,20,&HFF00FF00,0,100)
			Else
				Render_RenderFont(Chr(64+i),2+i*20,20,&HFFFF0000,0,100)
			EndIf
		Next
	' 绘制结束
	Render_EndScene()
	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)
	' 开始运行
	System_OD2DRun()
	System_OD2DStop()
Else
	MessageBox(0,"OurDream引擎初始化失败！","Error",MB_ICONERROR)
EndIf