#37 Renderer-dependant (interactive) nodes

오픈
caryoscelus7 년 전을 오픈 · 1개의 코멘트
caryoscelus 코멘트됨, 7 년 전
아직 콘텐츠가 없습니다.
caryoscelus 코멘트됨, 7 년 전
소유자

Implementation idea: store renderer pointer in Context. This would be really easy to implement.

The only question is then interface that will be used to retrieve information from renderer. The most intuitive thing to do would be to just call by node name. E.g. something like

class MousePosition : Node<Geom::Point> {
public:
    Geom::Point get(shared_ptr<Context> ctx) const override {
        if (auto r = ctx->get_renderer()) {
            return r->get_value<Geom::Point>("MousePosition");
        }
        return {}; // or throw instead
    }
};
Implementation idea: store renderer pointer in Context. This would be really easy to implement. The only question is then interface that will be used to retrieve information from renderer. The most intuitive thing to do would be to just call by node name. E.g. something like ```c++ class MousePosition : Node<Geom::Point> { public: Geom::Point get(shared_ptr<Context> ctx) const override { if (auto r = ctx->get_renderer()) { return r->get_value<Geom::Point>("MousePosition"); } return {}; // or throw instead } }; ```
로그인하여 이 대화에 참여
로딩중...
취소
저장
아직 콘텐츠가 없습니다.