import facebook 360 stripe

This commit is contained in:
2018-03-07 21:17:23 +01:00
parent 188a8df0e9
commit da54181754
6 changed files with 59 additions and 26 deletions

2
.gitignore vendored
View File

@@ -16,3 +16,5 @@ android/android.iml
android/local.properties
data/brushes
data/thumbs
PanoPainter.aps
panopainter-log.txt

View File

@@ -809,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);
@@ -1531,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];
@@ -1550,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();
}
@@ -1562,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]);
}

View File

@@ -145,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,