syncInputStateCache

This commit is contained in:
Atlante45 2015-05-22 17:31:37 +02:00
parent 9561086d0d
commit e5aa696dda
4 changed files with 14 additions and 13 deletions

View file

@ -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<GeometryCache> geometryCacheP = DependencyManager::get<GeometryCache>();
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

View file

@ -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) {

View file

@ -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;

View file

@ -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;