mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 21:38:40 +02:00
REsolving the input
This commit is contained in:
parent
a417b77c01
commit
32c253453b
2 changed files with 12 additions and 87 deletions
|
@ -57,47 +57,30 @@ void GLBackend::do_setInputBuffer(Batch& batch, uint32 paramOffset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (GPU_FEATURE_PROFILE == GPU_CORE)
|
#if (GPU_INPUT_PROFILE == GPU_CORE_41)
|
||||||
#define SUPPORT_VAO
|
#define NO_SUPPORT_VERTEX_ATTRIB_FORMAT
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SUPPORT_VAO)
|
|
||||||
#else
|
#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() {
|
void GLBackend::initInput() {
|
||||||
#if defined(SUPPORT_VAO)
|
|
||||||
if(!_input._defaultVAO) {
|
if(!_input._defaultVAO) {
|
||||||
glGenVertexArrays(1, &_input._defaultVAO);
|
glGenVertexArrays(1, &_input._defaultVAO);
|
||||||
}
|
}
|
||||||
glBindVertexArray(_input._defaultVAO);
|
glBindVertexArray(_input._defaultVAO);
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLBackend::killInput() {
|
void GLBackend::killInput() {
|
||||||
#if defined(SUPPORT_VAO)
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
if(_input._defaultVAO) {
|
if(_input._defaultVAO) {
|
||||||
glDeleteVertexArrays(1, &_input._defaultVAO);
|
glDeleteVertexArrays(1, &_input._defaultVAO);
|
||||||
}
|
}
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLBackend::syncInputStateCache() {
|
void GLBackend::syncInputStateCache() {
|
||||||
#if defined(SUPPORT_VAO)
|
|
||||||
for (int i = 0; i < _input._attributeActivation.size(); i++) {
|
for (int i = 0; i < _input._attributeActivation.size(); i++) {
|
||||||
GLint active = 0;
|
GLint active = 0;
|
||||||
glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &active);
|
glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &active);
|
||||||
|
@ -105,23 +88,10 @@ void GLBackend::syncInputStateCache() {
|
||||||
}
|
}
|
||||||
//_input._defaultVAO
|
//_input._defaultVAO
|
||||||
glBindVertexArray(_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() {
|
void GLBackend::updateInput() {
|
||||||
#if defined(SUPPORT_VAO)
|
#if defined(SUPPORT_VERTEX_ATTRIB_FORMAT)
|
||||||
if (_input._invalidFormat) {
|
if (_input._invalidFormat) {
|
||||||
|
|
||||||
InputStageState::ActivationCache newActivation;
|
InputStageState::ActivationCache newActivation;
|
||||||
|
@ -198,16 +168,7 @@ void GLBackend::updateInput() {
|
||||||
for (unsigned int i = 0; i < newActivation.size(); i++) {
|
for (unsigned int i = 0; i < newActivation.size(); i++) {
|
||||||
bool newState = newActivation[i];
|
bool newState = newActivation[i];
|
||||||
if (newState != _input._attributeActivation[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) {
|
if (newState) {
|
||||||
glEnableVertexAttribArray(i);
|
glEnableVertexAttribArray(i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -254,30 +215,9 @@ void GLBackend::updateInput() {
|
||||||
GLenum type = _elementTypeToGLType[attrib._element.getType()];
|
GLenum type = _elementTypeToGLType[attrib._element.getType()];
|
||||||
GLuint stride = strides[bufferNum];
|
GLuint stride = strides[bufferNum];
|
||||||
GLuint pointer = attrib._offset + offsets[bufferNum];
|
GLuint pointer = attrib._offset + offsets[bufferNum];
|
||||||
#if defined(SUPPORT_LEGACY_OPENGL)
|
GLboolean isNormalized = attrib._element.isNormalized();
|
||||||
const bool useClientState = slot < NUM_CLASSIC_ATTRIBS;
|
glVertexAttribPointer(slot, count, type, isNormalized, stride,
|
||||||
if (useClientState) {
|
|
||||||
switch (slot) {
|
|
||||||
case Stream::POSITION:
|
|
||||||
glVertexPointer(count, type, stride, reinterpret_cast<GLvoid*>(pointer));
|
|
||||||
break;
|
|
||||||
case Stream::NORMAL:
|
|
||||||
glNormalPointer(type, stride, reinterpret_cast<GLvoid*>(pointer));
|
|
||||||
break;
|
|
||||||
case Stream::COLOR:
|
|
||||||
glColorPointer(count, type, stride, reinterpret_cast<GLvoid*>(pointer));
|
|
||||||
break;
|
|
||||||
case Stream::TEXCOORD:
|
|
||||||
glTexCoordPointer(count, type, stride, reinterpret_cast<GLvoid*>(pointer));
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
GLboolean isNormalized = attrib._element.isNormalized();
|
|
||||||
glVertexAttribPointer(slot, count, type, isNormalized, stride,
|
|
||||||
reinterpret_cast<GLvoid*>(pointer));
|
reinterpret_cast<GLvoid*>(pointer));
|
||||||
}
|
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,28 +238,13 @@ void GLBackend::resetInputStage() {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
|
|
||||||
|
|
||||||
#if defined(SUPPORT_VAO)
|
|
||||||
// TODO
|
|
||||||
#else
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
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);
|
glDisableVertexAttribArray(i);
|
||||||
glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Reset vertex buffer and format
|
// Reset vertex buffer and format
|
||||||
_input._format.reset();
|
_input._format.reset();
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
#include "../GL/glew.h"
|
#include "../GL/glew.h"
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_CORE
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
#define GPU_INPUT_PROFILE GPU_CORE_41
|
||||||
|
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
#include "../GL/glew.h"
|
#include "../GL/glew.h"
|
||||||
#include "../GL/wglew.h"
|
#include "../GL/wglew.h"
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_CORE
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
#define GPU_INPUT_PROFILE GPU_CORE_41
|
||||||
|
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#include "../GL/glew.h"
|
#include "../GL/glew.h"
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_CORE
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
#define GPU_INPUT_PROFILE GPU_CORE_41
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue