switch back to ES 3.0

pull/3471/head
kallaballa 2 years ago
parent 1c2ac57b89
commit 85c412aab0
  1. 8
      modules/v4d/CMakeLists.txt
  2. 2
      modules/v4d/include/opencv2/v4d/dialog.hpp
  3. 4
      modules/v4d/include/opencv2/v4d/nvg.hpp
  4. 4
      modules/v4d/include/opencv2/v4d/v4d.hpp
  5. 12
      modules/v4d/samples/shader-demo.cpp
  6. 8
      modules/v4d/samples/shader/get.php
  7. 4
      modules/v4d/samples/tetra-demo.cpp
  8. 4
      modules/v4d/samples/video-demo.cpp
  9. 4
      modules/v4d/src/detail/framebuffercontext.cpp
  10. 4
      modules/v4d/src/detail/framebuffercontext.hpp
  11. 4
      modules/v4d/src/detail/nanovgcontext.cpp
  12. 2
      modules/v4d/src/detail/nanovgcontext.hpp
  13. 2
      modules/v4d/src/dialog.cpp
  14. 2
      modules/v4d/src/v4d.cpp

@ -14,7 +14,7 @@ if (${idx} LESS 0)
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L../../lib") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L../../lib")
OCV_OPTION(OPENCV_V4D_ENABLE_ES2 "Enable OpenGL ES 2.0 backend for V4D" OFF OCV_OPTION(OPENCV_V4D_ENABLE_ES3 "Enable OpenGL ES 3.0 backend for V4D" OFF
VERIFY HAVE_OPENGL) VERIFY HAVE_OPENGL)
find_package(Git QUIET) find_package(Git QUIET)
@ -78,9 +78,9 @@ set(NANOGUI_BUILD_PYTHON OFF)
set(NANOGUI_BUILD_EXAMPLES OFF) set(NANOGUI_BUILD_EXAMPLES OFF)
set(NANOGUI_BACKEND "OpenGL" CACHE STRING "Choose the backend used for rendering (OpenGL/GLES 2/GLES 3/Metal)" FORCE) set(NANOGUI_BACKEND "OpenGL" CACHE STRING "Choose the backend used for rendering (OpenGL/GLES 2/GLES 3/Metal)" FORCE)
if(OPENCV_V4D_ENABLE_ES2) if(OPENCV_V4D_ENABLE_ES3)
set(NANOGUI_BACKEND "GLES 2") set(NANOGUI_BACKEND "GLES 3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV_V4D_USE_ES2=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV_V4D_USE_ES3=1")
else() else()
set(NANOGUI_BACKEND "OpenGL") set(NANOGUI_BACKEND "OpenGL")
endif() endif()

@ -6,7 +6,7 @@
#ifndef SRC_OPENCV_V4D_DIALOG_HPP_ #ifndef SRC_OPENCV_V4D_DIALOG_HPP_
#define SRC_OPENCV_V4D_DIALOG_HPP_ #define SRC_OPENCV_V4D_DIALOG_HPP_
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#define OPENCV_V4D_USE_ES2 1 #define OPENCV_V4D_USE_ES3 1
#endif #endif
#include <nanogui/nanogui.h> #include <nanogui/nanogui.h>

@ -7,14 +7,14 @@
#define SRC_OPENCV_V4D_NVG_HPP_ #define SRC_OPENCV_V4D_NVG_HPP_
#include "v4d.hpp" #include "v4d.hpp"
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
# ifndef NANOGUI_USE_OPENGL # ifndef NANOGUI_USE_OPENGL
# define NANOGUI_USE_OPENGL # define NANOGUI_USE_OPENGL
# endif # endif
#else #else
# ifndef NANOGUI_USE_GLES # ifndef NANOGUI_USE_GLES
# define NANOGUI_USE_GLES # define NANOGUI_USE_GLES
# define NANOGUI_GLES_VERSION 2 # define NANOGUI_GLES_VERSION 3
# endif # endif
#endif #endif
#include <nanogui/opengl.h> #include <nanogui/opengl.h>

@ -21,12 +21,12 @@
#include "cxxpool.hpp" #include "cxxpool.hpp"
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#define OPENCV_V4D_USE_ES2 1 #define OPENCV_V4D_USE_ES3 1
#include <emscripten.h> #include <emscripten.h>
#endif #endif
#include <nanogui/nanogui.h> #include <nanogui/nanogui.h>
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
#include <GL/glew.h> #include <GL/glew.h>
#else #else
#include <GLES3/gl3.h> #include <GLES3/gl3.h>

@ -44,7 +44,7 @@ GLint zoom_hdl;
/** shader and program handle **/ /** shader and program handle **/
GLuint shader_program_hdl; GLuint shader_program_hdl;
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
//vertex array //vertex array
GLuint VAO; GLuint VAO;
#endif #endif
@ -71,7 +71,7 @@ unsigned int indices[] =
void load_buffer_data(){ void load_buffer_data(){
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
glGenVertexArrays(1, &VAO); glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO); glBindVertexArray(VAO);
#endif #endif
@ -89,7 +89,7 @@ void load_buffer_data(){
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
glBindVertexArray(0); glBindVertexArray(0);
#endif #endif
} }
@ -141,7 +141,7 @@ GLuint init_shader(const char* vShader, const char* fShader, const char* outputA
glAttachShader( program, shader ); glAttachShader( program, shader );
} }
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
/* Link output */ /* Link output */
glBindFragDataLocation(program, 0, outputAttributeName); glBindFragDataLocation(program, 0, outputAttributeName);
#endif #endif
@ -170,7 +170,7 @@ GLuint init_shader(const char* vShader, const char* fShader, const char* outputA
//mandelbrot shader code adapted from my own project: https://github.com/kallaballa/FractalDive#after //mandelbrot shader code adapted from my own project: https://github.com/kallaballa/FractalDive#after
void load_shader(){ void load_shader(){
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
const string shaderVersion = "330"; const string shaderVersion = "330";
#else #else
const string shaderVersion = "300 es"; const string shaderVersion = "300 es";
@ -293,7 +293,7 @@ void render_scene(const cv::Size& sz) {
glUniform1f(zoom_hdl, zoom); glUniform1f(zoom_hdl, zoom);
} }
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
glBindVertexArray(VAO); glBindVertexArray(VAO);
#endif #endif
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

@ -14,13 +14,13 @@ $fp = fopen($name, 'rb');
// send the right headers // send the right headers
if(endsWith($resource, ".html")) { if(endsWith($resource, ".html")) {
header("Content-Type: text/html"); header("Content-Type: text/html");
} elseif (endsWith($resource, ".js")) { } elseif (endsWith($resource, ".js")) {
header("Content-Type: text/javascript"); header("Content-Type: text/javascript");
} elseif (endsWith($resource, ".wasm")) { } elseif (endsWith($resource, ".wasm")) {
header("Content-Type: application/wasm"); header("Content-Type: application/wasm");
} else { } else {
header("Content-Type: text/html"); header("Content-Type: text/html");
} }
header("Content-Length: " . filesize($name)); header("Content-Length: " . filesize($name));
header("Cross-Origin-Embedder-Policy: require-corp"); header("Cross-Origin-Embedder-Policy: require-corp");

@ -20,7 +20,7 @@ using std::endl;
static cv::Ptr<cv::viz::V4D> v4d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo"); static cv::Ptr<cv::viz::V4D> v4d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
void init_scene(const cv::Size& sz) { void init_scene(const cv::Size& sz) {
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
//Initialize the OpenGL scene //Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height); glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
@ -41,7 +41,7 @@ void init_scene(const cv::Size& sz) {
} }
void render_scene(const cv::Size& sz) { void render_scene(const cv::Size& sz) {
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo //Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height); glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0); glRotatef(1, 0, 1, 0);

@ -21,7 +21,7 @@ using std::string;
static cv::Ptr<cv::viz::V4D> v4d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo"); static cv::Ptr<cv::viz::V4D> v4d = cv::viz::V4D::make(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Video Demo");
void init_scene(const cv::Size& sz) { void init_scene(const cv::Size& sz) {
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
//Initialize the OpenGL scene //Initialize the OpenGL scene
glViewport(0, 0, sz.width, sz.height); glViewport(0, 0, sz.width, sz.height);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
@ -42,7 +42,7 @@ void init_scene(const cv::Size& sz) {
} }
void render_scene(const cv::Size& sz) { void render_scene(const cv::Size& sz) {
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
//Render a tetrahedron using immediate mode because the code is more concise for a demo //Render a tetrahedron using immediate mode because the code is more concise for a demo
glViewport(0, 0, sz.width, sz.height); glViewport(0, 0, sz.width, sz.height);
glRotatef(1, 0, 1, 0); glRotatef(1, 0, 1, 0);

@ -8,7 +8,7 @@
#include "opencv2/v4d/util.hpp" #include "opencv2/v4d/util.hpp"
#include "opencv2/v4d/v4d.hpp" #include "opencv2/v4d/v4d.hpp"
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
#include <GL/glew.h> #include <GL/glew.h>
#endif #endif
@ -19,7 +19,7 @@ namespace detail {
//FIXME use cv::ogl //FIXME use cv::ogl
FrameBufferContext::FrameBufferContext(const cv::Size& frameBufferSize) : FrameBufferContext::FrameBufferContext(const cv::Size& frameBufferSize) :
frameBufferSize_(frameBufferSize) { frameBufferSize_(frameBufferSize) {
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
glewExperimental = true; glewExperimental = true;
glewInit(); glewInit();
try { try {

@ -13,10 +13,10 @@
# include <CL/cl.h> # include <CL/cl.h>
# include <CL/cl_gl.h> # include <CL/cl_gl.h>
#else #else
# define OPENCV_V4D_USE_ES2 1 # define OPENCV_V4D_USE_ES3 1
#endif #endif
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
# include <GL/glew.h> # include <GL/glew.h>
# define GLFW_INCLUDE_GLCOREARB # define GLFW_INCLUDE_GLCOREARB
#else #else

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

@ -8,7 +8,7 @@
#include "framebuffercontext.hpp" #include "framebuffercontext.hpp"
#include <nanogui/nanogui.h> #include <nanogui/nanogui.h>
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
#define NANOGUI_USE_OPENGL #define NANOGUI_USE_OPENGL
#else #else
#define NANOGUI_USE_GLES #define NANOGUI_USE_GLES

@ -5,7 +5,7 @@
#include "opencv2/v4d/dialog.hpp" #include "opencv2/v4d/dialog.hpp"
#include <nanogui/layout.h> #include <nanogui/layout.h>
#ifndef OPENCV_V4D_USE_ES2 #ifndef OPENCV_V4D_USE_ES3
# include <GL/glew.h> # include <GL/glew.h>
# define GLFW_INCLUDE_GLCOREARB # define GLFW_INCLUDE_GLCOREARB
#else #else

@ -124,7 +124,7 @@ bool V4D::initializeWindowing() {
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#elif defined(OPENCV_V4D_USE_ES2) #elif defined(OPENCV_V4D_USE_ES3)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);

Loading…
Cancel
Save