Skip to content

Commit

Permalink
format code using clang-format and simplify the check loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzzhHe committed Nov 30, 2024
1 parent db83b1e commit 5be9a71
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

#include "demo_0.h"

#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
#include "renderer/render_target.h"
#include "renderer/resources/mesh_data.h"
#include "renderer/resources/shader_source.h"
#include "renderer/shader_program.h"
#include "renderer/demo/util.h"


namespace openage::renderer::tests {
Expand Down Expand Up @@ -51,7 +51,7 @@ void renderer_demo_0(const util::Path &path) {
false,
};

if (!check_uniform_completeness({display_stuff})) {
if (not check_uniform_completeness({display_stuff})) {
log::log(WARN << "Uniforms not complete.");
}

Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <epoxy/gl.h>
#include <QMouseEvent>

#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
Expand All @@ -15,7 +16,6 @@
#include "renderer/shader_program.h"
#include "renderer/texture.h"
#include "util/math_constants.h"
#include "renderer/demo/util.h"


namespace openage::renderer::tests {
Expand Down Expand Up @@ -173,7 +173,7 @@ void renderer_demo_1(const util::Path &path) {

auto pass2 = renderer->add_render_pass({display_obj}, renderer->get_display_target());

if (!check_uniform_completeness({obj1, obj2, obj3, proj_update, display_obj})) {
if (not check_uniform_completeness({obj1, obj2, obj3, proj_update, display_obj})) {
log::log(WARN << "Uniforms not complete.");
}

Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <epoxy/gl.h>
#include <QMouseEvent>

#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
Expand All @@ -18,7 +19,6 @@
#include "renderer/resources/texture_data.h"
#include "renderer/shader_program.h"
#include "renderer/texture.h"
#include "renderer/demo/util.h"


namespace openage::renderer::tests {
Expand Down Expand Up @@ -225,7 +225,7 @@ void renderer_demo_2(const util::Path &path) {

auto pass2 = renderer->add_render_pass({display_obj}, renderer->get_display_target());

if (!check_uniform_completeness({proj_update, obj1, display_obj})) {
if (not check_uniform_completeness({proj_update, obj1, display_obj})) {
log::log(WARN << "Uniforms not complete.");
}

Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <eigen3/Eigen/Dense>
#include <QKeyEvent>

#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
Expand All @@ -16,7 +17,6 @@
#include "renderer/resources/shader_source.h"
#include "renderer/resources/texture_data.h"
#include "renderer/shader_program.h"
#include "renderer/demo/util.h"
#include "time/clock.h"


Expand Down Expand Up @@ -166,7 +166,7 @@ void renderer_demo_4(const util::Path &path) {

auto pass2 = renderer->add_render_pass({display_obj}, renderer->get_display_target());

if (!check_uniform_completeness({proj_update, obj1, display_obj})) {
if (not check_uniform_completeness({proj_update, obj1, display_obj})) {
log::log(WARN << "Uniforms not complete.");
}

Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QMouseEvent>

#include "renderer/camera/camera.h"
#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
Expand All @@ -17,7 +18,6 @@
#include "renderer/shader_program.h"
#include "renderer/uniform_buffer.h"
#include "renderer/uniform_input.h"
#include "renderer/demo/util.h"


namespace openage::renderer::tests {
Expand Down Expand Up @@ -135,7 +135,7 @@ void renderer_demo_5(const util::Path &path) {
"tex",
gltex);

if (!check_uniform_completeness({terrain_obj})) {
if (not check_uniform_completeness({terrain_obj})) {
log::log(WARN << "Uniforms not complete.");
}

Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/demo/demo_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "renderer/camera/camera.h"
#include "renderer/camera/frustum_2d.h"
#include "renderer/camera/frustum_3d.h"
#include "renderer/demo/util.h"
#include "renderer/gui/integration/public/gui_application_with_logger.h"
#include "renderer/opengl/window.h"
#include "renderer/render_pass.h"
Expand All @@ -23,7 +24,6 @@
#include "renderer/shader_program.h"
#include "renderer/texture.h"
#include "renderer/uniform_buffer.h"
#include "renderer/demo/util.h"
#include "time/clock.h"
#include "util/path.h"
#include "util/vector.h"
Expand Down Expand Up @@ -490,7 +490,7 @@ void RenderManagerDemo6::create_render_passes() {
{display_obj_3d, display_obj_2d, display_obj_frame},
renderer->get_display_target());

if (!check_uniform_completeness({display_obj_3d, display_obj_2d, display_obj_frame})) {
if (not check_uniform_completeness({display_obj_3d, display_obj_2d, display_obj_frame})) {
log::log(WARN << "Uniforms not complete.");
}
}
Expand Down
9 changes: 4 additions & 5 deletions libopenage/renderer/demo/util.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#include "util.h"

#include "renderer/uniform_input.h"


namespace openage::renderer::tests {

bool check_uniform_completeness(const std::vector<Renderable> &renderables) {
bool all_complete = true;

// Iterate over each renderable object
for (const auto &renderable : renderables) {
if (renderable.uniform && !renderable.uniform->is_complete()) {
all_complete = false;
if (renderable.uniform && not renderable.uniform->is_complete()) {
return false;
}
}

return all_complete;
return true;
}

} // namespace openage::renderer::tests
1 change: 1 addition & 0 deletions libopenage/renderer/demo/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include <vector>

#include "renderer/renderable.h"

namespace openage::renderer::tests {
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/opengl/uniform_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GlUniformBufferInput::GlUniformBufferInput(const std::shared_ptr<UniformBuffer>
}

bool GlUniformInput::is_complete() const {
for (const auto& uniform : this->update_offs) {
for (const auto &uniform : this->update_offs) {
if (!uniform.used) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions libopenage/renderer/opengl/uniform_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class GlUniformInput final : public UniformInput {
public:
GlUniformInput(const std::shared_ptr<ShaderProgram> &prog);

/**
* Check if all uniforms have been set.
*/
bool is_complete() const override;
/**
* Check if all uniforms have been set.
*/
bool is_complete() const override;

/**
* Store the IDs of the uniforms from the shader set by this uniform input.
Expand Down

0 comments on commit 5be9a71

Please sign in to comment.