C++ wrapper for NSView/GLView and mac stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

59 lines
1.4 KiB

//
// NSWrapper.hpp
// XcodeOpenCL
//
// Created by Joshua Moerman on 13/04/14.
//
//
#pragma once
#include <memory>
#include <functional>
#include <vector>
#include <string>
#include <CoreGraphics/CoreGraphics.h>
struct GLContext;
struct ContextParameters{
GLContext & context;
// These two functions will be set when invoking the draw_callback (and should be used)
std::function<void(void)> bind_framebuffer; // function to bind the systems framebuffer and set the viewport
std::function<void(void)> flush_drawable; // function to flush the drawable
};
struct GLViewFunctionality {
// All three will only be called with the current gl context already set
// May be called from different threads
std::function<void(ContextParameters)> initialize_callback;
std::function<void(ContextParameters)> draw_callback;
std::function<void(ContextParameters, CGFloat, CGFloat)> resize_callback;
};
struct Control {
std::string name = "default";
double start = 0, min = 0, max = 1;
std::function<void(double)> callback;
};
struct ControlFunctionality {
std::vector<Control> sliders;
};
// returns a GLViewFunctionality with only its draw function set.
GLViewFunctionality simple_draw(std::function<void()> f);
struct NSAppWrapper {
NSAppWrapper();
~NSAppWrapper();
void run();
void create_window(GLViewFunctionality const &);
void create_window(ControlFunctionality const &);
std::unique_ptr<struct NSAppWrapperImpl> impl;
};