Skip to content

Loading…

Add basic OpenGLES1.1 implementation #1101

Closed
wants to merge 1 commit into from

2 participants

@Schischu

Before we start, this pull request is mainly for discussing if openglesv1 support should ever be added to xbmc. This pull request is not yet complete and contains only very basic functionality to show what changes would be necessary to get basix opengles1.1 support.

ATM I am using GL_QUADS as the hardware blitter only knows 4point blits,
but I think that I will switch to 4point TRIANGLES_STRIP to be more standard conform.
As I am also writing the opengl library switching would not be a problem.

I did not really take care of the VideoRender stuff as I will not need it. My hardware renders directly into a layer behind the framebuffer. So basically just removing all the shader stuff so it compiles. It would be better if I could compile xbmc without the videorenders, but atm to many dependencies.

I also deactivated the visualizations as audio is decoded by the hardware. A pcm stream could be routed back, but only if it is downmixed (Surround ->Stereo). If the audio is routed directly undecoded to the av receiver then there will be never a pcm stream in the system. So pcm based visualizations wont work anyway.

So this is really just the basic stuff to get xbmc working with my gles1.1 implementation for sti7105/sti7111/sti7168 sh4 cpu arch based devices.

@jmarshallnz

For this you could expose CBaseTexture::GetBlockSize()

@jmarshallnz

Don't you want to only set alpha to source[i], and everything else to 255?

Nope, I need premultiplied textures, so every pixel has to be multiplied with the alpha value.
And if the color is white then the premultiplied value is just repeating the alpha 4 times.

Btw. this has to be done as blitting A8 textures does not work, I always need RGB/ARGB

@jmarshallnz

The code for this is just underneath this, right?

Yeah but in a slightly different order. QUADS are x1y1 -> x2y1 -> x2y2 -> x1y1 and TRIANGLE_STRIPS x1y1 -> x1y2 -> x2y1 -> x2y2.
This maybe changes if I move from QUADS to TRIANGLE_STRIPS, then the same code could be reused.

@jmarshallnz

??

I believe my intention was to ignore the second allocate call if the copy constructure has been used.
But not sure at the moment. Lets ignore this change for the moment.

@jmarshallnz

is m_loadedToGPU set when m_pixels is non-NULL?

@jmarshallnz
Team Kodi member

I've made some basic comments on the UI side of things. I wonder whether as the GLES1.1 branch follows the OpenGL branch most closely (basically it's a shader-free implementation?) that it might make sense to split the ifdef's slightly differently to reduce the amount of ifdef'ery.

Personally I'm against adding GLESv1.1 unless there's a definitive hardware platform that this opens XBMC up for, simply from a maintenance perspective.

@jmarshallnz
Team Kodi member

Closing. No likely platform that's usable for XBMC that doesn't have GLES2

@jmarshallnz jmarshallnz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 24, 2012
  1. @Schischu
View
13 Makefile.in
@@ -99,6 +99,11 @@ DIRECTORY_ARCHIVES += xbmc/rendering/gles/rendering_gles.a
DIRECTORY_ARCHIVES += xbmc/windowing/egl/windowing_egl.a
endif
+ifeq (@USE_OPENGLESV1@,1)
+DIRECTORY_ARCHIVES += xbmc/rendering/gles/rendering_gles.a
+DIRECTORY_ARCHIVES += xbmc/windowing/egl/windowing_egl.a
+endif
+
ifeq ($(findstring osx,@ARCH@),osx)
DIRECTORY_ARCHIVES += xbmc/osx/osx.a
DIRECTORY_ARCHIVES += xbmc/network/osx/network.a
@@ -153,8 +158,12 @@ ifneq (@DISABLE_RSXS@,1)
SS_DIRS+= xbmc/screensavers/rsxs-0.9/xbmc
endif
-VIS_DIRS=xbmc/visualizations/OpenGLSpectrum \
- xbmc/visualizations/WaveForm
+VIS_DIRS=
+ifneq (@USE_OPENGLESV1@,1)
+ VIS_DIRS+=\
+ xbmc/visualizations/OpenGLSpectrum \
+ xbmc/visualizations/WaveForm
+endif
ifneq (@DISABLE_PROJECTM@,1)
VIS_DIRS+= xbmc/visualizations/XBMCProjectM
View
33 configure.in
@@ -195,6 +195,12 @@ AC_ARG_ENABLE([gles],
[use_gles=$enableval],
[use_gles=no])
+AC_ARG_ENABLE([glesv1],
+ [AS_HELP_STRING([--enable-glesv1],
+ [enable OpenGLESv1 rendering (default is no)])],
+ [use_glesv1=$enableval],
+ [use_glesv1=no])
+
AC_ARG_ENABLE([sdl],
[AS_HELP_STRING([--enable-sdl],
[enable SDL (default is auto)])],
@@ -727,8 +733,19 @@ else
AC_CHECK_LIB([GLU], [main],, AC_MSG_ERROR($missing_library))
fi
else
- AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
- AC_CHECK_LIB([SDL_gfx],[main])
+ if test "$use_glesv1" = "yes"; then
+ if test "$host_alias" = "sh4-linux" ; then
+ AC_DEFINE([HAVE_LIBEGL],[1],["Define to 1 if you have the `EGL' library (-lEGL)."])
+ AC_DEFINE([HAVE_LIBGLES],[1],["Define to 1 if you have the `GLES' library (-lGLES)."])
+
+ PKG_CHECK_MODULES([STGLES], [libstgles],
+ INCLUDES="$INCLUDES $STGLES_CFLAGS"; LIBS="$LIBS $STGLES_LIBS"; use_stgles=yes],
+ AC_MSG_NOTICE($stgles_not_found); use_stgles=no)
+ fi
+ else
+ AC_MSG_RESULT(== WARNING: OpenGL support is disabled. XBMC will run VERY slow. ==)
+ AC_CHECK_LIB([SDL_gfx],[main])
+ fi
fi
fi
@@ -1640,16 +1657,23 @@ final_message="$final_message\n target CPU:\t$use_cpu"
if test "$use_gles" = "yes"; then
final_message="$final_message\n OpenGLES:\tYes"
USE_OPENGLES=1
+ USE_OPENGLESV1=0
USE_OPENGL=0
else
USE_OPENGLES=0
if test "$use_gl" = "yes"; then
final_message="$final_message\n OpenGL:\tYes"
USE_OPENGL=1
+ USE_OPENGLESV1=0
else
- final_message="$final_message\n OpenGL:\tNo (Very Slow)"
- SDL_DEFINES="-DHAS_SDL_2D"
USE_OPENGL=0
+ final_message="$final_message\n OpenGLESV1:\tYes"
+ if test "$use_glesv1" = "yes"; then
+ USE_OPENGLESV1=1
+ else
+ final_message="$final_message\n OpenGL:\tNo (Very Slow)"
+ SDL_DEFINES="-DHAS_SDL_2D"
+ fi
fi
fi
@@ -2075,6 +2099,7 @@ AC_SUBST(LIBMEPG2_BASENAME)
AC_SUBST_FILE(XBMC_STANDALONE_SH_PULSE)
AC_SUBST(USE_OPENGL)
AC_SUBST(USE_OPENGLES)
+AC_SUBST(USE_OPENGLESV1)
AC_SUBST(USE_VDPAU)
AC_SUBST(USE_VAAPI)
AC_SUBST(USE_CRYSTALHD)
View
2 xbmc/Util.cpp
@@ -928,7 +928,7 @@ void CUtil::TakeScreenshot(const CStdString &filename, bool sync)
unsigned char* pixels = new unsigned char[stride * height];
//read pixels from the backbuffer
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);
#else
glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);
View
46 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -24,7 +24,7 @@
#include "config.h"
#endif
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
#include "system_gl.h"
#include <locale.h>
@@ -36,9 +36,11 @@
#include "settings/Settings.h"
#include "settings/AdvancedSettings.h"
#include "settings/GUISettings.h"
+#if HAS_GLES == 2
#include "guilib/FrameBufferObject.h"
#include "VideoShaders/YUV2RGBShader.h"
#include "VideoShaders/VideoFilterShader.h"
+#endif
#include "windowing/WindowingFactory.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "guilib/Texture.h"
@@ -59,7 +61,9 @@
#include "osx/DarwinUtils.h"
#endif
+#if HAS_GLES == 2
using namespace Shaders;
+#endif
CLinuxRendererGLES::YUVBUFFER::YUVBUFFER()
{
@@ -94,9 +98,11 @@ CLinuxRendererGLES::CLinuxRendererGLES()
m_iYV12RenderBuffer = 0;
m_flipindex = 0;
m_currentField = FIELD_FULL;
+#if HAS_GLES == 2
m_reloadShaders = 0;
m_pYUVShader = NULL;
m_pVideoFilterShader = NULL;
+#endif
m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
m_scalingMethodGui = (ESCALINGMETHOD)-1;
@@ -122,13 +128,14 @@ CLinuxRendererGLES::~CLinuxRendererGLES()
delete [] m_rgbBuffer;
m_rgbBuffer = NULL;
}
-
+#if HAS_GLES == 2
if (m_pYUVShader)
{
m_pYUVShader->Free();
delete m_pYUVShader;
m_pYUVShader = NULL;
}
+#endif
delete m_dllSwScale;
}
@@ -146,9 +153,10 @@ bool CLinuxRendererGLES::ValidateRenderTarget()
{
CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
+#if HAS_GLES == 2
// create the yuv textures
LoadShaders();
-
+#endif
for (int i = 0 ; i < m_NumYV12Buffers ; i++)
(this->*m_textureCreate)(i);
@@ -458,14 +466,18 @@ void CLinuxRendererGLES::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#if HAS_GLES == 2
if (m_pYUVShader)
m_pYUVShader->SetAlpha(alpha / 255.0f);
+#endif
}
else
{
glDisable(GL_BLEND);
+#if HAS_GLES == 2
if (m_pYUVShader)
m_pYUVShader->SetAlpha(1.0f);
+#endif
}
if ((flags & RENDER_FLAG_TOP) && (flags & RENDER_FLAG_BOT))
@@ -484,6 +496,7 @@ void CLinuxRendererGLES::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
void CLinuxRendererGLES::FlipPage(int source)
{
+#if HAS_GLES == 2
if( source >= 0 && source < m_NumYV12Buffers )
m_iYV12RenderBuffer = source;
else
@@ -492,10 +505,12 @@ void CLinuxRendererGLES::FlipPage(int source)
m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
return;
+#endif
}
unsigned int CLinuxRendererGLES::PreInit()
{
+#if HAS_GLES == 2
CSingleLock lock(g_graphicsContext);
m_bConfigured = false;
m_bValidated = false;
@@ -522,11 +537,13 @@ unsigned int CLinuxRendererGLES::PreInit()
if (!m_dllSwScale->Load())
CLog::Log(LOGERROR,"CLinuxRendererGL::PreInit - failed to load rescale libraries!");
+#endif
return true;
}
void CLinuxRendererGLES::UpdateVideoFilter()
{
+#if HAS_GLES == 2
if (m_scalingMethodGui == g_settings.m_currentVideoSettings.m_ScalingMethod)
return;
m_scalingMethodGui = g_settings.m_currentVideoSettings.m_ScalingMethod;
@@ -587,10 +604,12 @@ void CLinuxRendererGLES::UpdateVideoFilter()
SetTextureFilter(GL_LINEAR);
m_renderQuality = RQ_SINGLEPASS;
+#endif
}
void CLinuxRendererGLES::LoadShaders(int field)
{
+#if HAS_GLES == 2
#ifdef TARGET_DARWIN_IOS
float ios_version = GetIOSVersion();
#endif
@@ -695,10 +714,12 @@ void CLinuxRendererGLES::LoadShaders(int field)
m_textureCreate = &CLinuxRendererGLES::CreateYV12Texture;
m_textureDelete = &CLinuxRendererGLES::DeleteYV12Texture;
}
+#endif
}
void CLinuxRendererGLES::UnInit()
{
+#if HAS_GLES == 2
CLog::Log(LOGDEBUG, "LinuxRendererGL: Cleaning up GL resources");
CSingleLock lock(g_graphicsContext);
@@ -723,10 +744,12 @@ void CLinuxRendererGLES::UnInit()
m_bValidated = false;
m_bImageReady = false;
m_bConfigured = false;
+#endif
}
void CLinuxRendererGLES::Render(DWORD flags, int index)
{
+#if HAS_GLES == 2
// If rendered directly by the hardware
if (m_renderMethod & RENDER_BYPASS)
return;
@@ -780,10 +803,12 @@ void CLinuxRendererGLES::Render(DWORD flags, int index)
RenderSoftware(index, m_currentField);
VerifyGLState();
}
+#endif
}
void CLinuxRendererGLES::RenderSinglePass(int index, int field)
{
+#if HAS_GLES == 2
YV12Image &im = m_buffers[index].image;
YUVFIELDS &fields = m_buffers[index].fields;
YUVPLANES &planes = fields[field];
@@ -885,10 +910,12 @@ void CLinuxRendererGLES::RenderSinglePass(int index, int field)
g_matrices.MatrixMode(MM_MODELVIEW);
VerifyGLState();
+#endif
}
void CLinuxRendererGLES::RenderMultiPass(int index, int field)
{
+#if HAS_GLES == 2
// TODO: Multipass rendering does not currently work! FIX!
CLog::Log(LOGERROR, "GLES: MULTIPASS rendering was called! But it doesnt work!!!");
return;
@@ -1075,10 +1102,12 @@ void CLinuxRendererGLES::RenderMultiPass(int index, int field)
glDisable(m_textureTarget);
VerifyGLState();
+#endif
}
void CLinuxRendererGLES::RenderSoftware(int index, int field)
{
+#if HAS_GLES == 2
YUVPLANES &planes = m_buffers[index].fields[field];
glDisable(GL_DEPTH_TEST);
@@ -1136,6 +1165,7 @@ void CLinuxRendererGLES::RenderSoftware(int index, int field)
glDisable(m_textureTarget);
VerifyGLState();
+#endif
}
void CLinuxRendererGLES::RenderOpenMax(int index, int field)
@@ -1268,6 +1298,7 @@ void CLinuxRendererGLES::RenderCoreVideoRef(int index, int field)
bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
{
+#if HAS_GLES == 2
if (!m_bValidated)
return false;
@@ -1309,6 +1340,7 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
// restore original video rect
m_destRect = saveSize;
+#endif
return true;
}
@@ -1317,6 +1349,7 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
//********************************************************************************************************
void CLinuxRendererGLES::UploadYV12Texture(int source)
{
+#if HAS_GLES == 2
YUVBUFFER& buf = m_buffers[source];
YV12Image* im = &buf.image;
YUVFIELDS& fields = buf.fields;
@@ -1455,10 +1488,12 @@ void CLinuxRendererGLES::UploadYV12Texture(int source)
CalculateTextureSourceRects(source, 3);
glDisable(m_textureTarget);
+#endif
}
void CLinuxRendererGLES::DeleteYV12Texture(int index)
{
+#if HAS_GLES == 2
YV12Image &im = m_buffers[index].image;
YUVFIELDS &fields = m_buffers[index].fields;
@@ -1488,10 +1523,12 @@ void CLinuxRendererGLES::DeleteYV12Texture(int index)
im.plane[p] = NULL;
}
}
+#endif
}
bool CLinuxRendererGLES::CreateYV12Texture(int index)
{
+#if HAS_GLES == 2
/* since we also want the field textures, pitch must be texture aligned */
YV12Image &im = m_buffers[index].image;
YUVFIELDS &fields = m_buffers[index].fields;
@@ -1596,6 +1633,7 @@ bool CLinuxRendererGLES::CreateYV12Texture(int index)
}
glDisable(m_textureTarget);
m_eventTexturesDone[index]->Set();
+#endif
return true;
}
@@ -1751,6 +1789,7 @@ bool CLinuxRendererGLES::CreateBYPASSTexture(int index)
void CLinuxRendererGLES::SetTextureFilter(GLenum method)
{
+#if HAS_GLES == 2
for (int i = 0 ; i<m_NumYV12Buffers ; i++)
{
YUVFIELDS &fields = m_buffers[i].fields;
@@ -1776,6 +1815,7 @@ void CLinuxRendererGLES::SetTextureFilter(GLenum method)
}
}
}
+#endif
}
bool CLinuxRendererGLES::Supports(ERENDERFEATURE feature)
View
6 xbmc/cores/VideoRenderers/LinuxRendererGLES.h
@@ -22,11 +22,13 @@
*
*/
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
#include "system_gl.h"
+#if HAS_GLES == 2
#include "xbmc/guilib/FrameBufferObject.h"
+#endif
#include "xbmc/guilib/Shader.h"
#include "settings/VideoSettings.h"
#include "RenderFlags.h"
@@ -193,7 +195,9 @@ class CLinuxRendererGLES : public CBaseRenderer
void RenderOpenMax(int index, int field); // OpenMAX rgb texture
void RenderCoreVideoRef(int index, int field); // CoreVideo reference
+#if HAS_GLES == 2
CFrameBufferObject m_fbo;
+#endif
int m_iYV12RenderBuffer;
int m_NumYV12Buffers;
View
6 xbmc/cores/VideoRenderers/Makefile.in
@@ -21,6 +21,12 @@ SRCS+= LinuxRendererGLES.cpp \
endif
+ifeq (@USE_OPENGLESV1@,1)
+SRCS+= LinuxRendererGLES.cpp \
+ OverlayRendererGL.cpp \
+
+endif
+
LIB=VideoRenderer.a
include @abs_top_srcdir@/Makefile.include
View
4 xbmc/cores/VideoRenderers/OverlayRenderer.cpp
@@ -300,7 +300,7 @@ COverlay* CRenderer::Convert(CDVDOverlaySSA* o, double pts)
return o->m_overlay->Acquire();
}
-#if defined(HAS_GL) || defined(HAS_GLES)
+#if defined(HAS_GL) || (defined(HAS_GLES) && HAS_GLES == 2)
return new COverlayGlyphGL(images, width, height);
#elif defined(HAS_DX)
return new COverlayQuadsDX(images, width, height);
@@ -326,7 +326,7 @@ COverlay* CRenderer::Convert(CDVDOverlay* o, double pts)
return r;
}
-#if defined(HAS_GL) || defined(HAS_GLES)
+#if defined(HAS_GL) || (defined(HAS_GLES) && HAS_GLES == 2)
if (o->IsOverlayType(DVDOVERLAY_TYPE_IMAGE))
r = new COverlayTextureGL((CDVDOverlayImage*)o);
else if(o->IsOverlayType(DVDOVERLAY_TYPE_SPU))
View
10 xbmc/cores/VideoRenderers/OverlayRendererGL.cpp
@@ -26,7 +26,7 @@
#include "OverlayRendererGL.h"
#ifdef HAS_GL
#include "LinuxRendererGL.h"
-#elif HAS_GLES == 2
+#elif HAS_GLES == 2 || HAS_GLES == 1
#include "LinuxRendererGLES.h"
#include "guilib/MatrixGLES.h"
#endif
@@ -41,9 +41,9 @@
#include "utils/GLUtils.h"
#include "RenderManager.h"
-#if defined(HAS_GL) || HAS_GLES == 2
+#if defined(HAS_GL) || HAS_GLES == 2 || HAS_GLES == 1
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
// GLES2.0 cant do CLAMP, but can do CLAMP_TO_EDGE.
#define GL_CLAMP GL_CLAMP_TO_EDGE
#endif
@@ -407,6 +407,7 @@ void COverlayGlyphGL::Render(SRenderState& state)
glPopMatrix();
#else
+#if defined(HAS_GL) || HAS_GLES == 2
g_matrices.MatrixMode(MM_MODELVIEW);
g_matrices.PushMatrix();
g_matrices.Translatef(state.x, state.y, 0.0f);
@@ -443,6 +444,7 @@ void COverlayGlyphGL::Render(SRenderState& state)
g_matrices.PopMatrix();
#endif
+#endif
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
@@ -512,6 +514,7 @@ void COverlayTextureGL::Render(SRenderState& state)
glVertex2f(rd.left , rd.bottom);
glEnd();
#else
+#if defined(HAS_GL) || HAS_GLES == 2
g_Windowing.EnableGUIShader(SM_TEXTURE);
GLfloat col[4][4];
@@ -556,6 +559,7 @@ void COverlayTextureGL::Render(SRenderState& state)
g_Windowing.DisableGUIShader();
#endif
+#endif
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
View
2 xbmc/cores/VideoRenderers/OverlayRendererGL.h
@@ -31,7 +31,7 @@ class CDVDOverlaySpu;
class CDVDOverlaySSA;
typedef struct ass_image ASS_Image;
-#if defined(HAS_GL) || HAS_GLES == 2
+#if defined(HAS_GL) || HAS_GLES == 2|| HAS_GLES == 1
namespace OVERLAY {
View
2 xbmc/cores/VideoRenderers/RenderManager.cpp
@@ -37,7 +37,7 @@
#if defined(HAS_GL)
#include "LinuxRendererGL.h"
-#elif HAS_GLES == 2
+#elif HAS_GLES == 2 || HAS_GLES == 1
#include "LinuxRendererGLES.h"
#elif defined(HAS_DX)
#include "WinRenderer.h"
View
2 xbmc/cores/VideoRenderers/RenderManager.h
@@ -113,7 +113,7 @@ class CXBMCRenderManager
#ifdef HAS_GL
CLinuxRendererGL *m_pRenderer;
-#elif HAS_GLES == 2
+#elif HAS_GLES == 2 || HAS_GLES == 1
CLinuxRendererGLES *m_pRenderer;
#elif defined(HAS_DX)
CWinRenderer *m_pRenderer;
View
40 xbmc/guilib/GUIFontTTFGL.cpp
@@ -28,7 +28,7 @@
#include "gui3d.h"
#include "utils/log.h"
#include "utils/GLUtils.h"
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
#include "windowing/WindowingFactory.h"
#endif
@@ -42,6 +42,9 @@ using namespace std;
#if defined(HAS_GL) || defined(HAS_GLES)
+#if HAS_GLES == 1 && defined(__sh__)
+ #define TTF_ARGB
+#endif
CGUIFontTTFGL::CGUIFontTTFGL(const CStdString& strFileName)
: CGUIFontTTFBase(strFileName)
@@ -63,7 +66,7 @@ void CGUIFontTTFGL::Begin()
// Bind the texture object
glBindTexture(GL_TEXTURE_2D, m_nTexture);
-#ifdef HAS_GL
+#if defined(HAS_GL) || HAS_GLES == 1
glEnable(GL_TEXTURE_2D);
#endif
// Set the texture's stretching properties
@@ -71,8 +74,13 @@ void CGUIFontTTFGL::Begin()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Set the texture image -- THIS WORKS, so the pixels must be wrong.
+#ifdef TTF_ARGB
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_texture->GetWidth(), m_texture->GetHeight(), 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, m_texture->GetPixels());
+#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_texture->GetWidth(), m_texture->GetHeight(), 0,
GL_ALPHA, GL_UNSIGNED_BYTE, m_texture->GetPixels());
+#endif
VerifyGLState();
m_bTextureLoaded = true;
@@ -81,7 +89,7 @@ void CGUIFontTTFGL::Begin()
// Turn Blending On
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
-#ifdef HAS_GL
+#if defined(HAS_GL) || HAS_GLES == 1
glEnable(GL_TEXTURE_2D);
#endif
glBindTexture(GL_TEXTURE_2D, m_nTexture);
@@ -97,6 +105,9 @@ void CGUIFontTTFGL::Begin()
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+#endif
+
+#if defined(HAS_GL) || HAS_GLES == 1
VerifyGLState();
#else
g_Windowing.EnableGUIShader(SM_FONTS);
@@ -116,17 +127,24 @@ void CGUIFontTTFGL::End()
if (--m_nestedBeginCount > 0)
return;
+#if defined(HAS_GL) || HAS_GLES == 1
#ifdef HAS_GL
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
-
+#endif
glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, r));
glVertexPointer (3, GL_FLOAT , sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, x));
glTexCoordPointer(2, GL_FLOAT , sizeof(SVertex), (char*)m_vertex + offsetof(SVertex, u));
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+#ifdef GL_QUADS
glDrawArrays(GL_QUADS, 0, m_vertex_count);
+#else
+ TODO: Convert quads to vertexes for real es1.1, without quads, support
+#endif
+#ifdef HAS_GL
glPopClientAttrib();
+#endif
#else
// GLES 2.0 version. Cannot draw quads. Convert to triangles.
GLint posLoc = g_Windowing.GUIShaderGetPos();
@@ -173,7 +191,11 @@ CBaseTexture* CGUIFontTTFGL::ReallocTexture(unsigned int& newHeight)
{
newHeight = CBaseTexture::PadPow2(newHeight);
+#ifdef TTF_ARGB
+ CBaseTexture* newTexture = new CTexture(m_textureWidth, newHeight, XB_FMT_A8R8G8B8);
+#else
CBaseTexture* newTexture = new CTexture(m_textureWidth, newHeight, XB_FMT_A8);
+#endif
if (!newTexture || newTexture->GetPixels() == NULL)
{
@@ -205,11 +227,21 @@ bool CGUIFontTTFGL::CopyCharToTexture(FT_BitmapGlyph bitGlyph, Character* ch)
FT_Bitmap bitmap = bitGlyph->bitmap;
unsigned char* source = (unsigned char*) bitmap.buffer;
+#ifdef TTF_ARGB
+ unsigned char* target = (unsigned char*) m_texture->GetPixels() + (m_posY + ch->offsetY) * m_texture->GetPitch() + (m_posX + bitGlyph->left)*4/*ARGB*/;
+#else
unsigned char* target = (unsigned char*) m_texture->GetPixels() + (m_posY + ch->offsetY) * m_texture->GetPitch() + m_posX + bitGlyph->left;
+#endif
for (int y = 0; y < bitmap.rows; y++)
{
+#ifdef TTF_ARGB
+ for (unsigned int i = 0, j = 0; i < bitmap.width; i++, j+=4) {
+ memset(target + j, source[i], 4);
+ }
+#else
memcpy(target, source, bitmap.width);
+#endif
source += bitmap.width;
target += m_texture->GetPitch();
}
View
84 xbmc/guilib/GUITextureGLES.cpp
@@ -57,9 +57,11 @@ void CGUITextureGLES::Begin(color_t color)
}
bool hasAlpha = m_texture.m_textures[m_currentFrame]->HasAlpha() || m_col[0][3] < 255;
-
+
+#if HAS_GLES == 2
if (m_diffuse.size())
{
+
if (m_col[0][0] == 255 && m_col[0][1] == 255 && m_col[0][2] == 255 && m_col[0][3] == 255 )
{
g_Windowing.EnableGUIShader(SM_MULTI);
@@ -90,7 +92,17 @@ void CGUITextureGLES::Begin(color_t color)
g_Windowing.EnableGUIShader(SM_TEXTURE_NOBLEND);
}
}
+#endif
+#if HAS_GLES == 1
+ glVertexPointer(3, GL_FLOAT, 0, m_vert);
+ glColorPointer(4, GL_UNSIGNED_BYTE, 0, m_col);
+ glTexCoordPointer(2, GL_FLOAT , 0, m_tex0);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+#else //HAS_GLES == 2
GLint posLoc = g_Windowing.GUIShaderGetPos();
GLint colLoc = g_Windowing.GUIShaderGetCol();
GLint tex0Loc = g_Windowing.GUIShaderGetCoord0();
@@ -104,6 +116,7 @@ void CGUITextureGLES::Begin(color_t color)
if(colLoc >= 0)
glEnableVertexAttribArray(colLoc);
glEnableVertexAttribArray(tex0Loc);
+#endif
if ( hasAlpha )
{
@@ -118,6 +131,11 @@ void CGUITextureGLES::Begin(color_t color)
void CGUITextureGLES::End()
{
+#if HAS_GLES == 1
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+#else //HAS_GLES == 2
if (m_diffuse.size())
{
glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord1());
@@ -129,13 +147,72 @@ void CGUITextureGLES::End()
if(colLoc >= 0)
glDisableVertexAttribArray(g_Windowing.GUIShaderGetCol());
glDisableVertexAttribArray(g_Windowing.GUIShaderGetCoord0());
-
+#endif
glEnable(GL_BLEND);
+#if HAS_GLES == 2
g_Windowing.DisableGUIShader();
+#endif
}
void CGUITextureGLES::Draw(float *x, float *y, float *z, const CRect &texture, const CRect &diffuse, int orientation)
{
+#if HAS_GLES == 1
+
+ // Setup vertex position values
+ m_vert[0][0] = x[3];
+ m_vert[0][1] = y[0];
+ m_vert[0][2] = z[0];
+
+ m_vert[1][0] = x[0];
+ m_vert[1][1] = y[2];
+ m_vert[1][2] = z[1];
+
+ m_vert[2][0] = x[1];
+ m_vert[2][1] = y[1];
+ m_vert[2][2] = z[2];
+
+ m_vert[3][0] = x[2];
+ m_vert[3][1] = y[3];
+ m_vert[3][2] = z[3];
+
+ // Setup texture coordinates
+ //TopLeft
+ m_tex0[0][0] = texture.x1;
+ m_tex0[0][1] = texture.y1;
+ //BottomLeft
+ if (orientation & 4)
+ {
+ m_tex0[1][0] = texture.x2;
+ m_tex0[1][1] = texture.y1;
+ }
+ else
+ {
+ m_tex0[1][0] = texture.x1;
+ m_tex0[1][1] = texture.y2;
+ }
+ //TopRight
+ if (orientation & 4)
+ {
+ m_tex0[2][0] = texture.x1;
+ m_tex0[2][1] = texture.y2;
+ }
+ else
+ {
+ m_tex0[2][0] = texture.x2;
+ m_tex0[2][1] = texture.y1;
+ }
+ //BottomRight
+ m_tex0[3][0] = texture.x2;
+ m_tex0[3][1] = texture.y2;
+
+#ifdef GL_QUADS
+ glEnable(GL_TEXTURE_2D);
+ glDrawArrays(GL_QUADS, 0, 4);
+#else
+ TODO: Convert quads to vertexes for real es1.1, without quads, support
+#endif
+
+#else //HAS_GLES == 2
GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip
// Setup vertex position values
@@ -209,10 +286,12 @@ void CGUITextureGLES::Draw(float *x, float *y, float *z, const CRect &texture, c
}
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
+#endif
}
void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords)
{
+#if HAS_GLES == 2 //TODO GLES == 1
if (texture)
{
texture->LoadToGPU();
@@ -291,6 +370,7 @@ void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *t
glDisableVertexAttribArray(tex0Loc);
g_Windowing.DisableGUIShader();
+#endif
}
#endif
View
16 xbmc/guilib/Makefile.in
@@ -3,7 +3,6 @@ SRCS=AnimatedGif.cpp \
DirectXGraphics.cpp \
DirtyRegionSolvers.cpp \
DirtyRegionTracker.cpp \
- FrameBufferObject.cpp \
GraphicContext.cpp \
GUIAction.cpp \
GUIAudioManager.cpp \
@@ -76,17 +75,24 @@ SRCS=AnimatedGif.cpp \
XBTFReader.cpp \
ifeq (@USE_OPENGL@,1)
-SRCS+=TextureGL.cpp \
+SRCS+=FrameBufferObject.cpp \
+ TextureGL.cpp \
GUIFontTTFGL.cpp \
GUITextureGL.cpp
endif
ifeq (@USE_OPENGLES@,1)
-SRCS+=TextureGL.cpp \
+SRCS+=FrameBufferObject.cpp \
+ TextureGL.cpp \
GUIFontTTFGL.cpp \
GUITextureGLES.cpp \
MatrixGLES.cpp \
- GUIShader.cpp \
-
+ GUIShader.cpp
+endif
+ifeq (@USE_OPENGLESV1@,1)
+SRCS+=TextureGL.cpp \
+ GUIFontTTFGL.cpp \
+ GUITextureGLES.cpp \
+ MatrixGLES.cpp
endif
LIB=guilib.a
View
2 xbmc/guilib/MatrixGLES.cpp
@@ -22,7 +22,7 @@
#include "system.h"
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
#include "system_gl.h"
#include <cmath>
View
5 xbmc/guilib/Texture.cpp
@@ -69,6 +69,11 @@ CBaseTexture::~CBaseTexture()
void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned int format)
{
+ if(m_imageWidth != width && m_imageHeight != height && m_format != format && m_pixels != NULL) {
+ //Nothing to do
+ return;
+ }
+
m_imageWidth = width;
m_imageHeight = height;
m_format = format;
View
5 xbmc/guilib/TextureGL.cpp
@@ -56,7 +56,7 @@ void CGLTexture::DestroyTextureObject()
void CGLTexture::LoadToGPU()
{
- if (!m_pixels)
+ if (m_loadedToGPU || !m_pixels)
{
// nothing to load - probably same image (no change)
return;
@@ -194,6 +194,9 @@ void CGLTexture::BindToUnit(unsigned int unit)
#else // GLES
glActiveTexture((unit == 1) ? GL_TEXTURE1 : GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_texture);
+#if HAS_GLES == 1
+ glEnable(GL_TEXTURE_2D);
+#endif
#endif
}
View
3 xbmc/pictures/SlideShowPicture.cpp
@@ -762,7 +762,7 @@ void CSlideShowPic::Render(float *x, float *y, CBaseTexture* pTexture, color_t c
glEnd();
g_graphicsContext.EndPaint();
-#elif defined(HAS_GLES)
+#elif defined(HAS_GLES) && HAS_GLES == 2
g_graphicsContext.BeginPaint();
if (pTexture)
{
@@ -833,6 +833,7 @@ void CSlideShowPic::Render(float *x, float *y, CBaseTexture* pTexture, color_t c
g_Windowing.DisableGUIShader();
g_graphicsContext.EndPaint();
+#elif defined(HAS_GLES) && HAS_GLES == 1
#else
// SDL render
g_Windowing.BlitToScreen(m_pImage, NULL, NULL);
View
23 xbmc/rendering/gles/RenderSystemGLES.cpp
@@ -22,7 +22,7 @@
#include "system.h"
-#if HAS_GLES == 2
+#if HAS_GLES == 2 || HAS_GLES == 1
#include "guilib/GraphicContext.h"
#include "settings/AdvancedSettings.h"
@@ -34,6 +34,7 @@
#include "utils/SystemInfo.h"
#include "utils/MathUtils.h"
+#if HAS_GLES == 2
static const char* ShaderNames[SM_ESHADERCOUNT] =
{"guishader_frag_default.glsl",
"guishader_frag_texture.glsl",
@@ -44,11 +45,14 @@ static const char* ShaderNames[SM_ESHADERCOUNT] =
"guishader_frag_rgba.glsl",
"guishader_frag_rgba_blendcolor.glsl"
};
+#endif
CRenderSystemGLES::CRenderSystemGLES()
: CRenderSystemBase()
+#if HAS_GLES == 2
, m_pGUIshader(0)
, m_method(SM_DEFAULT)
+#endif
{
m_enumRenderingSystem = RENDERING_SYSTEM_OPENGLES;
}
@@ -117,9 +121,9 @@ bool CRenderSystemGLES::InitRenderSystem()
m_bRenderCreated = true;
-
+#if HAS_GLES == 2
InitialiseGUIShader();
-
+#endif
return true;
}
@@ -153,6 +157,7 @@ bool CRenderSystemGLES::ResetRenderSystem(int width, int height, bool fullScreen
bool CRenderSystemGLES::DestroyRenderSystem()
{
+#if HAS_GLES == 2
CLog::Log(LOGDEBUG, "GUI Shader - Destroying Shader : %p", m_pGUIshader);
if (m_pGUIshader)
@@ -169,7 +174,7 @@ bool CRenderSystemGLES::DestroyRenderSystem()
delete[] m_pGUIshader;
m_pGUIshader = NULL;
}
-
+#endif
m_bRenderCreated = false;
return true;
@@ -200,6 +205,10 @@ bool CRenderSystemGLES::ClearBuffers(color_t color)
float g = GET_G(color) / 255.0f;
float b = GET_B(color) / 255.0f;
float a = GET_A(color) / 255.0f;
+#if HAS_GLES == 1
+ //TODO: Ugly Hack, somehow the alpha value goes missing, check this
+ a = 0.0f;
+#endif
glClearColor(r, g, b, a);
@@ -424,6 +433,7 @@ bool CRenderSystemGLES::TestRender()
{
static float theta = 0.0;
+#if HAS_GLES == 2
//RESOLUTION_INFO resInfo = g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution];
//glViewport(0, 0, resInfo.iWidth, resInfo.iHeight);
@@ -466,6 +476,7 @@ bool CRenderSystemGLES::TestRender()
theta += 1.0f;
+#endif
return true;
}
@@ -544,7 +555,7 @@ void CRenderSystemGLES::ResetScissors()
{
SetScissors(CRect(0, 0, (float)m_width, (float)m_height));
}
-
+#if HAS_GLES == 2
void CRenderSystemGLES::InitialiseGUIShader()
{
if (!m_pGUIshader)
@@ -626,5 +637,5 @@ GLint CRenderSystemGLES::GUIShaderGetCoord1()
return -1;
}
-
+#endif
#endif
View
6 xbmc/rendering/gles/RenderSystemGLES.h
@@ -27,6 +27,7 @@
#include "system.h"
#include "system_gl.h"
#include "rendering/RenderSystem.h"
+#if HAS_GLES == 2
#include "xbmc/guilib/GUIShader.h"
enum ESHADERMETHOD
@@ -41,6 +42,7 @@ enum ESHADERMETHOD
SM_TEXTURE_RGBA_BLENDCOLOR,
SM_ESHADERCOUNT
};
+#endif
class CRenderSystemGLES : public CRenderSystemBase
{
@@ -78,6 +80,7 @@ class CRenderSystemGLES : public CRenderSystemBase
virtual void Project(float &x, float &y, float &z);
+#if HAS_GLES == 2
void InitialiseGUIShader();
void EnableGUIShader(ESHADERMETHOD method);
void DisableGUIShader();
@@ -86,6 +89,7 @@ class CRenderSystemGLES : public CRenderSystemBase
GLint GUIShaderGetCol();
GLint GUIShaderGetCoord0();
GLint GUIShaderGetCoord1();
+#endif
protected:
virtual void SetVSyncImpl(bool enable) = 0;
@@ -103,8 +107,10 @@ class CRenderSystemGLES : public CRenderSystemBase
CStdString m_RenderExtensions;
+#if HAS_GLES == 2
CGUIShader **m_pGUIshader; // One GUI shader for each method
ESHADERMETHOD m_method; // Current GUI Shader method
+#endif
GLfloat m_view[16];
GLfloat m_projection[16];
View
3 xbmc/system_gl.h
@@ -52,4 +52,7 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
+#elif HAS_GLES == 1
+ #include <GLES/gl.h>
+ #include <GLES/glext.h>
#endif
View
2 xbmc/utils/GLUtils.cpp
@@ -86,11 +86,13 @@ void LogGraphicsInfo()
else
CLog::Log(LOGNOTICE, "GL_VERSION = NULL");
+#if defined(HAS_GL) || (defined(HAS_GLES) && HAS_GLES == 2)
s = glGetString(GL_SHADING_LANGUAGE_VERSION);
if (s)
CLog::Log(LOGNOTICE, "GL_SHADING_LANGUAGE_VERSION = %s", s);
else
CLog::Log(LOGNOTICE, "GL_SHADING_LANGUAGE_VERSION = NULL");
+#endif
//GL_NVX_gpu_memory_info extension
#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
View
4 xbmc/visualizations/EGLHelpers/VisMatrixGLES.h
@@ -24,8 +24,8 @@
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
- #include <GLES2/gl2.h>
- #include <GLES2/gl2ext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#endif//__APPLE__
#include <string.h>
View
9 xbmc/windowing/egl/WinBindingEGL.cpp
@@ -74,7 +74,7 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
m_nativeDisplay = nativeDisplay;
m_nativeWindow = nativeWindow;
- m_display = eglGetDisplay(nativeDisplay);
+ m_display = eglGetDisplay(((intptr_t)(NativeDisplayType)nativeDisplay));
if (m_display == EGL_NO_DISPLAY)
{
CLog::Log(LOGERROR, "EGL failed to obtain display");
@@ -96,7 +96,12 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
EGL_SAMPLE_BUFFERS, 0,
EGL_SAMPLES, 0,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RENDERABLE_TYPE,
+#if HAS_GLES == 2
+ EGL_OPENGL_ES2_BIT,
+#else
+ EGL_OPENGL_ES_BIT,
+#endif
EGL_NONE
};
View
10 xbmc/windowing/egl/WinSystemGLES.cpp
@@ -54,10 +54,14 @@ bool CWinSystemGLES::InitWindowSystem()
CLog::Log(LOGDEBUG, "Video mode: %dx%d with %d bits per pixel.",
m_fb_width, m_fb_height, m_fb_bpp);
- m_display = EGL_DEFAULT_DISPLAY;
+ m_display = (void*)EGL_DEFAULT_DISPLAY;
+#ifdef fbdev_window
m_window = (fbdev_window*)calloc(1, sizeof(fbdev_window));
m_window->width = m_fb_width;
m_window->height = m_fb_height;
+#else
+ m_window = NULL;
+#endif
if (!CWinSystemBase::InitWindowSystem())
return false;
@@ -106,6 +110,8 @@ bool CWinSystemGLES::ResizeWindow(int newWidth, int newHeight, int newLeft, int
bool CWinSystemGLES::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
{
CLog::Log(LOGDEBUG, "CWinSystemDFB::SetFullScreen");
+#if defined(__sh__) //TODO: Fix crash at this point
+#else
m_nWidth = res.iWidth;
m_nHeight = res.iHeight;
m_bFullScreen = fullScreen;
@@ -114,7 +120,7 @@ bool CWinSystemGLES::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool b
CreateNewWindow("", fullScreen, res, NULL);
CRenderSystemGLES::ResetRenderSystem(res.iWidth, res.iHeight, true, 0);
-
+#endif
return true;
}
View
5 xbmc/windowing/egl/WinSystemGLES.h
@@ -45,6 +45,7 @@ class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop);
virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays);
virtual void UpdateResolutions();
+ virtual int GetNumScreens() { return 1; }
virtual bool IsExtSupported(const char* extension);
virtual void ShowOSMouse(bool show);
@@ -60,7 +61,11 @@ class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
virtual bool PresentRenderImpl(const CDirtyRegionList &dirty);
virtual void SetVSyncImpl(bool enable);
void *m_display;
+#ifdef fbdev_window
fbdev_window *m_window;
+#else
+ void *m_window;
+#endif
CWinBindingEGL *m_eglBinding;
int m_fb_width;
int m_fb_height;
Something went wrong with that request. Please try again.