[drape] Link OpenGL on windows

Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
This commit is contained in:
Osyotr 2024-03-16 01:56:26 +03:00 committed by Alexander Borsuk
parent d9de3eee6e
commit 0a063dce44
2 changed files with 26 additions and 15 deletions

View file

@ -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
$<$<BOOL:${PLATFORM_MAC}>:-framework\ OpenGL>
$<$<BOOL:${PLATFORM_MAC}>:-framework\ Metal>
$<$<BOOL:${PLATFORM_LINUX}>:OpenGL::GL>
$<$<BOOL:${PLATFORM_WIN}>:OpenGL::GL>
)
target_link_libraries(${PROJECT_NAME} ${DRAPE_LINK_LIBRARIES})

View file

@ -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_Type>(&::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)