diff --git a/CMakeLists.txt b/CMakeLists.txt index fc8690a..a6141d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,50 +1,36 @@ project(screensaver.asteroids) -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.0) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) enable_language(CXX) find_package(Kodi REQUIRED) -find_package(CXX11 REQUIRED) if(NOT WIN32) - find_package(EMBEDDED) - if((APP_RENDER_SYSTEM STREQUAL "gl" OR NOT APP_RENDER_SYSTEM) AND NOT EMBEDDED_FOUND) - find_package(OpenGL) + if(APP_RENDER_SYSTEM STREQUAL "gl" OR NOT APP_RENDER_SYSTEM) + find_package(OpenGl REQUIRED) + set(DEPLIBS ${OPENGL_LIBRARIES}) + set(includes ${OPENGL_INCLUDE_DIR}) + add_definitions(${OPENGL_DEFINITIONS}) + elseif(APP_RENDER_SYSTEM STREQUAL "gles") + find_package(OpenGLES REQUIRED) + set(DEPLIBS ${OPENGLES_LIBRARIES}) + set(includes ${OPENGLES_INCLUDE_DIR}) + add_definitions(${OPENGLES_DEFINITIONS}) endif() - if(OPENGL_FOUND) - set(APP_RENDER_SYSTEM gl) - set(INCLUDES ${OPENGL_INCLUDE_DIR}) - set(DEPLIBS ${OPENGL_LIBRARIES}) - set(ASTEROIDS_SOURCES src/shaders/GUIShader.cpp - src/shaders/Matrix.cpp - src/shaders/Shader.cpp) - set(ASTEROIDS_HEADERS src/shaders/GUIShader.h - src/shaders/Matrix.h - src/shaders/Shader.h) - add_definitions(-DHAS_GL) - message(STATUS "Asteroids screensaver via OpenGL") - else() - find_package(OpenGLES2) - if(OPENGLES2_FOUND) - set(APP_RENDER_SYSTEM gles) - set(ASTEROIDS_SOURCES src/shaders/GUIShader.cpp - src/shaders/Matrix.cpp - src/shaders/Shader.cpp) - set(ASTEROIDS_HEADERS src/shaders/GUIShader.h - src/shaders/Matrix.h - src/shaders/Shader.h) - add_definitions(-DHAS_GLES2) - set(INCLUDES ${OPENGLES2_INCLUDE_DIRS}) - set(DEPLIBS ${OPENGLES2_LIBRARIES}) - message(STATUS "Asteroids screensaver via OpenGLES") - else() - message(FATAL_ERROR "Asteroids screensaver OpenGL(ES) wasn't found") - endif() + if(NOT OPENGL_FOUND AND NOT OPENGLES_FOUND) + message(FATAL_ERROR "No rendering API found. Bailing") endif() + + set(ASTEROIDS_SOURCES src/shaders/GUIShader.cpp + src/shaders/Matrix.cpp + src/shaders/Shader.cpp) + set(ASTEROIDS_HEADERS src/shaders/GUIShader.h + src/shaders/Matrix.h + src/shaders/Shader.h) endif() include_directories(${KODI_INCLUDE_DIR}/..) # Hack way with "/..", need bigger Kodi cmake rework to match right include ways diff --git a/FindCXX11.cmake b/FindCXX11.cmake deleted file mode 100644 index 001dc8a..0000000 --- a/FindCXX11.cmake +++ /dev/null @@ -1,18 +0,0 @@ -include(TestCXXAcceptsFlag) - -# try to use compiler flag -std=c++11 -check_cxx_accepts_flag("-std=c++11" CXX_FLAG_CXX11) -if(CXX_FLAG_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(CXX_STD11_FLAGS "-std=c++11") -else() - # try to use compiler flag -std=c++0x for older compilers - check_cxx_accepts_flag("-std=c++0x" CXX_FLAG_CXX0X) - if(CXX_FLAG_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - set(CXX_STD11_FLAGS "-std=c++0x") - endif(CXX_FLAG_CXX0X) -endif(CXX_FLAG_CXX11) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CXX11 DEFAULT_MSG CXX_STD11_FLAGS) diff --git a/FindEMBEDDED.cmake b/FindEMBEDDED.cmake deleted file mode 100644 index b60fcb9..0000000 --- a/FindEMBEDDED.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# - Try to find embedded platforms (RPI/IMX6) -# Once done this will define -# -# EMBEDDED_FOUND - system is RPI / IMX6 and we most probably want to compile for GLES2 support -# (don't configure for OpenGL) - -string(REGEX MATCH "^arm" TARGET_ARCH_ARM "${CMAKE_SYSTEM_PROCESSOR}") -if(NOT CMAKE_CROSSCOMPILING AND NOT TARGET_ARCH_ARM) - return() -endif(NOT CMAKE_CROSSCOMPILING AND NOT TARGET_ARCH_ARM) - -find_path(EMBEDDED_FOUND NAMES include/linux/imxfb.h include/bcm_host.h PATHS /opt/vc) diff --git a/FindOpenGLES.cmake b/FindOpenGLES.cmake new file mode 100644 index 0000000..0191d9e --- /dev/null +++ b/FindOpenGLES.cmake @@ -0,0 +1,54 @@ +#.rst: +# FindOpenGLES +# ------------ +# Finds the OpenGLES2 library +# +# This will define the following variables:: +# +# OPENGLES_FOUND - system has OpenGLES +# OPENGLES_INCLUDE_DIRS - the OpenGLES include directory +# OPENGLES_LIBRARIES - the OpenGLES libraries +# OPENGLES_DEFINITIONS - the OpenGLES definitions + +if(CORE_PLATFORM_NAME_LC STREQUAL rbpi) + set(_brcmprefix brcm) +endif() + +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_OPENGLES ${_brcmprefix}glesv2 QUIET) +endif() + +if(NOT CORE_SYSTEM_NAME STREQUAL ios) + find_path(OPENGLES_INCLUDE_DIR GLES2/gl2.h + PATHS ${PC_OPENGLES_INCLUDEDIR}) + find_library(OPENGLES_gl_LIBRARY NAMES ${_brcmprefix}GLESv2 + PATHS ${PC_OPENGLES_LIBDIR}) +else() + find_library(OPENGLES_gl_LIBRARY NAMES OpenGLES + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH) + set(OPENGLES_INCLUDE_DIR ${OPENGLES_gl_LIBRARY}/Headers) +endif() + +find_path(OPENGLES3_INCLUDE_DIR GLES3/gl3.h) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenGLES + REQUIRED_VARS OPENGLES_gl_LIBRARY OPENGLES_INCLUDE_DIR) + +find_path(OPENGLES3_INCLUDE_DIR GLES3/gl3.h + PATHS ${PC_OPENGLES_INCLUDEDIR}) + +if(OPENGLES_FOUND) + set(OPENGLES_LIBRARIES ${OPENGLES_gl_LIBRARY}) + if(OPENGLES3_INCLUDE_DIR) + set(OPENGLES_INCLUDE_DIRS ${OPENGLES_INCLUDE_DIR} ${OPENGLES3_INCLUDE_DIR}) + set(OPENGLES_DEFINITIONS -DHAS_GLES=3) + mark_as_advanced(OPENGLES_INCLUDE_DIR OPENGLES3_INCLUDE_DIR OPENGLES_gl_LIBRARY) + else() + set(OPENGLES_INCLUDE_DIRS ${OPENGLES_INCLUDE_DIR}) + set(OPENGLES_DEFINITIONS -DHAS_GLES=2) + mark_as_advanced(OPENGLES_INCLUDE_DIR OPENGLES_gl_LIBRARY) + endif() +endif() diff --git a/FindOpenGLES2.cmake b/FindOpenGLES2.cmake deleted file mode 100644 index b70ce74..0000000 --- a/FindOpenGLES2.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# - Try to find OpenGLES2 -# Once done this will define -# -# OPENGLES2_FOUND - system has OpenGLES2 -# OPENGLES2_INCLUDE_DIR - the GLES2 include directory -# OPENGLES2_LIBRARIES - Link these to use OpenGLES2 - -find_package(PkgConfig) -if(PKG_CONFIG_FOUND AND NOT EMBEDDED_FOUND) - pkg_check_modules(OpenGLES2 glesv2) -elseif(EMBEDDED_FOUND) - set(CMAKE_PREFIX_PATH ${EMBEDDED_FOUND} ${CMAKE_PREFIX_PATH}) -endif(PKG_CONFIG_FOUND AND NOT EMBEDDED_FOUND) - -if(NOT OPENGLES2_FOUND) - if("${CORE_SYSTEM_NAME}" STREQUAL "ios") - find_library(OPENGLES2_gl_LIBRARY NAMES OpenGLES PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH) - set(OPENGLES2_INCLUDE_DIRS ${OPENGLES2_gl_LIBRARY}/Headers) - set(OPENGLES2_egl_LIBRARY ${OPENGLES2_gl_LIBRARY}) - else() - find_path(OPENGLES2_INCLUDE_DIRS GLES2/gl2.h) - find_library(OPENGLES2_gl_LIBRARY NAMES GLESv2) - find_library(OPENGLES2_egl_LIBRARY NAMES EGL) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG - OPENGLES2_INCLUDE_DIRS OPENGLES2_gl_LIBRARY OPENGLES2_egl_LIBRARY) - - set(OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_egl_LIBRARY}) -endif(NOT OPENGLES2_FOUND) - -mark_as_advanced( - OPENGLES2_INCLUDE_DIRS - OPENGLES2_LIBRARIES - OPENGLES2_gl_LIBRARY - OPENGLES2_egl_LIBRARY -) diff --git a/FindOpenGl.cmake b/FindOpenGl.cmake new file mode 100644 index 0000000..e155cda --- /dev/null +++ b/FindOpenGl.cmake @@ -0,0 +1,40 @@ +#.rst: +# FindOpenGl +# ---------- +# Finds the FindOpenGl library +# +# This will define the following variables:: +# +# OPENGL_FOUND - system has OpenGl +# OPENGL_INCLUDE_DIRS - the OpenGl include directory +# OPENGL_LIBRARIES - the OpenGl libraries +# OPENGL_DEFINITIONS - the OpenGl definitions + +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_OPENGL gl QUIET) +endif() + +if(NOT CORE_SYSTEM_NAME STREQUAL osx) + find_path(OPENGL_INCLUDE_DIR GL/gl.h + PATHS ${PC_OPENGL_gl_INCLUDEDIR}) + find_library(OPENGL_gl_LIBRARY NAMES GL + PATHS ${PC_OPENGL_gl_LIBDIR}) +else() + find_library(OPENGL_gl_LIBRARY NAMES OpenGL + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH) + set(OPENGL_INCLUDE_DIR ${OPENGL_gl_LIBRARY}/Headers) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenGl + REQUIRED_VARS OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR) + +if(OPENGL_FOUND) + set(OPENGL_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) + set(OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY}) + set(OPENGL_DEFINITIONS -DHAS_GL=1) +endif() + +mark_as_advanced(OPENGL_INCLUDE_DIR OPENGL_gl_LIBRARY) diff --git a/debian/changelog.in b/debian/changelog.in index bddb0de..84efc17 100644 --- a/debian/changelog.in +++ b/debian/changelog.in @@ -1,7 +1,6 @@ kodi-screensaver-asteroids (#PACKAGEVERSION#-#TAGREV#~#DIST#) #DIST#; urgency=low - [ xbmc ] + [ kodi ] * autogenerated dummy changelog - -- Arne Morten Kvarving Sat, 01 Jun 2013 00:59:22 +0200 - + -- Nobody Sat, 01 Jun 2013 00:59:22 +0200 diff --git a/debian/control b/debian/control index 9982dcd..dfe2a4c 100644 --- a/debian/control +++ b/debian/control @@ -1,11 +1,11 @@ Source: kodi-screensaver-asteroids Priority: extra -Maintainer: Arne Morten Kvarving -Build-Depends: debhelper (>= 8.0.0), cmake, kodi-addon-dev, +Maintainer: Nobody +Build-Depends: debhelper (>= 9.0.0), cmake, kodi-addon-dev, libgl1-mesa-dev Standards-Version: 3.9.5 Section: libs -Homepage: http://xbmc.org +Homepage: http://kodi.tv Package: kodi-screensaver-asteroids Section: libs diff --git a/debian/copyright b/debian/copyright index 8addff6..36f76e7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,28 +1,10 @@ Format: http://dep.debian.net/deps/dep5 Upstream-Name: screensaver.asteroids +Source: https://github.com/xbmc/screensaver.asteroids Files: * - 2005-2013 Team XBMC -License: GPL-2+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". - - -Files: debian/* -Copyright: 2013 Arne Morten Kvarving +Copyright: 2005-2018 Team Kodi + 2013 Arne Morten Kvarving 2013 wsnipex License: GPL-2+ This package is free software; you can redistribute it and/or modify @@ -40,4 +22,3 @@ License: GPL-2+ . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". - diff --git a/debian/docs b/debian/docs deleted file mode 100644 index e69de29..0000000 diff --git a/debian/kodi-screensaver-asteroids.install b/debian/kodi-screensaver-asteroids.install new file mode 100644 index 0000000..db2d2dc --- /dev/null +++ b/debian/kodi-screensaver-asteroids.install @@ -0,0 +1,2 @@ +usr/lib/* +usr/share/* diff --git a/debian/rules b/debian/rules index ab2d2df..6d7835a 100755 --- a/debian/rules +++ b/debian/rules @@ -16,10 +16,7 @@ override_dh_auto_configure: dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DUSE_LTO=1 override_dh_strip: - dh_strip --dbg-package=kodi-screensaver-asteroids-dbg - -override_dh_auto_install: - dh_auto_install --destdir=debian/kodi-screensaver-asteroids + dh_strip -pkodi-screensaver-asteroids --dbg-package=kodi-screensaver-asteroids-dbg override_dh_installdocs: dh_installdocs --link-doc=kodi-screensaver-asteroids diff --git a/screensaver.asteroids/addon.xml.in b/screensaver.asteroids/addon.xml.in index 90c9dea..1552502 100644 --- a/screensaver.asteroids/addon.xml.in +++ b/screensaver.asteroids/addon.xml.in @@ -1,16 +1,23 @@  + provider-name="Team Kodi"> @ADDON_DEPENDS@ Asteroids screensaver - Asteroids screensaver + An old-style screen saver where the asteroids are shot away. @PLATFORM@ + + resources/icon.png + resources/fanart.png + resources/screenshot-01.png + resources/screenshot-02.png + resources/screenshot-03.png + diff --git a/screensaver.asteroids/resources/fanart.png b/screensaver.asteroids/resources/fanart.png new file mode 100644 index 0000000..1b3cca8 Binary files /dev/null and b/screensaver.asteroids/resources/fanart.png differ diff --git a/screensaver.asteroids/resources/icon.png b/screensaver.asteroids/resources/icon.png new file mode 100644 index 0000000..5f2cc96 Binary files /dev/null and b/screensaver.asteroids/resources/icon.png differ diff --git a/screensaver.asteroids/resources/screenshot-01.png b/screensaver.asteroids/resources/screenshot-01.png new file mode 100644 index 0000000..2c24cc1 Binary files /dev/null and b/screensaver.asteroids/resources/screenshot-01.png differ diff --git a/screensaver.asteroids/resources/screenshot-02.png b/screensaver.asteroids/resources/screenshot-02.png new file mode 100644 index 0000000..04d3509 Binary files /dev/null and b/screensaver.asteroids/resources/screenshot-02.png differ diff --git a/screensaver.asteroids/resources/screenshot-03.png b/screensaver.asteroids/resources/screenshot-03.png new file mode 100644 index 0000000..f048986 Binary files /dev/null and b/screensaver.asteroids/resources/screenshot-03.png differ diff --git a/screensaver.asteroids/resources/shaders/GL/1.5/vert.glsl b/screensaver.asteroids/resources/shaders/GL/1.5/vert.glsl deleted file mode 100644 index f4ca4dc..0000000 --- a/screensaver.asteroids/resources/shaders/GL/1.5/vert.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#version 150 - -in vec3 m_attrpos; -in vec4 m_attrcol; -out vec4 m_col; - -void main() -{ - gl_Position = vec4(m_attrpos.x, m_attrpos.y, m_attrpos.z, 1.0); - m_col = m_attrcol; -} diff --git a/screensaver.asteroids/resources/shaders/GL/1.5/frag.glsl b/screensaver.asteroids/resources/shaders/GL/frag.glsl similarity index 75% rename from screensaver.asteroids/resources/shaders/GL/1.5/frag.glsl rename to screensaver.asteroids/resources/shaders/GL/frag.glsl index 500ea09..9f454e1 100644 --- a/screensaver.asteroids/resources/shaders/GL/1.5/frag.glsl +++ b/screensaver.asteroids/resources/shaders/GL/frag.glsl @@ -5,5 +5,5 @@ out vec4 FragColor; void main() { - FragColor = m_col; + FragColor = m_col; } diff --git a/screensaver.asteroids/resources/shaders/GL/vert.glsl b/screensaver.asteroids/resources/shaders/GL/vert.glsl new file mode 100644 index 0000000..2b179de --- /dev/null +++ b/screensaver.asteroids/resources/shaders/GL/vert.glsl @@ -0,0 +1,17 @@ +#version 150 + +in vec3 m_attrpos; +in vec4 m_attrcol; + +out vec4 m_cord; +out vec4 m_col; + +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * vec4(m_attrpos.x, m_attrpos.y, m_attrpos.z, 1.0); + m_col = m_attrcol; +} diff --git a/screensaver.asteroids/resources/shaders/GLES/3.0/frag.glsl b/screensaver.asteroids/resources/shaders/GLES/frag.glsl similarity index 100% rename from screensaver.asteroids/resources/shaders/GLES/3.0/frag.glsl rename to screensaver.asteroids/resources/shaders/GLES/frag.glsl diff --git a/screensaver.asteroids/resources/shaders/GLES/3.0/vert.glsl b/screensaver.asteroids/resources/shaders/GLES/vert.glsl similarity index 100% rename from screensaver.asteroids/resources/shaders/GLES/3.0/vert.glsl rename to screensaver.asteroids/resources/shaders/GLES/vert.glsl diff --git a/src/shaders/GUIShader.h b/src/shaders/GUIShader.h index a126f28..dbc9bde 100644 --- a/src/shaders/GUIShader.h +++ b/src/shaders/GUIShader.h @@ -1,4 +1,3 @@ -#pragma once /* * Copyright (C) 2005-2018 Team Kodi * This file is part of Kodi - https://kodi.tv @@ -19,6 +18,8 @@ * */ +#pragma once + #include "Shader.h" #include "Matrix.h" diff --git a/src/shaders/Matrix.cpp b/src/shaders/Matrix.cpp index 945d366..8c12b74 100644 --- a/src/shaders/Matrix.cpp +++ b/src/shaders/Matrix.cpp @@ -61,7 +61,7 @@ void CMatrix::MatrixMode(EMATRIXMODE mode) else { m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = nullptr; + m_pMatrix = nullptr; } } diff --git a/src/shaders/Matrix.h b/src/shaders/Matrix.h index fa8b464..551b0a7 100644 --- a/src/shaders/Matrix.h +++ b/src/shaders/Matrix.h @@ -1,4 +1,3 @@ -#pragma once /* * Copyright (C) 2005-2018 Team Kodi * This file is part of Kodi - https://kodi.tv @@ -19,23 +18,42 @@ * */ -#if defined(HAS_GL) -#if defined(__APPLE__) -#include -#else -#define GL_GLEXT_PROTOTYPES -#include -#include -#endif//__APPLE__ -#else -#if defined(__APPLE__) -#include -#include -#else -#include -#include -#endif//__APPLE__ +#pragma once + +#ifdef HAS_GL + // always define GL_GLEXT_PROTOTYPES before include gl headers + #if !defined(GL_GLEXT_PROTOTYPES) + #define GL_GLEXT_PROTOTYPES + #endif + #if defined(TARGET_LINUX) + #include + #include + #elif defined(TARGET_FREEBSD) + #include + #elif defined(TARGET_DARWIN) + #include + #include + #endif +#elif HAS_GLES >= 2 + #if defined(TARGET_DARWIN) + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #else + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #endif #endif + #include #include diff --git a/src/shaders/Shader.cpp b/src/shaders/Shader.cpp index 12c5f2f..eeae229 100644 --- a/src/shaders/Shader.cpp +++ b/src/shaders/Shader.cpp @@ -40,7 +40,6 @@ bool CShader::LoadSource(std::string &file) kodi::Log(ADDON_LOG_ERROR, "Failed to load shader source: '%s'", file.c_str()); return false; } - size_t len = source.Read(buffer, sizeof(buffer)); m_source.assign(buffer); m_source[len] = 0; @@ -66,22 +65,16 @@ bool CVertexShader::Compile() if (params[0] != GL_TRUE) { GLchar log[LOG_SIZE]; - kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader"); glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); - kodi::Log(ADDON_LOG_ERROR, "%s", log); + kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); m_lastLog = log; m_compiled = false; } else { GLchar log[LOG_SIZE]; - GLsizei length; - glGetShaderInfoLog(m_vertexShader, LOG_SIZE, &length, log); - if (length > 0) - { - kodi::Log(ADDON_LOG_DEBUG, "GL: Vertex Shader compilation log:"); - kodi::Log(ADDON_LOG_DEBUG, "%s", log); - } + glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); m_lastLog = log; m_compiled = true; } @@ -105,10 +98,7 @@ bool CPixelShader::Compile() Free(); if (m_source.length()==0) - { - kodi::Log(ADDON_LOG_NOTICE, "GL: No pixel shader, fixed pipeline in use"); return true; - } m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); const char *ptr = m_source.c_str(); @@ -118,22 +108,16 @@ bool CPixelShader::Compile() if (params[0] != GL_TRUE) { GLchar log[LOG_SIZE]; - kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling pixel shader"); glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); - kodi::Log(ADDON_LOG_ERROR, "%s", log); + kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); m_lastLog = log; m_compiled = false; } else { GLchar log[LOG_SIZE]; - GLsizei length; glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); - if (length > 0) - { - kodi::Log(ADDON_LOG_DEBUG, "GL: Pixel Shader compilation log:"); - kodi::Log(ADDON_LOG_DEBUG, "%s", log); - } + kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); m_lastLog = log; m_compiled = true; } @@ -155,30 +139,15 @@ CShaderProgram::CShaderProgram(std::string &vert, std::string &frag) { std::string path = kodi::GetAddonPath(); - int major = 0; - int minor = 0; - const char* ver = reinterpret_cast(glGetString(GL_VERSION)); - if (ver != 0) - { - sscanf(ver, "%d.%d", &major, &minor); - } - - if (major > 3) - { #if defined(HAS_GL) - path += "/resources/shaders/GL/1.5/"; + path += "/resources/shaders/GL/"; +#elif defined(HAS_GLES) + path += "/resources/shaders/GLES/"; #else - path += "/resources/shaders/GLES/3.0/"; + #error Shader compiled without GL support! #endif - } - else - { - kodi::Log(ADDON_LOG_FATAL, "GL: Not supported OpenGL: %s", ver); - return; - } std::string file; - m_pFP = new CPixelShader(); file = path + frag; m_pFP->LoadSource(file); @@ -238,12 +207,11 @@ bool CShaderProgram::CompileAndLink() // link the program glLinkProgram(m_shaderProgram); glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); - if (params[0]!=GL_TRUE) + if (params[0] != GL_TRUE) { GLchar log[LOG_SIZE]; - kodi::Log(ADDON_LOG_ERROR, "GL: Error linking shader"); - glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "%s", log); + glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); goto error; } @@ -274,9 +242,8 @@ bool CShaderProgram::Enable() if (params[0] != GL_TRUE) { GLchar log[LOG_SIZE]; - kodi::Log(ADDON_LOG_ERROR, "GL: Error validating shader"); glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); - kodi::Log(ADDON_LOG_ERROR, "%s", log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); } m_validated = true; } diff --git a/src/shaders/Shader.h b/src/shaders/Shader.h index a332ad1..c6b121c 100644 --- a/src/shaders/Shader.h +++ b/src/shaders/Shader.h @@ -1,4 +1,3 @@ -#pragma once /* * Copyright (C) 2005-2018 Team Kodi * This file is part of Kodi - https://kodi.tv @@ -19,22 +18,40 @@ * */ -#if defined(HAS_GL) -#if defined(__APPLE__) -#include -#else -#define GL_GLEXT_PROTOTYPES -#include -#include -#endif//__APPLE__ -#else -#if defined(__APPLE__) -#include -#include -#else -#include -#include -#endif//__APPLE__ +#pragma once + +#ifdef HAS_GL + // always define GL_GLEXT_PROTOTYPES before include gl headers + #if !defined(GL_GLEXT_PROTOTYPES) + #define GL_GLEXT_PROTOTYPES + #endif + #if defined(TARGET_LINUX) + #include + #include + #elif defined(TARGET_FREEBSD) + #include + #elif defined(TARGET_DARWIN) + #include + #include + #endif +#elif HAS_GLES >= 2 + #if defined(TARGET_DARWIN) + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #else + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #endif #endif #include