diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 32c7f6987d..e2dac0df72 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -488,7 +488,8 @@ void Batch::_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DO_IT_NOW(_glColor4f, 4); } void GLBackend::do_glColor4f(Batch& batch, uint32 paramOffset) { - glColor4f( + // TODO Replace this with a proper sticky Input attribute buffer with frequency 0 + glVertexAttrib4f( gpu::Stream::COLOR, batch._params[paramOffset + 3]._float, batch._params[paramOffset + 2]._float, batch._params[paramOffset + 1]._float, diff --git a/libraries/gpu/src/gpu/GLBackendInput.cpp b/libraries/gpu/src/gpu/GLBackendInput.cpp index 9a99a912a4..eccd9dda49 100755 --- a/libraries/gpu/src/gpu/GLBackendInput.cpp +++ b/libraries/gpu/src/gpu/GLBackendInput.cpp @@ -57,47 +57,30 @@ void GLBackend::do_setInputBuffer(Batch& batch, uint32 paramOffset) { } } -#if (GPU_FEATURE_PROFILE == GPU_CORE) -#define SUPPORT_VAO -#endif - -#if defined(SUPPORT_VAO) +#if (GPU_INPUT_PROFILE == GPU_CORE_41) +#define NO_SUPPORT_VERTEX_ATTRIB_FORMAT #else +#define SUPPORT_VERTEX_ATTRIB_FORMAT +#endif -#define SUPPORT_LEGACY_OPENGL -#if defined(SUPPORT_LEGACY_OPENGL) -static const int NUM_CLASSIC_ATTRIBS = Stream::TANGENT; -static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = { - GL_VERTEX_ARRAY, - GL_NORMAL_ARRAY, - GL_COLOR_ARRAY, - GL_TEXTURE_COORD_ARRAY -}; -#endif -#endif void GLBackend::initInput() { -#if defined(SUPPORT_VAO) if(!_input._defaultVAO) { glGenVertexArrays(1, &_input._defaultVAO); } glBindVertexArray(_input._defaultVAO); (void) CHECK_GL_ERROR(); -#endif } void GLBackend::killInput() { -#if defined(SUPPORT_VAO) glBindVertexArray(0); if(_input._defaultVAO) { glDeleteVertexArrays(1, &_input._defaultVAO); } (void) CHECK_GL_ERROR(); -#endif } void GLBackend::syncInputStateCache() { -#if defined(SUPPORT_VAO) for (int i = 0; i < _input._attributeActivation.size(); i++) { GLint active = 0; glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &active); @@ -105,23 +88,10 @@ void GLBackend::syncInputStateCache() { } //_input._defaultVAO glBindVertexArray(_input._defaultVAO); -#else - size_t i = 0; -#if defined(SUPPORT_LEGACY_OPENGL) - for (; i < NUM_CLASSIC_ATTRIBS; i++) { - _input._attributeActivation[i] = glIsEnabled(attributeSlotToClassicAttribName[i]); - } -#endif - for (; i < _input._attributeActivation.size(); i++) { - GLint active = 0; - glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &active); - _input._attributeActivation[i] = active; - } -#endif } void GLBackend::updateInput() { -#if defined(SUPPORT_VAO) +#if defined(SUPPORT_VERTEX_ATTRIB_FORMAT) if (_input._invalidFormat) { InputStageState::ActivationCache newActivation; @@ -198,21 +168,11 @@ void GLBackend::updateInput() { for (unsigned int i = 0; i < newActivation.size(); i++) { bool newState = newActivation[i]; if (newState != _input._attributeActivation[i]) { -#if defined(SUPPORT_LEGACY_OPENGL) - if (i < NUM_CLASSIC_ATTRIBS) { - if (newState) { - glEnableClientState(attributeSlotToClassicAttribName[i]); - } else { - glDisableClientState(attributeSlotToClassicAttribName[i]); - } - } else -#endif - { - if (newState) { - glEnableVertexAttribArray(i); - } else { - glDisableVertexAttribArray(i); - } + + if (newState) { + glEnableVertexAttribArray(i); + } else { + glDisableVertexAttribArray(i); } (void) CHECK_GL_ERROR(); @@ -254,30 +214,9 @@ void GLBackend::updateInput() { GLenum type = _elementTypeToGLType[attrib._element.getType()]; GLuint stride = strides[bufferNum]; GLuint pointer = attrib._offset + offsets[bufferNum]; -#if defined(SUPPORT_LEGACY_OPENGL) - const bool useClientState = slot < NUM_CLASSIC_ATTRIBS; - if (useClientState) { - switch (slot) { - case Stream::POSITION: - glVertexPointer(count, type, stride, reinterpret_cast(pointer)); - break; - case Stream::NORMAL: - glNormalPointer(type, stride, reinterpret_cast(pointer)); - break; - case Stream::COLOR: - glColorPointer(count, type, stride, reinterpret_cast(pointer)); - break; - case Stream::TEXCOORD: - glTexCoordPointer(count, type, stride, reinterpret_cast(pointer)); - break; - }; - } else -#endif - { - GLboolean isNormalized = attrib._element.isNormalized(); - glVertexAttribPointer(slot, count, type, isNormalized, stride, + GLboolean isNormalized = attrib._element.isNormalized(); + glVertexAttribPointer(slot, count, type, isNormalized, stride, reinterpret_cast(pointer)); - } (void) CHECK_GL_ERROR(); } } @@ -298,28 +237,13 @@ void GLBackend::resetInputStage() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); (void) CHECK_GL_ERROR(); - -#if defined(SUPPORT_VAO) - // TODO -#else glBindBuffer(GL_ARRAY_BUFFER, 0); - size_t i = 0; -#if defined(SUPPORT_LEGACY_OPENGL) - for (; i < NUM_CLASSIC_ATTRIBS; i++) { - glDisableClientState(attributeSlotToClassicAttribName[i]); - } - glVertexPointer(4, GL_FLOAT, 0, 0); - glNormalPointer(GL_FLOAT, 0, 0); - glColorPointer(4, GL_FLOAT, 0, 0); - glTexCoordPointer(4, GL_FLOAT, 0, 0); -#endif - for (; i < _input._attributeActivation.size(); i++) { + for (int i = 0; i < _input._attributeActivation.size(); i++) { glDisableVertexAttribArray(i); glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, 0); } -#endif // Reset vertex buffer and format _input._format.reset(); diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index 5de41c1d13..5ef17f3aeb 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -23,6 +23,7 @@ #define GPU_FEATURE_PROFILE GPU_CORE #define GPU_TRANSFORM_PROFILE GPU_CORE +#define GPU_INPUT_PROFILE GPU_CORE_41 #elif defined(WIN32) #include "../GL/glew.h" @@ -30,6 +31,7 @@ #define GPU_FEATURE_PROFILE GPU_CORE #define GPU_TRANSFORM_PROFILE GPU_CORE +#define GPU_INPUT_PROFILE GPU_CORE_41 #elif defined(ANDROID) @@ -39,6 +41,7 @@ #define GPU_FEATURE_PROFILE GPU_CORE #define GPU_TRANSFORM_PROFILE GPU_CORE +#define GPU_INPUT_PROFILE GPU_CORE_41 #endif