From 8abbf0117d4e520bc66f77311cbd723d7dbd0529 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 28 Nov 2018 15:58:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E7=9A=84OutputGLInf?= =?UTF-8?q?o=E8=8C=83=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/CMakeLists.txt | 2 + example/DrawTriangle/CMakeLists.txt | 4 ++ example/DrawTriangle/main.cpp | 54 ++++++++++++++++++++++ example/OutputGLInfo/CMakeLists.txt | 5 +++ example/OutputGLInfo/main.cpp | 70 +++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 example/DrawTriangle/CMakeLists.txt create mode 100644 example/DrawTriangle/main.cpp create mode 100644 example/OutputGLInfo/CMakeLists.txt create mode 100644 example/OutputGLInfo/main.cpp 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; +} + +