make opengl compatibility mode optional

pull/3471/head
kallaballa 2 years ago
parent 353bc3b846
commit 33d4130c03
  1. 5
      modules/viz2d/include/opencv2/viz2d/viz2d.hpp
  2. 12
      modules/viz2d/src/viz2d.cpp
  3. 2
      modules/viz2d/tutorials/00-intro.markdown
  4. 2
      modules/viz2d/tutorials/06-custom_source_and_sink.markdown

@ -130,6 +130,7 @@ class CV_EXPORTS Viz2D {
string title_; string title_;
int major_; int major_;
int minor_; int minor_;
bool compat_;
int samples_; int samples_;
bool debug_; bool debug_;
GLFWwindow* glfwWindow_ = nullptr; GLFWwindow* glfwWindow_ = nullptr;
@ -180,7 +181,7 @@ public:
*/ */
CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& initialSize, CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& initialSize,
const cv::Size& frameBufferSize, bool offscreen, const string& title, int major = 3, const cv::Size& frameBufferSize, bool offscreen, const string& title, int major = 3,
int minor = 2, int samples = 0, bool debug = false); int minor = 2, bool compat = true, int samples = 0, bool debug = false);
/*! /*!
* Default destructor * Default destructor
*/ */
@ -439,7 +440,7 @@ private:
* @param debug Create a debug OpenGL context. * @param debug Create a debug OpenGL context.
*/ */
CV_EXPORTS Viz2D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen, CV_EXPORTS Viz2D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major = 3, int minor = 2, int samples = 0, bool debug = false); const string& title, int major = 3, int minor = 2, bool compat = true, int samples = 0, bool debug = false);
void setDefaultKeyboardEventCallback(); void setDefaultKeyboardEventCallback();
void setKeyboardEventCallback( void setKeyboardEventCallback(
std::function<bool(int key, int scancode, int action, int modifiers)> fn); std::function<bool(int key, int scancode, int action, int modifiers)> fn);

@ -66,21 +66,21 @@ void resizeKeepAspectRatio(const cv::UMat& src, cv::UMat& output, const cv::Size
} }
cv::Ptr<Viz2D> Viz2D::make(const cv::Size& size, const string& title, bool debug) { cv::Ptr<Viz2D> Viz2D::make(const cv::Size& size, const string& title, bool debug) {
cv::Ptr<Viz2D> v2d = new Viz2D(size, size, false, title, 4, 6, 0, debug); cv::Ptr<Viz2D> v2d = new Viz2D(size, size, false, title, 4, 6, true, 0, debug);
v2d->setVisible(true); v2d->setVisible(true);
return v2d; return v2d;
} }
cv::Ptr<Viz2D> Viz2D::make(const cv::Size& initialSize, const cv::Size& frameBufferSize, cv::Ptr<Viz2D> Viz2D::make(const cv::Size& initialSize, const cv::Size& frameBufferSize,
bool offscreen, const string& title, int major, int minor, int samples, bool debug) { bool offscreen, const string& title, int major, int minor, bool compat, int samples, bool debug) {
return new Viz2D(initialSize, frameBufferSize, offscreen, title, major, minor, samples, debug); return new Viz2D(initialSize, frameBufferSize, offscreen, title, major, minor, compat, samples, debug);
} }
Viz2D::Viz2D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscreen, Viz2D::Viz2D(const cv::Size& size, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major, int minor, int samples, bool debug) : const string& title, int major, int minor, bool compat, int samples, bool debug) :
initialSize_(size), frameBufferSize_(frameBufferSize), viewport_(0, 0, initialSize_(size), frameBufferSize_(frameBufferSize), viewport_(0, 0,
frameBufferSize.width, frameBufferSize.height), scale_(1), mousePos_(0, 0), offscreen_( frameBufferSize.width, frameBufferSize.height), scale_(1), mousePos_(0, 0), offscreen_(
offscreen), stretch_(false), title_(title), major_(major), minor_(minor), samples_( offscreen), stretch_(false), title_(title), major_(major), minor_(minor), compat_(compat), samples_(
samples), debug_(debug) { samples), debug_(debug) {
assert( assert(
frameBufferSize_.width >= initialSize_.width frameBufferSize_.width >= initialSize_.width
@ -132,7 +132,7 @@ bool Viz2D::initializeWindowing() {
#else #else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major_); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major_);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor_); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor_);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, compat_ ? GLFW_OPENGL_COMPAT_PROFILE : GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API) ; glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API) ;
#endif #endif

@ -55,7 +55,7 @@ v2d->gl([](const Size sz) {
# Requirements # Requirements
* C++20 (at the moment) * C++20 (at the moment)
* OpenGL 3.2 Compat/OpenGL ES 3.0 Core * OpenGL 3.2 Core (optionally Compat)/OpenGL ES 3.0 Core
# Optional requirements # Optional requirements
* Support for OpenCL 1.2 * Support for OpenCL 1.2

@ -1,4 +1,4 @@
# Video editing {#viz2d_custom_source_and_sink} # Custom Source and Sink {#viz2d_custom_source_and_sink}
@prev_tutorial{viz2d_video_editing} @prev_tutorial{viz2d_video_editing}
@next_tutorial{viz2d_font_with_gui} @next_tutorial{viz2d_font_with_gui}

Loading…
Cancel
Save