From 0a063dce44784c05a423d3e80e772c6d26255d26 Mon Sep 17 00:00:00 2001 From: Osyotr Date: Sat, 16 Mar 2024 01:56:26 +0300 Subject: [PATCH] [drape] Link OpenGL on windows Signed-off-by: Osyotr --- drape/CMakeLists.txt | 3 ++- drape/gl_functions.cpp | 38 ++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/drape/CMakeLists.txt b/drape/CMakeLists.txt index 1501dbf5c0..c98e28d652 100644 --- a/drape/CMakeLists.txt +++ b/drape/CMakeLists.txt @@ -166,7 +166,7 @@ omim_add_library(${PROJECT_NAME} ${SRC}) # Do not include glm's CMakeLists.txt, because it's outdated and not necessary. target_include_directories(${PROJECT_NAME} PUBLIC ${OMIM_ROOT}/3party/glm) -if (PLATFORM_LINUX) +if (PLATFORM_LINUX OR PLATFORM_WIN) find_package(OpenGL) endif() @@ -189,6 +189,7 @@ set(DRAPE_LINK_LIBRARIES $<$:-framework\ OpenGL> $<$:-framework\ Metal> $<$:OpenGL::GL> + $<$:OpenGL::GL> ) target_link_libraries(${PROJECT_NAME} ${DRAPE_LINK_LIBRARIES}) diff --git a/drape/gl_functions.cpp b/drape/gl_functions.cpp index 14c6ecf3eb..0a7bd3372d 100644 --- a/drape/gl_functions.cpp +++ b/drape/gl_functions.cpp @@ -44,6 +44,8 @@ typedef void(DP_APIENTRY * TglClearFn)(GLbitfield mask); typedef void(DP_APIENTRY * TglViewportFn)(GLint x, GLint y, GLsizei w, GLsizei h); typedef void(DP_APIENTRY * TglScissorFn)(GLint x, GLint y, GLsizei w, GLsizei h); typedef void(DP_APIENTRY * TglFlushFn)(); +typedef void(DP_APIENTRY * TglStencilOpSeparateFn)(GLenum face, GLenum func, GLenum ref, GLenum mask); +typedef void(DP_APIENTRY * TglStencilFuncSeparateFn)(GLenum face, GLenum sfail, GLint dpfail, GLuint dppass); typedef void(DP_APIENTRY * TglActiveTextureFn)(GLenum texture); typedef void(DP_APIENTRY * TglBlendEquationFn)(GLenum mode); @@ -79,7 +81,7 @@ typedef void(DP_APIENTRY * TglFlushMappedBufferRangeFn)(GLenum target, GLintptr typedef GLuint(DP_APIENTRY * TglCreateShaderFn)(GLenum type); typedef void(DP_APIENTRY * TglShaderSourceFn)(GLuint shaderID, GLsizei count, - GLchar const ** string, GLint const * length); + GLchar const * const * string, GLint const * length); typedef void(DP_APIENTRY * TglCompileShaderFn)(GLuint shaderID); typedef void(DP_APIENTRY * TglDeleteShaderFn)(GLuint shaderID); typedef void(DP_APIENTRY * TglGetShaderivFn)(GLuint shaderID, GLenum name, GLint * p); @@ -138,6 +140,9 @@ TglViewportFn glViewportFn = nullptr; TglScissorFn glScissorFn = nullptr; TglFlushFn glFlushFn = nullptr; +TglStencilOpSeparateFn glStencilOpSeparateFn = nullptr; +TglStencilFuncSeparateFn glStencilFuncSeparateFn = nullptr; + TglActiveTextureFn glActiveTextureFn = nullptr; TglBlendEquationFn glBlendEquationFn = nullptr; @@ -305,6 +310,11 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) CHECK(false, ("Unknown Graphics API")); } + glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor); + glClearFn = LOAD_GL_FUNC(TglClearFn, glClear); + glViewportFn = LOAD_GL_FUNC(TglViewportFn, glViewport); + glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor); + glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush); #else // OMIM_OS_WINDOWS if (ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) { @@ -314,13 +324,19 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) } glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer); glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer); + glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange); + glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange); + glGetStringiFn = LOAD_GL_FUNC(TglGetStringiFn, glGetStringi); + + glClearColorFn = ::glClearColor; + glClearFn = ::glClear; + glViewportFn = ::glViewport; + glScissorFn = ::glScissor; + glFlushFn = ::glFlush; #endif - glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor); - glClearFn = LOAD_GL_FUNC(TglClearFn, glClear); - glViewportFn = LOAD_GL_FUNC(TglViewportFn, glViewport); - glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor); - glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush); + glStencilFuncSeparateFn = LOAD_GL_FUNC(TglStencilFuncSeparateFn, glStencilFuncSeparate); + glStencilOpSeparateFn = LOAD_GL_FUNC(TglStencilOpSeparateFn, glStencilOpSeparate); glActiveTextureFn = LOAD_GL_FUNC(TglActiveTextureFn, glActiveTexture); glBlendEquationFn = LOAD_GL_FUNC(TglBlendEquationFn, glBlendEquation); @@ -340,13 +356,7 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) /// Shaders glCreateShaderFn = LOAD_GL_FUNC(TglCreateShaderFn, glCreateShader); -#ifdef OMIM_OS_WINDOWS glShaderSourceFn = LOAD_GL_FUNC(TglShaderSourceFn, glShaderSource); -#else - typedef void(DP_APIENTRY * glShaderSource_Type)(GLuint shaderID, GLsizei count, - GLchar const ** string, GLint const * length); - glShaderSourceFn = reinterpret_cast(&::glShaderSource); -#endif glCompileShaderFn = LOAD_GL_FUNC(TglCompileShaderFn, glCompileShader); glDeleteShaderFn = LOAD_GL_FUNC(TglDeleteShaderFn, glDeleteShader); glGetShaderivFn = LOAD_GL_FUNC(TglGetShaderivFn, glGetShaderiv); @@ -484,13 +494,13 @@ void GLFunctions::glCullFace(glConst face) void GLFunctions::glStencilOpSeparate(glConst face, glConst sfail, glConst dpfail, glConst dppass) { ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); - GLCHECK(::glStencilOpSeparate(face, sfail, dpfail, dppass)); + GLCHECK(glStencilOpSeparateFn(face, sfail, dpfail, dppass)); } void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask) { ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); - GLCHECK(::glStencilFuncSeparate(face, func, ref, mask)); + GLCHECK(glStencilFuncSeparateFn(face, func, ref, mask)); } void GLFunctions::glPixelStore(glConst name, uint32_t value)