Skip to content

Commit

Permalink
Обновления Framebuffer и библиотек
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyaalabai committed Apr 13, 2024
1 parent 201c2ea commit 62a400f
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 27 deletions.
2 changes: 1 addition & 1 deletion external/glm
Submodule glm updated 1 files
+5 −1 glm/detail/setup.hpp
2 changes: 1 addition & 1 deletion external/imgui
4 changes: 2 additions & 2 deletions firesteel/includes/firesteel/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace firesteel {
}

template <typename T>
void push() {
creators_[typeid(T)] = [=](const Component& original) -> std::shared_ptr<Component> {
static void push() {
instance().creators_[typeid(T)] = [=](const Component& original) -> std::shared_ptr<Component> {
return std::make_shared<T>(dynamic_cast<const T&>(original));
};
}
Expand Down
15 changes: 11 additions & 4 deletions firesteel/includes/firesteel/rendering/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ namespace firesteel {
/// Sets up camera.
/// </summary>
/// <param name="t_pos">Position of new camera.</param>
/// <param name="t_yaw">Yaw.</param>
/// <param name="t_pitch">Pitch.</param>
Camera(glm::vec3 t_pos, float t_yaw, float t_pitch);
/// <param name="t_roll">Roll (X).</param>
/// <param name="t_yaw">Yaw (Y).</param>
/// <param name="t_pitch">Pitch (Z).</param>
Camera(glm::vec3 t_pos, float t_roll, float t_yaw, float t_pitch);
/// <summary>
/// Sets up camera.
/// </summary>
/// <param name="t_pos">Position of new camera.</param>
/// <param name="t_yaw">Rotation.</param>
Camera(glm::vec3 t_pos, glm::vec3 t_rot);

/// <summary>
/// Updates camera vectors.
Expand All @@ -38,7 +45,7 @@ namespace firesteel {
glm::mat4 get_projection_matrix(float t_clip_size = 1);

glm::vec3 position;
glm::vec4 rotation;
glm::vec3 rotation;
glm::vec3 world_up;

glm::vec3 forward;
Expand Down
5 changes: 2 additions & 3 deletions firesteel/includes/firesteel/rendering/framebuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace firesteel {
public:
FrameBuffer();
FrameBuffer(glm::vec2 t_scale, bool t_drawer);
~FrameBuffer() { remove(); }

/// <summary>
/// Resize frame buffer.
Expand All @@ -31,7 +30,7 @@ namespace firesteel {
/// Get ID of buffer's texture.
/// </summary>
/// <returns>ID of buffer's texture.</returns>
unsigned int get_id() const { return m_texture_color_buffer; }
unsigned int get_id() const { return m_texture; }
/// <summary>
/// Draw texture to object.
/// </summary>
Expand All @@ -43,7 +42,7 @@ namespace firesteel {
/// <param name="t_screen_shader">Draw shader.</param>
void draw(Shader t_screen_shader);
private:
unsigned int m_fbo = 0, m_texture_color_buffer = 0, m_rbo = 0, m_vao = 0, m_vbo = 0;
unsigned int m_fbo = 0, m_texture = 0, m_rbo = 0, m_vao = 0, m_vbo = 0;
};
}

Expand Down
2 changes: 1 addition & 1 deletion firesteel/includes/firesteel/rendering/material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace firesteel {
shader = Shader(data.at("shaders").value("vertex", "").c_str(),
data.at("shaders").value("fragment", "").c_str());
//Compatability.
if(data.contains("name")) name = data.value("name", "New Material");
name = data.value("name", "New Material");
if(data.contains("variables")) {
shader.enable();
for(auto& i : data.at("variables").items()) {
Expand Down
2 changes: 1 addition & 1 deletion firesteel/includes/firesteel/rendering/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace firesteel {
/// Loads transform.
/// </summary>
/// <param name="t_path">Path to model.</param>
void load_model(std::string t_path);
void load(std::string t_path);
/// <summary>
/// Add mesh to model.
/// </summary>
Expand Down
13 changes: 7 additions & 6 deletions firesteel/includes/firesteel/rendering/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#define WINDOW_H

#include <string>
#include "firesteel/common.hpp"
#ifdef FS_IMGUI
//Includes ImGui without need to add it to CMake project.
#include <imgui/imgui.h>
#include <imgui/misc/cpp/imgui_stdlib.h>
#endif // FS_IMGUI
#include "firesteel/math.hpp"
#include "firesteel/common.hpp"

struct GLFWwindow;
struct ImFont;
Expand Down Expand Up @@ -52,26 +51,27 @@ namespace firesteel {
/// <returns>true=success;false=failure</returns>
bool initialize();
/// <summary>
/// Updates events and clears buffers.
/// Get events.
/// </summary>
void update();
void pull_events();
/// <summary>
/// Closes window.
/// </summary>
void close();
/// <summary>
/// Clear window's contents.
/// </summary>
void clear();

/// <summary>
/// Initializes ImGui.
/// </summary>
void gui_initialize();
/// <summary>
/// [HANDELED BY APP CLASS]
/// Updates ImGui.
/// </summary>
void gui_update();
/// <summary>
/// [HANDELED BY APP CLASS]
/// Draws ImGui.
/// </summary>
void gui_draw();
Expand All @@ -90,6 +90,7 @@ namespace firesteel {
/// </summary>
void set_init_params();
void set_drop_callback(void (*t_drop_callback)(int count, const char** paths));
void set_resize_callback(void (*t_resize_callback)(int t_width, int t_height));

int get_param_i(WindowParam t_param) const;
bool get_param_b(WindowParam t_param) const;
Expand Down
2 changes: 1 addition & 1 deletion firesteel/src/firesteel/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace firesteel {
if(!drawn_ui) { window.gui_draw(); drawn_ui = true; }
window.pull_events();
if(drawn_ui) window.gui_update();
window.update();
window.clear();
if(update_app) update();
drawn_ui = false;
}
Expand Down
18 changes: 13 additions & 5 deletions firesteel/src/firesteel/rendering/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@ namespace firesteel {

Camera::Camera()
: position(glm::vec3(0.f)), world_up(glm::vec3(0.f, 1.f, 0.f)),
rotation(glm::vec4(0.f, 0.f, -90.f, 1.f)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
rotation(glm::vec3(0.f, 0.f, -90.f)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
is_perspective(true), far_plane(100.f), near_plane(0.1f),
up(glm::vec3(0.f)), right(glm::vec3(0.f)), aspect(0.5f) { }

Camera::Camera(glm::vec3 t_pos)
: position(t_pos), world_up(glm::vec3(0.f, 1.f, 0.f)),
rotation(glm::vec4(0.f, 0.f, -90.f, 1.f)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
rotation(glm::vec3(0.f, 0.f, -90.f)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
is_perspective(true), far_plane(100.f), near_plane(0.1f) {
update_vectors();
}

Camera::Camera(glm::vec3 t_pos, float t_yaw, float t_pitch)
Camera::Camera(glm::vec3 t_pos, float t_roll, float t_yaw, float t_pitch)
: position(t_pos), world_up(glm::vec3(0.f, 1.f, 0.f)),
rotation(glm::vec4(0.f, t_pitch, t_yaw, 1.f)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
rotation(glm::vec3(t_roll, t_pitch, t_yaw)), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
is_perspective(true), far_plane(100.f), near_plane(0.1f) {
update_vectors();
}

Camera::Camera(glm::vec3 t_pos, glm::vec3 t_rot)
: position(t_pos), world_up(glm::vec3(0.f, 1.f, 0.f)),
rotation(t_rot), fov(45.f), forward(glm::vec3(0.f, 0.f, -1.f)),
is_perspective(true), far_plane(100.f), near_plane(0.1f) {
update_vectors();
}
Expand All @@ -34,7 +41,8 @@ namespace firesteel {
//Calculate directions.
forward = glm::normalize(dir);
right = glm::normalize(glm::cross(forward, world_up));
up = glm::normalize(glm::cross(right, forward));
up = glm::mat3(glm::rotate(glm::mat4(1.0f), roll, forward))
* glm::normalize(glm::cross(right, forward));
}

glm::mat4 Camera::get_view_matrix() const {
Expand Down
2 changes: 1 addition & 1 deletion firesteel/src/firesteel/rendering/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace firesteel {
return static_cast<int>(m_instances.size());
}

void Transform::load_model(std::string t_path) {
void Transform::load(std::string t_path) {
//Clear old model (if present).
remove_model();
//Initialize importer.
Expand Down

0 comments on commit 62a400f

Please sign in to comment.