aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authordavilla <davilla@svn>2010-05-18 07:29:17 +0000
committerdavilla <davilla@svn>2010-05-18 07:29:17 +0000
commit07e5742b33364530dcb27835d7d62eeb84b07c95 (patch)
treec3d3d19fdfca7d7e82bf5c4637c20bc0b2169da4 /guilib
parent7c8f29a57f510944bfa0beae8371b8d20a8e22f0 (diff)
[arm] merge arm-camelot into trunk, thanks to mcgeagh for all his hard working getting arm platform rolling
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@30281 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/FrameBufferObject.cpp12
-rw-r--r--guilib/FrameBufferObject.h7
-rw-r--r--guilib/GUIFontTTF.cpp27
-rw-r--r--guilib/GUIFontTTF.h5
-rw-r--r--guilib/GUIFontTTFGL.cpp38
-rw-r--r--guilib/GUIFontTTFGLES.cpp82
-rw-r--r--guilib/GUIShader.cpp93
-rw-r--r--guilib/GUIShader.h (renamed from guilib/GUIFontTTFGLES.h)56
-rw-r--r--guilib/GUITextureGLES.cpp211
-rw-r--r--guilib/GUITextureGLES.h9
-rw-r--r--guilib/Makefile.in3
-rw-r--r--guilib/MatrixGLES.cpp304
-rw-r--r--guilib/MatrixGLES.h69
-rw-r--r--guilib/Shader.cpp16
-rw-r--r--guilib/TextureGL.cpp18
-rw-r--r--guilib/system.h33
16 files changed, 853 insertions, 130 deletions
diff --git a/guilib/FrameBufferObject.cpp b/guilib/FrameBufferObject.cpp
index 3f4c3050fc..98b22269f1 100644
--- a/guilib/FrameBufferObject.cpp
+++ b/guilib/FrameBufferObject.cpp
@@ -21,12 +21,22 @@
#include "system.h"
-#ifdef HAS_GL
+#if defined(HAS_GL) || HAS_GLES == 2
#include "../xbmc/Settings.h"
#include "WindowingFactory.h"
#include "FrameBufferObject.h"
#include "utils/log.h"
+#if HAS_GLES == 2
+// For OpenGL ES2.0, FBO are not extensions but part of the API.
+#define glGenFramebuffersEXT glGenFramebuffers
+#define glDeleteFramebuffersEXT glDeleteFramebuffers
+#define glFramebufferTexture2DEXT glFramebufferTexture2D
+#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
+#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
+#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
+#endif
+
//////////////////////////////////////////////////////////////////////
// CFrameBufferObject
//////////////////////////////////////////////////////////////////////
diff --git a/guilib/FrameBufferObject.h b/guilib/FrameBufferObject.h
index 6134678e22..d86182ffc9 100644
--- a/guilib/FrameBufferObject.h
+++ b/guilib/FrameBufferObject.h
@@ -24,7 +24,7 @@
#include "system.h" // for HAS_GL
-#ifdef HAS_GL
+#if defined(HAS_GL) || HAS_GLES == 2
//
// CFrameBufferObject
@@ -45,6 +45,11 @@
// glBindTexture(GL_TEXTURE_2D, fbo->Texture());
//
+#if HAS_GLES == 2
+// For OpenGL ES2.0, FBO are not extensions but part of the API.
+#define glBindFramebufferEXT glBindFramebuffer
+#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
+#endif
class CFrameBufferObject
{
diff --git a/guilib/GUIFontTTF.cpp b/guilib/GUIFontTTF.cpp
index 177ae8f368..9f33b28713 100644
--- a/guilib/GUIFontTTF.cpp
+++ b/guilib/GUIFontTTF.cpp
@@ -673,6 +673,7 @@ void CGUIFontTTFBase::RenderCharacter(float posX, float posY, const Character *c
v[i].a = GET_A(color);
}
+#ifdef HAS_GL
v[0].u = tl;
v[0].v = tt;
v[0].x = x[0];
@@ -696,6 +697,32 @@ void CGUIFontTTFBase::RenderCharacter(float posX, float posY, const Character *c
v[3].x = x[3];
v[3].y = y4;
v[3].z = z4;
+#else
+ // GLES uses triangle strips, not quads, so have to rearrange the vertex order
+ v[0].u = tl;
+ v[0].v = tt;
+ v[0].x = x[0];
+ v[0].y = y1;
+ v[0].z = z1;
+
+ v[1].u = tl;
+ v[1].v = tb;
+ v[1].x = x[3];
+ v[1].y = y4;
+ v[1].z = z4;
+
+ v[2].u = tr;
+ v[2].v = tt;
+ v[2].x = x[1];
+ v[2].y = y2;
+ v[2].z = z2;
+
+ v[3].u = tr;
+ v[3].v = tb;
+ v[3].x = x[2];
+ v[3].y = y3;
+ v[3].z = z3;
+#endif
RenderInternal(v);
diff --git a/guilib/GUIFontTTF.h b/guilib/GUIFontTTF.h
index e2a89afa82..277c1378c1 100644
--- a/guilib/GUIFontTTF.h
+++ b/guilib/GUIFontTTF.h
@@ -159,12 +159,9 @@ private:
int m_referenceCount;
};
-#if defined(HAS_GL)
+#if defined(HAS_GL) || defined(HAS_GLES)
#include "GUIFontTTFGL.h"
#define CGUIFontTTF CGUIFontTTFGL
-#elif defined(HAS_GLES)
-#include "GUIFontTTFGLES.h"
-#define CGUIFontTTF CGUIFontTTFGLES
#elif defined(HAS_DX)
#include "GUIFontTTFDX.h"
#define CGUIFontTTF CGUIFontTTFDX
diff --git a/guilib/GUIFontTTFGL.cpp b/guilib/GUIFontTTFGL.cpp
index 533be095dd..051d80ef84 100644
--- a/guilib/GUIFontTTFGL.cpp
+++ b/guilib/GUIFontTTFGL.cpp
@@ -27,6 +27,9 @@
#include "GraphicContext.h"
#include "gui3d.h"
#include "utils/log.h"
+#if HAS_GLES == 2
+#include "WindowingFactory.h"
+#endif
// stuff for freetype
#ifndef _LINUX
@@ -40,7 +43,7 @@
using namespace std;
-#ifdef HAS_GL
+#if defined(HAS_GL) || defined(HAS_GLES)
CGUIFontTTFGL::CGUIFontTTFGL(const CStdString& strFileName)
@@ -82,6 +85,8 @@ void CGUIFontTTFGL::Begin()
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_nTexture);
+
+#ifdef HAS_GL
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
@@ -93,6 +98,9 @@ void CGUIFontTTFGL::Begin()
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
VerifyGLState();
+#else
+ g_Windowing.EnableGUIShader(SM_FONTS);
+#endif
m_vertex_count = 0;
}
@@ -108,6 +116,7 @@ void CGUIFontTTFGL::End()
if (--m_nestedBeginCount > 0)
return;
+#ifdef HAS_GL
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, r));
@@ -118,6 +127,33 @@ void CGUIFontTTFGL::End()
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_QUADS, 0, m_vertex_count);
glPopClientAttrib();
+#else
+ GLint posLoc = g_Windowing.GUIShaderGetPos();
+ GLint colLoc = g_Windowing.GUIShaderGetCol();
+ GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
+
+ glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, x));
+ glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, 0, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, r));
+ glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, u));
+
+ glEnableVertexAttribArray(posLoc);
+ glEnableVertexAttribArray(colLoc);
+ glEnableVertexAttribArray(tex0Loc);
+
+ // GLES2 version
+ // As using triangle strips, have to do in sets of 4.
+ // This is due to limitations of ES, in that tex/col has to be same size as ver!
+ for (int i=0; i<m_vertex_count; i+=4)
+ {
+ glDrawArrays(GL_TRIANGLE_STRIP, i, 4);
+ }
+
+ glDisableVertexAttribArray(posLoc);
+ glDisableVertexAttribArray(colLoc);
+ glDisableVertexAttribArray(tex0Loc);
+
+ g_Windowing.DisableGUIShader();
+#endif
}
CBaseTexture* CGUIFontTTFGL::ReallocTexture(unsigned int& newHeight)
diff --git a/guilib/GUIFontTTFGLES.cpp b/guilib/GUIFontTTFGLES.cpp
deleted file mode 100644
index a6bc5f28da..0000000000
--- a/guilib/GUIFontTTFGLES.cpp
+++ /dev/null
@@ -1,82 +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"
-#include "GUIFont.h"
-#include "GUIFontTTFGL.h"
-#include "GUIFontManager.h"
-#include "Texture.h"
-#include "GraphicContext.h"
-#include "gui3d.h"
-
-// stuff for freetype
-#ifndef _LINUX
-#include "ft2build.h"
-#else
-#include <ft2build.h>
-#endif
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_OUTLINE_H
-
-using namespace std;
-
-#ifdef HAS_GLES
-
-CGUIFontTTFGLES::CGUIFontTTFGLES(const CStdString& strFileName)
-: CGUIFontTTFBase(strFileName)
-{
-
-}
-
-CGUIFontTTFGLES::~CGUIFontTTFGLES(void)
-{
-
-}
-
-void CGUIFontTTFGLES::Begin()
-{
- // TODO: GLES
-}
-
-void CGUIFontTTFGLES::End()
-{
- // TODO: GLES
-}
-
-CBaseTexture* CGUIFontTTFGLES::ReallocTexture(unsigned int& newHeight)
-{
- // TODO: GLES
- return NULL;
-}
-
-bool CGUIFontTTFGLES::CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character* ch)
-{
- // TODO: GLES
- return false;
-}
-
-void CGUIFontTTFGLES::DeleteHardwareTexture()
-{
- // TODO: GLES
-}
-
-#endif
diff --git a/guilib/GUIShader.cpp b/guilib/GUIShader.cpp
new file mode 100644
index 0000000000..c5ab76fe9e
--- /dev/null
+++ b/guilib/GUIShader.cpp
@@ -0,0 +1,93 @@
+/*
+* 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() : CGLSLShaderProgram("guishader_vert.glsl", "guishader_frag.glsl")
+{
+ // Initialise values
+ m_hTex0 = NULL;
+ m_hTex1 = NULL;
+ m_hMethod = NULL;
+ m_hProj = NULL;
+ m_hModel = NULL;
+ m_hPos = NULL;
+ m_hCol = NULL;
+ m_hCord0 = NULL;
+ m_hCord1 = NULL;
+
+ m_method = SM_DEFAULT;
+ 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");
+ m_hMethod = glGetUniformLocation(ProgramHandle(), "m_method");
+ // 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");
+}
+
+bool CGUIShader::OnEnabled()
+{
+ // This is called after glUseProgram()
+
+ glUniform1i(m_hMethod, (int)m_method);
+ glUniformMatrix4fv(m_hProj, 1, GL_FALSE, g_matrices.GetMatrix(MM_PROJECTION));
+ glUniformMatrix4fv(m_hModel, 1, GL_FALSE, g_matrices.GetMatrix(MM_MODELVIEW));
+
+ if (m_method == SM_TEXTURE)
+ {
+ glUniform1i(m_hTex0, 0);
+ }
+ else if (m_method == SM_MULTI)
+ {
+ glUniform1i(m_hTex0, 0);
+ glUniform1i(m_hTex1, 1);
+ }
+
+ return true;
+}
+
+void CGUIShader::Free()
+{
+ // Do Cleanup here
+ CGLSLShaderProgram::Free();
+}
+
+#endif
diff --git a/guilib/GUIFontTTFGLES.h b/guilib/GUIShader.h
index 17939729fb..a40e83ed8a 100644
--- a/guilib/GUIFontTTFGLES.h
+++ b/guilib/GUIShader.h
@@ -19,38 +19,52 @@
*
*/
-/*!
-\file GUIFont.h
-\brief
-*/
+#ifndef GUI_SHADER_H
+#define GUI_SHADER_H
-#ifndef CGUILIB_GUIFONTTTF_GLES_H
-#define CGUILIB_GUIFONTTTF_GLES_H
#pragma once
+#include "Shader.h"
-#include "GUIFontTTF.h"
+using namespace Shaders;
+enum ESHADERMETHOD
+{
+ SM_DEFAULT = 0,
+ SM_TEXTURE = 1,
+ SM_MULTI = 2,
+ SM_FONTS = 3,
+};
-/*!
- \ingroup textures
- \brief
- */
-class CGUIFontTTFGLES : public CGUIFontTTFBase
+class CGUIShader : public CGLSLShaderProgram
{
public:
- CGUIFontTTFGLES(const CStdString& strFileName);
- virtual ~CGUIFontTTFGLES(void);
+ CGUIShader();
+ void OnCompiledAndLinked();
+ bool OnEnabled();
+ void Free();
- virtual void Begin();
- virtual void End();
+ void Setup(ESHADERMETHOD method) { m_method = method; }
+ GLint GetPosLoc() { return m_hPos; }
+ GLint GetColLoc() { return m_hCol; }
+ GLint GetCord0Loc() { return m_hCord0; }
+ GLint GetCord1Loc() { return m_hCord1; }
+
protected:
- virtual CBaseTexture* ReallocTexture(unsigned int& newHeight);
- virtual bool CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character *ch);
- virtual void DeleteHardwareTexture();
- virtual void RenderInternal(SVertex* v) {}
+ GLint m_hTex0;
+ GLint m_hTex1;
+ GLint m_hMethod;
+ GLint m_hProj;
+ GLint m_hModel;
+ GLint m_hPos;
+ GLint m_hCol;
+ GLint m_hCord0;
+ GLint m_hCord1;
+ ESHADERMETHOD m_method;
+ GLfloat *m_proj;
+ GLfloat *m_model;
};
-#endif
+#endif // GUI_SHADER_H
diff --git a/guilib/GUITextureGLES.cpp b/guilib/GUITextureGLES.cpp
index 52fc0c86cd..2b8437b213 100644
--- a/guilib/GUITextureGLES.cpp
+++ b/guilib/GUITextureGLES.cpp
@@ -22,33 +22,232 @@
#include "system.h"
#include "GUITextureGLES.h"
#include "Texture.h"
+#include "utils/log.h"
+#include "WindowingFactory.h"
#if defined(HAS_GLES)
CGUITextureGLES::CGUITextureGLES(float posX, float posY, float width, float height, const CTextureInfo &texture)
: CGUITextureBase(posX, posY, width, height, texture)
{
- // TODO: OpenGLES
}
void CGUITextureGLES::Begin()
{
- // TODO: OpenGLES
+ CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
+ glActiveTexture(GL_TEXTURE0);
+ texture->LoadToGPU();
+ if (m_diffuse.size())
+ m_diffuse.m_textures[0]->LoadToGPU();
+
+ glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
+ glEnable(GL_TEXTURE_2D);
+
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND); // Turn Blending On
+
+ if (m_diffuse.size())
+ {
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject());
+ glEnable(GL_TEXTURE_2D);
+
+ g_Windowing.EnableGUIShader(SM_MULTI);
+ }
+ else
+ {
+ g_Windowing.EnableGUIShader(SM_TEXTURE);
+ }
+
+ GLint posLoc = g_Windowing.GUIShaderGetPos();
+ GLint colLoc = g_Windowing.GUIShaderGetCol();
+ GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
+
+ glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, m_vert);
+ glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, 0, 0, m_col);
+ glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, m_tex0);
+
+ glEnableVertexAttribArray(posLoc);
+ glEnableVertexAttribArray(colLoc);
+ glEnableVertexAttribArray(tex0Loc);
+
+ if (m_diffuse.size())
+ {
+ GLint tex1Loc = g_Windowing.GUIShaderGetCoord1();
+ glVertexAttribPointer(tex1Loc, 2, GL_FLOAT, 0, 0, m_tex1);
+ glEnableVertexAttribArray(tex1Loc);
+ }
}
void CGUITextureGLES::End()
{
- // TODO: OpenGLES
+ if (m_diffuse.size())
+ {
+ glDisable(GL_TEXTURE_2D);
+ glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord1());
+ glActiveTexture(GL_TEXTURE0);
+ }
+
+ glDisable(GL_TEXTURE_2D);
+ glDisableVertexAttribArray(g_Windowing.GUIShaderGetPos());
+ glDisableVertexAttribArray(g_Windowing.GUIShaderGetCol());
+ glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord0());
+
+ g_Windowing.DisableGUIShader();
}
void CGUITextureGLES::Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, DWORD color, int orientation)
{
- // TODO: OpenGLES
+ GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
+
+ for (int i=0; i<4; i++)
+ {
+ // Setup vertex position values
+ m_vert[i][0] = x[i];
+ m_vert[i][1] = y[i];
+ m_vert[i][2] = z[i];
+
+ // Setup Colours
+ m_col[i][0] = (GLubyte)GET_R(color);
+ m_col[i][1] = (GLubyte)GET_G(color);
+ m_col[i][2] = (GLubyte)GET_B(color);
+ m_col[i][3] = (GLubyte)GET_A(color);
+ }
+
+ // Setup texture coordinates
+ //TopLeft
+ m_tex0[0][0] = texture.x1;
+ m_tex0[0][1] = texture.y1;
+ //TopRight
+ if (orientation & 4)
+ {
+ m_tex0[1][0] = texture.x1;
+ m_tex0[1][1] = texture.y2;
+ }
+ else
+ {
+ m_tex0[1][0] = texture.x2;
+ m_tex0[1][1] = texture.y1;
+ }
+ //BottomRight
+ m_tex0[2][0] = texture.x2;
+ m_tex0[2][1] = texture.y2;
+ //BottomLeft
+ if (orientation & 4)
+ {
+ m_tex0[3][0] = texture.x2;
+ m_tex0[3][1] = texture.y1;
+ }
+ else
+ {
+ m_tex0[3][0] = texture.x1;
+ m_tex0[3][1] = texture.y2;
+ }
+
+ if (m_diffuse.size())
+ {
+ //TopLeft
+ m_tex1[0][0] = diffuse.x1;
+ m_tex1[0][1] = diffuse.y1;
+ //TopRight
+ if (m_info.orientation & 4)
+ {
+ m_tex1[1][0] = diffuse.x1;
+ m_tex1[1][1] = diffuse.y2;
+ }
+ else
+ {
+ m_tex1[1][0] = diffuse.x2;
+ m_tex1[1][1] = diffuse.y1;
+ }
+ //BottomRight
+ m_tex1[2][0] = diffuse.x2;
+ m_tex1[2][1] = diffuse.y2;
+ //BottomLeft
+ if (m_info.orientation & 4)
+ {
+ m_tex1[3][0] = diffuse.x2;
+ m_tex1[3][1] = diffuse.y1;
+ }
+ else
+ {
+ m_tex1[3][0] = diffuse.x1;
+ m_tex1[3][1] = diffuse.y2;
+ }
+ }
+
+ glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
}
-void CGUITextureGLES::DrawQuad(const CRect &rect, DWORD color)
+void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords)
{
- // TODO: OpenGLES
+ if (texture)
+ {
+ glActiveTexture(GL_TEXTURE0);
+ texture->LoadToGPU();
+ glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject());
+ glEnable(GL_TEXTURE_2D);
+ }
+ else
+ glDisable(GL_TEXTURE_2D);
+
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND); // Turn Blending On
+
+ VerifyGLState();
+
+ GLfloat col[4][4];
+ GLfloat ver[4][3];
+ GLfloat tex[4][2];
+ GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
+
+ g_Windowing.EnableGUIShader(SM_TEXTURE);
+
+ GLint posLoc = g_Windowing.GUIShaderGetPos();
+ GLint colLoc = g_Windowing.GUIShaderGetCol();
+ GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
+
+ glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver);
+ glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, 0, 0, col);
+ glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex);
+
+ glEnableVertexAttribArray(posLoc);
+ glEnableVertexAttribArray(tex0Loc);
+ glEnableVertexAttribArray(colLoc);
+
+ for (int i=0; i<4; i++)
+ {
+ // Setup Colour Values
+ col[i][0] = (GLubyte)GET_R(color);
+ col[i][1] = (GLubyte)GET_G(color);
+ col[i][2] = (GLubyte)GET_B(color);
+ col[i][3] = (GLubyte)GET_A(color);
+ }
+
+ // Setup vertex position values
+ ver[0][3] = ver[1][3] = ver[2][3] = ver[3][3] = 0.0f;
+ ver[0][0] = ver[3][0] = rect.x1;
+ ver[0][1] = ver[1][1] = rect.y1;
+ ver[1][0] = ver[2][0] = rect.x2;
+ ver[2][1] = ver[3][1] = rect.y2;
+
+ // Setup texture coordinates
+ CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f);
+ tex[0][0] = tex[3][0] = coords.x1;
+ tex[0][1] = tex[1][1] = coords.y1;
+ tex[1][0] = tex[2][0] = coords.x2;
+ tex[2][1] = tex[3][1] = coords.y2;
+
+ glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
+
+ glDisableVertexAttribArray(posLoc);
+ glDisableVertexAttribArray(colLoc);
+ glDisableVertexAttribArray(tex0Loc);
+
+ g_Windowing.DisableGUIShader();
+
+ if (texture)
+ glDisable(GL_TEXTURE_2D);
}
#endif
diff --git a/guilib/GUITextureGLES.h b/guilib/GUITextureGLES.h
index 2b2d046a97..9b4dc6cf0b 100644
--- a/guilib/GUITextureGLES.h
+++ b/guilib/GUITextureGLES.h
@@ -35,11 +35,16 @@ class CGUITextureGLES : public CGUITextureBase
{
public:
CGUITextureGLES(float posX, float posY, float width, float height, const CTextureInfo& texture);
- static void DrawQuad(const CRect &rect, DWORD color);
+ static void DrawQuad(const CRect &coords, color_t color, CBaseTexture *texture = NULL, const CRect *texCoords = NULL);
protected:
void Begin();
- void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, DWORD color, int orientation);
+ void Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, color_t color, int orientation);
void End();
+
+ GLubyte m_col [4][4];
+ GLfloat m_vert[4][3];
+ GLfloat m_tex0[4][2];
+ GLfloat m_tex1[4][2];
};
#endif
diff --git a/guilib/Makefile.in b/guilib/Makefile.in
index bf2a875c01..7b346050c2 100644
--- a/guilib/Makefile.in
+++ b/guilib/Makefile.in
@@ -72,13 +72,14 @@ SRCS=AnimatedGif.cpp \
GUIColorManager.cpp \
FrameBufferObject.cpp \
Shader.cpp \
+ GUIShader.cpp \
+ MatrixGLES.cpp \
GUIListLabel.cpp \
GUIBorderedImage.cpp \
GUITextLayout.cpp \
GUIMultiSelectText.cpp \
GUIInfoTypes.cpp \
GUIFontTTFGL.cpp \
- GUIFontTTFGLES.cpp \
Texture.cpp \
TextureGL.cpp \
GUIControlProfiler.cpp \
diff --git a/guilib/MatrixGLES.cpp b/guilib/MatrixGLES.cpp
new file mode 100644
index 0000000000..f87a3f3b9f
--- /dev/null
+++ b/guilib/MatrixGLES.cpp
@@ -0,0 +1,304 @@
+/*
+* 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_matrices;
+
+#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);
+ }
+}
+
+void CMatrixGLES::PopMatrix()
+{
+ if (MODE_WITHIN_RANGE(m_matrixMode) && (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 - 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);
+}
+
+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;
+ }
+}
+
+// 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);
+ CLog::Log(LOGDEBUG, "MatrixGLES - Matrix:%d", i);
+ CLog::Log(LOGDEBUG, "%f %f %f %f", m[0], m[4], m[8], m[12]);
+ CLog::Log(LOGDEBUG, "%f %f %f %f", m[1], m[5], m[9], m[13]);
+ CLog::Log(LOGDEBUG, "%f %f %f %f", m[2], m[6], m[10], m[14]);
+ CLog::Log(LOGDEBUG, "%f %f %f %f", m[3], m[7], m[11], m[15]);
+ }
+}
+
+#endif
diff --git a/guilib/MatrixGLES.h b/guilib/MatrixGLES.h
new file mode 100644
index 0000000000..8de26f3afd
--- /dev/null
+++ b/guilib/MatrixGLES.h
@@ -0,0 +1,69 @@
+/*
+* 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_matrices;
+
+#endif // MATRIX_GLES_H
diff --git a/guilib/Shader.cpp b/guilib/Shader.cpp
index 359350c396..abdf5d441b 100644
--- a/guilib/Shader.cpp
+++ b/guilib/Shader.cpp
@@ -48,8 +48,12 @@ bool CShader::LoadSource(const string& filename, const string& prefix)
CLog::Log(LOGERROR, "CYUVShaderGLSL::CYUVShaderGLSL - failed to open file %s", filename.c_str());
return false;
}
-
+#ifdef _ARMEL
+ CLog::Log(LOGDEBUG, "Shader - Loading shader file %s", filename.c_str());
+ m_source.assign(file.ReadFile());
+#else
getline(file, m_source, '\0');
+#endif
m_source.insert(0, prefix);
return true;
}
@@ -81,7 +85,7 @@ bool CGLSLVertexShader::Compile()
if (params[0]!=GL_TRUE)
{
GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error compiling shader");
+ CLog::Log(LOGERROR, "GL: Error compiling vertex shader");
glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log);
CLog::Log(LOGERROR, "%s", log);
m_lastLog = log;
@@ -90,7 +94,7 @@ bool CGLSLVertexShader::Compile()
else
{
GLchar log[LOG_SIZE];
- CLog::Log(LOGDEBUG, "GL: Shader compilation log:");
+ CLog::Log(LOGDEBUG, "GL: Vertex Shader compilation log:");
glGetShaderInfoLog(m_vertexShader, LOG_SIZE, NULL, log);
CLog::Log(LOGDEBUG, "%s", log);
m_lastLog = log;
@@ -190,7 +194,7 @@ bool CGLSLPixelShader::Compile()
if (params[0]!=GL_TRUE)
{
GLchar log[LOG_SIZE];
- CLog::Log(LOGERROR, "GL: Error compiling shader");
+ CLog::Log(LOGERROR, "GL: Error compiling pixel shader");
glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log);
CLog::Log(LOGERROR, "%s", log);
m_lastLog = log;
@@ -199,7 +203,7 @@ bool CGLSLPixelShader::Compile()
else
{
GLchar log[LOG_SIZE];
- CLog::Log(LOGDEBUG, "GL: Shader compilation log:");
+ CLog::Log(LOGDEBUG, "GL: Pixel Shader compilation log:");
glGetShaderInfoLog(m_pixelShader, LOG_SIZE, NULL, log);
CLog::Log(LOGDEBUG, "%s", log);
m_lastLog = log;
@@ -311,6 +315,7 @@ bool CGLSLShaderProgram::CompileAndLink()
CLog::Log(LOGERROR, "GL: Error compiling vertex shader");
return false;
}
+ CLog::Log(LOGDEBUG, "GL: Vertex Shader compiled successfully");
// compile pixel shader
if (!m_pFP->Compile())
@@ -319,6 +324,7 @@ bool CGLSLShaderProgram::CompileAndLink()
CLog::Log(LOGERROR, "GL: Error compiling fragment shader");
return false;
}
+ CLog::Log(LOGDEBUG, "GL: Fragment Shader compiled successfully");
// create program object
if (!(m_shaderProgram = glCreateProgram()))
diff --git a/guilib/TextureGL.cpp b/guilib/TextureGL.cpp
index 3ce4299868..040fb39177 100644
--- a/guilib/TextureGL.cpp
+++ b/guilib/TextureGL.cpp
@@ -87,7 +87,6 @@ void CGLTexture::LoadToGPU()
CLog::Log(LOGERROR, "GL: Image width %d too big to fit into single texture unit, truncating to %u", m_textureWidth, maxSize);
#ifndef HAS_GLES
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_textureWidth);
-#endif
m_textureWidth = maxSize;
}
@@ -107,11 +106,7 @@ void CGLTexture::LoadToGPU()
break;
case XB_FMT_A8R8G8B8:
default:
-#ifdef HAS_GL
format = GL_BGRA;
-#elif HAS_GLES
- format = GL_BGRA_EXT;
-#endif
break;
}
@@ -127,8 +122,19 @@ void CGLTexture::LoadToGPU()
m_textureWidth, m_textureHeight, 0, GetPitch() * GetRows(), m_pixels);
}
-#ifndef HAS_GLES
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+#else // GLES version
+ m_textureWidth = maxSize;
+ }
+
+#if HAS_GLES == 1
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, m_textureWidth, m_textureHeight, 0,
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixels);
+#elif HAS_GLES == 2
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureWidth, m_textureHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, m_pixels);
+#endif
+
#endif
VerifyGLState();
diff --git a/guilib/system.h b/guilib/system.h
index 15205c7ea0..855b907561 100644
--- a/guilib/system.h
+++ b/guilib/system.h
@@ -196,6 +196,32 @@
#include "PlatformInclude.h"
#endif
+// ARM does not support certain features... disable them here!
+#ifdef _ARMEL
+#undef HAS_AVAHI
+#undef HAS_ZEROCONF
+#undef HAS_VISUALISATION
+#undef HAS_FILESYSTEM_HTSP
+#endif
+
+// EGL detected. Dont use GLX!
+#ifdef HAVE_LIBEGL
+#undef HAS_GLX
+#define HAS_EGL
+#endif
+
+// GLES2.0 detected. Dont use GL!
+#ifdef HAVE_LIBGLESV2
+#undef HAS_GL
+#define HAS_GLES 2
+#endif
+
+// GLES1.0 detected. Dont use GL!
+#ifdef HAVE_LIBGLES
+#undef HAS_GL
+#define HAS_GLES 1
+#endif
+
#ifdef HAS_GL
#ifdef _WIN32
#include "GL/glew.h"
@@ -212,9 +238,16 @@
#endif
#if HAS_GLES == 2
+#ifdef _ARMEL // PowerVR SGX Header
+// not sure about this one tg2 (arm) does not have gl2extimg.h
+//#include <GLES2/gl2extimg.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
+#endif
#define SAFE_DELETE(p) { delete (p); (p)=NULL; }
#define SAFE_DELETE_ARRAY(p) { delete[] (p); (p)=NULL; }