diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 7912cc8d..69c2caad 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,2 +1,4 @@ add_subdirectory(EnumRenderDevice) +add_subdirectory(OutputGLInfo) add_subdirectory(NullWindow) +add_subdirectory(DrawTriangle) diff --git a/example/DrawTriangle/CMakeLists.txt b/example/DrawTriangle/CMakeLists.txt new file mode 100644 index 00000000..aef0e8d0 --- /dev/null +++ b/example/DrawTriangle/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(DrawTriangle main.cpp) + +target_link_libraries(DrawTriangle PRIVATE glfw GL ULRE.RenderDevice) + diff --git a/example/DrawTriangle/main.cpp b/example/DrawTriangle/main.cpp new file mode 100644 index 00000000..20ce07a0 --- /dev/null +++ b/example/DrawTriangle/main.cpp @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +using namespace hgl; + +void draw() +{ + glClearColor(0,0,0,1); //设置清屏颜色 + glClear(GL_COLOR_BUFFER_BIT); //清屏 +} + +int main(void) +{ + RenderDevice *device=CreateRenderDeviceGLFW(); + + if(!device) + { + std::cerr<<"Create RenderDevice(GLFW) failed."<Init()) + { + std::cerr<<"Init RenderDevice(GLFW) failed."<CreateWindow(1280,720,&ws,&rs); + + win->MakeToCurrent(); //切换当前窗口到前台 + win->Show(); + + while(win->IsOpen()) + { + draw(); + + win->SwapBuffer(); //交换前后台显示缓冲区 + win->PollEvent(); //处理窗口事件 + } + + delete win; + delete device; + + return 0; +} diff --git a/example/OutputGLInfo/CMakeLists.txt b/example/OutputGLInfo/CMakeLists.txt new file mode 100644 index 00000000..a7f91a2b --- /dev/null +++ b/example/OutputGLInfo/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(OutputGLInfo main.cpp) + +target_link_libraries(OutputGLInfo PRIVATE glfw GL ULRE.RenderDevice) + + diff --git a/example/OutputGLInfo/main.cpp b/example/OutputGLInfo/main.cpp new file mode 100644 index 00000000..861a542e --- /dev/null +++ b/example/OutputGLInfo/main.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include + +using namespace hgl; + +void draw() +{ + glClearColor(0,0,0,1); //设置清屏颜色 + glClear(GL_COLOR_BUFFER_BIT); //清屏 +} + +void output_ogl_info() +{ + std::cout<<"Vendor: "<Init()) + { + std::cerr<<"Init RenderDevice(GLFW) failed."<CreateWindow(1280,720,&ws,&rs); + + win->MakeToCurrent(); //切换当前窗口到前台 + + output_ogl_info(); + + delete win; + delete device; + + return 0; +} + +