-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RenderingEndPoint #1147
base: master
Are you sure you want to change the base?
RenderingEndPoint #1147
Changes from 1 commit
2078a50
408844e
6395573
eac2adc
6c65508
6302e48
97fa665
3fd7031
c20d6ae
c8aa318
e86cbc8
cfb910d
9c5be3b
1c79b20
27467b9
cb5da54
4f6e420
02933ab
27992c8
84ad2d3
9d722f7
219f00a
78c587b
c4e3804
0607843
e4bf0ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "RenderingEndPoint.h" | ||
|
||
|
||
megamol::gui::RenderingEndPoint::RenderingEndPoint(std::string const& window_name) | ||
: AbstractWindow(window_name, AbstractWindow::WINDOW_IF_RENDERING_ENDPOINT) {} | ||
|
||
|
||
void megamol::gui::RenderingEndPoint::SetTexture(GLuint texture, uint32_t x, uint32_t y) { | ||
tex_ = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture)); | ||
size_ = ImVec2(x, y); | ||
} | ||
|
||
|
||
bool megamol::gui::RenderingEndPoint::Draw() { | ||
static const char* current_item = nullptr; | ||
megamol::frontend::ImagePresentation_Service::EntryPointRenderFunctions entry_point; | ||
/*if (ImGui::BeginMainMenuBar()) { | ||
|
||
|
||
ImGui::EndMainMenuBar(); | ||
}*/ | ||
|
||
auto& img_pres_ep_resource_ptr = resources_[0].getResource<frontend_resources::ImagePresentationEntryPoints>(); | ||
|
||
bool isSelected = false; | ||
if (ImGui::BeginCombo("Views", current_item)) { | ||
for (auto const& item : entry_points_) { | ||
if (ImGui::Selectable(item.first.c_str(), &isSelected)) { | ||
current_item = item.first.c_str(); | ||
entry_point = item.second; | ||
} | ||
} | ||
ImGui::EndCombo(); | ||
} | ||
|
||
/*ImGui::Text("RenderEndPoint"); | ||
ImGui::Spacing();*/ | ||
|
||
//entry_point | ||
if (current_item != nullptr) { | ||
auto ep = img_pres_ep_resource_ptr.get_entry_point(current_item); | ||
if (ep.has_value()) { | ||
frontend_resources::EntryPoint& ep_v = ep.value(); | ||
|
||
ep_v.entry_point_data->update(); | ||
|
||
ep_v.execute(ep_v.modulePtr, ep_v.entry_point_resources, ep_v.execution_result_image); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose dragging the frontend resources up until here would also be not necessary without executing the entry points? |
||
|
||
ImGui::Image(ep_v.execution_result_image.referenced_image_handle, | ||
ImVec2{(float)ep_v.execution_result_image.size.width, (float)ep_v.execution_result_image.size.height}, | ||
ImVec2(0, 1), ImVec2(1, 0)); | ||
//ImGui::Image(tex_, size_, ImVec2(0, 1), ImVec2(1, 0)); | ||
} | ||
} | ||
/*if (ImGui::Begin("RenderingEndPoint")) { | ||
ImGui::Text("RenderEndPoint"); | ||
ImGui::Spacing(); | ||
|
||
ImGui::Image(tex_, size_, ImVec2(0, 1), ImVec2(1, 0)); | ||
} | ||
ImGui::End();*/ | ||
|
||
return true; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <stdint.h> | ||
|
||
#include <glad/gl.h> | ||
|
||
#include "AbstractWindow.h" | ||
|
||
#include "ImagePresentationEntryPoints.h" | ||
#include "ImagePresentation_Service.hpp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This dependency between GUI (GUI Service) and Image Presentation Service may lead to problems. For cleaner separation of code it will be cleaner to pull the dependencies from |
||
|
||
namespace megamol::gui { | ||
class RenderingEndPoint : public AbstractWindow { | ||
public: | ||
std::vector<std::string> requested_lifetime_resources() const override { | ||
auto res = AbstractWindow::requested_lifetime_resources(); | ||
res.push_back("ImagePresentationEntryPoints"); | ||
return res; | ||
} | ||
|
||
void setRequestedResources(std::vector<frontend::FrontendResource> resources) override { | ||
resources_ = resources; | ||
auto& img_pres_ep_resource_ptr = resources[0].getResource<frontend_resources::ImagePresentationEntryPoints>(); | ||
|
||
auto sub_func = [&](frontend_resources::ImagePresentationEntryPoints::SubscriptionEvent const& event, | ||
std::vector<std::any> const& args) -> void { | ||
switch (event) { | ||
case frontend_resources::ImagePresentationEntryPoints::SubscriptionEvent::Add: { | ||
entry_points_.insert(std::make_pair(std::any_cast<std::string>(args[0]), | ||
std::any_cast<frontend::ImagePresentation_Service::EntryPointRenderFunctions>(args[1]))); | ||
} break; | ||
case frontend_resources::ImagePresentationEntryPoints::SubscriptionEvent::Remove: { | ||
entry_points_.erase(std::any_cast<std::string>(args[0])); | ||
} break; | ||
case frontend_resources::ImagePresentationEntryPoints::SubscriptionEvent::Rename: { | ||
auto func = entry_points_[std::any_cast<std::string>(args[0])]; | ||
entry_points_.erase(std::any_cast<std::string>(args[0])); | ||
entry_points_.insert(std::make_pair(std::any_cast<std::string>(args[1]), func)); | ||
} break; | ||
case frontend_resources::ImagePresentationEntryPoints::SubscriptionEvent::Clear: | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
img_pres_ep_resource_ptr.subscribe_to_entry_point_changes(sub_func); | ||
} | ||
|
||
explicit RenderingEndPoint(const std::string& window_name); | ||
|
||
void SetTexture(GLuint texture, uint32_t x, uint32_t y); | ||
|
||
bool Draw() override; | ||
|
||
private: | ||
ImTextureID tex_; | ||
ImVec2 size_; | ||
std::map<std::string, frontend::ImagePresentation_Service::EntryPointRenderFunctions> entry_points_; | ||
std::vector<frontend::FrontendResource> resources_; | ||
}; | ||
} // namespace megamol::gui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done by the image presentation service once a framce for each registered entry point. Triggering re-rendering of a frame from inside the GUI seems a bad idea. The intended approach is to then use the
ep_v.execution_result_image
texture handle (either GL or CPU texture) to present the rendered texture in an ImGui window.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rendering execution result image is only available after entry point/graph execution, which introduces a recursive dependency on showing the entry point results in the GUI, which itself is rendered as an entry point.