[drape] GLFunctions::Init must be called in thread with valid OGL context and executed only once

This commit is contained in:
ExMix 2015-01-28 08:16:54 +03:00 committed by r.kuznetsov
parent 977a2db52e
commit 7e0259f7a5
4 changed files with 8 additions and 2 deletions

View file

@ -239,7 +239,7 @@ int32_t GLFunctions::glGetInteger(glConst pname)
return MOCK_CALL(glGetInteger(pname));
}
void CheckGLError() {}
void CheckGLError(my::SrcPoint const & /*srcPt*/) {}
// @TODO add actual unit tests
void GLFunctions::glEnable(glConst mode) {}

View file

@ -12,6 +12,7 @@
#endif
#include "std/cstring.hpp"
#include "std/atomic.hpp"
#if defined(OMIM_OS_WINDOWS)
#define APIENTRY __stdcall
@ -111,10 +112,15 @@ namespace
int const GLCompileStatus = GL_COMPILE_STATUS;
int const GLLinkStatus = GL_LINK_STATUS;
atomic_flag s_inited = ATOMIC_FLAG_INIT;
}
void GLFunctions::Init()
{
if (s_inited.test_and_set())
return;
/// VAO
#if defined(OMIM_OS_MAC)
glGenVertexArraysFn = &glGenVertexArraysAPPLE;

View file

@ -15,7 +15,6 @@ DrapeEngine::DrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextfactory,
MapDataProvider const & model)
: m_viewport(viewport)
{
GLFunctions::Init();
VisualParams::Init(viewport.GetPixelRatio(), df::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight()));
m_threadCommutator = dp::MasterPointer<ThreadsCommutator>(new ThreadsCommutator());

View file

@ -385,6 +385,7 @@ void FrontendRenderer::Routine::Do()
{
dp::OGLContext * context = m_renderer.m_contextFactory->getDrawContext();
context->makeCurrent();
GLFunctions::Init();
my::Timer timer;
//double processingTime = InitAvarageTimePerMessage; // By init we think that one message processed by 1ms