aboutsummaryrefslogtreecommitdiff
path: root/guilib/GUITextureGLES.cpp
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/GUITextureGLES.cpp
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/GUITextureGLES.cpp')
-rw-r--r--guilib/GUITextureGLES.cpp211
1 files changed, 205 insertions, 6 deletions
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