diff options
author | Memphiz <memphis@machzwo.de> | 2011-08-21 17:40:54 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2011-08-29 18:19:02 +0200 |
commit | ba422e1835e3893e5f7287b229d20ebfa4fef325 (patch) | |
tree | aaa340f6b7c915dd0e1e773d5aa3305d1ae6f5c1 | |
parent | bfbb8cdc3201c0a4864d69257b9bee9a80e41d02 (diff) |
[remove] - removed EGLSpectrum because it is refactored into Waveform and OpenGLSpectrum viz
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | addons/visualization.glesspectrum/addon.xml | 50 | ||||
-rw-r--r-- | addons/visualization.glesspectrum/resources/language/English/strings.xml | 26 | ||||
-rw-r--r-- | addons/visualization.glesspectrum/resources/settings.xml | 8 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/GUIShader.cpp | 85 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/GUIShader.h | 61 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/Makefile.in | 16 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/MatrixGLES.cpp | 357 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/MatrixGLES.h | 69 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/Shader.cpp | 268 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/Shader.h | 208 | ||||
-rw-r--r-- | xbmc/visualizations/EGLSpectrum/gles_spectrum.cpp | 729 |
12 files changed, 0 insertions, 1879 deletions
diff --git a/.gitignore b/.gitignore index 390e021837..3e0137054d 100644 --- a/.gitignore +++ b/.gitignore @@ -106,7 +106,6 @@ config.log /addons/skin.confluence/media/Textures.xbt /addons/skin.pm3-hd/media/Textures.xbt /addons/visualization.dxspectrum/Spectrum_win32dx.vis -/addons/visualization.glesspectrum/gles_spectrum.vis /addons/visualization.glspectrum/opengl_spectrum.vis /addons/visualization.milkdrop/MilkDrop_win32dx.vis /addons/visualization.projectm/projectM.vis @@ -1181,7 +1180,6 @@ lib/cmyth/Makefile /xbmc/visualizations/Milkdrop/Release /xbmc/visualizations/OpenGLSpectrum/Makefile -/xbmc/visualizations/EGLSpectrum/Makefile /xbmc/visualizations/WaveForm/Makefile /xbmc/visualizations/WaveForm/Debug (DirectX) diff --git a/addons/visualization.glesspectrum/addon.xml b/addons/visualization.glesspectrum/addon.xml deleted file mode 100644 index f65e15f419..0000000000 --- a/addons/visualization.glesspectrum/addon.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<addon - id="visualization.glspectrum" - version="1.0.0" - name="GLES Spectrum" - provider-name="Team XBMC"> - <extension - point="xbmc.player.musicviz" - library_linux="gles_spectrum.vis" - library_osx="gles_spectrum.vis" /> - <extension point="xbmc.addon.metadata"> - <summary lang="en">Visualisation showing a rotating 3D Spectrum Analyzer</summary> - <summary lang="es">Visualización que muestra un analizador de espectro en 3D girando</summary> - <summary lang="fi">Pyörivä 3D-spektrianalysaattori</summary> - <summary lang="fr">Visualisation montrant un analyseur de spectre 3D en rotation</summary> - <summary lang="hu">Vizualizáció 3D spektrum analizátorral</summary> - <summary lang="ko">회전하는 3D 스펙트럼 분석기를 보여지는 음악시각화</summary> - <summary lang="nl">GLES-visualisatie</summary> - <summary lang="pl">Wizualizacja pokazująca obracający się analizator widma w 3D (GLES)</summary> - <summary lang="pt">Visualização que mostra um analisador espectral rotativo em 3D (GLES)</summary> - <summary lang="ro">Vizualizare care afișează un analizator de spectre 3D rotativ</summary> - <summary lang="se">Visualisering som visar en roterande 3D-spektrumanalysator</summary> - <summary lang="zh">显示旋转三维频谱分析图像的可视化效果</summary> - <description lang="en">GLES Spectrum is a Visualisation showing a rotating 3D Spectrum Analyzer rendered in GLES that moves to the beat of the music creating a wave effect across the spectrum grid. -It also has settings to adjust the spectrum bar height, Its speed, and how the bars are rendered (solid, points, wire frame) and is a nice light weight, low cpu useage visualisation that looks great</description> - <description lang="es">GLES Spectrum es una visualización que muestra un analizador de espectro en 3D girando renderizado con GLES que se mueve al ritmo de la música creando un efecto de onda en la rejilla del espectro. -Se puede ajustar la altura de las barras, su velocidad, y como son renderizadas (sólido, puntos, malla). Es una visualización que utiliza poca CPU y muy agradable.</description> - <description lang="fi">Näyttää pyörivän 3D-spektrianalysaattorin, joka liikkuu musiikin tahdissa tuottaen aaltotehosteen spektrikuvaajaan. -Spektripalkin korkeuden, nopeuden, ja piirtotavan (täytetyt, pisteet, ääriviivat) voi asettaa asetuksista. Spectrum on kevyt visualisointi joka näyttää hyvältä.</description> - <description lang="fr">GLES Spectrum est une visualisation montrant un analyseur de spectre 3D en rotation sous GLES. Il réagit au tempo de la musique créant un effet d'onde sur la grille. -Il possède quelques paramètres pour ajuster la hauteur de barre du spectre, sa vitesse, et le rendu des barres (plein, en points, en fil de fer). Une visualisation légère, agréable à regarder.</description> - <description lang="hu">Az GLES Spectrum egy olyan vizualizáció ami egy 3D hang spektrum analizátort mutat GLES segítségével megjelenítve, ami a zene ritmusára mozog egy hullám-effektust képezve a teljes spektrumhálón. -Beállítható a spektrum oszlopok magassága, mozgási sebessége és hogy az oszlopok hogyan jelenjenek meg (teli, pontok, drótváz). Ez egy kis erőforrásigényű vizualizáció ami nagyon jól mutat.</description> - <description lang="ko">GLES 스펙트럼은 회전하는 3D 스펙트럼 분석기를 통해 음악시각화를 보여주며 음악의 비트가 만들어내는 웨이브 효과를 스펙트럼 그리드에 보여줍니다. 설정에서 스펙트럼 바의 높이, 속도, 바의 갯수 (채워짐, 점, 와이어 프레임)를 지정할수 있습니다. 가볍고 CPU를 많이 사용하지 않습니다.</description> - <description lang="nl">GLES-spectrum toont een roterende 3D-spectrumanalyse via GLES. Het beweegt mee met de beat van de muziek, waarbij een golfeffect ontstaat over het spectrumraster. -U kunt de hoogte, snelheid en weergave (vol, stippen, ...) van de spectrumbalk zelf instellen. Deze visualisatie vereist weinig geheugen en belast processor nauwelijks. -</description> - <description lang="pl">Wizualizacja pokazuje obracający się, trójwymiarowy analizator widma, renderowany przy użyciu GLES. Możesz ustawić wysokość słupków, ich prędkość i wygląd.</description> - <description lang="pt">O GLES Spectrum é uma visualização que mostra um analisador espectral rotativavo, renderizado em GLES, que se sincroniza com a batida, criando assin um efeito de ondas na grelha espectral. -Pode-se definir a altura das barras, a sua velocidade e como são renderizadas (sólido, pontos ou contorno). É uma visualização que utiliza pouco o CPU e com um visual fantástico.</description> - <description lang="ro">Spectrul GLES este o vizualizare care afișează un analizator de spectre 3D rotativ randat în GLES care se mișcă după bătăile muzicii creând un val dea-lungul grilei spectrale. -De asemenea, are setări pentru ajustarea înălțimii bărilor spectrale, a vitezei, și a modului în care bările sunt randate (umplere, puncte, contur). Este o vizualizare cu consum redus al procesorului care arată fantastic de bine.</description> - <description lang="se">GLES Spectrum är en visualisering som visar en roterande 3D-spektrumanalysator renderad i GLES som rör sig i takt med musiken och skapar vågor av effekter över spektrumområdet. -Det har också inställningar för att justera spektrumhöjden, hastigheten och hur staplarna är renderade (solida, punkter, ramverk) och det är lätt, liten cpuanvändning samt ser bra ut</description> - <description lang="zh">GLES Spectrum可视化效果是GLES渲染的一个旋转的三维频谱分析图像,频谱矩阵随着音乐节拍而象波浪起伏。 -你还可以设置频谱棒的高度、变换速度、以及呈现效果(固体、点、框架)。这是一个不错的轻量级,低CPU使用率的可视化效果。</description> - <disclaimer></disclaimer> - <platform>ios</platform> - </extension> -</addon> diff --git a/addons/visualization.glesspectrum/resources/language/English/strings.xml b/addons/visualization.glesspectrum/resources/language/English/strings.xml deleted file mode 100644 index 3ef1a178e3..0000000000 --- a/addons/visualization.glesspectrum/resources/language/English/strings.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<strings> - <!-- settings labels --> - - <string id="30000">Visualisation</string> - <string id="30001">3D Spectrum</string> - <string id="30002">Waveform</string> - - <!-- - <string id="30000">Mode</string> - <string id="30001">Filled</string> - <string id="30002">Wireframe</string> - <string id="30003">Points</string> - <string id="30004">Bar Height</string> - <string id="30005">Small</string> - <string id="30006">Default</string> - <string id="30007">Big</string> - <string id="30008">Very Big</string> - <string id="30009">Speed</string> - <string id="30010">Very Slow</string> - <string id="30011">Slow</string> - <string id="30012">Default</string> - <string id="30013">Fast</string> - <string id="30014">Very Fast</string> - --> -</strings> diff --git a/addons/visualization.glesspectrum/resources/settings.xml b/addons/visualization.glesspectrum/resources/settings.xml deleted file mode 100644 index b56d879dc1..0000000000 --- a/addons/visualization.glesspectrum/resources/settings.xml +++ /dev/null @@ -1,8 +0,0 @@ -<settings> -<setting id="vis" label="30000" type="enum" lvalues="30001|30002" default="0"/> -<!-- -<setting id="mode" label="30000" type="enum" lvalues="30001|30002|30003" default="0"/> -<setting id="bar_height" label="30004" type="enum" lvalues="30005|30006|30007|30008" default="1"/> -<setting id="speed" label="30009" type="enum" lvalues="30010|30011|30012|30013|30014" default="2"/> ---> -</settings> diff --git a/xbmc/visualizations/EGLSpectrum/GUIShader.cpp b/xbmc/visualizations/EGLSpectrum/GUIShader.cpp deleted file mode 100644 index 4f20854e44..0000000000 --- a/xbmc/visualizations/EGLSpectrum/GUIShader.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright (C) 2005-2008 Team XBMC -* http://www.xbmc.org -* -* 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 XBMC; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -* http://www.gnu.org/copyleft/gpl.html -* -*/ - - -#include "system.h" - -#if HAS_GLES == 2 - -#include "GUIShader.h" -#include "MatrixGLES.h" -#include "utils/log.h" - -CGUIShader::CGUIShader( const std::string& vert, const std::string& frag ) : CGLSLShaderProgram(vert, frag) -{ - // Initialise values - m_hTex0 = 0; - m_hTex1 = 0; - m_hProj = 0; - m_hModel = 0; - m_hPos = 0; - m_hCol = 0; - m_hCord0 = 0; - m_hCord1 = 0; - - m_proj = NULL; - m_model = NULL; -} - -void CGUIShader::OnCompiledAndLinked() -{ - // This is called after CompileAndLink() - - // Variables passed directly to the Fragment shader - m_hTex0 = glGetUniformLocation(ProgramHandle(), "m_samp0"); - m_hTex1 = glGetUniformLocation(ProgramHandle(), "m_samp1"); - // 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_hCord0 = glGetAttribLocation(ProgramHandle(), "m_attrcord0"); - m_hCord1 = glGetAttribLocation(ProgramHandle(), "m_attrcord1"); - - // It's okay to do this only one time. Textures units never change. - glUseProgram( ProgramHandle() ); - glUniform1i(m_hTex0, 0); - glUniform1i(m_hTex1, 1); - glUseProgram( 0 ); -} - -bool CGUIShader::OnEnabled() -{ - // This is called after glUseProgram() - - glUniformMatrix4fv(m_hProj, 1, GL_FALSE, g_matricesSpectrum.GetMatrix(MM_PROJECTION)); - glUniformMatrix4fv(m_hModel, 1, GL_FALSE, g_matricesSpectrum.GetMatrix(MM_MODELVIEW)); - - return true; -} - -void CGUIShader::Free() -{ - // Do Cleanup here - CGLSLShaderProgram::Free(); -} - -#endif diff --git a/xbmc/visualizations/EGLSpectrum/GUIShader.h b/xbmc/visualizations/EGLSpectrum/GUIShader.h deleted file mode 100644 index 234b348343..0000000000 --- a/xbmc/visualizations/EGLSpectrum/GUIShader.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright (C) 2005-2008 Team XBMC -* http://www.xbmc.org -* -* 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 XBMC; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -* http://www.gnu.org/copyleft/gpl.html -* -*/ - -#ifndef GUI_SHADER_H -#define GUI_SHADER_H - -#pragma once - -#include "Shader.h" - -#if HAS_GLES == 2 - -using namespace Shaders; - -class CGUIShader : public CGLSLShaderProgram -{ -public: - CGUIShader( const std::string& vert, const std::string& frag); - void OnCompiledAndLinked(); - bool OnEnabled(); - void Free(); - - GLint GetPosLoc() { return m_hPos; } - GLint GetColLoc() { return m_hCol; } - GLint GetCord0Loc() { return m_hCord0; } - GLint GetCord1Loc() { return m_hCord1; } - -protected: - GLint m_hTex0; - GLint m_hTex1; - GLint m_hProj; - GLint m_hModel; - GLint m_hPos; - GLint m_hCol; - GLint m_hCord0; - GLint m_hCord1; - - GLfloat *m_proj; - GLfloat *m_model; -}; -#endif - -#endif // GUI_SHADER_H diff --git a/xbmc/visualizations/EGLSpectrum/Makefile.in b/xbmc/visualizations/EGLSpectrum/Makefile.in deleted file mode 100644 index 895ca83623..0000000000 --- a/xbmc/visualizations/EGLSpectrum/Makefile.in +++ /dev/null @@ -1,16 +0,0 @@ -ARCH=@ARCH@ -DEFINES+=-DHAS_SDL_OPENGL -DHAS_SDL -CXXFLAGS=-fPIC -OBJS=Shader.o GUIShader.o MatrixGLES.o gles_spectrum.o - -SLIB=@abs_top_srcdir@/addons/visualization.glesspectrum/gles_spectrum.vis - -$(SLIB): $(OBJS) -ifeq ($(findstring osx,$(ARCH)), osx) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -bundle -undefined dynamic_lookup -read_only_relocs suppress -o $@ $(OBJS) -framework OpenGLES -else - $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -g -o $(SLIB) $(OBJS) -endif - -include @abs_top_srcdir@/Makefile.include - diff --git a/xbmc/visualizations/EGLSpectrum/MatrixGLES.cpp b/xbmc/visualizations/EGLSpectrum/MatrixGLES.cpp deleted file mode 100644 index e816a7b514..0000000000 --- a/xbmc/visualizations/EGLSpectrum/MatrixGLES.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* -* Copyright (C) 2005-2008 Team XBMC -* http://www.xbmc.org -* -* 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 XBMC; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -* http://www.gnu.org/copyleft/gpl.html -* -*/ - - -#include "system.h" - -#if HAS_GLES == 2 - -#include <cmath> -#include "MatrixGLES.h" -#include "utils/log.h" - -CMatrixGLES g_matricesSpectrum; - -#define MODE_WITHIN_RANGE(m) ((m >= 0) && (m < (int)MM_MATRIXSIZE)) - -CMatrixGLES::CMatrixGLES() -{ - for (int i=0; i<(int)MM_MATRIXSIZE; i++) - { - m_matrices[i].push_back(new GLfloat[16]); - MatrixMode((EMATRIXMODE)i); - LoadIdentity(); - } - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; -} - -CMatrixGLES::~CMatrixGLES() -{ - for (int i=0; i<(int)MM_MATRIXSIZE; i++) - { - while (!m_matrices[i].empty()) - { - m_matrices[i].pop_back(); - } - } - m_matrixMode = (EMATRIXMODE)-1; - m_pMatrix = NULL; -} - -GLfloat* CMatrixGLES::GetMatrix(EMATRIXMODE mode) -{ - if (MODE_WITHIN_RANGE(mode)) - { - if (!m_matrices[mode].empty()) - { - return m_matrices[mode].back(); - } - } - return NULL; -} - -void CMatrixGLES::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 CMatrixGLES::PushMatrix() -{ - if (m_pMatrix && MODE_WITHIN_RANGE(m_matrixMode)) - { - GLfloat *matrix = new GLfloat[16]; - memcpy(matrix, m_pMatrix, sizeof(GLfloat)*16); - m_matrices[m_matrixMode].push_back(matrix); - m_pMatrix = matrix; - } -} - -void CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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 CMatrixGLES::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.0f - 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__) - -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 CMatrixGLES::MultMatrixf(const GLfloat *matrix) -{ - if (m_pMatrix) - { - GLfloat m[16]; - Matrix4Mul(m_pMatrix, matrix, m); - } -} - -#else -void CMatrixGLES::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 CMatrixGLES::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); -} - -void CMatrixGLES::PrintMatrix(void) -{ - for (int i=0; i<(int)MM_MATRIXSIZE; i++) - { - GLfloat *m = GetMatrix((EMATRIXMODE)i); - fprintf(stderr, "MatrixGLES - Matrix:%d", i); - fprintf(stderr, "%f %f %f %f", m[0], m[4], m[8], m[12]); - fprintf(stderr, "%f %f %f %f", m[1], m[5], m[9], m[13]); - fprintf(stderr, "%f %f %f %f", m[2], m[6], m[10], m[14]); - fprintf(stderr, "%f %f %f %f", m[3], m[7], m[11], m[15]); - } -} - -#endif diff --git a/xbmc/visualizations/EGLSpectrum/MatrixGLES.h b/xbmc/visualizations/EGLSpectrum/MatrixGLES.h deleted file mode 100644 index 4525ff4b07..0000000000 --- a/xbmc/visualizations/EGLSpectrum/MatrixGLES.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright (C) 2005-2008 Team XBMC -* http://www.xbmc.org -* -* 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 XBMC; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -* http://www.gnu.org/copyleft/gpl.html -* -*/ - -#ifndef MATRIX_GLES_H -#define MATRIX_GLES_H - -#pragma once - -#include <vector> - -using namespace std; - -enum EMATRIXMODE -{ - MM_PROJECTION = 0, - MM_MODELVIEW, - MM_TEXTURE, - MM_MATRIXSIZE // Must be last! used for size of matrices -}; - -class CMatrixGLES -{ -public: - CMatrixGLES(); - ~CMatrixGLES(); - - 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); - void PrintMatrix(void); - -protected: - vector<GLfloat*> m_matrices[(int)MM_MATRIXSIZE]; - GLfloat *m_pMatrix; - EMATRIXMODE m_matrixMode; -}; - -extern CMatrixGLES g_matricesSpectrum; - -#endif // MATRIX_GLES_H diff --git a/xbmc/visualizations/EGLSpectrum/Shader.cpp b/xbmc/visualizations/EGLSpectrum/Shader.cpp deleted file mode 100644 index 58796f3891..0000000000 --- a/xbmc/visualizations/EGLSpectrum/Shader.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * 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 XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "system.h" - -#if HAS_GLES == 2 - -#include "Shader.h" -#include "utils/GLUtils.h" - -#define LOG_SIZE 1024 - -using namespace Shaders; -using namespace std; - -////////////////////////////////////////////////////////////////////// -// CShader -////////////////////////////////////////////////////////////////////// -bool CShader::LoadSource(const string& buffer) -{ - fprintf(stderr, "GL: loadsource\n"); - - m_source = buffer; - return true; -} - -////////////////////////////////////////////////////////////////////// -// CGLSLVertexShader -////////////////////////////////////////////////////////////////////// - -bool CGLSLVertexShader::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); - VerifyGLState(); - if (params[0]!=GL_TRUE) - { - GLchar log[LOG_SIZE]; - fprintf(stderr, "GL: Error compiling vertex shader "); - glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log); - printf("%s\n", log); - m_lastLog = log; - m_compiled = false; - } - else - { - GLchar log[LOG_SIZE]; - fprintf(stderr, "GL: Vertex Shader compilation log: "); - glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log); - printf("%s\n", log); - m_lastLog = log; - m_compiled = true; - } - return m_compiled; -} - -void CGLSLVertexShader::Free() -{ - if (m_vertexShader) - glDeleteShader(m_vertexShader); - m_vertexShader = 0; -} - -////////////////////////////////////////////////////////////////////// -// CGLSLPixelShader -////////////////////////////////////////////////////////////////////// -bool CGLSLPixelShader::Compile() -{ - GLint params[4]; - - Free(); - - // Pixel shaders are not mandatory. - if (m_source.length()==0) - { - fprintf(stderr, "GL: No pixel shader, fixed pipeline in use\n"); - 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]; - fprintf(stderr, "GL: Error compiling pixel shader "); - glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log); - printf("%s \n", log); - m_lastLog = log; - m_compiled = false; - } - else - { - GLchar log[LOG_SIZE]; - fprintf(stderr, "GL: Pixel Shader compilation log: "); - glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log); - fprintf(stderr, "%s \n", log); - m_lastLog = log; - m_compiled = true; - } - return m_compiled; -} - -void CGLSLPixelShader::Free() -{ - if (m_pixelShader) - glDeleteShader(m_pixelShader); - m_pixelShader = 0; -} - -////////////////////////////////////////////////////////////////////// -// CGLSLShaderProgram -////////////////////////////////////////////////////////////////////// -void CGLSLShaderProgram::Free() -{ - m_pVP->Free(); - VerifyGLState(); - m_pFP->Free(); - VerifyGLState(); - if (m_shaderProgram) - { - glDeleteProgram(m_shaderProgram); - } - m_shaderProgram = 0; - m_ok = false; - m_lastProgram = 0; -} - -bool CGLSLShaderProgram::CompileAndLink() -{ - GLint params[4]; - - // free resources - Free(); - - // compiled vertex shader - if (!m_pVP->Compile()) - { - fprintf(stderr, "GL: Error compiling vertex shader\n"); - return false; - } - fprintf(stderr, "GL: Vertex Shader compiled successfully\n"); - - // compile pixel shader - if (!m_pFP->Compile()) - { - m_pVP->Free(); - fprintf(stderr, "GL: Error compiling fragment shader\n"); - return false; - } - fprintf(stderr, "GL: Fragment Shader compiled successfully\n"); - - // create program object - if (!(m_shaderProgram = glCreateProgram())) - { - fprintf(stderr, "GL: Error creating shader program handle\n"); - goto error; - } - - // attach the vertex shader - glAttachShader(m_shaderProgram, m_pVP->Handle()); - VerifyGLState(); - - // if we have a pixel shader, attach it. If not, fixed pipeline - // will be used. - if (m_pFP->Handle()) - { - glAttachShader(m_shaderProgram, m_pFP->Handle()); - VerifyGLState(); - } - - // link the program - glLinkProgram(m_shaderProgram); - glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); - if (params[0]!=GL_TRUE) - { - GLchar log[LOG_SIZE]; - fprintf(stderr, "GL: Error linking shader "); - glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log); - fprintf(stderr, "%s\n", log); - goto error; - } - VerifyGLState(); - - m_validated = false; - m_ok = true; - OnCompiledAndLinked(); - VerifyGLState(); - return true; - - error: - m_ok = false; - Free(); - return false; -} - -bool CGLSLShaderProgram::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]; - fprintf(stderr, "GL: Error validating shader "); - glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, NULL, log); - fprintf(stderr, "%s \n", log); - } - m_validated = true; - } - VerifyGLState(); - return true; - } - else - { - glUseProgram(0); - return false; - } - return true; - } - return false; -} - -void CGLSLShaderProgram::Disable() -{ - if (OK()) - { - glUseProgram(0); - OnDisabled(); - } -} - -#endif diff --git a/xbmc/visualizations/EGLSpectrum/Shader.h b/xbmc/visualizations/EGLSpectrum/Shader.h deleted file mode 100644 index e5eadc87fe..0000000000 --- a/xbmc/visualizations/EGLSpectrum/Shader.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef __SHADER_H__ -#define __SHADER_H__ - -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * 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 XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "system.h" // for HAS_GL/HAS_GLES - -#if HAS_GLES == 2 - -#include <vector> -#include <string> - -namespace Shaders { - - using namespace std; - - ////////////////////////////////////////////////////////////////////// - // CShader - base class - ////////////////////////////////////////////////////////////////////// - class CShader - { - public: - CShader() { m_compiled = false; } - virtual ~CShader() {} - virtual bool Compile() = 0; - virtual void Free() = 0; - virtual GLuint Handle() = 0; - virtual void SetSource(const string& src) { m_source = src; } - virtual bool LoadSource(const string& buffer); - bool OK() { return m_compiled; } - - protected: - string m_source; - string m_lastLog; - vector<string> m_attr; - bool m_compiled; - - }; - - - ////////////////////////////////////////////////////////////////////// - // CVertexShader - vertex shader class - ////////////////////////////////////////////////////////////////////// - class CVertexShader : public CShader - { - public: - CVertexShader() { m_vertexShader = 0; } - virtual ~CVertexShader() { Free(); } - virtual void Free() {} - virtual GLuint Handle() { return m_vertexShader; } - - protected: - GLuint m_vertexShader; - }; - - class CGLSLVertexShader : public CVertexShader - { - public: - virtual void Free(); - virtual bool Compile(); - }; - - ////////////////////////////////////////////////////////////////////// - // CPixelShader - abstract pixel shader class - ////////////////////////////////////////////////////////////////////// - class CPixelShader : public CShader - { - public: - CPixelShader() { m_pixelShader = 0; } - virtual ~CPixelShader() { Free(); } - virtual void Free() {} - virtual GLuint Handle() { return m_pixelShader; } - - protected: - GLuint m_pixelShader; - }; - - - class CGLSLPixelShader : public CPixelShader - { - public: - virtual void Free(); - virtual bool Compile(); - }; - - ////////////////////////////////////////////////////////////////////// - // CShaderProgram - the complete shader consisting of both the vertex - // and pixel programs. (abstract) - ////////////////////////////////////////////////////////////////////// - class CShaderProgram - { - public: - CShaderProgram() - { - m_ok = false; - m_shaderProgram = 0; - m_pFP = NULL; - m_pVP = NULL; - } - - virtual ~CShaderProgram() - { - Free(); - delete m_pFP; - delete m_pVP; - } - - // enable the shader - virtual bool Enable() = 0; - - // disable the shader - virtual void Disable() = 0; - - // returns true if shader is compiled and linked - bool OK() { return m_ok; } - - // free resources - virtual void Free() {} - - // return the vertex shader object - CVertexShader* VertexShader() { return m_pVP; } - - // return the pixel shader object - CPixelShader* PixelShader() { return m_pFP; } - - // compile and link the shaders - virtual bool CompileAndLink() = 0; - - // override to to perform custom tasks on successfull compilation - // and linkage. E.g. obtaining handles to shader attributes. - virtual void OnCompiledAndLinked() {} - - // override to to perform custom tasks before shader is enabled - // and after it is disabled. Return false in OnDisabled() to - // disable shader. - // E.g. setting attributes, disabling texture unites, etc - virtual bool OnEnabled() { return true; } - virtual void OnDisabled() { } - - virtual GLuint ProgramHandle() { return m_shaderProgram; } - - protected: - CVertexShader* m_pVP; - CPixelShader* m_pFP; - GLuint m_shaderProgram; - bool m_ok; - }; - - - class CGLSLShaderProgram - : virtual public CShaderProgram - { - public: - CGLSLShaderProgram() - { - m_pFP = new CGLSLPixelShader(); - m_pVP = new CGLSLVertexShader(); - } - CGLSLShaderProgram(const std::string& vert - , const std::string& frag) - { - m_pFP = new CGLSLPixelShader(); - m_pFP->LoadSource(frag); - m_pVP = new CGLSLVertexShader(); - m_pVP->LoadSource(vert); - } - - // enable the shader - virtual bool Enable(); - - // disable the shader - virtual void Disable(); - - // free resources - virtual void Free(); - - // compile and link the shaders - virtual bool CompileAndLink(); - - protected: - GLint m_lastProgram; - bool m_validated; - }; - - -} // close namespace -#endif - -#endif //__SHADER_H__ diff --git a/xbmc/visualizations/EGLSpectrum/gles_spectrum.cpp b/xbmc/visualizations/EGLSpectrum/gles_spectrum.cpp deleted file mode 100644 index 69a03a5ce2..0000000000 --- a/xbmc/visualizations/EGLSpectrum/gles_spectrum.cpp +++ /dev/null @@ -1,729 +0,0 @@ -/* XMMS - Cross-platform multimedia player - * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies - * - * 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 of the License, 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* - * Wed May 24 10:49:37 CDT 2000 - * Fixes to threading/context creation for the nVidia X4 drivers by - * Christian Zander <phoenix@minion.de> - */ - -/* - * Ported to XBMC by d4rk - * Also added 'hSpeed' to animate transition between bar heights - */ - - -#include "system.h" - -#if HAS_GLES == 2 - -#include "addons/include/xbmc_vis_dll.h" -#include <string.h> -#include <math.h> -#if defined(__APPLE__) -#include <OpenGLES/ES2/gl.h> -#include <OpenGLES/ES2/glext.h> -#else -#include <GLES/gl.h> -#endif - -#include "MatrixGLES.h" -#include "GUIShader.h" - -#define NUM_BANDS 16 - -#ifndef M_PI -#define M_PI 3.141592654f -#endif -#define DEG2RAD(d) ( (d) * M_PI/180.0f ) - -GLfloat x_angle = 20.0f, x_speed = 0.0f; -GLfloat y_angle = 45.0f, y_speed = 0.5f; -GLfloat z_angle = 0.0f, z_speed = 0.0f; -GLfloat heights[16][16], cHeights[16][16], scale; -GLfloat hSpeed = 0.025f; -GLenum g_mode = GL_TRIANGLES; -float g_fWaveform[2][512]; - -enum VIS -{ - VIS_3D_SPECTRUM = 0, - VIS_WAVEFORM, -}; - -VIS g_vis = VIS_3D_SPECTRUM; - -std::string frag = "precision mediump float; \n" - "varying lowp vec4 m_colour; \n" - "void main () \n" - "{ \n" - " gl_FragColor = m_colour; \n" - "}\n"; - -std::string vert = "attribute vec4 m_attrpos;\n" - "attribute vec4 m_attrcol;\n" - "attribute vec4 m_attrcord0;\n" - "attribute vec4 m_attrcord1;\n" - "varying vec4 m_cord0;\n" - "varying vec4 m_cord1;\n" - "varying lowp vec4 m_colour;\n" - "uniform mat4 m_proj;\n" - "uniform mat4 m_model;\n" - "void main ()\n" - "{\n" - " mat4 mvp = m_proj * m_model;\n" - " gl_Position = mvp * m_attrpos;\n" - " m_colour = m_attrcol;\n" - " m_cord0 = m_attrcord0;\n" - " m_cord1 = m_attrcord1;\n" - "}\n"; - -CGUIShader *m_shader = NULL; - -#if 0 -void draw_rectangle(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2) -{ - GLint posLoc = m_shader->GetPosLoc(); - GLint colLoc = m_shader->GetColLoc(); - - glVertexAttribPointer(colLoc, 4, GL_FLOAT, 0, 0, col); - glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); - - glEnableVertexAttribArray(posLoc); - glEnableVertexAttribArray(colLoc); - - if(y1 == y2) - { - ver[0][0] = x1; ver[0][1] = y1; ver[0][2] = z1; - ver[1][0] = x2; ver[1][1] = y1; ver[1][2] = z1; - ver[2][0] = x2; ver[2][1] = y2; ver[2][2] = z2; - - glDrawArrays (GL_TRIANGLES, 0, 3); - - ver[0][0] = x2; ver[0][1] = y2; ver[0][2] = z2; - ver[1][0] = x1; ver[1][1] = y2; ver[1][2] = z2; - ver[2][0] = x1; ver[2][1] = y1; ver[2][2] = z1; - - glDrawArrays (GL_TRIANGLES, 0, 3); - } - else - { - ver[0][0] = x1; ver[0][1] = y1; ver[0][2] = z1; - ver[1][0] = x2; ver[1][1] = y1; ver[1][2] = z2; - ver[2][0] = x2; ver[2][1] = y2; ver[2][2] = z2; - - glDrawArrays (GL_TRIANGLES, 0, 3); - - ver[0][0] = x2; ver[0][1] = y2; ver[0][2] = z2; - ver[1][0] = x1; ver[1][1] = y2; ver[1][2] = z1; - ver[2][0] = x1; ver[2][1] = y1; ver[2][2] = z1; - - glDrawArrays (GL_TRIANGLES, 0, 3); - } - - glDisableVertexAttribArray(posLoc); - glDisableVertexAttribArray(colLoc); - -} - -void set_color(GLfloat red, GLfloat blue, GLfloat green, GLfloat alpha) -{ - for (int i=0; i<4; i++) - { - // Setup Colour Values - col[i][0] = red; - col[i][1] = blue; - col[i][2] = green; - col[i][3] = alpha; - } -} - - -void draw_bar(GLfloat x_offset, GLfloat z_offset, GLfloat height, GLfloat red, GLfloat green, GLfloat blue ) -{ - GLfloat width = 0.1; - - if (g_mode == GL_POINTS) - set_color(0.2f, 1.0f, 0.2f, 1.0f); - - if (g_mode != GL_POINTS) - { - set_color(red, green, blue, 1.0f); - draw_rectangle(x_offset, height, z_offset, x_offset + width, height, z_offset + 0.1f); - } - draw_rectangle(x_offset, 0.0f, z_offset, x_offset + width, 0.0f, z_offset + 0.1f); - - if (g_mode != GL_POINTS) - { - set_color(0.5f * red, 0.5f * green, 0.5f * blue, 1.0f); - draw_rectangle(x_offset, 0.0f, z_offset + 0.1f, x_offset + width, height, z_offset + 0.1f); - } - draw_rectangle(x_offset, 0.0f, z_offset, x_offset + width, height, z_offset ); - - if (g_mode != GL_POINTS) - { - set_color(0.25f * red, 0.25f * green, 0.25f * blue, 1.0f); - draw_rectangle(x_offset, 0.0f, z_offset , x_offset, height, z_offset + 0.1f); - } - draw_rectangle(x_offset + width, 0.0f, z_offset , x_offset + width, height, z_offset + 0.1f); -} -#else - -void draw_bar(GLfloat x_offset, GLfloat z_offset, GLfloat height, GLfloat red, GLfloat green, GLfloat blue ) -{ - GLfloat col[] = { - red * 0.1f, green * 0.1f, blue * 0.1f, - red * 0.2f, green * 0.2f, blue * 0.2f, - red * 0.3f, green * 0.3f, blue * 0.3f, - red * 0.4f, green * 0.4f, blue * 0.4f, - red * 0.5f, green * 0.5f, blue * 0.5f, - red * 0.6f, green * 0.6f, blue * 0.6f, - red * 0.7f, green * 0.7f, blue * 0.7f, - red * 0.8f, green * 0.8f, blue *0.8f - }; - GLfloat ver[] = { - x_offset + 0.0f, 0.0f, z_offset + 0.0f, - x_offset + 0.1f, 0.0f, z_offset + 0.0f, - x_offset + 0.1f, 0.0f, z_offset + 0.1f, - x_offset + 0.0f, 0.0f, z_offset + 0.1f, - x_offset + 0.0f, height, z_offset + 0.0f, - x_offset + 0.1f, height, z_offset + 0.0f, - x_offset + 0.1f, height, z_offset + 0.1f, - x_offset + 0.0f, height, z_offset + 0.1f - }; - - GLubyte idx[] = { - // Bottom - 0, 1, 2, - 0, 2, 3, - // Left - 0, 4, 7, - 0, 7, 3, - // Back - 3, 7, 6, - 3, 6, 2, - // Right - 1, 5, 6, - 1, 6, 2, - // Front - 0, 4, 5, - 0, 5, 1, - // Top - 4, 5, 6, - 4, 6, 7 - }; - - GLint posLoc = m_shader->GetPosLoc(); - GLint colLoc = m_shader->GetColLoc(); - - glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col); - glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); - - glEnableVertexAttribArray(posLoc); - glEnableVertexAttribArray(colLoc); - - glDrawElements(g_mode, 36, GL_UNSIGNED_BYTE, idx); - - glDisableVertexAttribArray(posLoc); - glDisableVertexAttribArray(colLoc); -} -#endif - -void draw_bars(void) -{ - int x,y; - GLfloat x_offset, z_offset, r_base, b_base; - - glClear(GL_DEPTH_BUFFER_BIT); - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.Translatef(0.0f ,-0.5f, -5.0f); - g_matricesSpectrum.Rotatef(DEG2RAD(x_angle), 1.0f, 0.0f, 0.0f); - g_matricesSpectrum.Rotatef(DEG2RAD(y_angle), 0.0f, 1.0f, 0.0f); - g_matricesSpectrum.Rotatef(DEG2RAD(z_angle), 0.0f, 0.0f, 1.0f); - - m_shader->Enable(); - - for(y = 0; y < 16; y++) - { - z_offset = -1.6f + ((15.0f - y) * 0.2f); - - b_base = y * (1.0f / 15.0f); - r_base = 1.0f - b_base; - - for(x = 0; x < 16; x++) - { - x_offset = -1.6f + ((float)x * 0.2f); - if (::fabs(cHeights[y][x]-heights[y][x])>hSpeed) - { - if (cHeights[y][x]<heights[y][x]) - cHeights[y][x] += hSpeed; - else - cHeights[y][x] -= hSpeed; - } - draw_bar(x_offset, z_offset, - cHeights[y][x], r_base - (float(x) * (r_base / 15.0f)), - (float)x * (1.0f / 15.0f), b_base); - } - } - - m_shader->Disable(); - - g_matricesSpectrum.PopMatrix(); -} - -//-- Create ------------------------------------------------------------------- -// Called on load. Addon should fully initalize or return error status -//----------------------------------------------------------------------------- -ADDON_STATUS ADDON_Create(void* hdl, void* props) -{ - if (!props) - return ADDON_STATUS_UNKNOWN; - - m_shader = new CGUIShader(vert, frag); - - if(!m_shader) - return ADDON_STATUS_UNKNOWN; - - if(!m_shader->CompileAndLink()) - { - delete m_shader; - return ADDON_STATUS_UNKNOWN; - } - - return ADDON_STATUS_NEED_SETTINGS; -} - -void render_waveform() -{ - GLfloat col[256][3]; - GLfloat ver[256][3]; - GLubyte idx[256]; - - glDisable(GL_BLEND); - - g_matricesSpectrum.MatrixMode(MM_PROJECTION); - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.LoadIdentity(); - //g_matricesSpectrum.Frustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 10.0f); - g_matricesSpectrum.MatrixMode(MM_MODELVIEW); - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.LoadIdentity(); - - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.Translatef(0.0f ,0.0f ,-1.0f); - g_matricesSpectrum.Rotatef(0.0f, 1.0f, 0.0f, 0.0f); - g_matricesSpectrum.Rotatef(0.0f, 0.0f, 1.0f, 0.0f); - g_matricesSpectrum.Rotatef(0.0f, 0.0f, 0.0f, 1.0f); - - m_shader->Enable(); - - GLint posLoc = m_shader->GetPosLoc(); - GLint colLoc = m_shader->GetColLoc(); - - glVertexAttribPointer(colLoc, 3, GL_FLOAT, 0, 0, col); - glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); - - glEnableVertexAttribArray(posLoc); - glEnableVertexAttribArray(colLoc); - - for (int i = 0; i < 256; i++) - { - col[i][0] = 128; - col[i][1] = 128; - col[i][2] = 128; - //ver[i][0] = g_viewport.X + ((i / 255.0f) * g_viewport.Width); - //ver[i][1] = g_viewport.Y + g_viewport.Height * 0.33f + (g_fWaveform[0][i] * g_viewport.Height * 0.15f); - ver[i][0] = -1.0f + ((i / 255.0f) * 2.0f); - ver[i][1] = 0.5f + (g_fWaveform[0][i] * 0.000015f); - ver[i][2] = 1.0f; - idx[i] = i; - } - - glDrawElements(GL_LINE_STRIP, 256, GL_UNSIGNED_BYTE, idx); - - // Right channel - for (int i = 0; i < 256; i++) - { - col[i][0] = 128; - col[i][1] = 128; - col[i][2] = 128; - //ver[i][0] = g_viewport.X + ((i / 255.0f) * g_viewport.Width); - //ver[i][1] = g_viewport.Y + g_viewport.Height * 0.66f + (g_fWaveform[1][i] * g_viewport.Height * 0.15f); - ver[i][0] = -1.0f + ((i / 255.0f) * 2.0f); - ver[i][1] = -0.5f + (g_fWaveform[1][i] * 0.000015f); - ver[i][2] = 1.0f; - idx[i] = i; - - } - - glDrawElements(GL_LINE_STRIP, 256, GL_UNSIGNED_BYTE, idx); - - glDisableVertexAttribArray(posLoc); - glDisableVertexAttribArray(colLoc); - - m_shader->Disable(); - - g_matricesSpectrum.PopMatrix(); - - g_matricesSpectrum .PopMatrix(); - g_matricesSpectrum.MatrixMode(MM_PROJECTION); - g_matricesSpectrum.PopMatrix(); - - glEnable(GL_BLEND); - -} - -void render_3d_spectrum() -{ - glDisable(GL_BLEND); - - g_matricesSpectrum.MatrixMode(MM_PROJECTION); - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.LoadIdentity(); - g_matricesSpectrum.Frustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 10.0f); - g_matricesSpectrum.MatrixMode(MM_MODELVIEW); - g_matricesSpectrum.PushMatrix(); - g_matricesSpectrum.LoadIdentity(); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - x_angle += x_speed; - if(x_angle >= 360.0f) - x_angle -= 360.0f; - - y_angle += y_speed; - if(y_angle >= 360.0f) - y_angle -= 360.0f; - - z_angle += z_speed; - if(z_angle >= 360.0f) - z_angle -= 360.0f; - - draw_bars(); - - g_matricesSpectrum .PopMatrix(); - g_matricesSpectrum.MatrixMode(MM_PROJECTION); - g_matricesSpectrum.PopMatrix(); - - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); -} - -extern "C" void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName) -{ - int x, y; - - for(x = 0; x < 16; x++) - { - for(y = 0; y < 16; y++) - { - cHeights[y][x] = 0.0f; - } - } - - scale = 1.0f / log(256.0f); - - x_speed = 0.0f; - y_speed = 0.5f; - z_speed = 0.0f; - x_angle = 20.0f; - y_angle = 45.0f; - z_angle = 0.0f; -} - -//-- Render ------------------------------------------------------------------- -// Called once per frame. Do all rendering here. -//----------------------------------------------------------------------------- -extern "C" void Render() -{ - switch(g_vis) - { - case VIS_3D_SPECTRUM: - render_3d_spectrum(); - break; - case VIS_WAVEFORM: - render_waveform(); - break; - } -} -extern "C" void AudioData(const short* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength) -{ - int i,c; - int y=0; - GLfloat val; - - int xscale[] = {0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 101, 137, 187, 255}; - - if(g_vis == VIS_WAVEFORM) - { - int ipos=0; - - while (ipos < 512) - { - for (int i=0; i < iAudioDataLength; i+=2) - { - g_fWaveform[0][ipos] = pAudioData[i ]; // left channel - g_fWaveform[1][ipos] = pAudioData[i+1]; // right channel - ipos++; - if (ipos >= 512) break; - } - } - - } else if(g_vis == VIS_3D_SPECTRUM) { - for(y = 15; y > 0; y--) - { - for(i = 0; i < 16; i++) - { - heights[y][i] = heights[y - 1][i]; - } - } - - for(i = 0; i < NUM_BANDS; i++) - { - for(c = xscale[i], y = 0; c < xscale[i + 1]; c++) - { - if (c<iAudioDataLength) - { - if(pAudioData[c] > y) - y = (int)(pAudioData[c]); - } - else - continue; - } - y >>= 7; - if(y > 0) - val = (logf(y) * scale); - else - val = 0; - heights[0][i] = val; - } - } -} - - -//-- GetInfo ------------------------------------------------------------------ -// Tell XBMC our requirements -//----------------------------------------------------------------------------- -extern "C" void GetInfo(VIS_INFO* pInfo) -{ - pInfo->bWantsFreq = false; - pInfo->iSyncDelay = 0; -} - - -//-- GetSubModules ------------------------------------------------------------ -// Return any sub modules supported by this vis -//----------------------------------------------------------------------------- -extern "C" unsigned int GetSubModules(char ***names) -{ - return 0; // this vis supports 0 sub modules -} - -//-- OnAction ----------------------------------------------------------------- -// Handle XBMC actions such as next preset, lock preset, album art changed etc -//----------------------------------------------------------------------------- -extern "C" bool OnAction(long flags, const void *param) -{ - bool ret = false; - return ret; -} - -//-- GetPresets --------------------------------------------------------------- -// Return a list of presets to XBMC for display -//----------------------------------------------------------------------------- -extern "C" unsigned int GetPresets(char ***presets) -{ - return 0; -} - -//-- GetPreset ---------------------------------------------------------------- -// Return the index of the current playing preset -//----------------------------------------------------------------------------- -extern "C" unsigned GetPreset() -{ - return 0; -} - -//-- IsLocked ----------------------------------------------------------------- -// Returns true if this add-on use settings -//----------------------------------------------------------------------------- -extern "C" bool IsLocked() -{ - return false; -} - -//-- Stop --------------------------------------------------------------------- -// This dll must cease all runtime activities -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" void ADDON_Stop() -{ -} - -//-- Destroy ------------------------------------------------------------------ -// Do everything before unload of this add-on -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" void ADDON_Destroy() -{ - if(m_shader) - { - m_shader->Free(); - delete m_shader; - } -} - -//-- HasSettings -------------------------------------------------------------- -// Returns true if this add-on use settings -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" bool ADDON_HasSettings() -{ - return true; -} - -//-- GetStatus --------------------------------------------------------------- -// Returns the current Status of this visualisation -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" ADDON_STATUS ADDON_GetStatus() -{ - return ADDON_STATUS_OK; -} - -//-- GetSettings -------------------------------------------------------------- -// Return the settings for XBMC to display -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" unsigned int ADDON_GetSettings(ADDON_StructSetting ***sSet) -{ - return 0; -} - -//-- FreeSettings -------------------------------------------------------------- -// Free the settings struct passed from XBMC -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- - -extern "C" void ADDON_FreeSettings() -{ -} - -//-- SetSetting --------------------------------------------------------------- -// Set a specific Setting value (called from XBMC) -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -extern "C" ADDON_STATUS ADDON_SetSetting(const char *strSetting, const void* value) -{ - if (!strSetting || !value) - return ADDON_STATUS_UNKNOWN; - - if (strcmp(strSetting, "vis")==0) - { - switch (*(int*) value) - { - case 1: - g_vis = VIS_WAVEFORM; - break; - default: - g_vis = VIS_3D_SPECTRUM; - break; - } - return ADDON_STATUS_OK; - } - /* - else if (strcmp(strSetting, "mode")==0) - { - switch (*(int*) value) - { - case 1: - g_mode = GL_LINES; - break; - - case 2: - g_mode = GL_LINES; - break; - - case 0: - default: - g_mode = GL_TRIANGLES; - break; - } - return ADDON_STATUS_OK; - } - else if (strcmp(strSetting, "bar_height")==0) - { - switch (*(int*) value) - { - case 1: - scale = 2.0f / log(256.f); - break; - - case 2: - scale = 3.0f / log(256.f); - break; - - case 3: - scale = 0.5f / log(256.f); - break; - - case 4: - scale = 0.33f / log(256.f); - break; - - case 0: - default: - scale = 1.0f / log(256.f); - break; - } - return ADDON_STATUS_OK; - } - else if (strcmp(strSetting, "speed")==0) - { - switch (*(int*) value) - { - case 1: - hSpeed = 0.025f; - break; - - case 2: - hSpeed = 0.0125f; - break; - - case 3: - hSpeed = 0.1f; - break; - - case 4: - hSpeed = 0.2f; - break; - - case 0: - default: - hSpeed = 0.05f; - break; - } - return ADDON_STATUS_OK; - } - */ - - return ADDON_STATUS_UNKNOWN; -} - -#endif |