diff -Nru kodi-screensaver-matrixtrails-2.2.0/CMakeLists.txt kodi-screensaver-matrixtrails-2.2.1/CMakeLists.txt --- kodi-screensaver-matrixtrails-2.2.0/CMakeLists.txt 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/CMakeLists.txt 2019-03-19 23:02:55.000000000 +0000 @@ -1,11 +1,8 @@ +cmake_minimum_required(VERSION 3.5) project(screensaver.matrixtrails) -cmake_minimum_required(VERSION 3.0) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) -enable_language(CXX) - find_package(Kodi REQUIRED) if(APP_RENDER_SYSTEM STREQUAL "gl" OR NOT APP_RENDER_SYSTEM) @@ -20,29 +17,20 @@ add_definitions(${OPENGLES_DEFINITIONS}) endif() -if(NOT OPENGL_FOUND AND NOT OPENGLES_FOUND) - message(FATAL_ERROR "No rendering API found. Bailing") -endif() - add_subdirectory(lib/SOIL2) -include_directories(${KODI_INCLUDE_DIR}/..) # Hack way with "/..", need bigger Kodi cmake rework to match right include ways +include_directories(${KODI_INCLUDE_DIR}/.. # Hack way with "/..", need bigger Kodi cmake rework to match right include ways + ${PROJECT_SOURCE_DIR}/lib) set(MATRIXTRAILS_SOURCES src/column.cpp src/main.cpp - src/matrixtrails.cpp - src/shaders/GUIShader.cpp - src/shaders/Matrix.cpp - src/shaders/Shader.cpp) + src/matrixtrails.cpp) set(MATRIXTRAILS_HEADERS src/column.h src/main.h src/matrixtrails.h src/timer.h - src/types.h - src/shaders/GUIShader.h - src/shaders/Matrix.h - src/shaders/Shader.h) + src/types.h) list(APPEND DEPLIBS soil2) diff -Nru kodi-screensaver-matrixtrails-2.2.0/debian/changelog kodi-screensaver-matrixtrails-2.2.1/debian/changelog --- kodi-screensaver-matrixtrails-2.2.0/debian/changelog 2018-11-30 10:19:50.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/debian/changelog 2013-05-31 22:59:22.000000000 +0000 @@ -1,4 +1,4 @@ -kodi-screensaver-matrixtrails (2.2.0-1~bionic) bionic; urgency=low +kodi-screensaver-matrixtrails (2.2.1-1~bionic) bionic; urgency=low [ kodi ] * autogenerated dummy changelog diff -Nru kodi-screensaver-matrixtrails-2.2.0/.gitignore kodi-screensaver-matrixtrails-2.2.1/.gitignore --- kodi-screensaver-matrixtrails-2.2.0/.gitignore 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/.gitignore 2019-03-19 23:02:55.000000000 +0000 @@ -1,38 +1,27 @@ -.build -.cproject -.deps -.libs -.project - +# build artifacts +build/ +obj-x86_64-linux-gnu/ screensaver.*/addon.xml -.dummy -.dummy.in +# commonly used editors +# vim +*.swp + +# Eclipse +*.project +*.cproject +.classpath +*.sublime-* +.settings/ + +# KDevelop 4 +*.kdev4 -*.o -*.a -*.P -*.lo -*.la -*.pvr -*.zip -*.patch -*.orig -*.diff - -*.idb -*.tlog -*.lastbuildstate - -# Windows specific generated files -*.exp -*.lib -*.pdb -*.ilk -*.suo -*.sdf -*.opensdf -*.vcxproj.user +# gedit +*~ -build/ -VS2013Kodi_AddonProject/ +# CLion +/.idea + +# clion +.idea/ diff -Nru kodi-screensaver-matrixtrails-2.2.0/Jenkinsfile kodi-screensaver-matrixtrails-2.2.1/Jenkinsfile --- kodi-screensaver-matrixtrails-2.2.0/Jenkinsfile 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/Jenkinsfile 2019-03-19 23:02:55.000000000 +0000 @@ -1 +1 @@ -buildPlugin(platforms: ['osx-x86_64', 'ubuntu-ppa']) +buildPlugin(platforms: ['android-armv7', 'android-aarch64', 'ios-armv7', 'ios-aarch64', 'osx-x86_64', 'ubuntu-ppa']) diff -Nru kodi-screensaver-matrixtrails-2.2.0/lib/kodi/gui/gl/GL.h kodi-screensaver-matrixtrails-2.2.1/lib/kodi/gui/gl/GL.h --- kodi-screensaver-matrixtrails-2.2.0/lib/kodi/gui/gl/GL.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/lib/kodi/gui/gl/GL.h 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +//============================================================================== +/// +/// \defgroup cpp_kodi_gui_gl Kodi OpenGL helpers +/// \ingroup cpp_kodi_gui +/// \brief Auxiliary functions for Open GL +/// +/// This group includes help for definitions, functions, and classes for +/// OpenGL. +/// +/// To use OpenGL for your system, add the \ref GL.h "#include ". +/// +/// +///----------------------------------------------------------------------------- +/// +/// The \ref HAS_GL is declared if Open GL is required and \ref HAS_GLES if Open GL +/// Embedded Systems (ES) is required, with ES the version is additionally given +/// in the definition, this can be "2" or "3". +/// +/// +///----------------------------------------------------------------------------- +/// +/// Following \ref GL_TYPE_STRING define can be used, for example, to manage +/// different folders for GL and GLES and make the selection easier. +/// This are on OpenGL **"`GL`"** and on Open GL|ES **"`GLES`"**. +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); +/// ~~~~~~~~~~~~~~~~~ +/// +/// +///---------------------------------------------------------------------------- +/// +/// In addition, \ref BUFFER_OFFSET is declared in it which can be used to give an +/// offset on the array to GL. +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// const struct PackedVertex { +/// float position[3]; // Position x, y, z +/// float color[4]; // Color r, g, b, a +/// } vertices[3] = { +/// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, +/// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, +/// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } } +/// }; +/// +/// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position))); +/// glEnableVertexAttribArray(m_aPosition); +/// +/// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color))); +/// glEnableVertexAttribArray(m_aColor); +/// ~~~~~~~~~~~~~~~~~ + +#if HAS_GL + #define GL_TYPE_STRING "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 + #elif defined(WIN32) + #error Use of GL under Windows is not possible + #endif +#elif HAS_GLES >= 2 + #define GL_TYPE_STRING "GLES" + #if defined(WIN32) + #error Use of GLES under Windows is not possible + #elif 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 + +#ifndef BUFFER_OFFSET +#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) +#endif diff -Nru kodi-screensaver-matrixtrails-2.2.0/lib/kodi/gui/gl/Shader.h kodi-screensaver-matrixtrails-2.2.1/lib/kodi/gui/gl/Shader.h --- kodi-screensaver-matrixtrails-2.2.0/lib/kodi/gui/gl/Shader.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/lib/kodi/gui/gl/Shader.h 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "GL.h" + +#include +#include +#include + +#include +#include + +#define LOG_SIZE 1024 +#define GLchar char + +namespace kodi +{ + namespace gui + { + namespace gl + { + //======================================================================== + /// CShader - base class + class ATTRIBUTE_HIDDEN CShader + { + public: + CShader() = default; + virtual ~CShader() = default; + virtual bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") = 0; + virtual void Free() = 0; + virtual GLuint Handle() = 0; + + bool LoadSource(const std::string& file) + { + char buffer[16384]; + + kodi::vfs::CFile source; + if (!source.OpenFile(file)) + { + kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, file.c_str()); + return false; + } + size_t len = source.Read(buffer, sizeof(buffer)); + m_source.assign(buffer); + m_source[len] = 0; + source.Close(); + return true; + } + + bool OK() { return m_compiled; } + + protected: + std::string m_source; + std::string m_lastLog; + bool m_compiled = false; + }; + //------------------------------------------------------------------------ + + //======================================================================== + /// CVertexShader + class ATTRIBUTE_HIDDEN CVertexShader : public CShader + { + public: + CVertexShader() = default; + ~CVertexShader() override { Free(); } + + void Free() override + { + if (m_vertexShader) + glDeleteShader(m_vertexShader); + m_vertexShader = 0; + } + + bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") override + { + GLint params[4]; + + Free(); + + m_vertexShader = glCreateShader(GL_VERTEX_SHADER); + + GLsizei count = 0; + const char *sources[3]; + if (!extraBegin.empty()) + sources[count++] = extraBegin.c_str(); + if (!m_source.empty()) + sources[count++] = m_source.c_str(); + if (!extraEnd.empty()) + sources[count++] = extraEnd.c_str(); + + glShaderSource(m_vertexShader, count, sources, nullptr); + glCompileShader(m_vertexShader); + glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CVertexShader::%s: %s\n", __FUNCTION__, log); + m_lastLog = log; + m_compiled = false; + } + else + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); + m_lastLog = log; + m_compiled = true; + } + return m_compiled; + } + + GLuint Handle() override { return m_vertexShader; } + + protected: + GLuint m_vertexShader = 0; + }; + //------------------------------------------------------------------------ + + //======================================================================== + /// CPixelShader + class ATTRIBUTE_HIDDEN CPixelShader : public CShader + { + public: + CPixelShader() = default; + ~CPixelShader() { Free(); } + void Free() override + { + if (m_pixelShader) + glDeleteShader(m_pixelShader); + m_pixelShader = 0; + } + + bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") override + { + GLint params[4]; + + Free(); + + if (m_source.length()==0) + return true; + + m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); + + GLsizei count = 0; + const char *sources[3]; + if (!extraBegin.empty()) + sources[count++] = extraBegin.c_str(); + if (!m_source.empty()) + sources[count++] = m_source.c_str(); + if (!extraEnd.empty()) + sources[count++] = extraEnd.c_str(); + + glShaderSource(m_pixelShader, count, sources, 0); + glCompileShader(m_pixelShader); + glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CPixelShader::%s: %s\n", __FUNCTION__, log); + m_lastLog = log; + m_compiled = false; + } + else + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); + m_lastLog = log; + m_compiled = true; + } + return m_compiled; + } + + GLuint Handle() override { return m_pixelShader; } + + protected: + GLuint m_pixelShader = 0; + }; + //------------------------------------------------------------------------ + + //======================================================================== + /// CShaderProgram + class ATTRIBUTE_HIDDEN CShaderProgram + { + public: + CShaderProgram() = default; + CShaderProgram(const std::string &vert, const std::string &frag) + { + LoadShaderFiles(vert, frag); + } + + virtual ~CShaderProgram() + { + ShaderFree(); + } + + bool LoadShaderFiles(const std::string &vert, const std::string &frag) + { + if (!kodi::vfs::FileExists(vert) || !m_pVP.LoadSource(vert)) + { + kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, vert.c_str()); + return false; + } + + if (!kodi::vfs::FileExists(frag) || !m_pFP.LoadSource(frag)) + { + kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, frag.c_str()); + return false; + } + + return true; + } + + bool CompileAndLink(const std::string& vertexExtraBegin = "", + const std::string& vertexExtraEnd = "", + const std::string& fragmentExtraBegin = "", + const std::string& fragmentExtraEnd = "") + { + GLint params[4]; + + // free resources + ShaderFree(); + m_ok = false; + + // compiled vertex shader + if (!m_pVP.Compile(vertexExtraBegin, vertexExtraEnd)) + { + kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader"); + return false; + } + + // compile pixel shader + if (!m_pFP.Compile(fragmentExtraBegin, fragmentExtraEnd)) + { + m_pVP.Free(); + kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling fragment shader"); + return false; + } + + // create program object + if (!(m_shaderProgram = glCreateProgram())) + { + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: Failed to create GL program", __FUNCTION__); + ShaderFree(); + return false; + } + + // attach the vertex shader + glAttachShader(m_shaderProgram, m_pVP.Handle()); + glAttachShader(m_shaderProgram, m_pFP.Handle()); + + // link the program + glLinkProgram(m_shaderProgram); + glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); + ShaderFree(); + return false; + } + + m_validated = false; + m_ok = true; + OnCompiledAndLinked(); + return true; + } + + bool EnableShader() + { + if (ShaderOK()) + { + glUseProgram(m_shaderProgram); + if (OnEnabled()) + { + if (!m_validated) + { + // validate the program + GLint params[4]; + glValidateProgram(m_shaderProgram); + glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); + } + m_validated = true; + } + return true; + } + else + { + glUseProgram(0); + return false; + } + return true; + } + return false; + } + + void DisableShader() + { + if (ShaderOK()) + { + glUseProgram(0); + OnDisabled(); + } + } + + ATTRIBUTE_FORCEINLINE bool ShaderOK() { return m_ok; } + ATTRIBUTE_FORCEINLINE CVertexShader& VertexShader() { return m_pVP; } + ATTRIBUTE_FORCEINLINE CPixelShader& PixelShader() { return m_pFP; } + ATTRIBUTE_FORCEINLINE GLuint ProgramHandle() { return m_shaderProgram; } + + virtual void OnCompiledAndLinked() {}; + virtual bool OnEnabled() { return false; }; + virtual void OnDisabled() {}; + + private: + void ShaderFree() + { + if (m_shaderProgram) + glDeleteProgram(m_shaderProgram); + m_shaderProgram = 0; + m_ok = false; + } + + CVertexShader m_pVP; + CPixelShader m_pFP; + GLuint m_shaderProgram = 0; + bool m_ok = false; + bool m_validated = false; + }; + //------------------------------------------------------------------------ + } /* namespace gl */ + } /* namespace gui */ +} /* namespace kodi */ diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/addon.xml.in kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/addon.xml.in --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/addon.xml.in 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/addon.xml.in 2019-03-19 23:02:55.000000000 +0000 @@ -1,7 +1,7 @@  @ADDON_DEPENDS@ @@ -9,8 +9,8 @@ point="xbmc.ui.screensaver" library_@PLATFORM@="@LIBRARY_FILENAME@"/> - Matrix trails screensaver - The "digital rain" effect, as seen on the computer monitors in "The Matrix". + Matrix trails screensaver + The "digital rain" effect, as seen on the computer monitors in "The Matrix". @PLATFORM@ resources/icon.png diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/language/English/strings.po kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/language/English/strings.po --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/language/English/strings.po 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/language/English/strings.po 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: XBMC Main Translation Project (Frodo)\n" -"Report-Msgid-Bugs-To: http://trac.xbmc.org/\n" -"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: XBMC Translation Team\n" -"Language-Team: English (http://www.transifex.com/projects/p/XBMC-Main-Frodo/language/en/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: en\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -msgctxt "#30000" -msgid "Number of columns" -msgstr "" - -msgctxt "#30001" -msgid "Number of rows" -msgstr "" - -msgctxt "#30002" -msgid "Speed" -msgstr "" - -msgctxt "#30003" -msgid "{0:d}x" -msgstr "" diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/language/resource.language.en_gb/strings.po kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/language/resource.language.en_gb/strings.po --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/language/resource.language.en_gb/strings.po 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/language/resource.language.en_gb/strings.po 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,29 @@ +msgid "" +msgstr "" +"Project-Id-Version: XBMC Main Translation Project (Frodo)\n" +"Report-Msgid-Bugs-To: http://trac.xbmc.org/\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: XBMC Translation Team\n" +"Language-Team: English (http://www.transifex.com/projects/p/XBMC-Main-Frodo/language/en/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgctxt "#30000" +msgid "Number of columns" +msgstr "" + +msgctxt "#30001" +msgid "Number of rows" +msgstr "" + +msgctxt "#30002" +msgid "Speed" +msgstr "" + +msgctxt "#30003" +msgid "{0:d}x" +msgstr "" diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/frag.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/frag.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/frag.glsl 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/frag.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -#version 150 - -in vec4 m_col; -in vec2 m_cord; -out vec4 fragColor; - -uniform sampler2D tex; - -void main () -{ - fragColor.rgba = vec4(texture(tex, m_cord).rgba * m_col); -} diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GL/frag.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GL/frag.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GL/frag.glsl 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GL/frag.glsl 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,13 @@ +#version 150 + +uniform sampler2D u_texture; + +in vec2 v_coord; +in vec4 v_color; + +out vec4 fragColor; + +void main () +{ + fragColor = texture(u_texture, v_coord) * v_color; +} diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GL/vert.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GL/vert.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GL/vert.glsl 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GL/vert.glsl 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,15 @@ +#version 150 + +in vec3 a_pos; +in vec4 a_color; +in vec2 a_coord; + +out vec2 v_coord; +out vec4 v_color; + +void main () +{ + gl_Position = vec4(a_pos, 1.0); + v_color = a_color; + v_coord = a_coord; +} diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GLES/frag.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GLES/frag.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GLES/frag.glsl 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GLES/frag.glsl 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,13 @@ +#version 100 + +precision mediump float; + +uniform sampler2D u_texture; + +varying vec2 v_coord; +varying vec4 v_color; + +void main () +{ + gl_FragColor = texture2D(u_texture, v_coord) * v_color; +} diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GLES/vert.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GLES/vert.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/GLES/vert.glsl 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/GLES/vert.glsl 2019-03-19 23:02:55.000000000 +0000 @@ -0,0 +1,15 @@ +#version 100 + +attribute vec3 a_pos; +attribute vec4 a_color; +attribute vec2 a_coord; + +varying vec2 v_coord; +varying vec4 v_color; + +void main () +{ + gl_Position = vec4(a_pos, 1.0); + v_color = a_color; + v_coord = a_coord; +} diff -Nru kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/vert.glsl kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/vert.glsl --- kodi-screensaver-matrixtrails-2.2.0/screensaver.matrixtrails/resources/shaders/vert.glsl 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/screensaver.matrixtrails/resources/shaders/vert.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#version 150 - -in vec3 m_attrpos; -in vec4 m_attrcol; -in vec2 m_attrcoord; - -out vec2 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, 1.0); - m_col = m_attrcol; - m_cord = m_attrcoord; -} diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/main.cpp kodi-screensaver-matrixtrails-2.2.1/src/main.cpp --- kodi-screensaver-matrixtrails-2.2.0/src/main.cpp 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/main.cpp 2019-03-19 23:02:55.000000000 +0000 @@ -32,6 +32,7 @@ #include "timer.h" #include +#include #include #include diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/matrixtrails.cpp kodi-screensaver-matrixtrails-2.2.1/src/matrixtrails.cpp --- kodi-screensaver-matrixtrails-2.2.0/src/matrixtrails.cpp 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/matrixtrails.cpp 2019-03-19 23:02:55.000000000 +0000 @@ -27,8 +27,6 @@ #include -#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) - //////////////////////////////////////////////////////////////////////////// // CMatrixTrails::CMatrixTrails(CConfig* config) @@ -59,16 +57,12 @@ m_CharSize.y = 2.0 / (f32)m_NumRows; m_CharSize.z = 0.0f; - m_shader = new CGUIShader("vert.glsl", "frag.glsl"); - if (!m_shader->CompileAndLink()) - { - delete m_shader; - m_shader = nullptr; + std::string fraqShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); + std::string vertShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/vert.glsl"); + if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink()) return false; - } glGenBuffers(1, &m_vertexVBO); - glGenBuffers(1, &m_indexVBO); m_Texture = SOIL_load_OGL_texture(path.c_str(), SOIL_LOAD_RGB, 0, 0); @@ -81,11 +75,6 @@ { glDeleteBuffers(1, &m_vertexVBO); m_vertexVBO = 0; - glDeleteBuffers(1, &m_indexVBO); - m_indexVBO = 0; - - delete(m_shader); - m_shader = nullptr; } //////////////////////////////////////////////////////////////////////////// @@ -114,39 +103,40 @@ posX += m_CharSize.x; } - GLint posLoc = m_shader->GetPosLoc(); - GLint colLoc = m_shader->GetColLoc(); - GLint texCoord = m_shader->GetTexCoord(); - - m_shader->PushMatrix(); - m_shader->Enable(); + EnableShader(); glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO); glBufferData(GL_ARRAY_BUFFER, sizeof(TRenderVertex)*nVSize, &vert[0], GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, m_Texture); - glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, pos))); - glEnableVertexAttribArray(posLoc); + glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, pos))); + glEnableVertexAttribArray(m_aPosition); - glVertexAttribPointer(colLoc, 4, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, col))); - glEnableVertexAttribArray(colLoc); + glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, col))); + glEnableVertexAttribArray(m_aColor); - glVertexAttribPointer(texCoord, 2, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, u))); - glEnableVertexAttribArray(texCoord); + glVertexAttribPointer(m_aCoord, 2, GL_FLOAT, GL_FALSE, sizeof(TRenderVertex), BUFFER_OFFSET(offsetof(TRenderVertex, u))); + glEnableVertexAttribArray(m_aCoord); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnable(GL_BLEND); glDrawArrays(GL_TRIANGLE_STRIP, 0, nVSize); - glDisableVertexAttribArray(posLoc); - glDisableVertexAttribArray(colLoc); - glDisableVertexAttribArray(texCoord); + glDisableVertexAttribArray(m_aPosition); + glDisableVertexAttribArray(m_aColor); + glDisableVertexAttribArray(m_aCoord); - m_shader->Disable(); - m_shader->PopMatrix(); + DisableShader(); return true; } + +void CMatrixTrails::OnCompiledAndLinked() +{ + // Variables passed directly to the Vertex shader + m_aPosition = glGetAttribLocation(ProgramHandle(), "a_pos"); + m_aColor = glGetAttribLocation(ProgramHandle(), "a_color"); + m_aCoord = glGetAttribLocation(ProgramHandle(), "a_coord"); +} diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/matrixtrails.h kodi-screensaver-matrixtrails-2.2.1/src/matrixtrails.h --- kodi-screensaver-matrixtrails-2.2.0/src/matrixtrails.h 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/matrixtrails.h 2019-03-19 23:02:55.000000000 +0000 @@ -7,7 +7,8 @@ #pragma once -#include "shaders/GUIShader.h" +#include + #include "column.h" /***************************** D E F I N E S *******************************/ @@ -25,16 +26,21 @@ //////////////////////////////////////////////////////////////////////////// // -class ATTRIBUTE_HIDDEN CMatrixTrails +class ATTRIBUTE_HIDDEN CMatrixTrails : public kodi::gui::gl::CShaderProgram { public: CMatrixTrails(CConfig* config); ~CMatrixTrails(); + bool RestoreDevice(const std::string& path); void InvalidateDevice(); void Update(f32 dt); bool Draw(); + // override functions for kodi::gui::gl::CShaderProgram + void OnCompiledAndLinked() override; + bool OnEnabled() override { return true; } + protected: int m_NumColumns; int m_NumRows; @@ -44,10 +50,12 @@ GLuint m_Texture; private: - CGUIShader* m_shader = nullptr; - unsigned int m_vertexVBO = -1; - unsigned int m_vertexVAO = -1; - unsigned int m_indexVBO = -1; + GLuint m_vertexVBO = -1; + + GLint m_aPosition = -1; + GLint m_aColor = -1; + GLint m_aCoord = -1; + CConfig* m_config; }; diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/GUIShader.cpp kodi-screensaver-matrixtrails-2.2.1/src/shaders/GUIShader.cpp --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/GUIShader.cpp 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/GUIShader.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#include "GUIShader.h" - -CGUIShader::CGUIShader(std::string vert, std::string frag ) : CShaderProgram(vert, frag) -{ -} - -void CGUIShader::OnCompiledAndLinked() -{ - // Variables passed directly to the Vertex shader - m_hProj = glGetUniformLocation(ProgramHandle(), "m_proj"); - m_hModel = glGetUniformLocation(ProgramHandle(), "m_model"); - m_hPos = glGetAttribLocation(ProgramHandle(), "m_attrpos"); - m_hCol = glGetAttribLocation(ProgramHandle(), "m_attrcol"); - m_hTexCoord = glGetAttribLocation(ProgramHandle(), "m_attrcoord"); - - // It's okay to do this only one time. Textures units never change. - glUseProgram(ProgramHandle()); - glUseProgram(0); -} - -bool CGUIShader::OnEnabled() -{ - // This is called after glUseProgram() - glUniformMatrix4fv(m_hProj, 1, GL_FALSE, GetMatrix(MM_PROJECTION)); - glUniformMatrix4fv(m_hModel, 1, GL_FALSE, GetMatrix(MM_MODELVIEW)); - - return true; -} - -void CGUIShader::Free() -{ - CShaderProgram::Free(); -} diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/GUIShader.h kodi-screensaver-matrixtrails-2.2.1/src/shaders/GUIShader.h --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/GUIShader.h 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/GUIShader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#pragma once - -#include "Shader.h" -#include "Matrix.h" - -class ATTRIBUTE_HIDDEN CGUIShader : public CShaderProgram, public CMatrix -{ -public: - CGUIShader(std::string vert, std::string frag); - - void OnCompiledAndLinked() override; - bool OnEnabled() override; - void Free(); - - GLint GetPosLoc() { return m_hPos; } - GLint GetColLoc() { return m_hCol; } - GLint GetTexCoord() { return m_hTexCoord; } - -protected: - GLint m_hTex = -1; - GLint m_hProj = -1; - GLint m_hModel = -1; - GLint m_hPos = -1; - GLint m_hCol = -1; - GLint m_hTexCoord = -1; - - GLfloat *m_proj = nullptr; - GLfloat *m_model = nullptr; -}; diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/Matrix.cpp kodi-screensaver-matrixtrails-2.2.1/src/shaders/Matrix.cpp --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/Matrix.cpp 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/Matrix.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,369 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#include "Matrix.h" -#include - -#define MODE_WITHIN_RANGE(m) ((m >= 0) && (m < (int)MM_MATRIXSIZE)) - -CMatrix::CMatrix() -{ - for (unsigned int i=0; i < MM_MATRIXSIZE; i++) - { - m_matrices[i].push_back(MatrixWrapper()); - MatrixMode((EMATRIXMODE)i); - LoadIdentity(); - } - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; -} - -CMatrix::~CMatrix() -{ -} - -GLfloat* CMatrix::GetMatrix(EMATRIXMODE mode) -{ - if (MODE_WITHIN_RANGE(mode)) - { - if (!m_matrices[mode].empty()) - { - return m_matrices[mode].back(); - } - } - return NULL; -} - -void CMatrix::MatrixMode(EMATRIXMODE mode) -{ - if (MODE_WITHIN_RANGE(mode)) - { - m_matrixMode = mode; - m_pMatrix = m_matrices[mode].back(); - } - else - { - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; - } -} - -void CMatrix::PushMatrix() -{ - if (m_pMatrix && MODE_WITHIN_RANGE(m_matrixMode)) - { - m_matrices[m_matrixMode].push_back(MatrixWrapper(m_pMatrix)); - m_pMatrix = m_matrices[m_matrixMode].back(); - } -} - -void CMatrix::PopMatrix() -{ - if (MODE_WITHIN_RANGE(m_matrixMode)) - { - if (m_matrices[m_matrixMode].size() > 1) - { - m_matrices[m_matrixMode].pop_back(); - } - m_pMatrix = m_matrices[m_matrixMode].back(); - } -} - -void CMatrix::LoadIdentity() -{ - if (m_pMatrix) - { - m_pMatrix[0] = 1.0f; m_pMatrix[4] = 0.0f; m_pMatrix[8] = 0.0f; m_pMatrix[12] = 0.0f; - m_pMatrix[1] = 0.0f; m_pMatrix[5] = 1.0f; m_pMatrix[9] = 0.0f; m_pMatrix[13] = 0.0f; - m_pMatrix[2] = 0.0f; m_pMatrix[6] = 0.0f; m_pMatrix[10] = 1.0f; m_pMatrix[14] = 0.0f; - m_pMatrix[3] = 0.0f; m_pMatrix[7] = 0.0f; m_pMatrix[11] = 0.0f; m_pMatrix[15] = 1.0f; - } -} - -void CMatrix::Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) -{ - GLfloat u = 2.0f / (r - l); - GLfloat v = 2.0f / (t - b); - GLfloat w = -2.0f / (f - n); - GLfloat x = - (r + l) / (r - l); - GLfloat y = - (t + b) / (t - b); - GLfloat z = - (f + n) / (f - n); - GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f, - 0.0f, v, 0.0f, 0.0f, - 0.0f, 0.0f, w, 0.0f, - x, y, z, 1.0f}; - MultMatrixf(matrix); -} - -void CMatrix::Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t) -{ - GLfloat u = 2.0f / (r - l); - GLfloat v = 2.0f / (t - b); - GLfloat x = - (r + l) / (r - l); - GLfloat y = - (t + b) / (t - b); - GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f, - 0.0f, v, 0.0f, 0.0f, - 0.0f, 0.0f,-1.0f, 0.0f, - x, y, 0.0f, 1.0f}; - MultMatrixf(matrix); -} - -void CMatrix::Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f) -{ - GLfloat u = (2.0f * n) / (r - l); - GLfloat v = (2.0f * n) / (t - b); - GLfloat w = (r + l) / (r - l); - GLfloat x = (t + b) / (t - b); - GLfloat y = - (f + n) / (f - n); - GLfloat z = - (2.0f * f * n) / (f - n); - GLfloat matrix[16] = { u, 0.0f, 0.0f, 0.0f, - 0.0f, v, 0.0f, 0.0f, - w, x, y,-1.0f, - 0.0f, 0.0f, z, 0.0f}; - MultMatrixf(matrix); -} - -void CMatrix::Translatef(GLfloat x, GLfloat y, GLfloat z) -{ - GLfloat matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - x, y, z, 1.0f}; - MultMatrixf(matrix); -} - -void CMatrix::Scalef(GLfloat x, GLfloat y, GLfloat z) -{ - GLfloat matrix[16] = { x, 0.0f, 0.0f, 0.0f, - 0.0f, y, 0.0f, 0.0f, - 0.0f, 0.0f, z, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - MultMatrixf(matrix); -} - -void CMatrix::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GLfloat modulous = sqrt((x*x)+(y*y)+(z*z)); - if (modulous != 0.0) - { - x /= modulous; - y /= modulous; - z /= modulous; - } - GLfloat cosine = cos(angle); - GLfloat sine = sin(angle); - GLfloat cos1 = 1 - cosine; - GLfloat a = (x*x*cos1) + cosine; - GLfloat b = (x*y*cos1) - (z*sine); - GLfloat c = (x*z*cos1) + (y*sine); - GLfloat d = (y*x*cos1) + (z*sine); - GLfloat e = (y*y*cos1) + cosine; - GLfloat f = (y*z*cos1) - (x*sine); - GLfloat g = (z*x*cos1) - (y*sine); - GLfloat h = (z*y*cos1) + (x*sine); - GLfloat i = (z*z*cos1) + cosine; - GLfloat matrix[16] = { a, d, g, 0.0f, - b, e, h, 0.0f, - c, f, i, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - MultMatrixf(matrix); -} - -#if defined(__ARM_NEON__) && !defined(__arm64__) - -inline void Matrix4Mul(const float* src_mat_1, const float* src_mat_2, float* dst_mat) -{ - asm volatile ( - // Store A & B leaving room at top of registers for result (q0-q3) - "vldmia %1, { q4-q7 } \n\t" - "vldmia %2, { q8-q11 } \n\t" - - // result = first column of B x first row of A - "vmul.f32 q0, q8, d8[0]\n\t" - "vmul.f32 q1, q8, d10[0]\n\t" - "vmul.f32 q2, q8, d12[0]\n\t" - "vmul.f32 q3, q8, d14[0]\n\t" - - // result += second column of B x second row of A - "vmla.f32 q0, q9, d8[1]\n\t" - "vmla.f32 q1, q9, d10[1]\n\t" - "vmla.f32 q2, q9, d12[1]\n\t" - "vmla.f32 q3, q9, d14[1]\n\t" - - // result += third column of B x third row of A - "vmla.f32 q0, q10, d9[0]\n\t" - "vmla.f32 q1, q10, d11[0]\n\t" - "vmla.f32 q2, q10, d13[0]\n\t" - "vmla.f32 q3, q10, d15[0]\n\t" - - // result += last column of B x last row of A - "vmla.f32 q0, q11, d9[1]\n\t" - "vmla.f32 q1, q11, d11[1]\n\t" - "vmla.f32 q2, q11, d13[1]\n\t" - "vmla.f32 q3, q11, d15[1]\n\t" - - // output = result registers - "vstmia %2, { q0-q3 }" - : //no output - : "r" (dst_mat), "r" (src_mat_2), "r" (src_mat_1) // input - note *value* of pointer doesn't change - : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11" //clobber - ); -} -void CMatrix::MultMatrixf(const GLfloat *matrix) -{ - if (m_pMatrix) - { - GLfloat m[16]; - Matrix4Mul(m_pMatrix, matrix, m); - } -} - -#else -void CMatrix::MultMatrixf(const GLfloat *matrix) -{ - if (m_pMatrix) - { - GLfloat a = (matrix[0] * m_pMatrix[0]) + (matrix[1] * m_pMatrix[4]) + (matrix[2] * m_pMatrix[8]) + (matrix[3] * m_pMatrix[12]); - GLfloat b = (matrix[0] * m_pMatrix[1]) + (matrix[1] * m_pMatrix[5]) + (matrix[2] * m_pMatrix[9]) + (matrix[3] * m_pMatrix[13]); - GLfloat c = (matrix[0] * m_pMatrix[2]) + (matrix[1] * m_pMatrix[6]) + (matrix[2] * m_pMatrix[10]) + (matrix[3] * m_pMatrix[14]); - GLfloat d = (matrix[0] * m_pMatrix[3]) + (matrix[1] * m_pMatrix[7]) + (matrix[2] * m_pMatrix[11]) + (matrix[3] * m_pMatrix[15]); - GLfloat e = (matrix[4] * m_pMatrix[0]) + (matrix[5] * m_pMatrix[4]) + (matrix[6] * m_pMatrix[8]) + (matrix[7] * m_pMatrix[12]); - GLfloat f = (matrix[4] * m_pMatrix[1]) + (matrix[5] * m_pMatrix[5]) + (matrix[6] * m_pMatrix[9]) + (matrix[7] * m_pMatrix[13]); - GLfloat g = (matrix[4] * m_pMatrix[2]) + (matrix[5] * m_pMatrix[6]) + (matrix[6] * m_pMatrix[10]) + (matrix[7] * m_pMatrix[14]); - GLfloat h = (matrix[4] * m_pMatrix[3]) + (matrix[5] * m_pMatrix[7]) + (matrix[6] * m_pMatrix[11]) + (matrix[7] * m_pMatrix[15]); - GLfloat i = (matrix[8] * m_pMatrix[0]) + (matrix[9] * m_pMatrix[4]) + (matrix[10] * m_pMatrix[8]) + (matrix[11] * m_pMatrix[12]); - GLfloat j = (matrix[8] * m_pMatrix[1]) + (matrix[9] * m_pMatrix[5]) + (matrix[10] * m_pMatrix[9]) + (matrix[11] * m_pMatrix[13]); - GLfloat k = (matrix[8] * m_pMatrix[2]) + (matrix[9] * m_pMatrix[6]) + (matrix[10] * m_pMatrix[10]) + (matrix[11] * m_pMatrix[14]); - GLfloat l = (matrix[8] * m_pMatrix[3]) + (matrix[9] * m_pMatrix[7]) + (matrix[10] * m_pMatrix[11]) + (matrix[11] * m_pMatrix[15]); - GLfloat m = (matrix[12] * m_pMatrix[0]) + (matrix[13] * m_pMatrix[4]) + (matrix[14] * m_pMatrix[8]) + (matrix[15] * m_pMatrix[12]); - GLfloat n = (matrix[12] * m_pMatrix[1]) + (matrix[13] * m_pMatrix[5]) + (matrix[14] * m_pMatrix[9]) + (matrix[15] * m_pMatrix[13]); - GLfloat o = (matrix[12] * m_pMatrix[2]) + (matrix[13] * m_pMatrix[6]) + (matrix[14] * m_pMatrix[10]) + (matrix[15] * m_pMatrix[14]); - GLfloat p = (matrix[12] * m_pMatrix[3]) + (matrix[13] * m_pMatrix[7]) + (matrix[14] * m_pMatrix[11]) + (matrix[15] * m_pMatrix[15]); - m_pMatrix[0] = a; m_pMatrix[4] = e; m_pMatrix[8] = i; m_pMatrix[12] = m; - m_pMatrix[1] = b; m_pMatrix[5] = f; m_pMatrix[9] = j; m_pMatrix[13] = n; - m_pMatrix[2] = c; m_pMatrix[6] = g; m_pMatrix[10] = k; m_pMatrix[14] = o; - m_pMatrix[3] = d; m_pMatrix[7] = h; m_pMatrix[11] = l; m_pMatrix[15] = p; - } -} -#endif - -// gluLookAt implementation taken from Mesa3D -void CMatrix::LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz) -{ - GLfloat forward[3], side[3], up[3]; - GLfloat m[4][4]; - - forward[0] = centerx - eyex; - forward[1] = centery - eyey; - forward[2] = centerz - eyez; - - up[0] = upx; - up[1] = upy; - up[2] = upz; - - GLfloat tmp = sqrt(forward[0]*forward[0] + forward[1]*forward[1] + forward[2]*forward[2]); - if (tmp != 0.0) - { - forward[0] /= tmp; - forward[1] /= tmp; - forward[2] /= tmp; - } - - side[0] = forward[1]*up[2] - forward[2]*up[1]; - side[1] = forward[2]*up[0] - forward[0]*up[2]; - side[2] = forward[0]*up[1] - forward[1]*up[0]; - - tmp = sqrt(side[0]*side[0] + side[1]*side[1] + side[2]*side[2]); - if (tmp != 0.0) - { - side[0] /= tmp; - side[1] /= tmp; - side[2] /= tmp; - } - - up[0] = side[1]*forward[2] - side[2]*forward[1]; - up[1] = side[2]*forward[0] - side[0]*forward[2]; - up[2] = side[0]*forward[1] - side[1]*forward[0]; - - m[0][0] = 1.0f; m[0][1] = 0.0f; m[0][2] = 0.0f; m[0][3] = 0.0f; - m[1][0] = 0.0f; m[1][1] = 1.0f; m[1][2] = 0.0f; m[1][3] = 0.0f; - m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f; - m[3][0] = 0.0f; m[3][1] = 0.0f; m[3][2] = 0.0f; m[3][3] = 1.0f; - - m[0][0] = side[0]; - m[1][0] = side[1]; - m[2][0] = side[2]; - - m[0][1] = up[0]; - m[1][1] = up[1]; - m[2][1] = up[2]; - - m[0][2] = -forward[0]; - m[1][2] = -forward[1]; - m[2][2] = -forward[2]; - - MultMatrixf(&m[0][0]); - Translatef(-eyex, -eyey, -eyez); -} - -static void __gluMultMatrixVecf(const GLfloat matrix[16], const GLfloat in[4], GLfloat out[4]) -{ - int i; - - for (i=0; i<4; i++) - { - out[i] = in[0] * matrix[0*4+i] + - in[1] * matrix[1*4+i] + - in[2] * matrix[2*4+i] + - in[3] * matrix[3*4+i]; - } -} - -// gluProject implementation taken from Mesa3D -bool CMatrix::Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz) -{ - GLfloat in[4]; - GLfloat out[4]; - - in[0]=objx; - in[1]=objy; - in[2]=objz; - in[3]=1.0; - __gluMultMatrixVecf(modelMatrix, in, out); - __gluMultMatrixVecf(projMatrix, out, in); - if (in[3] == 0.0) - return false; - in[0] /= in[3]; - in[1] /= in[3]; - in[2] /= in[3]; - /* Map x, y and z to range 0-1 */ - in[0] = in[0] * 0.5 + 0.5; - in[1] = in[1] * 0.5 + 0.5; - in[2] = in[2] * 0.5 + 0.5; - - /* Map x,y to viewport */ - in[0] = in[0] * viewport[2] + viewport[0]; - in[1] = in[1] * viewport[3] + viewport[1]; - - *winx=in[0]; - *winy=in[1]; - *winz=in[2]; - return true; -} diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/Matrix.h kodi-screensaver-matrixtrails-2.2.1/src/shaders/Matrix.h --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/Matrix.h 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/Matrix.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#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) - #include - #include - #else - #include - #include - #endif - #if HAS_GLES == 3 - #include - #endif -#endif - -#include -#include - -enum EMATRIXMODE -{ - MM_PROJECTION = 0, - MM_MODELVIEW, - MM_TEXTURE, - MM_MATRIXSIZE // Must be last! used for size of matrices -}; - -class CMatrix -{ -public: - CMatrix(); - virtual ~CMatrix(); - - GLfloat* GetMatrix(EMATRIXMODE mode); - - void MatrixMode(EMATRIXMODE mode); - void PushMatrix(); - void PopMatrix(); - void LoadIdentity(); - void Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); - void Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t); - void Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); - void Translatef(GLfloat x, GLfloat y, GLfloat z); - void Scalef(GLfloat x, GLfloat y, GLfloat z); - void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - void MultMatrixf(const GLfloat *matrix); - void LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz); - bool Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz); - -protected: - - struct MatrixWrapper - { - MatrixWrapper(){}; - MatrixWrapper( const float values[16]) { memcpy(m_values,values,sizeof(m_values)); } - MatrixWrapper( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); } - MatrixWrapper &operator=( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); return *this;} - operator float*() { return m_values; } - operator const float*() const { return m_values; } - - float m_values[16]; - }; - - std::vector m_matrices[(int)MM_MATRIXSIZE]; - GLfloat *m_pMatrix; - EMATRIXMODE m_matrixMode; -}; diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/Shader.cpp kodi-screensaver-matrixtrails-2.2.1/src/shaders/Shader.cpp --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/Shader.cpp 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/Shader.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#include "Shader.h" -#include -#include - -#define LOG_SIZE 1024 -#define GLchar char - -////////////////////////////////////////////////////////////////////// -// CShader -////////////////////////////////////////////////////////////////////// -bool CShader::LoadSource(std::string &file) -{ - char buffer[1024]; - - kodi::vfs::CFile source; - source.OpenFile(file); - size_t len = source.Read(buffer, sizeof(buffer)); - m_source.assign(buffer); - m_source[len] = 0; - source.Close(); - return true; -} - -////////////////////////////////////////////////////////////////////// -// CGLSLVertexShader -////////////////////////////////////////////////////////////////////// - -bool CVertexShader::Compile() -{ - GLint params[4]; - - Free(); - - m_vertexShader = glCreateShader(GL_VERTEX_SHADER); - const char *ptr = m_source.c_str(); - glShaderSource(m_vertexShader, 1, &ptr, 0); - glCompileShader(m_vertexShader); - glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params); - if (params[0] != GL_TRUE) - { - GLchar log[LOG_SIZE]; - glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); - m_lastLog = log; - m_compiled = false; - } - else - { - GLchar log[LOG_SIZE]; - glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); - m_lastLog = log; - m_compiled = true; - } - return m_compiled; -} - -void CVertexShader::Free() -{ - if (m_vertexShader) - glDeleteShader(m_vertexShader); - m_vertexShader = 0; -} - -////////////////////////////////////////////////////////////////////// -// CVisGLSLPixelShader -////////////////////////////////////////////////////////////////////// -bool CPixelShader::Compile() -{ - GLint params[4]; - - Free(); - - if (m_source.length()==0) - return true; - - m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); - const char *ptr = m_source.c_str(); - glShaderSource(m_pixelShader, 1, &ptr, 0); - glCompileShader(m_pixelShader); - glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params); - if (params[0] != GL_TRUE) - { - GLchar log[LOG_SIZE]; - glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); - m_lastLog = log; - m_compiled = false; - } - else - { - GLchar log[LOG_SIZE]; - glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); - m_lastLog = log; - m_compiled = true; - } - return m_compiled; -} - -void CPixelShader::Free() -{ - if (m_pixelShader) - glDeleteShader(m_pixelShader); - m_pixelShader = 0; -} - -////////////////////////////////////////////////////////////////////// -// CShaderProgram -////////////////////////////////////////////////////////////////////// - -CShaderProgram::CShaderProgram(std::string &vert, std::string &frag) -{ - std::string path = kodi::GetAddonPath() + "/resources/shaders/"; - std::string file; - - m_pFP = new CPixelShader(); - file = path + frag; - m_pFP->LoadSource(file); - m_pVP = new CVertexShader(); - file = path + vert; - m_pVP->LoadSource(file); -} - -void CShaderProgram::Free() -{ - m_pVP->Free(); - m_pFP->Free(); - if (m_shaderProgram) - glDeleteProgram(m_shaderProgram); - m_shaderProgram = 0; - m_ok = false; -} - -bool CShaderProgram::CompileAndLink() -{ - GLint params[4]; - - // free resources - Free(); - - // compiled vertex shader - if (!m_pVP->Compile()) - return false; - - // compile pixel shader - if (!m_pFP->Compile()) - { - m_pVP->Free(); - return false; - } - - // create program object - if (!(m_shaderProgram = glCreateProgram())) - goto error; - - // attach the vertex shader - glAttachShader(m_shaderProgram, m_pVP->Handle()); - glAttachShader(m_shaderProgram, m_pFP->Handle()); - - // link the program - glLinkProgram(m_shaderProgram); - glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); - if (params[0] != GL_TRUE) - { - GLchar log[LOG_SIZE]; - glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); - goto error; - } - - m_validated = false; - m_ok = true; - OnCompiledAndLinked(); - return true; - - error: - m_ok = false; - Free(); - return false; -} - -bool CShaderProgram::Enable() -{ - if (OK()) - { - glUseProgram(m_shaderProgram); - if (OnEnabled()) - { - if (!m_validated) - { - // validate the program - GLint params[4]; - glValidateProgram(m_shaderProgram); - glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params); - if (params[0] != GL_TRUE) - { - GLchar log[LOG_SIZE]; - glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log); - kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); - } - m_validated = true; - } - return true; - } - else - { - glUseProgram(0); - return false; - } - return true; - } - return false; -} - -void CShaderProgram::Disable() -{ - if (OK()) - { - glUseProgram(0); - OnDisabled(); - } -} diff -Nru kodi-screensaver-matrixtrails-2.2.0/src/shaders/Shader.h kodi-screensaver-matrixtrails-2.2.1/src/shaders/Shader.h --- kodi-screensaver-matrixtrails-2.2.0/src/shaders/Shader.h 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/src/shaders/Shader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * This Program 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, or (at your option) - * any later version. - * - * This Program 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 Kodi; see the file COPYING. If not, see - * . - * - */ - -#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) - #include - #include - #else - #include - #include - #endif - #if HAS_GLES == 3 - #include - #endif -#endif - -#include -#include - -#include "kodi/AddonBase.h" - -////////////////////////////////////////////////////////////////////// -// CShader - base class -////////////////////////////////////////////////////////////////////// -class ATTRIBUTE_HIDDEN CShader -{ -public: - CShader() = default; - virtual ~CShader() = default; - virtual bool Compile() = 0; - virtual void Free() = 0; - virtual GLuint Handle() = 0; - - bool LoadSource(std::string &file); - bool OK() { return m_compiled; } - -protected: - std::string m_source; - std::string m_lastLog; - std::vector m_attr; - bool m_compiled = false; -}; - - -////////////////////////////////////////////////////////////////////// -// CVertexShader -////////////////////////////////////////////////////////////////////// -class ATTRIBUTE_HIDDEN CVertexShader : public CShader -{ -public: - CVertexShader() = default; - ~CVertexShader() override { Free(); } - void Free() override; - bool Compile() override; - GLuint Handle() override { return m_vertexShader; } - -protected: - GLuint m_vertexShader = 0; -}; - -////////////////////////////////////////////////////////////////////// -// CPixelShader -////////////////////////////////////////////////////////////////////// -class ATTRIBUTE_HIDDEN CPixelShader : public CShader -{ -public: - CPixelShader() = default; - ~CPixelShader() { Free(); } - void Free() override; - bool Compile() override; - GLuint Handle() override { return m_pixelShader; } - -protected: - GLuint m_pixelShader = 0; -}; - -////////////////////////////////////////////////////////////////////// -// CShaderProgram -////////////////////////////////////////////////////////////////////// -class ATTRIBUTE_HIDDEN CShaderProgram -{ -public: - CShaderProgram(std::string &vert, std::string &frag); - - virtual ~CShaderProgram() - { - Free(); - delete m_pFP; - delete m_pVP; - } - - bool Enable(); - void Disable(); - bool OK() { return m_ok; } - void Free(); - - CVertexShader* VertexShader() { return m_pVP; } - CPixelShader* PixelShader() { return m_pFP; } - bool CompileAndLink(); - - virtual void OnCompiledAndLinked() {}; - virtual bool OnEnabled() { return false; }; - virtual void OnDisabled() {}; - - GLuint ProgramHandle() { return m_shaderProgram; } - -protected: - CVertexShader* m_pVP = nullptr; - CPixelShader* m_pFP = nullptr; - GLuint m_shaderProgram = 0; - bool m_ok = false; - bool m_validated = false; -}; diff -Nru kodi-screensaver-matrixtrails-2.2.0/.travis.yml kodi-screensaver-matrixtrails-2.2.1/.travis.yml --- kodi-screensaver-matrixtrails-2.2.0/.travis.yml 2018-11-30 09:58:47.000000000 +0000 +++ kodi-screensaver-matrixtrails-2.2.1/.travis.yml 2019-03-19 23:02:55.000000000 +0000 @@ -24,14 +24,7 @@ - os: osx osx_image: xcode9 -# -# Some of the OS X images don't have cmake, contrary to what people -# on the Internet say -# before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake || brew update ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake || brew install cmake ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew upgrade cmake || true; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libgl1-mesa-dev; fi #