diff -Nru kodi-screensaver-stars-2.1.1/CMakeLists.txt kodi-screensaver-stars-2.1.2/CMakeLists.txt --- kodi-screensaver-stars-2.1.1/CMakeLists.txt 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/CMakeLists.txt 2019-03-20 01:13:35.000000000 +0000 @@ -1,11 +1,8 @@ +cmake_minimum_required(VERSION 3.5) project(screensaver.stars) -cmake_minimum_required(VERSION 2.6) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) -enable_language(CXX) - find_package(Kodi REQUIRED) if (NOT WIN32) @@ -20,20 +17,10 @@ set(includes ${OPENGLES_INCLUDE_DIR}) add_definitions(${OPENGLES_DEFINITIONS}) endif() - - if(NOT OPENGL_FOUND AND NOT OPENGLES_FOUND) - message(FATAL_ERROR "No rendering API found. Bailing") - endif() - - set(STARS_SOURCES src/shaders/GUIShader.cpp - src/shaders/Matrix.cpp - src/shaders/Shader.cpp) - set(STARS_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 +include_directories(${includes} ${KODI_INCLUDE_DIR}/.. # Hack way with "/..", need bigger Kodi cmake rework to match right include ways + ${PROJECT_SOURCE_DIR}/lib) list(APPEND STARS_SOURCES src/StarField.cpp src/Stars.cpp) diff -Nru kodi-screensaver-stars-2.1.1/debian/changelog kodi-screensaver-stars-2.1.2/debian/changelog --- kodi-screensaver-stars-2.1.1/debian/changelog 2019-01-13 11:49:01.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/debian/changelog 2013-05-31 22:59:22.000000000 +0000 @@ -1,4 +1,4 @@ -kodi-screensaver-stars (2.1.1-1~xenial) xenial; urgency=low +kodi-screensaver-stars (2.1.2-1~xenial) xenial; urgency=low [ kodi ] * autogenerated dummy changelog diff -Nru kodi-screensaver-stars-2.1.1/debian/compat kodi-screensaver-stars-2.1.2/debian/compat --- kodi-screensaver-stars-2.1.1/debian/compat 2018-12-01 11:32:10.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/debian/compat 2013-05-31 22:59:22.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru kodi-screensaver-stars-2.1.1/debian/control kodi-screensaver-stars-2.1.2/debian/control --- kodi-screensaver-stars-2.1.1/debian/control 2018-12-01 11:32:10.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/debian/control 2013-05-31 22:59:22.000000000 +0000 @@ -2,8 +2,8 @@ Priority: extra Maintainer: Nobody Build-Depends: debhelper (>= 9.0.0), cmake, kodi-addon-dev, - libgl1-mesa-dev -Standards-Version: 3.9.5 + libgles2-mesa-dev [arm64 armhf], libgl1-mesa-dev [i386 amd64] +Standards-Version: 4.1.2 Section: libs Homepage: http://kodi.tv diff -Nru kodi-screensaver-stars-2.1.1/debian/copyright kodi-screensaver-stars-2.1.2/debian/copyright --- kodi-screensaver-stars-2.1.1/debian/copyright 2018-12-01 11:32:10.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/debian/copyright 2013-05-31 22:59:22.000000000 +0000 @@ -3,7 +3,7 @@ Source: https://github.com/xbmc/screensaver.stars Files: * -Copyright: 2005-2018 Team Kodi +Copyright: 2005-2019 Team Kodi 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 diff -Nru kodi-screensaver-stars-2.1.1/debian/rules kodi-screensaver-stars-2.1.2/debian/rules --- kodi-screensaver-stars-2.1.1/debian/rules 2019-01-13 11:48:40.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/debian/rules 2013-05-31 22:59:22.000000000 +0000 @@ -10,10 +10,13 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DUSE_LTO=1 + dh_auto_configure -- \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=1 \ + -DUSE_LTO=1 override_dh_strip: dh_strip -pkodi-screensaver-stars --dbg-package=kodi-screensaver-stars-dbg diff -Nru kodi-screensaver-stars-2.1.1/.gitignore kodi-screensaver-stars-2.1.2/.gitignore --- kodi-screensaver-stars-2.1.1/.gitignore 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/.gitignore 2019-03-20 01:13:35.000000000 +0000 @@ -1,8 +1,17 @@ # build artifacts build/ -obj-x86_64-linux-gnu/ screensaver.*/addon.xml +# Debian build files +debian/changelog +debian/files +debian/*.log +debian/*.substvars +debian/.debhelper/ +debian/tmp/ +debian/kodi-screensaver-*/ +obj-x86_64-linux-gnu/ + # commonly used editors # vim *.swp diff -Nru kodi-screensaver-stars-2.1.1/lib/kodi/gui/gl/GL.h kodi-screensaver-stars-2.1.2/lib/kodi/gui/gl/GL.h --- kodi-screensaver-stars-2.1.1/lib/kodi/gui/gl/GL.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/lib/kodi/gui/gl/GL.h 2019-03-20 01:13:35.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-stars-2.1.1/lib/kodi/gui/gl/Shader.h kodi-screensaver-stars-2.1.2/lib/kodi/gui/gl/Shader.h --- kodi-screensaver-stars-2.1.1/lib/kodi/gui/gl/Shader.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/lib/kodi/gui/gl/Shader.h 2019-03-20 01:13:35.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-stars-2.1.1/lib/kodi/utils/Time.h kodi-screensaver-stars-2.1.2/lib/kodi/utils/Time.h --- kodi-screensaver-stars-2.1.1/lib/kodi/utils/Time.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/lib/kodi/utils/Time.h 2019-03-20 01:13:35.000000000 +0000 @@ -0,0 +1,91 @@ +#pragma once +/* + * Copyright (C) 2005-2019 Team Kodi + * Copyright (C) 2011-2012 Pulse-Eight Limited. + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#if defined(TARGET_DARWIN) +#include +#include +#elif defined(TARGET_WINDOWS) +#include +#include +#else +#include +#endif + +namespace kodi +{ + namespace time + { + + //========================================================================== + /// @brief Function to get current time in milliseconds + /// + /// @return Current time in milliseconds as a double value + /// + /// + /// ------------------------------------------------------------------------ + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// + /// #include + /// + /// ... + /// double time = kodi::time::GetTimeMs(); + /// ... + /// ~~~~~~~~~~~~~ + /// + inline double GetTimeMs() + { + #if defined(TARGET_DARWIN) + return (double) (CVGetCurrentHostTime() / (double)(CVGetHostClockFrequency() * 0.001)); + #elif defined(TARGET_WINDOWS) + LARGE_INTEGER tickPerSecond; + LARGE_INTEGER tick; + if (QueryPerformanceFrequency(&tickPerSecond)) + { + QueryPerformanceCounter(&tick); + return (double) (tick.QuadPart / (tickPerSecond.QuadPart / 1000.)); + } + return -1; + #else + timespec time; + clock_gettime(CLOCK_MONOTONIC, &time); + return (double)time.tv_sec * 1000.0 + time.tv_nsec / 1000000.0; + #endif + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @brief Function to get current time in seconds + /// + /// @return Current time in seconds with the value type defined in the template + /// + /// + /// ------------------------------------------------------------------------ + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// + /// #include + /// + /// ... + /// double time = kodi::time::GetTimeSec(); + /// ... + /// ~~~~~~~~~~~~~ + /// + template + inline T GetTimeSec() + { + return (T)GetTimeMs() / (T)1000.0; + } + //-------------------------------------------------------------------------- + + } /* namespace time */ +} /* namespace kodi */ diff -Nru kodi-screensaver-stars-2.1.1/screensaver.stars/addon.xml.in kodi-screensaver-stars-2.1.2/screensaver.stars/addon.xml.in --- kodi-screensaver-stars-2.1.1/screensaver.stars/addon.xml.in 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/screensaver.stars/addon.xml.in 2019-03-20 01:13:35.000000000 +0000 @@ -1,7 +1,7 @@  @ADDON_DEPENDS@ diff -Nru kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GL/frag.glsl kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GL/frag.glsl --- kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GL/frag.glsl 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GL/frag.glsl 2019-03-20 01:13:35.000000000 +0000 @@ -1,9 +1,11 @@ #version 150 -in vec4 m_col; +// varying +in vec4 v_color; + out vec4 FragColor; void main() { - FragColor = m_col; + FragColor = v_color; } diff -Nru kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GL/vert.glsl kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GL/vert.glsl --- kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GL/vert.glsl 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GL/vert.glsl 2019-03-20 01:13:35.000000000 +0000 @@ -1,17 +1,14 @@ #version 150 -in vec3 m_attrpos; -in vec4 m_attrcol; +// attribute +in vec3 a_position; +in vec4 a_color; -out vec4 m_cord; -out vec4 m_col; - -uniform mat4 m_proj; -uniform mat4 m_model; +// varying +out vec4 v_color; 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; + gl_Position = vec4(a_position, 1.0); + v_color = a_color; } diff -Nru kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GLES/frag.glsl kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GLES/frag.glsl --- kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GLES/frag.glsl 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GLES/frag.glsl 2019-03-20 01:13:35.000000000 +0000 @@ -1,10 +1,11 @@ -#version 300 es +#version 100 precision mediump float; -in vec4 m_col; -out vec4 FragColor; + +// varying +varying vec4 v_color; void main() { - FragColor = m_col; + gl_FragColor = v_color; } diff -Nru kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GLES/vert.glsl kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GLES/vert.glsl --- kodi-screensaver-stars-2.1.1/screensaver.stars/resources/shaders/GLES/vert.glsl 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/screensaver.stars/resources/shaders/GLES/vert.glsl 2019-03-20 01:13:35.000000000 +0000 @@ -1,12 +1,13 @@ -#version 300 es +#version 100 -uniform mat4 modelViewProjectionMatrix; -layout (location = 0) in vec4 m_attrpos; -layout (location = 1) in vec4 m_attrcol; -out vec4 m_col; +attribute vec3 a_position; +attribute vec4 a_color; + +// varying +varying vec4 v_color; void main() { - gl_Position = vec4(m_attrpos.x, m_attrpos.y, m_attrpos.z, 1.0); - m_col = m_attrcol; + gl_Position = vec4(a_position, 1.0); + v_color = a_color; } diff -Nru kodi-screensaver-stars-2.1.1/src/shaders/GUIShader.cpp kodi-screensaver-stars-2.1.2/src/shaders/GUIShader.cpp --- kodi-screensaver-stars-2.1.1/src/shaders/GUIShader.cpp 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/shaders/GUIShader.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +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"); - - // 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-stars-2.1.1/src/shaders/GUIShader.h kodi-screensaver-stars-2.1.2/src/shaders/GUIShader.h --- kodi-screensaver-stars-2.1.1/src/shaders/GUIShader.h 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/shaders/GUIShader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +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; } - -protected: - GLint m_hTex = -1; - GLint m_hProj = -1; - GLint m_hModel = -1; - GLint m_hPos = -1; - GLint m_hCol = -1; - - GLfloat *m_proj = nullptr; - GLfloat *m_model = nullptr; -}; diff -Nru kodi-screensaver-stars-2.1.1/src/shaders/Matrix.cpp kodi-screensaver-stars-2.1.2/src/shaders/Matrix.cpp --- kodi-screensaver-stars-2.1.1/src/shaders/Matrix.cpp 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/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-stars-2.1.1/src/shaders/Matrix.h kodi-screensaver-stars-2.1.2/src/shaders/Matrix.h --- kodi-screensaver-stars-2.1.1/src/shaders/Matrix.h 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/shaders/Matrix.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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) - #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 - -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-stars-2.1.1/src/shaders/Shader.cpp kodi-screensaver-stars-2.1.2/src/shaders/Shader.cpp --- kodi-screensaver-stars-2.1.1/src/shaders/Shader.cpp 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/shaders/Shader.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,251 +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(); - -#if defined(HAS_GL) - path += "/resources/shaders/GL/"; -#elif defined(HAS_GLES) - path += "/resources/shaders/GLES/"; -#else - #error Shader compiled without GL support! -#endif - - 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-stars-2.1.1/src/shaders/Shader.h kodi-screensaver-stars-2.1.2/src/shaders/Shader.h --- kodi-screensaver-stars-2.1.1/src/shaders/Shader.h 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/shaders/Shader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +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) - #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 - -#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-stars-2.1.1/src/StarField.cpp kodi-screensaver-stars-2.1.2/src/StarField.cpp --- kodi-screensaver-stars-2.1.1/src/StarField.cpp 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/StarField.cpp 2019-03-20 01:13:35.000000000 +0000 @@ -7,8 +7,6 @@ #include #include -#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) - const int POINTSPERSTAR = 2; CStarField::CStarField(void) @@ -220,16 +218,12 @@ m_pCurVertice = m_pVertices; - m_shader = new CGUIShader("vert.glsl", "frag.glsl"); - if (!m_shader->CompileAndLink()) - { - delete m_shader; - m_shader = nullptr; - return false; - } + 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 -1; glGenBuffers(1, &m_vertexVBO); - glGenBuffers(1, &m_indexVBO); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -255,11 +249,6 @@ glDeleteBuffers(1, &m_vertexVBO); m_vertexVBO = 0; - glDeleteBuffers(1, &m_indexVBO); - m_indexVBO = 0; - - delete(m_shader); - m_shader = nullptr; #else SAFE_RELEASE(m_pVBuffer); @@ -427,39 +416,30 @@ return; } #ifndef WIN32 - if (!m_shader) - return; - glClear(GL_COLOR_BUFFER_BIT); size_t nVSize = m_nDrawnStars * POINTSPERSTAR; - GLint posLoc = m_shader->GetPosLoc(); - GLint colLoc = m_shader->GetColLoc(); - m_shader->PushMatrix(); - m_shader->Enable(); + EnableShader(); glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO); glBufferData(GL_ARRAY_BUFFER, sizeof(ST_CUSTOMVERTEX)*nVSize, m_pVertices, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(ST_CUSTOMVERTEX), BUFFER_OFFSET(offsetof(ST_CUSTOMVERTEX, x))); + glEnableVertexAttribArray(m_aPosition); - glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, sizeof(ST_CUSTOMVERTEX), BUFFER_OFFSET(offsetof(ST_CUSTOMVERTEX, x))); - glEnableVertexAttribArray(posLoc); - - glVertexAttribPointer(colLoc, 4, GL_FLOAT, GL_FALSE, sizeof(ST_CUSTOMVERTEX), BUFFER_OFFSET(offsetof(ST_CUSTOMVERTEX, color))); - glEnableVertexAttribArray(colLoc); + glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(ST_CUSTOMVERTEX), BUFFER_OFFSET(offsetof(ST_CUSTOMVERTEX, color))); + glEnableVertexAttribArray(m_aColor); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnable(GL_BLEND); glDrawArrays(GL_LINES, 0, nVSize); - glDisableVertexAttribArray(posLoc); - glDisableVertexAttribArray(colLoc); + glDisableVertexAttribArray(m_aPosition); + glDisableVertexAttribArray(m_aColor); - m_shader->Disable(); - m_shader->PopMatrix(); + DisableShader(); #else m_pContext->Unmap(m_pVBuffer, 0); @@ -478,3 +458,11 @@ m_dwPalette[nIndex] = CRGBA(iRed / 255.0f, iGreen / 255.0f, iBlue / 255.0f, 1.0f); } } + +#ifndef WIN32 +void CStarField::OnCompiledAndLinked() +{ + m_aPosition = glGetAttribLocation(ProgramHandle(), "a_position"); + m_aColor = glGetAttribLocation(ProgramHandle(), "a_color"); +} +#endif // !WIN32 diff -Nru kodi-screensaver-stars-2.1.1/src/StarField.h kodi-screensaver-stars-2.1.2/src/StarField.h --- kodi-screensaver-stars-2.1.1/src/StarField.h 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/StarField.h 2019-03-20 01:13:35.000000000 +0000 @@ -4,12 +4,15 @@ #include "types.h" #ifndef WIN32 -#include "shaders/GUIShader.h" +#include #else #include #endif class ATTRIBUTE_HIDDEN CStarField +#ifndef WIN32 + : public kodi::gui::gl::CShaderProgram +#endif { protected: struct ST_STAR @@ -111,9 +114,13 @@ ST_CUSTOMVERTEX* m_pVertices = nullptr; ST_CUSTOMVERTEX* m_pCurVertice = nullptr; #ifndef WIN32 - CGUIShader* m_shader = nullptr; - unsigned int m_vertexVBO; - unsigned int m_indexVBO; + // override functions for kodi::gui::gl::CShaderProgram + void OnCompiledAndLinked() override; + bool OnEnabled() override { return true; } + + GLuint m_vertexVBO = 0; + GLint m_aPosition = -1; + GLint m_aColor = -1; #else ID3D11DeviceContext* m_pContext = nullptr; ID3D11Buffer* m_pVBuffer = nullptr; diff -Nru kodi-screensaver-stars-2.1.1/src/Stars.cpp kodi-screensaver-stars-2.1.2/src/Stars.cpp --- kodi-screensaver-stars-2.1.1/src/Stars.cpp 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/Stars.cpp 2019-03-20 01:13:35.000000000 +0000 @@ -23,13 +23,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#ifndef WIN32 -#include "shaders/GUIShader.h" -#endif - #include "StarField.h" +#include #include #include #include diff -Nru kodi-screensaver-stars-2.1.1/src/types.h kodi-screensaver-stars-2.1.2/src/types.h --- kodi-screensaver-stars-2.1.1/src/types.h 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/src/types.h 2019-03-20 01:13:35.000000000 +0000 @@ -52,7 +52,9 @@ #define DEGTORAD(d) ((d)*(PI / 180.0f)) #define RADTODEG(r) ((r)*(180.0f / PI)) +#ifndef assert #define assert(_x) +#endif /***************************** C L A S S E S *******************************/ diff -Nru kodi-screensaver-stars-2.1.1/.travis.yml kodi-screensaver-stars-2.1.2/.travis.yml --- kodi-screensaver-stars-2.1.1/.travis.yml 2019-01-12 23:26:47.000000000 +0000 +++ kodi-screensaver-stars-2.1.2/.travis.yml 2019-03-20 01:13:35.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 #