add ve name
This commit is contained in:
@@ -11,7 +11,7 @@ namespace sandbox
|
|||||||
void local_panel::render()
|
void local_panel::render()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ImGui::Button("RUN thread", ImVec2(128, 130)))
|
if (ImGui::Button(VE_NAME("RUN thread"), ImVec2(128, 130)))
|
||||||
{
|
{
|
||||||
auto f = []()
|
auto f = []()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ namespace sandbox
|
|||||||
struct camera
|
struct camera
|
||||||
{
|
{
|
||||||
// Начальное положение камеры
|
// Начальное положение камеры
|
||||||
mt::vec3 m_pos = mt::vec3{ 0.0f, 0.0f, 3.0f };
|
glm::vec3 m_pos = glm::vec3{ 0.0f, 0.0f, 3.0f };
|
||||||
mt::vec3 m_front = mt::vec3{ 0.0f, 0.0f, -1.0f };
|
glm::vec3 m_front = glm::vec3{ 0.0f, 0.0f, -1.0f };
|
||||||
mt::vec3 m_up = mt::vec3{ 0.0f, 1.0f, 0.0f };
|
glm::vec3 m_up = glm::vec3{ 0.0f, 1.0f, 0.0f };
|
||||||
float m_speed = 0.05f;
|
float m_speed = 0.05f;
|
||||||
|
|
||||||
glm::mat4 m_view, m_projection;
|
glm::mat4 m_view, m_projection;
|
||||||
|
|
||||||
void up() { m_pos += m_speed * m_front; }
|
void up() { m_pos += m_speed * m_front; }
|
||||||
void down() { m_pos -= m_speed * m_front; }
|
void down() { m_pos -= m_speed * m_front; }
|
||||||
void left() { m_pos -= mt::normalize(mt::cross(m_front, m_up)) * m_speed; }
|
void left() { m_pos -= glm::normalize(glm::cross(m_front, m_up)) * m_speed; }
|
||||||
void right() { m_pos += mt::normalize(mt::cross(m_front, m_up)) * m_speed; }
|
void right() { m_pos += glm::normalize(glm::cross(m_front, m_up)) * m_speed; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void update(const T& obj)
|
void update(const T& obj)
|
||||||
@@ -41,7 +41,7 @@ namespace sandbox
|
|||||||
static_cast<float>(VE::application::get()->get_glfw()->width()) / VE::application::get()->get_glfw()->height(),
|
static_cast<float>(VE::application::get()->get_glfw()->width()) / VE::application::get()->get_glfw()->height(),
|
||||||
0.1f, 100.0f);
|
0.1f, 100.0f);
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "view"), 1, GL_FALSE, mt::value_ptr(m_view));
|
glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "view"), 1, GL_FALSE, glm::value_ptr(m_view));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "projection"), 1, GL_FALSE, glm::value_ptr(m_projection));
|
glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "projection"), 1, GL_FALSE, glm::value_ptr(m_projection));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,11 +75,11 @@ namespace sandbox
|
|||||||
if (m_pitch > 89.0f) m_pitch = 89.0f;
|
if (m_pitch > 89.0f) m_pitch = 89.0f;
|
||||||
if (m_pitch < -89.0f) m_pitch = -89.0f;
|
if (m_pitch < -89.0f) m_pitch = -89.0f;
|
||||||
|
|
||||||
mt::vec3 front;
|
glm::vec3 front;
|
||||||
front.x = std::cos(mt::radians(m_yaw)) * std::cos(mt::radians(m_pitch));
|
front.x = std::cos(glm::radians(m_yaw)) * std::cos(glm::radians(m_pitch));
|
||||||
front.y = std::sin(mt::radians(m_pitch));
|
front.y = std::sin(glm::radians(m_pitch));
|
||||||
front.z = std::sin(mt::radians(m_yaw)) * std::cos(mt::radians(m_pitch));
|
front.z = std::sin(glm::radians(m_yaw)) * std::cos(glm::radians(m_pitch));
|
||||||
m_front = mt::normalize(front);
|
m_front = glm::normalize(front);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace VE
|
|||||||
// что не есть хорошо для умных указателей
|
// что не есть хорошо для умных указателей
|
||||||
GLFWwindow* m_win;
|
GLFWwindow* m_win;
|
||||||
std::unique_ptr<context> m_context;
|
std::unique_ptr<context> m_context;
|
||||||
mt::vec4 m_bgcolor = { 0.1f, 0.1f, 0.1f, 1.f };
|
glm::vec4 m_bgcolor = { 0.1f, 0.1f, 0.1f, 1.f };
|
||||||
|
|
||||||
struct win_data
|
struct win_data
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
#include "utils/utils.hpp" // IWYU pragma: keep
|
#include "utils/utils.hpp" // IWYU pragma: keep
|
||||||
|
|
||||||
namespace VE
|
namespace VE
|
||||||
@@ -17,11 +19,11 @@ namespace VE
|
|||||||
GLuint get_id() const noexcept;
|
GLuint get_id() const noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set(std::string location, mt::vec2 value);
|
void set(std::string location, glm::vec2 value);
|
||||||
void set(std::string location, mt::vec3 value);
|
void set(std::string location, glm::vec3 value);
|
||||||
void set(std::string location, mt::vec4 value);
|
void set(std::string location, glm::vec4 value);
|
||||||
void set(std::string location, mt::mat3 value);
|
void set(std::string location, glm::mat3 value);
|
||||||
void set(std::string location, mt::mat4 value);
|
void set(std::string location, glm::mat4 value);
|
||||||
void set(std::string location, float value);
|
void set(std::string location, float value);
|
||||||
void set(std::string location, int value);
|
void set(std::string location, int value);
|
||||||
|
|
||||||
|
|||||||
@@ -17,3 +17,5 @@
|
|||||||
#define VE_PUSH_FONT(def_font, def_size)\
|
#define VE_PUSH_FONT(def_font, def_size)\
|
||||||
ImGui::PushFont(VE::style::fonts::get_font(VE::style::fonts::font_type::def_font, def_size))
|
ImGui::PushFont(VE::style::fonts::get_font(VE::style::fonts::font_type::def_font, def_size))
|
||||||
#define VE_POP_FONT() ImGui::PopFont()
|
#define VE_POP_FONT() ImGui::PopFont()
|
||||||
|
|
||||||
|
#define VE_NAME(n) VE::func::name(n).data()
|
||||||
|
|||||||
26
src/utils/func.hpp
Normal file
26
src/utils/func.hpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
namespace VE::func
|
||||||
|
{
|
||||||
|
inline auto name(std::string n)
|
||||||
|
{
|
||||||
|
return "##" + n;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ImU32 color(std::string hex, unsigned char alpha = 255)
|
||||||
|
{
|
||||||
|
if (hex[0] == '#') hex.erase(0, 1);
|
||||||
|
|
||||||
|
unsigned int r = 255;
|
||||||
|
unsigned int g = 255;
|
||||||
|
unsigned int b = 255;
|
||||||
|
|
||||||
|
if (hex.length() == 6) std::sscanf(hex.c_str(), "%2x%2x%2x", &r, &g, &b);
|
||||||
|
|
||||||
|
return IM_COL32(r, g, b, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,10 +22,12 @@
|
|||||||
второй это поставить glad первым
|
второй это поставить glad первым
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glad.h> // IWYU pragma: keep
|
#include <glad.h>
|
||||||
#include <GLFW/glfw3.h> // IWYU pragma: keep
|
#include <GLFW/glfw3.h>
|
||||||
#include <hack/logger/logger.hpp> // IWYU pragma: keep
|
#include <hack/logger/logger.hpp>
|
||||||
#include <hack/patterns/singleton.hpp> // IWYU pragma: keep
|
#include <hack/patterns/singleton.hpp>
|
||||||
#include <imgui.h> // IWYU pragma: keep
|
#include <imgui.h>
|
||||||
#include <imgui_impl_glfw.h> // IWYU pragma: keep
|
#include <imgui_impl_glfw.h>
|
||||||
#include <imgui_impl_opengl3.h> // IWYU pragma: keep
|
#include <imgui_impl_opengl3.h>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
|
|
||||||
namespace mt
|
|
||||||
{
|
|
||||||
using namespace glm;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T convert(vec2& v) { return T{ v.x, v.y }; }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T convert(vec3& v) { return T{ v.x, v.y, v.z }; }
|
|
||||||
}
|
|
||||||
@@ -6,4 +6,4 @@
|
|||||||
#include "var.hpp" // IWYU pragma: keep
|
#include "var.hpp" // IWYU pragma: keep
|
||||||
#include "include.hpp" // IWYU pragma: keep
|
#include "include.hpp" // IWYU pragma: keep
|
||||||
#include "using.hpp" // IWYU pragma: keep
|
#include "using.hpp" // IWYU pragma: keep
|
||||||
#include "math.hpp" // IWYU pragma: keep
|
#include "func.hpp" // IWYU pragma: keep
|
||||||
|
|||||||
Reference in New Issue
Block a user