51 lines
1001 B
C++
Raw Normal View History

2018-11-30 17:46:58 +08:00
#include<hgl/graph/RenderDevice.h>
#include<hgl/graph/RenderWindow.h>
#include<iostream>
2018-11-27 21:32:36 +08:00
#include<GLFW/glfw3.h>
2018-11-27 15:43:32 +08:00
using namespace hgl;
int main(void)
{
RenderDevice *device=CreateRenderDeviceGLFW();
2018-11-27 16:16:23 +08:00
if(!device)
2018-11-27 16:16:23 +08:00
{
std::cerr<<"Create RenderDevice(GLFW) failed."<<std::endl;
2018-11-27 16:16:23 +08:00
return -1;
}
if(!device->Init())
{
std::cerr<<"Init RenderDevice(GLFW) failed."<<std::endl;
return -2;
}
2018-11-27 16:16:23 +08:00
2018-11-27 21:32:36 +08:00
WindowSetup ws;
2018-11-27 21:32:36 +08:00
ws.Name=U8_TEXT("Null Window");
2018-11-27 16:16:23 +08:00
2018-11-27 21:32:36 +08:00
RenderSetup rs;
RenderWindow *win=device->Create(1280,720,&ws,&rs);
2018-11-27 21:32:36 +08:00
win->Show();
2018-11-27 21:33:38 +08:00
glClearColor(0,0,0,1); //设置清屏颜色
2018-11-27 21:32:36 +08:00
while(win->IsOpen())
{
2018-11-27 21:33:38 +08:00
win->MakeToCurrent(); //切换当前窗口到前台
2018-11-27 16:16:23 +08:00
2018-11-27 21:33:38 +08:00
glClear(GL_COLOR_BUFFER_BIT); //清屏
2018-11-27 21:32:36 +08:00
2018-11-27 21:33:38 +08:00
win->SwapBuffer(); //交换前后台显示缓冲区
win->PollEvent(); //处理窗口事件
2018-11-27 16:16:23 +08:00
}
2018-11-27 21:32:36 +08:00
delete win;
delete device;
2018-11-27 15:43:32 +08:00
return 0;
}