Skip to content

Commit c0e7532

Browse files
committed
Fix OpenGL linking error on Windows
Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
1 parent 04a156e commit c0e7532

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

libs/drape/gl_functions.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ typedef GLenum(DP_APIENTRY * TglCheckFramebufferStatusFn)(GLenum target);
127127

128128
typedef GLubyte const *(DP_APIENTRY * TglGetStringiFn)(GLenum name, GLuint index);
129129

130+
typedef void(DP_APIENTRY * TglTexImage3DFn)(GLenum target, GLint level, GLint internalformat, GLsizei width,
131+
GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type,
132+
void const * pixels);
133+
typedef void(DP_APIENTRY * TglTexSubImage3DFn)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
134+
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
135+
void const * pixels);
136+
typedef void(DP_APIENTRY * TglDrawArraysInstancedFn)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
137+
130138
TglClearColorFn glClearColorFn = nullptr;
131139
TglClearFn glClearFn = nullptr;
132140
TglViewportFn glViewportFn = nullptr;
@@ -205,6 +213,10 @@ TglCheckFramebufferStatusFn glCheckFramebufferStatusFn = nullptr;
205213

206214
TglGetStringiFn glGetStringiFn = nullptr;
207215

216+
TglTexImage3DFn glTexImage3DFn = nullptr;
217+
TglTexSubImage3DFn glTexSubImage3DFn = nullptr;
218+
TglDrawArraysInstancedFn glDrawArraysInstancedFn = nullptr;
219+
208220
#if !defined(GL_NUM_EXTENSIONS)
209221
#define GL_NUM_EXTENSIONS 0x821D
210222
#endif
@@ -282,6 +294,9 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
282294
glMapBufferRangeFn = ::glMapBufferRange;
283295
glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
284296
glGetStringiFn = ::glGetStringi;
297+
glTexImage3DFn = ::glTexImage3D;
298+
glTexSubImage3DFn = ::glTexSubImage3D;
299+
glDrawArraysInstancedFn = ::glDrawArraysInstanced;
285300

286301
glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor);
287302
glClearFn = LOAD_GL_FUNC(TglClearFn, glClear);
@@ -296,6 +311,9 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
296311
glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange);
297312
glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange);
298313
glGetStringiFn = LOAD_GL_FUNC(TglGetStringiFn, glGetStringi);
314+
glTexImage3DFn = LOAD_GL_FUNC(TglTexImage3DFn, glTexImage3D);
315+
glTexSubImage3DFn = LOAD_GL_FUNC(TglTexSubImage3DFn, glTexSubImage3D);
316+
glDrawArraysInstancedFn = LOAD_GL_FUNC(TglDrawArraysInstancedFn, glDrawArraysInstanced);
299317

300318
glClearColorFn = ::glClearColor;
301319
glClearFn = ::glClear;
@@ -1000,8 +1018,9 @@ void GLFunctions::glTexImage2DArray(int width, int height, int layers, glConst l
10001018
void const * data)
10011019
{
10021020
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
1021+
ASSERT(glTexImage3DFn != nullptr, ());
10031022
int const internalFormat = TextureInternalFormatByLayout(layout, pixelType);
1004-
GLCHECK(::glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, layout, pixelType, data));
1023+
GLCHECK(glTexImage3DFn(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, layout, pixelType, data));
10051024
}
10061025

10071026
void GLFunctions::glTexSubImage2D(int x, int y, int width, int height, glConst layout, glConst pixelType,
@@ -1015,7 +1034,8 @@ void GLFunctions::glTexSubImage2DArray(int x, int y, int layer, int width, int h
10151034
glConst pixelType, void const * data)
10161035
{
10171036
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
1018-
GLCHECK(::glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, x, y, layer, width, height, 1, layout, pixelType, data));
1037+
ASSERT(glTexSubImage3DFn != nullptr, ());
1038+
GLCHECK(glTexSubImage3DFn(GL_TEXTURE_2D_ARRAY, 0, x, y, layer, width, height, 1, layout, pixelType, data));
10191039
}
10201040

10211041
void GLFunctions::glTexParameter(glConst param, glConst value, glConst target)
@@ -1036,10 +1056,12 @@ void GLFunctions::glDrawArrays(glConst mode, int32_t first, uint32_t count)
10361056
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
10371057
GLCHECK(::glDrawArrays(mode, first, count));
10381058
}
1059+
10391060
void GLFunctions::glDrawArraysInstanced(glConst mode, int32_t first, uint32_t count, uint32_t instanceCount)
10401061
{
10411062
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
1042-
GLCHECK(::glDrawArraysInstanced(mode, first, count, instanceCount));
1063+
ASSERT(glDrawArraysInstancedFn != nullptr, ());
1064+
GLCHECK(glDrawArraysInstancedFn(mode, first, count, instanceCount));
10431065
}
10441066

10451067
void GLFunctions::glGenFramebuffer(uint32_t * fbo)

libs/drape/gl_includes.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <OpenGL/glext.h>
1313
#elif defined(OMIM_OS_WINDOWS)
1414
#include "std/windows.hpp"
15-
#define GL_GLEXT_PROTOTYPES
1615
#include <GL/gl.h>
1716
#include "3party/GL/glext.h"
1817
#elif defined(OMIM_OS_ANDROID)

libs/std/windows.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#undef min
99
#undef max
10-
// #undef far
11-
// #undef near
10+
#undef FindResource
1211

1312
#endif // OMIM_OS_WINDOWS

0 commit comments

Comments
 (0)