diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 05fc2fec0a..c0eb1a16f1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -391,7 +391,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : // emit checkBackgroundDownloads to cause the GeometryCache to check it's queue for requested background // downloads. QSharedPointer geometryCacheP = DependencyManager::get(); - ResourceCache *geometryCache = geometryCacheP.data(); + ResourceCache* geometryCache = geometryCacheP.data(); connect(this, &Application::checkBackgroundDownloads, geometryCache, &ResourceCache::checkAsynchronousGets); // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 2e5a4d4508..a84af10a82 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -76,12 +76,10 @@ GLBackend::GLBackend() : _output() { initTransform(); - initInput(); } GLBackend::~GLBackend() { killTransform(); - killInput(); } void GLBackend::render(Batch& batch) { @@ -143,6 +141,7 @@ bool GLBackend::checkGLError(const char* name) { void GLBackend::syncCache() { syncTransformStateCache(); syncPipelineStateCache(); + syncInputStateCache(); } void GLBackend::do_draw(Batch& batch, uint32 paramOffset) { diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index e00aa2e02a..d898c9b6c6 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -216,8 +216,10 @@ protected: void do_setInputBuffer(Batch& batch, uint32 paramOffset); void do_setIndexBuffer(Batch& batch, uint32 paramOffset); - void initInput(); - void killInput(); + void pushInputState(); + void popInputState(); + // Synchronize the state cache of this Backend with the actual real state of the GL Context + void syncInputStateCache(); void updateInput(); struct InputStageState { bool _invalidFormat; diff --git a/libraries/gpu/src/gpu/GLBackendInput.cpp b/libraries/gpu/src/gpu/GLBackendInput.cpp index 6646ae3f64..c5ec60f6ee 100755 --- a/libraries/gpu/src/gpu/GLBackendInput.cpp +++ b/libraries/gpu/src/gpu/GLBackendInput.cpp @@ -46,24 +46,27 @@ static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = { }; #endif -void GLBackend::initInput() { +void GLBackend::pushInputState() { glPushClientAttrib(GL_VERTEX_ARRAY); glPushClientAttrib(GL_NORMAL_ARRAY); glPushClientAttrib(GL_COLOR_ARRAY); glPushClientAttrib(GL_TEXTURE_COORD_ARRAY); - for (int i = 0; i < NUM_CLASSIC_ATTRIBS; i++) { - _input._attributeActivation[i] = glIsEnabled(attributeSlotToClassicAttribName[i]); - } } -void GLBackend::killInput() { +void GLBackend::popInputState() { glPopClientAttrib(); // GL_VERTEX_ARRAY glPopClientAttrib(); // GL_NORMAL_ARRAY glPopClientAttrib(); // GL_COLOR_ARRAY glPopClientAttrib(); // GL_TEXTURE_COORD_ARRAY } +void GLBackend::syncInputStateCache() { + for (int i = 0; i < NUM_CLASSIC_ATTRIBS; i++) { + _input._attributeActivation[i] = glIsEnabled(attributeSlotToClassicAttribName[i]); + } +} + void GLBackend::updateInput() { if (_input._invalidFormat || _input._buffersState.any()) { @@ -164,9 +167,6 @@ void GLBackend::updateInput() { } } } - } else { - glBindBuffer(GL_ARRAY_BUFFER, 0); - (void) CHECK_GL_ERROR(); } // everything format related should be in sync now _input._invalidFormat = false;