diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index 904b80c63e84..173f892cab83 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -1407,11 +1407,20 @@ void cv::ogl::Arrays::bind() const cv::ogl::Program::Program() { +#ifndef HAVE_OPENGL + throw_no_ogl(); +#else program_ = gl::CreateProgram(); +#endif } void cv::ogl::Program::attachShaders(const std::string& fragment_shader_source, const std::string& vertex_shader_source) { +#ifndef HAVE_OPENGL + CV_UNUSED(fragment_shader_source); + CV_UNUSED(vertex_shader_source); + throw_no_ogl(); +#else GLuint fragment_shader = gl::CreateShader(gl::FRAGMENT_SHADER); GLuint vertex_shader = gl::CreateShader(gl::VERTEX_SHADER); const char* fragment_source = fragment_shader_source.c_str(); @@ -1424,10 +1433,14 @@ void cv::ogl::Program::attachShaders(const std::string& fragment_shader_source, gl::AttachShader(program_, vertex_shader); gl::LinkProgram(program_); gl::UseProgram(program_); +#endif }; std::string cv::ogl::Program::getDefaultFragmentShader() { +#ifndef HAVE_OPENGL + throw_no_ogl(); +#else return "#version 330 core\n" "in vec2 TexCoord;\n" @@ -1436,10 +1449,14 @@ std::string cv::ogl::Program::getDefaultFragmentShader() "void main() {\n" " color = texture(ourTexture, TexCoord);\n" "}\n"; +#endif } std::string cv::ogl::Program::getDefaultVertexShader() { +#ifndef HAVE_OPENGL + throw_no_ogl() +#else return "#version 330 core\n" "layout (location = 0) in vec3 position;\n" @@ -1450,11 +1467,16 @@ std::string cv::ogl::Program::getDefaultVertexShader() " gl_Position = transform * vec4(position, 1.0);\n" " TexCoord = texCoord;\n" "}\n"; +#endif } unsigned int cv::ogl::Program::getProgramId() { +#ifndef HAVE_OPENGL + throw_no_ogl() +#else return program_; +#endif } ////////////////////////////////////////////////////////////////////////