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); //是否显示