add opengl

This commit is contained in:
Andrey Zimin
2024-05-15 10:57:21 +03:00
parent a0b5e810f7
commit b1d693dbd4
9 changed files with 130 additions and 44 deletions

View File

@@ -6,6 +6,8 @@ namespace VE
{
application::application(std::string app_name) : m_glfw{ std::make_unique<glfw>() }
{
m_instance = std::unique_ptr<application>(this);
m_glfw->init(app_name);
m_glfw->set_event_fn(VE_EVENT_FN);
@@ -14,10 +16,6 @@ namespace VE
void application::run()
{
glEnable(GL_DEPTH_TEST);
glClearColor(0.07f, 0.13f, 0.17f, 1.0f);
glViewport(0, 0, m_glfw->width(), m_glfw->height());
while(!glfwWindowShouldClose(m_glfw->get_win()))
{
m_glfw->clear();
@@ -35,6 +33,11 @@ namespace VE
return m_glfw;
}
std::unique_ptr<application>& application::get()
{
return m_instance;
}
void application::attach_layers()
{
for (auto l : m_layers_stack) l->on_attach();

View File

@@ -16,9 +16,11 @@ namespace VE
std::unique_ptr<glfw> m_glfw;
std::unique_ptr<gui> m_gui;
layers_stack<layer> m_layers_stack;
inline static std::unique_ptr<application> m_instance;
public:
void run();
static std::unique_ptr<application>& get();
std::unique_ptr<glfw>& get_glfw();
public:

View File

@@ -33,7 +33,7 @@ namespace VE
set_key_callback();
set_mouse_callback();
set_window_callback();
set_opengl();
}
void glfw::set_hint()
@@ -122,6 +122,12 @@ namespace VE
auto d = static_cast<win_data*>(glfwGetWindowUserPointer(w));
event e{ action, key };
// HERE
// тут одноврекменно срабатывает только один сигнал
// т.е. если нажада клавиша и удерживается сигнал о повторе идет
// но если нажать одновременно еще, то сигнал о той нажатой пропадает
// нужносамому реализовывать функцию повтора а не полагаться на внутреннюю
// реализацию glfw
switch (action)
{
case GLFW_PRESS:
@@ -212,4 +218,11 @@ namespace VE
d->execute(e);
});
}
void glfw::set_opengl()
{
glEnable(GL_DEPTH_TEST);
glClearColor(0.07f, 0.13f, 0.17f, 1.0f);
glViewport(0, 0, m_win_data.m_width, m_win_data.m_height);
}
}

View File

@@ -50,6 +50,7 @@ namespace VE
void set_key_callback();
void set_mouse_callback();
void set_window_callback();
void set_opengl();
};
}

View File

@@ -24,6 +24,7 @@
#include "glad.h"
#include "GLFW/glfw3.h"
#include "hack/logger/logger.hpp"
#include "hack/utils/singleton.hpp"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"

View File

@@ -4,14 +4,8 @@
namespace mt
{
using vec2 = glm::vec2;
using vec3 = glm::vec3;
using vec4 = glm::vec4;
using mat2 = glm::mat2;
using mat3 = glm::mat3;
using mat4 = glm::mat4;
using namespace glm;
template<typename T>
T convert(glm::vec2& v) { return T{ v.x, v.y }; }
T convert(vec2& v) { return T{ v.x, v.y }; }
}