Merge branch 'master' of https://bitbucket.org/omigamedev/new_engine
This commit is contained in:
@@ -31,11 +31,11 @@ public:
|
||||
|
||||
struct StrokeSample
|
||||
{
|
||||
glm::vec2 pos;
|
||||
glm::vec2 origin;
|
||||
float size;
|
||||
float flow;
|
||||
float angle;
|
||||
glm::vec2 pos = { 0, 0 };
|
||||
glm::vec2 origin = { 0,0 };
|
||||
float size = 0;
|
||||
float flow = 0;
|
||||
float angle = 0;
|
||||
};
|
||||
|
||||
class BrushMesh
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
GLuint vao{ 0 };
|
||||
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; };
|
||||
struct instance_t { glm::mat4 mvp; float flow; };
|
||||
int loc_flow;
|
||||
int loc_mvp;
|
||||
int loc_flow = 0;
|
||||
int loc_mvp = 0;
|
||||
|
||||
bool create();
|
||||
void draw(const std::vector<StrokeSample>& samples, const glm::mat4& proj);
|
||||
@@ -57,19 +57,19 @@ class Stroke
|
||||
public:
|
||||
struct Keypoint
|
||||
{
|
||||
glm::vec2 pos;
|
||||
float pressure;
|
||||
float dist;
|
||||
glm::vec2 pos = { 0, 0 };
|
||||
float pressure = 0;
|
||||
float dist = 0;
|
||||
};
|
||||
struct Camera
|
||||
{
|
||||
glm::vec2 rot;
|
||||
float fov;
|
||||
glm::vec2 rot = { 0, 0 };
|
||||
float fov = 0;
|
||||
};
|
||||
int m_layer;
|
||||
float m_curve;
|
||||
float m_dist;
|
||||
float m_step;
|
||||
int m_layer = 0;
|
||||
float m_curve = 0;
|
||||
float m_dist = 0;
|
||||
float m_step = 0;
|
||||
Camera m_camera;
|
||||
ui::Brush m_brush;
|
||||
cbuffer<float, 3> m_curve_angles;
|
||||
|
||||
@@ -580,7 +580,8 @@ void ui::Canvas::stroke_start(glm::vec2 point, float pressure, const ui::Brush&
|
||||
}
|
||||
|
||||
m_current_stroke = std::make_unique<Stroke>();
|
||||
m_current_stroke->m_camera = { m_cam_rot, m_cam_fov };
|
||||
m_current_stroke->m_camera.rot = m_cam_rot;
|
||||
m_current_stroke->m_camera.fov = m_cam_fov;
|
||||
m_current_stroke->start(brush);
|
||||
m_current_stroke->add_point(point, pressure);
|
||||
|
||||
@@ -808,27 +809,58 @@ void ui::Canvas::import_equirectangular(std::string file_path)
|
||||
|
||||
void ui::Canvas::import_equirectangular_thread(std::string file_path)
|
||||
{
|
||||
Texture2D tex;
|
||||
gl_state gl;
|
||||
App::I.async_start();
|
||||
|
||||
gl_state gl;
|
||||
gl.save();
|
||||
snap_history({0,1,2,3,4,5});
|
||||
tex.load_file(file_path);
|
||||
ui::Sphere sphere;
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
sphere.create<64, 64>(2.f);
|
||||
draw_objects([&](const glm::mat4& camera, const glm::mat4& proj){
|
||||
m_sampler.bind(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
ShaderManager::use(ui::kShader::Texture);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj * camera *
|
||||
glm::eulerAngleY(glm::radians(-90.f)) * glm::scale(glm::vec3(1,-1,1)));
|
||||
sphere.draw_fill();
|
||||
tex.unbind();
|
||||
m_sampler.unbind();
|
||||
});
|
||||
|
||||
Image img;
|
||||
img.load_file(file_path);
|
||||
|
||||
if (img.width == img.height / 6)
|
||||
{
|
||||
Texture2D tex;
|
||||
static GLint indices[] = { 5, 1, 4, 0, 2, 3 };
|
||||
static GLint formats[] = { GL_RED, GL_RG, GL_RGB, GL_RGBA };
|
||||
static GLint iformats[] = { GL_R8, GL_RG8, GL_RGB8, GL_RGBA8 };
|
||||
tex.create(img.width, img.width, iformats[img.comp - 1], formats[img.comp - 1]);
|
||||
int stride = img.width * img.width * img.comp;
|
||||
ui::Plane plane;
|
||||
plane.create<1>(2, 2);
|
||||
draw_objects([&](const glm::mat4& camera, const glm::mat4& proj, int i) {
|
||||
tex.update(img.m_data.get() + indices[i] * stride);
|
||||
m_sampler.bind(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
ShaderManager::use(ui::kShader::Texture);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::scale(glm::vec3(1, -1, 1)));
|
||||
plane.draw_fill();
|
||||
tex.unbind();
|
||||
m_sampler.unbind();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Texture2D tex;
|
||||
tex.load_file(file_path);
|
||||
ui::Sphere sphere;
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
sphere.create<64, 64>(2.f);
|
||||
draw_objects([&](const glm::mat4& camera, const glm::mat4& proj, int i) {
|
||||
m_sampler.bind(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
ShaderManager::use(ui::kShader::Texture);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj * camera *
|
||||
glm::eulerAngleY(glm::radians(-90.f)) * glm::scale(glm::vec3(1, -1, 1)));
|
||||
sphere.draw_fill();
|
||||
tex.unbind();
|
||||
m_sampler.unbind();
|
||||
});
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
m_layers[m_current_layer_idx].m_dirty_box[i] = glm::vec4(0, 0, m_width, m_height);
|
||||
@@ -1530,7 +1562,7 @@ ui::Image ui::Canvas::thumbnail_read(std::string data_path)
|
||||
return std::move(thumb);
|
||||
}
|
||||
|
||||
void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj)> observer, Layer& layer)
|
||||
void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)> observer, Layer& layer)
|
||||
{
|
||||
// save viewport and clear color states
|
||||
GLint vp[4];
|
||||
@@ -1549,7 +1581,7 @@ void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const
|
||||
glm::mat4 plane_camera = glm::lookAt(glm::vec3(0), m_plane_origin[i], m_plane_tangent[i]);
|
||||
layer.m_rtt[i].bindFramebuffer();
|
||||
|
||||
observer(plane_camera, proj);
|
||||
observer(plane_camera, proj, i);
|
||||
|
||||
layer.m_rtt[i].unbindFramebuffer();
|
||||
}
|
||||
@@ -1561,7 +1593,7 @@ void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj)> observer)
|
||||
void ui::Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)> observer)
|
||||
{
|
||||
draw_objects(observer, m_layers[m_current_layer_idx]);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,20 @@ class Layer
|
||||
{
|
||||
public:
|
||||
RTT m_rtt[6];
|
||||
glm::vec4 m_dirty_box[6];
|
||||
bool m_dirty_face[6];
|
||||
glm::vec4 m_dirty_box[6] = SIXPLETTE(glm::vec4(0));
|
||||
bool m_dirty_face[6] = SIXPLETTE(false);
|
||||
bool m_visible = true;
|
||||
bool m_alpha_locked = false;
|
||||
float m_opacity = 1.f;
|
||||
bool m_hightlight = false;
|
||||
std::string m_name;
|
||||
int w, h;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
struct Snapshot
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> image[6];
|
||||
glm::vec4 m_dirty_box[6];
|
||||
bool m_dirty_face[6];
|
||||
std::unique_ptr<uint8_t[]> image[6] = SIXPLETTE(0);
|
||||
glm::vec4 m_dirty_box[6] = SIXPLETTE(glm::vec4(0));
|
||||
bool m_dirty_face[6] = SIXPLETTE(false);
|
||||
void create(int w, int h)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -53,20 +54,20 @@ public:
|
||||
static Canvas* I;
|
||||
bool m_alpha_lock = false;
|
||||
bool m_touch_lock = true;
|
||||
glm::mat4 m_mv;
|
||||
glm::mat4 m_proj;
|
||||
glm::vec4 m_box;
|
||||
glm::vec2 m_pan;
|
||||
int m_width;
|
||||
int m_height;
|
||||
glm::mat4 m_mv{ 1 };
|
||||
glm::mat4 m_proj{ 1 };
|
||||
glm::vec4 m_box{ 0 };
|
||||
glm::vec2 m_pan{ 0 };
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
bool m_use_instanced = false;
|
||||
int m_current_layer_idx = 0;
|
||||
std::unique_ptr<Stroke> m_current_stroke;
|
||||
bool m_show_tmp = false;
|
||||
std::vector<Layer> m_layers;
|
||||
std::vector<int> m_order;
|
||||
glm::vec4 m_dirty_box[6];
|
||||
bool m_dirty_face[6];
|
||||
glm::vec4 m_dirty_box[6] = SIXPLETTE(glm::vec4(0));
|
||||
bool m_dirty_face[6] = SIXPLETTE(false);
|
||||
Layer m_smask; // selection mask
|
||||
bool m_smask_active = false;
|
||||
RTT m_tmp[6];
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
Texture2D m_tex[6];
|
||||
Texture2D m_tex2[6];
|
||||
bool m_pick_ready[6];
|
||||
std::unique_ptr<glm::u8vec4[]> m_pick_data[6];
|
||||
std::unique_ptr<glm::u8vec4[]> m_pick_data[6] = SIXPLETTE(nullptr);
|
||||
static glm::vec3 m_plane_origin[6];
|
||||
static glm::vec3 m_plane_normal[6];
|
||||
static glm::vec3 m_plane_tangent[6];
|
||||
@@ -84,8 +85,8 @@ public:
|
||||
Sampler m_sampler_bg;
|
||||
Sampler m_sampler_mask;
|
||||
Sampler m_sampler_stencil;
|
||||
glm::vec2 m_cam_rot;
|
||||
glm::vec3 m_cam_pos;
|
||||
glm::vec2 m_cam_rot{ 0 };
|
||||
glm::vec3 m_cam_pos{ 0 };
|
||||
float m_cam_fov = 85;
|
||||
|
||||
Brush m_current_brush;
|
||||
@@ -144,8 +145,8 @@ public:
|
||||
ui::Image thumbnail_generate(int w, int h);
|
||||
ui::Image thumbnail_read(std::string data_path);
|
||||
void preview_generate();
|
||||
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj)>);
|
||||
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj)>, Layer& layer);
|
||||
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)>);
|
||||
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)>, Layer& layer);
|
||||
bool ray_intersect(glm::vec3 ray_origin, glm::vec3 ray_dir, glm::vec3 plane_origin,
|
||||
glm::vec3 plane_normal, glm::vec3 plane_tangent, glm::vec3 &out_hit);
|
||||
void point_unproject(glm::vec2 loc, glm::vec4 vp, glm::mat4 camera, glm::mat4 proj,
|
||||
|
||||
@@ -67,8 +67,8 @@ void TextMesh::update(kFont id, const char* text)
|
||||
float y = 0;
|
||||
std::vector<glm::vec4> v;
|
||||
std::vector<GLushort> idx;
|
||||
glm::vec2 bbmin;
|
||||
glm::vec2 bbmax;
|
||||
glm::vec2 bbmin(FLT_MAX);
|
||||
glm::vec2 bbmax(-FLT_MAX);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int c = text[i] - f.start_char;
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
int font_array_count = 0;
|
||||
GLuint font_buffers[2] = {0, 0};
|
||||
kFont font_id;
|
||||
glm::vec2 bb;
|
||||
glm::vec2 bb = { 0, 0 };
|
||||
bool create();
|
||||
void update(kFont id, const char* text);
|
||||
void draw();
|
||||
|
||||
@@ -389,6 +389,26 @@ Node::Node(Node&& o)
|
||||
m_mouse_ignore = o.m_mouse_ignore;
|
||||
o.y_node = nullptr;
|
||||
o.parent = nullptr;
|
||||
|
||||
m_manager = o.m_manager;
|
||||
current_mouse_capture = o.current_mouse_capture;
|
||||
current_key_capture = o.current_key_capture;
|
||||
m_mouse_captured = o.m_mouse_captured;
|
||||
m_key_captured = o.m_key_captured;
|
||||
|
||||
m_proj = o.m_proj;
|
||||
m_mvp = o.m_mvp;
|
||||
m_mouse_inside = o.m_mouse_inside;
|
||||
m_flood_events = o.m_flood_events;
|
||||
m_capture_children = o.m_capture_children;
|
||||
m_destroyed = o.m_destroyed;
|
||||
|
||||
m_scale = o.m_scale;
|
||||
m_pos_origin = o.m_pos_origin;
|
||||
m_pos_offset = o.m_pos_offset;
|
||||
m_pos_offset_childred = o.m_pos_offset_childred;
|
||||
m_clip_uncut = o.m_clip_uncut;
|
||||
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
@@ -904,6 +924,24 @@ void Node::clone_copy(Node* dest) const
|
||||
dest->m_size = m_size;
|
||||
dest->m_clip = m_clip;
|
||||
dest->m_flood_events = m_flood_events;
|
||||
|
||||
dest->m_manager = m_manager;
|
||||
dest->current_mouse_capture = current_mouse_capture;
|
||||
dest->current_key_capture = current_key_capture;
|
||||
dest->m_mouse_captured = m_mouse_captured;
|
||||
dest->m_key_captured = m_key_captured;
|
||||
dest->m_proj = m_proj;
|
||||
dest->m_mvp = m_mvp;
|
||||
dest->m_mouse_inside = m_mouse_inside;
|
||||
dest->m_capture_children = m_capture_children;
|
||||
dest->m_destroyed = m_destroyed;
|
||||
dest->m_scale = m_scale;
|
||||
dest->m_pos_origin = m_pos_origin;
|
||||
dest->m_pos_offset = m_pos_offset;
|
||||
dest->m_pos_offset_childred = m_pos_offset_childred;
|
||||
dest->m_clip_uncut = m_clip_uncut;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Node::clone_children(Node* dest) const
|
||||
|
||||
@@ -104,16 +104,17 @@ public:
|
||||
|
||||
bool m_mouse_ignore = true;
|
||||
float m_zoom = 1.f;
|
||||
glm::vec2 m_scale{ 1.f };
|
||||
glm::vec2 m_pos;
|
||||
glm::vec2 m_pos_origin; // original layout position without offset
|
||||
glm::vec2 m_pos_offset; // artificial position offset for scrolling
|
||||
glm::vec2 m_pos_offset_childred; // artificial position offset for scrolling
|
||||
glm::vec2 m_size;
|
||||
glm::vec4 m_clip;
|
||||
glm::vec4 m_clip_uncut;
|
||||
glm::vec2 m_scale{ 1, 1 };
|
||||
glm::vec2 m_pos{ 0, 0 };
|
||||
glm::vec2 m_pos_origin{ 0, 0 }; // original layout position without offset
|
||||
glm::vec2 m_pos_offset{ 0, 0 }; // artificial position offset for scrolling
|
||||
glm::vec2 m_pos_offset_childred{ 0, 0 }; // artificial position offset for scrolling
|
||||
glm::vec2 m_size{ 0, 0 };
|
||||
glm::vec4 m_clip{ 0, 0, 0, 0 };
|
||||
glm::vec4 m_clip_uncut{ 0, 0, 0, 0 };
|
||||
std::string m_name;
|
||||
bool m_display = true;
|
||||
|
||||
Node(const Node&) = delete;
|
||||
Node& operator=(const Node&) = delete;
|
||||
Node&& operator=(Node&& o);
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
|
||||
#define NS_START namespace ui {
|
||||
#define NS_END }
|
||||
#define SIXPLETTE(I) {I, I, I, I, I, I}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <map>
|
||||
|
||||
@@ -7,8 +7,8 @@ class RTT
|
||||
GLuint fboID = 0;
|
||||
GLuint rboID = 0;
|
||||
GLuint texID = 0;
|
||||
int w;
|
||||
int h;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
|
||||
public:
|
||||
RTT();
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace ui {
|
||||
class Shape
|
||||
{
|
||||
protected:
|
||||
GLuint buffers[2]{ 0 };
|
||||
GLuint arrays[2]{ 0 };
|
||||
GLuint count[2]{ 0 };
|
||||
GLvoid* ioff[2]{ 0 };
|
||||
GLuint buffers[2]{ 0, 0 };
|
||||
GLuint arrays[2]{ 0, 0 };
|
||||
GLuint count[2]{ 0, 0 };
|
||||
GLvoid* ioff[2]{ 0, 0 };
|
||||
bool use_idx = true;
|
||||
public:
|
||||
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; };
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
class Texture2D
|
||||
{
|
||||
GLuint m_tex;
|
||||
int m_width;
|
||||
int m_height;
|
||||
GLint m_format;
|
||||
GLint m_iformat;
|
||||
GLuint m_tex = 0;
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
GLint m_format = 0;
|
||||
GLint m_iformat = 0;
|
||||
public:
|
||||
bool create(int width, int height, GLint internal_format = GL_RGBA8, GLint format = GL_RGBA, const uint8_t* data = nullptr);
|
||||
bool create(const ui::Image& img);
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
|
||||
class Sampler
|
||||
{
|
||||
GLuint id;
|
||||
GLint current_unit;
|
||||
GLuint id = 0;
|
||||
GLint current_unit = 0;
|
||||
public:
|
||||
bool create(GLint filter = GL_LINEAR, GLint wrap = GL_CLAMP_TO_EDGE);
|
||||
void set(GLint filter = GL_LINEAR, GLint wrap = GL_CLAMP_TO_EDGE);
|
||||
|
||||
@@ -32,9 +32,9 @@ inline glm::vec2 xy(const glm::vec3& v) { return glm::vec2(v.x, v.y); }
|
||||
template<typename T, int N> struct cbuffer
|
||||
{
|
||||
T m_vec[N];
|
||||
int m_capacity;
|
||||
int m_count;
|
||||
int m_index;
|
||||
int m_capacity = 0;
|
||||
int m_count = 0;
|
||||
int m_index = 0;
|
||||
cbuffer()
|
||||
{
|
||||
m_capacity = N;
|
||||
|
||||
@@ -153,8 +153,11 @@ bool WacomTablet::init(HWND hWnd)
|
||||
|
||||
void WacomTablet::terminate()
|
||||
{
|
||||
gpWTClose(g_hCtx);
|
||||
UnloadWintab();
|
||||
if (gpWTClose)
|
||||
{
|
||||
gpWTClose(g_hCtx);
|
||||
UnloadWintab();
|
||||
}
|
||||
}
|
||||
|
||||
void WacomTablet::handle_message(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
Reference in New Issue
Block a user