void VideoShader::update(VideoMaterial *material) { if (!material->bind()) return; const VideoFormat fmt(material->currentFormat()); //format is out of date because we may use the same shader for different formats setVideoFormat(fmt); // uniforms begin program()->bind(); //glUseProgram(id). for glUniform // all texture ids should be binded when renderering even for packed plane! const int nb_planes = fmt.planeCount(); //number of texture id for (int i = 0; i < nb_planes; ++i) { // use glUniform1i to swap planes. swap uv: i => (3-i)%3 // TODO: in shader, use uniform sample2D u_Texture[], and use glUniform1iv(u_Texture, 3, {...}) program()->setUniformValue(textureLocation(i), (GLint)i); } if (nb_planes < textureLocationCount()) { for (int i = nb_planes; i < textureLocationCount(); ++i) { program()->setUniformValue(textureLocation(i), (GLint)(nb_planes - 1)); } } //qDebug() << "color mat " << material->colorMatrix(); program()->setUniformValue(colorMatrixLocation(), material->colorMatrix()); program()->setUniformValue(bppLocation(), (GLfloat)material->bpp()); //program()->setUniformValue(matrixLocation(), material->matrix()); //what about sgnode? state.combindMatrix()? // uniform end. attribute begins }
void LevelMainCharacter::setStunned(const sf::Time& stunnedTime) { if (m_isDead) return; LevelMovableGameObject::setStunned(stunnedTime); DamageOverTimeData data; data.isStunned = true; sf::IntRect textureLocation(300, 0, 50, 50); dynamic_cast<LevelScreen*>(m_screen)->addDotBuffToInterface(textureLocation, stunnedTime, data); }
void LevelMainCharacter::addDamageOverTime(DamageOverTimeData& data) { if (m_isDead || data.damageType == DamageType::VOID) return; sf::IntRect textureLocation((static_cast<int>(data.damageType)-1) * 50, 0, 50, 50); dynamic_cast<LevelScreen*>(m_screen)->addDotBuffToInterface(textureLocation, data.duration, data); LevelMovableGameObject::addDamageOverTime(data); }