diff --git a/Makefile.am b/Makefile.am index 9572425..ff8c876 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,17 +118,21 @@ libkmscon_core_la_SOURCES = \ src/pty.c src/pty.h \ src/gl.h \ src/gl_math.c \ - src/gl_shader.c \ src/font_pango.c +if KMSCON_HAVE_GLES2 +libkmscon_core_la_SOURCES += \ + src/gl_shader.c +endif + libkmscon_core_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ - $(OPENGLES2_CFLAGS) \ + $(GLES2_CFLAGS) \ $(PANGO_CFLAGS) \ $(FREETYPE2_CFLAGS) \ $(GLIB_CFLAGS) libkmscon_core_la_LIBADD = \ - $(OPENGLES2_LIBS) \ + $(GLES2_LIBS) \ $(PANGO_LIBS) \ $(FREETYPE2_LIBS) \ $(GLIB_LIBS) \ @@ -160,8 +164,7 @@ libuterm_la_CPPFLAGS = \ $(DRM_CFLAGS) \ $(EGL_CFLAGS) \ $(GBM_CFLAGS) \ - $(OPENGL_CFLAGS) \ - $(OPENGLES2_CFLAGS) \ + $(GLES2_CFLAGS) \ $(UDEV_CFLAGS) \ $(XKBCOMMON_CFLAGS) libuterm_la_LIBADD = \ @@ -169,8 +172,7 @@ libuterm_la_LIBADD = \ $(DRM_LIBS) \ $(EGL_LIBS) \ $(GBM_LIBS) \ - $(OPENGL_LIBS) \ - $(OPENGLES2_LIBS) \ + $(GLES2_LIBS) \ $(UDEV_LIBS) \ $(XKBCOMMON_LIBS) \ libkmscon-static.la \ diff --git a/configure.ac b/configure.ac index 0909dad..5c32524 100644 --- a/configure.ac +++ b/configure.ac @@ -70,10 +70,7 @@ PKG_CHECK_MODULES([GBM], [gbm], PKG_CHECK_MODULES([EGL], [egl], [have_egl=yes], [have_egl=no]) -PKG_CHECK_MODULES([OPENGL], [gl], - [have_gl=yes], [have_gl=no]) - -PKG_CHECK_MODULES([OPENGLES2], [glesv2], +PKG_CHECK_MODULES([GLES2], [glesv2], [have_gles2=yes], [have_gles2=no]) PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon], @@ -115,10 +112,10 @@ AC_ARG_ENABLE([drm], [enable uterm drm video backend])]) AC_MSG_RESULT([ok]) -AC_MSG_CHECKING([whether to provide OpenGL support]) -AC_ARG_ENABLE([opengl], - [AS_HELP_STRING([--enable-opengl], - [provide uterm opengl support])]) +AC_MSG_CHECKING([whether to provide OpenGLES2 support]) +AC_ARG_ENABLE([gles2], + [AS_HELP_STRING([--enable-gles2], + [provide uterm OpenGLES2 support])]) AC_MSG_RESULT([ok]) AC_MSG_CHECKING([whether to use xkbcommon keyboard backend]) @@ -243,23 +240,17 @@ AM_CONDITIONAL([UTERM_HAVE_FBDEV], [test x$fbdev_enabled = xyes]) dumb_enabled=no drm_enabled=no -gl_enabled=no gles2_enabled=no if test ! x$enable_drm = xno ; then if test x$have_drm = xyes ; then dumb_enabled=yes fi - if test ! x$enable_opengl = xno ; then + if test ! x$enable_gles2 = xno ; then if test x$have_drm = xyes -a x$have_gbm = xyes -a x$have_egl = xyes ; then - if test x$have_gl = xyes -o x$have_gles2 = xyes ; then + if test x$have_gles2 = xyes ; then drm_enabled=yes - if test x$have_gl = xyes ; then - gl_enabled=yes - fi - if test x$have_gles2 = xyes ; then - gles2_enabled=yes - fi + gles2_enabled=yes fi fi fi @@ -268,14 +259,14 @@ if test ! x$enable_drm = xno ; then AC_ERROR([drm library not found for uterm dumb drm backend]) fi - if test x$enable_opengl = xyes -a x$drm_enabled = xno ; then + if test x$enable_gles2 = xyes -a x$drm_enabled = xno ; then AC_ERROR([drm, gbm, egl, gl or gles2 libraries not found for uterm drm backend]) fi fi if test x$dumb_enabled = xyes ; then AC_DEFINE([UTERM_HAVE_DUMB], [1], - [Use uterm dubm drm video backend]) + [Use uterm dumb drm video backend]) if test x$drm_enabled = xyes ; then AC_DEFINE([UTERM_HAVE_DRM], [1], @@ -291,25 +282,18 @@ else DRM_LIBS="" fi -AM_CONDITIONAL([UTERM_HAVE_DUMB], [test x$dumb_enabled = xyes]) -AM_CONDITIONAL([UTERM_HAVE_DRM], [test x$drm_enabled = xyes]) - -if test x$gl_enabled = xyes ; then - AC_DEFINE([UTERM_HAVE_GL], [1], - [Use OpenGL as drawing backend]) -else - OPENGL_CFLAGS="" - OPENGL_LIBS="" -fi - if test x$gles2_enabled = xyes ; then - AC_DEFINE([UTERM_HAVE_GLES2], [1], + AC_DEFINE([KMSCON_HAVE_GLES2], [1], [Use OpenGLESv2 as drawing backend]) else - OPENGLES2_CFLAGS="" - OPENGLES2_LIBS="" + GLES2_CFLAGS="" + GLES2_LIBS="" fi +AM_CONDITIONAL([UTERM_HAVE_DUMB], [test x$dumb_enabled = xyes]) +AM_CONDITIONAL([UTERM_HAVE_DRM], [test x$drm_enabled = xyes]) +AM_CONDITIONAL([KMSCON_HAVE_GLES2], [test x$gles2_enabled = xyes]) + # # xkbcommon keyboard backend # This checks for the xkbcommon library for keyboard handling in uterm. If it is @@ -348,10 +332,8 @@ AC_SUBST(EGL_CFLAGS) AC_SUBST(EGL_LIBS) AC_SUBST(GBM_CFLAGS) AC_SUBST(GBM_LIBS) -AC_SUBST(OPENGLES2_CFLAGS) -AC_SUBST(OPENGLES2_LIBS) -AC_SUBST(OPENGL_CFLAGS) -AC_SUBST(OPENGL_LIBS) +AC_SUBST(GLES2_CFLAGS) +AC_SUBST(GLES2_LIBS) AC_SUBST(UDEV_CFLAGS) AC_SUBST(UDEV_LIBS) AC_SUBST(XKBCOMMON_CFLAGS) @@ -384,7 +366,6 @@ AC_MSG_NOTICE([Build configuration: fbdev: $fbdev_enabled dumb drm: $dumb_enabled drm: $drm_enabled - opengl: $gl_enabled - opengles2: $gles2_enabled + OpenGLES2: $gles2_enabled Run "make" to start compilation process]) diff --git a/src/gl.h b/src/gl.h index 06182de..f25508d 100644 --- a/src/gl.h +++ b/src/gl.h @@ -37,13 +37,6 @@ #include #include "uterm.h" -/* miscellaneous */ -void gl_clear_error(); -bool gl_has_error(); -void gl_viewport(struct uterm_screen *screen); -void gl_clear_color(float r, float g, float b, float a); -void gl_clear(void); - /* * Math Helpers * The gl_m4 type is a 4x4 matrix of floats. The gl_m4_stack is a stack of m4 @@ -67,6 +60,15 @@ float *gl_m4_stack_push(struct gl_m4_stack *stack); float *gl_m4_stack_pop(struct gl_m4_stack *stack); float *gl_m4_stack_tip(struct gl_m4_stack *stack); +#ifdef KMSCON_HAVE_GLES2 + +/* miscellaneous */ +void gl_clear_error(); +bool gl_has_error(); +void gl_viewport(struct uterm_screen *screen); +void gl_clear_color(float r, float g, float b, float a); +void gl_clear(void); + /* * Texture API * This allows to create new textures which can then be used to draw images with @@ -94,4 +96,87 @@ void gl_shader_draw_tex(struct gl_shader *shader, const float *vertices, const float *texcoords, size_t num, unsigned int tex, const float *m); +#else /* !KMSCON_HAVE_GLES2 */ + +/* dummy helpers for the case that OpenGL is not available */ + +static inline void gl_clear_error() +{ +} + +static inline bool gl_has_error() +{ + return false; +} + +static inline void gl_viewport(struct uterm_screen *screen) +{ +} + +static inline void gl_clear_color(float r, float g, float b, float a) +{ +} + +static inline void gl_clear(void) +{ +} + +/* + * Texture API + * This allows to create new textures which can then be used to draw images with + * the shader API. + */ + +static inline unsigned int gl_tex_new() +{ + return 1; +} + +static inline void gl_tex_free(unsigned int tex) +{ +} + +static inline void gl_tex_load(unsigned int tex, unsigned int width, + unsigned int stride, + unsigned int height, void *buf) +{ +} + +/* + * Shader API + */ + +struct gl_shader { + int unused; +}; + +static inline int gl_shader_new(struct gl_shader **out) +{ + *out = NULL; + return 0; +} + +static inline void gl_shader_ref(struct gl_shader *shader) +{ +} + +static inline void gl_shader_unref(struct gl_shader *shader) +{ +} + +static inline void gl_shader_draw_def(struct gl_shader *shader, + float *vertices, + float *colors, size_t num) +{ +} + +static inline void gl_shader_draw_tex(struct gl_shader *shader, + const float *vertices, + const float *texcoords, size_t num, + unsigned int tex, const float *m) +{ +} + +#endif /* KMSCON_HAVE_GLES2 */ + #endif /* GL_GL_H */