renaming shaderDrawable to shaderDrawable 2d

This commit is contained in:
Clément Le Bihan
2021-06-08 16:10:20 +02:00
parent 7bff82a5c9
commit 3e9037ed92
4 changed files with 27 additions and 22 deletions

View File

@@ -30,33 +30,34 @@ namespace BBM
this->_window.clear();
this->_window.useCamera(this->_camera);
for (auto &[_, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable3DComponent>()) {
auto *modelShader = _.tryGetComponent<ShaderComponentModel>();
auto *shader = _.tryGetComponent<ShaderComponentModel>();
for (auto &[entity, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable3DComponent>()) {
auto *modelShader = entity.tryGetComponent<ShaderComponentModel>();
if (modelShader) {
auto &model = dynamic_cast<RAY::Drawables::Drawables3D::Model &>(*drawable.drawable);
model.setShader(modelShader->getShader());
}
if (shader) {
RAY::Shader::BeginUsingCustomShader(shader->getShader());
}
drawable.drawable->setPosition(pos.position);
drawable.drawable->drawOn(this->_window);
if (modelShader) {
auto &model = dynamic_cast<RAY::Drawables::Drawables3D::Model &>(*drawable.drawable);
model.resetShader();
}
if (shader) {
RAY::Shader::EndUsingCustomShader();
}
}
this->_window.unuseCamera();
// TODO sort entities based on the Z axis
for (auto &[_, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable2DComponent>()) {
for (auto &[entity, pos, drawable] : this->_wal.scene->view<PositionComponent, Drawable2DComponent>()) {
auto *shader = entity.tryGetComponent<ShaderComponentDrawable2D>();
if (shader) {
RAY::Shader::BeginUsingCustomShader(shader->getShader());
}
drawable.drawable->setPosition(Vector2f(pos.position.x, pos.position.y));
drawable.drawable->drawOn(this->_window);
if (shader) {
RAY::Shader::EndUsingCustomShader();
}
}
if (this->_debugMode)
this->_window.drawFPS(Vector2f());