raise minimal OpenGL version to 3.2 compat

pull/3471/head
kallaballa 2 years ago
parent e4eea31d82
commit d6ca3d351c
  1. 4
      modules/viz2d/include/opencv2/viz2d/viz2d.hpp
  2. 28
      modules/viz2d/src/detail/nanovgcontext.cpp
  3. 2
      modules/viz2d/src/viz2d.cpp

@ -168,7 +168,7 @@ public:
*/
CV_EXPORTS static cv::Ptr<Viz2D> make(const cv::Size& initialSize,
const cv::Size& frameBufferSize, bool offscreen, const string& title, int major = 3,
int minor = 0, int samples = 0, bool debug = false);
int minor = 2, int samples = 0, bool debug = false);
/*!
* Default destructor
*/
@ -427,7 +427,7 @@ private:
* @param debug Create a debug OpenGL context.
*/
CV_EXPORTS Viz2D(const cv::Size& initialSize, const cv::Size& frameBufferSize, bool offscreen,
const string& title, int major = 3, int minor = 0, int samples = 0, bool debug = false);
const string& title, int major = 3, int minor = 2, int samples = 0, bool debug = false);
void setDefaultKeyboardEventCallback();
void setKeyboardEventCallback(
std::function<bool(int key, int scancode, int action, int modifiers)> fn);

@ -26,7 +26,34 @@ void NanoVGContext::render(std::function<void(const cv::Size&)> fn) {
cv::viz::nvg::detail::NVG::initializeContext(context_), fn(clglContext_.getSize());
}
void push() {
#ifndef VIZ2D_USE_ES3
GL_CHECK(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS));
GL_CHECK(glPushAttrib(GL_ALL_ATTRIB_BITS));
GL_CHECK(glMatrixMode(GL_MODELVIEW));
GL_CHECK(glPushMatrix());
GL_CHECK(glMatrixMode(GL_PROJECTION));
GL_CHECK(glPushMatrix());
GL_CHECK(glMatrixMode(GL_TEXTURE));
GL_CHECK(glPushMatrix());
#endif
}
void pop() {
#ifndef VIZ2D_USE_ES3
GL_CHECK(glMatrixMode(GL_TEXTURE));
GL_CHECK(glPopMatrix());
GL_CHECK(glMatrixMode(GL_PROJECTION));
GL_CHECK(glPopMatrix());
GL_CHECK(glMatrixMode(GL_MODELVIEW));
GL_CHECK(glPopMatrix());
GL_CHECK(glPopClientAttrib());
GL_CHECK(glPopAttrib());
#endif
}
void NanoVGContext::begin() {
push();
float w = v2d_.getFrameBufferSize().width;
float h = v2d_.getFrameBufferSize().height;
float r = v2d_.getXPixelRatio();
@ -43,6 +70,7 @@ void NanoVGContext::end() {
//FIXME make nvgCancelFrame possible
nvgEndFrame(context_);
nvgRestore(context_);
pop();
}
}
}

@ -132,8 +132,8 @@ bool Viz2D::initializeWindowing() {
#else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major_);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor_);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API) ;
#endif
glfwWindowHint(GLFW_SAMPLES, samples_);

Loading…
Cancel
Save