GLES3 adaption

pull/3471/head
kallaballa 2 years ago
parent a21fa297eb
commit fea913e0ec
  1. 1
      Makefile
  2. 2
      src/beauty/beauty-demo.cpp
  3. 6
      src/common/detail/framebuffercontext.cpp
  4. 8
      src/common/detail/framebuffercontext.hpp
  5. 4
      src/common/detail/nanovgcontext.cpp
  6. 5
      src/common/detail/nanovgcontext.hpp
  7. 7
      src/common/util.cpp
  8. 2
      src/common/viz2d.cpp
  9. 10
      src/common/viz2d.hpp
  10. 2
      src/optflow/optflow-demo.cpp
  11. 4
      src/shader/shader-demo.cpp
  12. 4
      src/tetra/tetra-demo.cpp
  13. 4
      src/video/video-demo.cpp

@ -15,6 +15,7 @@ ifndef EMSDK
LIBS += `pkg-config --libs glfw3 glew` -lopencv_face -lopencv_gapi -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_optflow -lopencv_tracking -lopencv_highgui -lopencv_plot -lopencv_videostab -lopencv_videoio -lopencv_photo -lopencv_ximgproc -lopencv_video -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_imgproc -lopencv_flann -lopencv_core -lGL -lOpenCL
endif
CXXFLAGS += -DCL_TARGET_OPENCL_VERSION=120
# -DVIZ2D_USE_ES3=1
ifdef EMSDK
CXX := em++
EMCXXFLAGS += -flto -s USE_PTHREADS=1 -pthread -msimd128

@ -394,7 +394,7 @@ int main(int argc, char **argv) {
while (keep_running())
iteration();
#else
Source src = make_capture_source(v2d, WIDTH, HEIGHT);
Source src = make_capture_source(WIDTH, HEIGHT);
v2d->setSource(src);
emscripten_set_main_loop(iteration, -1, true);
#endif

@ -8,6 +8,10 @@
#include "../util.hpp"
#include "../viz2d.hpp"
#ifndef VIZ2D_USE_ES3
#include <GL/glew.h>
#endif
namespace cv {
namespace viz {
namespace detail {
@ -15,7 +19,7 @@ namespace detail {
//FIXME use cv::ogl
FrameBufferContext::FrameBufferContext(const cv::Size& frameBufferSize) :
frameBufferSize_(frameBufferSize) {
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
glewExperimental = true;
glewInit();
try {

@ -6,14 +6,14 @@
#ifndef SRC_COMMON_CLGLCONTEXT_HPP_
#define SRC_COMMON_CLGLCONTEXT_HPP_
#define CL_TARGET_OPENCL_VERSION 120
#ifndef __EMSCRIPTEN__
#include <GL/glew.h>
#include <CL/cl.h>
#include <CL/cl_gl.h>
#else
#define VIZ2D_USE_ES3 1
#endif
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
# include <GL/glew.h>
# define GLFW_INCLUDE_GLCOREARB
#else
# define GLFW_INCLUDE_ES3

@ -27,7 +27,7 @@ void NanoVGContext::render(std::function<void(const cv::Size&)> fn) {
}
void push() {
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
GL_CHECK(glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS));
GL_CHECK(glPushAttrib(GL_ALL_ATTRIB_BITS));
GL_CHECK(glMatrixMode(GL_MODELVIEW));
@ -40,7 +40,7 @@ void push() {
}
void pop() {
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
GL_CHECK(glMatrixMode(GL_TEXTURE));
GL_CHECK(glPopMatrix());
GL_CHECK(glMatrixMode(GL_PROJECTION));

@ -5,8 +5,11 @@
#ifndef SRC_COMMON_NANOVGCONTEXT_HPP_
#define SRC_COMMON_NANOVGCONTEXT_HPP_
#ifdef __EMSCRIPTEN__
#define VIZ2D_USE_ES3 1
#endif
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
#define NANOGUI_USE_OPENGL
#else
#define NANOGUI_USE_GLES

@ -14,9 +14,10 @@
#else
# include <opencv2/core/ocl.hpp>
# include <va/va.h>
# include <csignal>
#endif
#include <csignal>
namespace cv {
namespace viz {
std::string get_gl_info() {
@ -178,7 +179,6 @@ void update_fps(cv::Ptr<cv::viz::Viz2D> v2d, bool graphical) {
}
#ifndef __EMSCRIPTEN__
Sink make_va_sink(const string& outputFilename, const int fourcc, const float fps,
const cv::Size& frameSize, const int vaDeviceIndex) {
cv::Ptr<cv::VideoWriter> writer = new cv::VideoWriter(outputFilename, cv::CAP_FFMPEG,
@ -214,7 +214,8 @@ Sink make_va_sink(const string &outputFilename, const int fourcc, const float fp
Source make_va_source(const string &inputFilename, const int vaDeviceIndex) {
return Source([=](cv::UMat& frame){
return false;
}, fps);
}, 0);
}
#endif
#ifndef __EMSCRIPTEN__

@ -95,7 +95,7 @@ bool Viz2D::initializeWindowing() {
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#elif __EMSCRIPTEN__
#elif defined(VIZ2D_USE_ES3)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);

@ -10,7 +10,6 @@
#include "sink.hpp"
#include "dialog.hpp"
#include "formhelper.hpp"
#include <filesystem>
#include <iostream>
#include <set>
@ -18,11 +17,16 @@
#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <nanogui/nanogui.h>
#include <GL/glew.h>
#ifdef __EMSCRIPTEN__
#include <GLES3/gl3.h>
#define VIZ2D_USE_ES3 1
#include <emscripten.h>
#endif
#ifndef VIZ2D_USE_ES3
#include <GL/glew.h>
#else
#include <GLES3/gl3.h>
#endif
using std::cout;
using std::cerr;

@ -493,7 +493,7 @@ int main(int argc, char **argv) {
while (keep_running())
iteration();
#else
Source src = make_capture_source(v2d, WIDTH, HEIGHT);
Source src = make_capture_source(WIDTH, HEIGHT);
v2d->setSource(src);
emscripten_set_main_loop(iteration, -1, true);
#endif

@ -142,7 +142,7 @@ GLuint init_shader(const char* vShader, const char* fShader, const char* outputA
glAttachShader( program, shader );
}
#ifndef __EMSCRIPTEN__
#ifndef VIZ2D_USE_ES3
/* Link output */
glBindFragDataLocation(program, 0, outputAttributeName);
#endif
@ -440,7 +440,7 @@ int main(int argc, char **argv) {
while(keep_running())
iteration();
#else
Source src = make_capture_source(v2d, WIDTH, HEIGHT);
Source src = make_capture_source(WIDTH, HEIGHT);
v2d->setSource(src);
emscripten_set_main_loop(iteration, -1, true);
#endif

@ -19,6 +19,7 @@ using std::cerr;
using std::endl;
void init_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
//Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0);
@ -35,9 +36,11 @@ void init_scene(const cv::Size& sz) {
glTranslatef(0, 0, -3);
glRotatef(50, 1, 0, 0);
glRotatef(70, 0, 1, 0);
#endif
}
void render_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0);
@ -58,6 +61,7 @@ void render_scene(const cv::Size& sz) {
glColor3f(1, 0, 0);
glVertex3f(-1, 0, 1);
glEnd();
#endif
}
void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {

@ -20,6 +20,7 @@ using std::endl;
using std::string;
void init_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
//Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0);
@ -36,9 +37,11 @@ void init_scene(const cv::Size& sz) {
glTranslatef(0, 0, -3);
glRotatef(50, 1, 0, 0);
glRotatef(70, 0, 1, 0);
#endif
}
void render_scene(const cv::Size& sz) {
#ifndef VIZ2D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0);
@ -58,6 +61,7 @@ void render_scene(const cv::Size& sz) {
glColor3f(1, 0, 0);
glVertex3f(-1, 0, 1);
glEnd();
#endif
}
void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {

Loading…
Cancel
Save