context: add GLES2 support
OpenGL pulls in lot of X dependencies on linux. To avoid this we also support OpenGLES2 now. This will also allow to run kmscon on embedded/mobile platforms. We still get X dependencies through EGL which we cannot avoid as EGL is compiled with multiple backends on most systems. However, switching to GLES2 reduces memory footprint by 30MB which is pretty good. This also enables GLES2 as default in autogen.sh. However, default behaviour of configure will still be GL. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
67d0b75640
commit
b860e485b4
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
mkdir -p m4/
|
||||
autoreconf -i
|
||||
./configure --enable-debug --enable-pango $*
|
||||
./configure --enable-debug --enable-pango --enable-gles2 $*
|
||||
|
17
configure.ac
17
configure.ac
@ -33,7 +33,22 @@ PKG_CHECK_MODULES([GBM], [gbm])
|
||||
AC_SUBST(GBM_CFLAGS)
|
||||
AC_SUBST(GBM_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES([OPENGL], [gl])
|
||||
AC_MSG_CHECKING([whether to use OpenGLES2 instead of OpenGL])
|
||||
AC_ARG_ENABLE([gles2],
|
||||
[AS_HELP_STRING([--enable-gles2], [whether to use OpenGLES2 instead of OpenGL])],
|
||||
[force_gles2="$enableval";
|
||||
AC_DEFINE([USE_GLES2], [1], [Define if OpenGLES2 should be used])],
|
||||
[force_gles2=no])
|
||||
AC_MSG_RESULT([$force_gles2])
|
||||
|
||||
if test x$force_gles2 = xyes ; then
|
||||
PKG_CHECK_MODULES([OPENGLES2], [glesv2])
|
||||
OPENGL_CFLAGS=$OPENGLES2_CFLAGS
|
||||
OPENGL_LIBS=$OPENGLES2_LIBS
|
||||
else
|
||||
PKG_CHECK_MODULES([OPENGL], [gl])
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENGL_CFLAGS)
|
||||
AC_SUBST(OPENGL_LIBS)
|
||||
|
||||
|
@ -37,8 +37,14 @@
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#ifdef USE_GLES2
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
#include "output.h"
|
||||
@ -362,6 +368,14 @@ int kmscon_context_new(struct kmscon_context **out, void *gbm)
|
||||
EGLint major, minor;
|
||||
int ret;
|
||||
const char *ext;
|
||||
EGLenum api;
|
||||
|
||||
#ifdef USE_GLES2
|
||||
static const EGLint ctx_attribs[] =
|
||||
{ EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||
#else
|
||||
static const EGLint *ctx_attribs = NULL;
|
||||
#endif
|
||||
|
||||
if (!out || !gbm)
|
||||
return -EINVAL;
|
||||
@ -395,14 +409,20 @@ int kmscon_context_new(struct kmscon_context **out, void *gbm)
|
||||
goto err_display;
|
||||
}
|
||||
|
||||
if (!eglBindAPI(EGL_OPENGL_API)) {
|
||||
#ifdef USE_GLES2
|
||||
api = EGL_OPENGL_ES_API;
|
||||
#else
|
||||
api = EGL_OPENGL_API;
|
||||
#endif
|
||||
|
||||
if (!eglBindAPI(api)) {
|
||||
log_warning("context: cannot bind EGL OpenGL API\n");
|
||||
ret = -EFAULT;
|
||||
goto err_display;
|
||||
}
|
||||
|
||||
ctx->context = eglCreateContext(ctx->display, NULL, EGL_NO_CONTEXT,
|
||||
NULL);
|
||||
ctx_attribs);
|
||||
if (!ctx->context) {
|
||||
log_warning("context: cannot create EGL context\n");
|
||||
ret = -EFAULT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user