void BufferObject::bind() { glGetIntegerv(GetBindingTarget(type_), &old_); glBindBuffer(type_, object_); }
void MaterialBindingImpl::FlushInternalState() const { if( m_isInputsValid ) { return; } for( InputsCache::iterator it = m_cachedInputs.begin(); m_cachedInputs.end() != it; ++it ) { it->second.clear(); Scene *context = it->first; const Batch *batch = GetBatch(context); const Effect *effect = GetMaterial(context)->GetEffect(context); for( size_t i = 0; i < effect->GetInputCount(); ++i ) { const char *sem = effect->GetInputSemantic(i); MaterialBinding::Target target; if( !GetBindingTarget(sem, &target) ) { // explicit binding is not specified, use semantic as is target.index = -1; // target should be located at primary attribute set target.semantic = sem; } bool found = false; const VertexElementDesc *desc = NULL; // search primary for( size_t j = 0; j < batch->GetMesh(context)->GetPrimaryVertexElementCount() && !found; ++j ) { desc = batch->GetMesh(context)->GetPrimaryVertexElementDescs() + j; if( 0 == strcmp(desc->semanticName, target.semantic) && (-1 == target.index || batch->GetPrimarySet() == target.index) ) { found = true; } } // search extra for( size_t j = 0; j < batch->GetExtraVertexElementCount() && !found; ++j ) { const VertexElementDescEx *descEx = batch->GetExtraVertexElementDescs() + j; if( 0 == strcmp(descEx->semanticName, target.semantic) && (-1 == target.index || descEx->semanticIndex == target.index) ) { desc = descEx; found = true; } } if( !found ) { printf("WARNING! semantic \"%s/%d\" not found in vertex declaration\n", target.semantic, target.index); // TODO: search for any compatible vertex attribute } assert(desc); if( desc ) { VertexElementDesc requiredInput; requiredInput.componentType = desc->componentType; requiredInput.componentCount = desc->componentCount; requiredInput.inputSlot = desc->inputSlot; requiredInput.semanticName = sem; it->second.push_back(requiredInput); } } } m_isInputsValid = true; }