From 52fb2eed7ec2d081dabf951f319b146a2c5c53c2 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 28 Nov 2018 16:13:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=9D=9ECORE=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/OutputGLInfo/main.cpp | 13 ++++++++++++- inc/hgl/render/RenderDevice.h | 1 + src/RenderDevice/GLFW/RenderDeviceGLFW.cpp | 13 ++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/example/OutputGLInfo/main.cpp b/example/OutputGLInfo/main.cpp index 861a542e..5d1e80c3 100644 --- a/example/OutputGLInfo/main.cpp +++ b/example/OutputGLInfo/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ void output_ogl_info() std::cout<<" "<1) + { + if(stricmp(argv[1],"core")==0) + rs.opengl.core=true; + else + rs.opengl.core=false; + } + else + rs.opengl.core=false; + RenderWindow *win=device->CreateWindow(1280,720,&ws,&rs); win->MakeToCurrent(); //切换当前窗口到前台 diff --git a/inc/hgl/render/RenderDevice.h b/inc/hgl/render/RenderDevice.h index 9c431f79..ee5df5fd 100644 --- a/inc/hgl/render/RenderDevice.h +++ b/inc/hgl/render/RenderDevice.h @@ -95,6 +95,7 @@ namespace hgl { bool debug=true; + bool core=true; bool es=false; bool egl=false; diff --git a/src/RenderDevice/GLFW/RenderDeviceGLFW.cpp b/src/RenderDevice/GLFW/RenderDeviceGLFW.cpp index 85c21a43..43945da1 100644 --- a/src/RenderDevice/GLFW/RenderDeviceGLFW.cpp +++ b/src/RenderDevice/GLFW/RenderDeviceGLFW.cpp @@ -86,16 +86,23 @@ namespace hgl if(gs->opengl.es) { + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, gs->opengl.major); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, gs->opengl.minor); } - else + else if(gs->opengl.core) { glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //核心模式 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true); //向前兼容模式(无旧特性) + + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, gs->opengl.major); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, gs->opengl.minor); + } + else + { + //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE); //兼容模式 } glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, gs->opengl.debug); //调试模式 - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, gs->opengl.major); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, gs->opengl.minor); glfwWindowHint(GLFW_VISIBLE, true); //是否显示