Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/polyscope/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <functional>
#include <string>
#include <tuple>
#include <vector>

#include "imgui.h"

Expand Down Expand Up @@ -141,6 +142,9 @@ extern std::function<void()> configureImGuiStyleCallback;
// assign your own function to create custom styles. If this callback is null, default fonts will be used.
extern std::function<std::tuple<ImFontAtlas*, ImFont*, ImFont*>()> prepareImGuiFontsCallback;

// A callback function which will be invoked when a file is dropped on the Polyscope window. No action is taken by default.
extern std::function<void(const std::vector<std::string>&)> filesDroppedCallback;

// === Backend and low-level options

// When using the EGL backend, which device to try to initialize with
Expand Down
4 changes: 2 additions & 2 deletions include/polyscope/slice_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SlicePlane {
void setPose(glm::vec3 planePosition, glm::vec3 planeNormal);

// == Some getters and setters
glm::vec3 getCenter();
glm::vec3 getNormal();

bool getActive();
void setActive(bool newVal);
Expand Down Expand Up @@ -104,8 +106,6 @@ class SlicePlane {
void setSliceAttributes(render::ShaderProgram& p);
void createVolumeSliceProgram();
void prepare();
glm::vec3 getCenter();
glm::vec3 getNormal();
void updateWidgetEnabled();
};

Expand Down
1 change: 1 addition & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bool renderScene = true;
bool openImGuiWindowForUserCallback = true;
std::function<void()> configureImGuiStyleCallback = configureImGuiStyle;
std::function<std::tuple<ImFontAtlas*, ImFont*, ImFont*>()> prepareImGuiFontsCallback = prepareImGuiFonts;
std::function<void(const std::vector<std::string>&)> filesDroppedCallback = nullptr;

// Backend and low-level options
int eglDeviceIndex = -1; // means "try all of them"
Expand Down
3 changes: 3 additions & 0 deletions src/polyscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,9 @@ void shutdown(bool allowMidFrameShutdown) {
removeAllSlicePlanes();
clearMessages();
state::userCallback = nullptr;
options::configureImGuiStyleCallback = nullptr;
options::prepareImGuiFontsCallback = nullptr;
options::filesDroppedCallback = nullptr;

// Shut down the render engine
render::engine->shutdown();
Expand Down
17 changes: 15 additions & 2 deletions src/render/opengl/gl_engine_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,21 @@ void GLEngineGLFW::initialize() {

setWindowResizable(view::windowResizable);

// === Initialize openGL
// Load openGL functions (using GLAD)
// Drag & drop support
glfwSetDropCallback(mainWindow, [](GLFWwindow* window, int path_count, const char* paths[]) {
if (!options::filesDroppedCallback)
return;

std::vector<std::string> pathsVec(path_count);
for (int i = 0; i < path_count; i++) {
pathsVec[i] = paths[i];
}
options::filesDroppedCallback(pathsVec);
});


// === Initialize openGL
// Load openGL functions (using GLAD)
#ifndef __APPLE__
if (!gladLoadGL()) {
exception("ERROR: Failed to load openGL using GLAD");
Expand Down