From 5b21579db4cfa09b71a2d04375f50c8dc1be9534 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 9 Aug 2017 20:10:52 +0200 Subject: [PATCH] Add --disable-opengl flag. This flag disables GL, GLES, but also Glew and EGL libraries. --- build/autotools/m4/lol-conf.m4 | 38 +++++++++++++++++--------------- build/autotools/m4/lol-ffmpeg.m4 | 3 ++- build/autotools/m4/lol-gl.m4 | 20 ++++++++++++----- build/autotools/m4/lol-sdl.m4 | 19 ++++++++-------- configure.ac | 4 +++- src/gpu/framebuffer.cpp | 5 +++++ src/gpu/indexbuffer.cpp | 19 +++++++++++----- src/gpu/renderer.cpp | 7 +++++- src/gpu/shader.cpp | 7 +++++- src/gpu/texture.cpp | 19 +++++++++++----- src/gpu/vertexbuffer.cpp | 7 +++++- 11 files changed, 97 insertions(+), 51 deletions(-) diff --git a/build/autotools/m4/lol-conf.m4 b/build/autotools/m4/lol-conf.m4 index c41b3553..b3ab4a56 100644 --- a/build/autotools/m4/lol-conf.m4 +++ b/build/autotools/m4/lol-conf.m4 @@ -1,7 +1,7 @@ dnl dnl Lol Engine dnl -dnl Copyright © 2010—2016 Sam Hocevar +dnl Copyright © 2010—2017 Sam Hocevar dnl dnl Lol Engine is free software. It comes without any warranty, to dnl the extent permitted by applicable law. You can redistribute it @@ -102,25 +102,27 @@ AC_CHECK_LIB(log, __android_log_vprint, AM_CONDITIONAL(LOL_USE_ANDROID, test "${ac_cv_my_have_android}" != "no") -dnl Use EGL? +dnl Use EGL? (autodetect unless GL is disabled) ac_cv_my_have_egl="no" -PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:]) -if test "${ac_cv_my_have_egl}" != "no"; then - AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) - EGL_LIBS="${EGL_LIBS} -lX11" +if test "${enable_gl}" != "no"; then + PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:]) + if test "${ac_cv_my_have_egl}" != "no"; then + AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) + EGL_LIBS="${EGL_LIBS} -lX11" + fi + AC_CHECK_LIB(EGL, main, + [ac_cv_my_have_egl="yes" + AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) + EGL_LIBS="-lEGL"]) + dnl Raspberry Pi is different, check for it with extra libs; also we + dnl look for a different function to bypass autoconf caching + AC_CHECK_LIB(EGL, eglGetDisplay, + [ac_cv_my_have_egl="yes" + AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) + EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"], + [:], + [-lvcos -lvchiq_arm -lbcm_host -lGLESv2]) fi -AC_CHECK_LIB(EGL, main, - [ac_cv_my_have_egl="yes" - AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) - EGL_LIBS="-lEGL"]) -dnl Raspberry Pi is different, check for it with extra libs; also we -dnl look for a different function to bypass autoconf caching -AC_CHECK_LIB(EGL, eglGetDisplay, - [ac_cv_my_have_egl="yes" - AC_DEFINE(LOL_USE_EGL, 1, Define to 1 to use libegl) - EGL_LIBS="-lEGL -lvcos -lvchiq_arm -lbcm_host -lGLESv2"], - [:], - [-lvcos -lvchiq_arm -lbcm_host -lGLESv2]) AM_CONDITIONAL(LOL_USE_EGL, test "${ac_cv_my_have_egl}" != "no") diff --git a/build/autotools/m4/lol-ffmpeg.m4 b/build/autotools/m4/lol-ffmpeg.m4 index 5c8ac90c..2a8a9b11 100644 --- a/build/autotools/m4/lol-ffmpeg.m4 +++ b/build/autotools/m4/lol-ffmpeg.m4 @@ -1,7 +1,7 @@ dnl dnl Lol Engine dnl -dnl Copyright © 2010—2016 Sam Hocevar +dnl Copyright © 2010—2017 Sam Hocevar dnl dnl Lol Engine is free software. It comes without any warranty, to dnl the extent permitted by applicable law. You can redistribute it @@ -15,6 +15,7 @@ dnl # --------------------- AC_DEFUN([LOL_AC_CHECK_FFMPEG], [ +ac_cv_my_have_ffmpeg="no" if test "${enable_ffmpeg}" != "no"; then LOL_AC_CHECK_FFMPEG_INNER() fi diff --git a/build/autotools/m4/lol-gl.m4 b/build/autotools/m4/lol-gl.m4 index 34715387..c5f085b1 100644 --- a/build/autotools/m4/lol-gl.m4 +++ b/build/autotools/m4/lol-gl.m4 @@ -1,7 +1,7 @@ dnl dnl Lol Engine dnl -dnl Copyright © 2010—2016 Sam Hocevar +dnl Copyright © 2010—2017 Sam Hocevar dnl dnl Lol Engine is free software. It comes without any warranty, to dnl the extent permitted by applicable law. You can redistribute it @@ -12,9 +12,20 @@ dnl # LOL_AC_CHECK_OPENGL() -# ------------------ +# --------------------- AC_DEFUN([LOL_AC_CHECK_OPENGL], [ +ac_cv_my_have_glew="no" +if test "${enable_gl}" != "no"; then + LOL_AC_CHECK_OPENGL_INNER() +fi +AM_CONDITIONAL(LOL_USE_GLEW, test "${ac_cv_my_have_glew}" != "no") +]) + +# LOL_AC_CHECK_OPENGL_INNER() +# --------------------------- +AC_DEFUN([LOL_AC_CHECK_OPENGL_INNER], +[ dnl Find which version of OpenGL to use ac_cv_my_have_gl="no" ac_cv_my_stop_looking_for_gl="no" @@ -106,7 +117,6 @@ if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then fi dnl Use Glew? -ac_cv_my_have_glew="no" PKG_CHECK_MODULES(GLEW, glew, [ac_cv_my_have_glew="yes" GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}" @@ -128,7 +138,6 @@ if test "${ac_cv_my_have_glew}" != "no"; then AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) AC_DEFINE(LOL_USE_GLEW, 1, Define to 1 to use libglew) fi -AM_CONDITIONAL(LOL_USE_GLEW, test "${ac_cv_my_have_glew}" != "no") dnl Poor man's GL feature detection if all else failed. save_LIBS="${LIBS}" @@ -141,6 +150,5 @@ if test "${ac_cv_my_have_gl}" = "no"; then AC_MSG_WARN([[No OpenGL or OpenGL ES implementation found]]) fi -]) # LOL_AC_CHECK_OPENGL - +]) # LOL_AC_CHECK_OPENGL_INNER diff --git a/build/autotools/m4/lol-sdl.m4 b/build/autotools/m4/lol-sdl.m4 index 393852ab..73b74499 100644 --- a/build/autotools/m4/lol-sdl.m4 +++ b/build/autotools/m4/lol-sdl.m4 @@ -1,7 +1,7 @@ dnl dnl Lol Engine dnl -dnl Copyright © 2010—2016 Sam Hocevar +dnl Copyright © 2010—2017 Sam Hocevar dnl dnl Lol Engine is free software. It comes without any warranty, to dnl the extent permitted by applicable law. You can redistribute it @@ -15,13 +15,17 @@ dnl # ------------------ AC_DEFUN([LOL_AC_CHECK_SDL], [ +ac_cv_my_have_sdl="no" +ac_cv_my_have_old_sdl="no" +ac_cv_my_have_sdl_image="no" +ac_cv_my_have_sdl_mixer="no" if test "${enable_sdl}" != "no"; then LOL_AC_CHECK_SDL_INNER() fi -AM_CONDITIONAL(LOL_USE_SDL, test "x${ac_cv_my_have_sdl}" = xyes) -AM_CONDITIONAL(LOL_USE_SDL_MIXER, test "x${ac_cv_my_have_sdl_mixer}" = xyes) -AM_CONDITIONAL(LOL_USE_SDL_IMAGE, test "x${ac_cv_my_have_sdl_image}" = xyes) -AM_CONDITIONAL(LOL_USE_OLD_SDL, test "x${ac_cv_my_have_old_sdl}" = xyes) +AM_CONDITIONAL(LOL_USE_SDL, test "${ac_cv_my_have_sdl}" != "no") +AM_CONDITIONAL(LOL_USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" != "no") +AM_CONDITIONAL(LOL_USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" != "no") +AM_CONDITIONAL(LOL_USE_OLD_SDL, test "${ac_cv_my_have_old_sdl}" != "no") ]) # LOL_AC_CHECK_SDL_INNER() @@ -47,11 +51,6 @@ dnl Generated shell variables: dnl SDL_CFLAGS -- flags for SDL compilation dnl SDL_LIBS -- flags for SDL linking -ac_cv_my_have_sdl="no" -ac_cv_my_have_old_sdl="no" -ac_cv_my_have_sdl_image="no" -ac_cv_my_have_sdl_mixer="no" - dnl First, try the proper pkg-config check for SDL2 diff --git a/configure.ac b/configure.ac index 92b9b3a4..08c333be 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl dnl Lol Engine dnl -dnl Copyright © 2010—2016 Sam Hocevar +dnl Copyright © 2010—2017 Sam Hocevar dnl dnl Lol Engine is free software. It comes without any warranty, to dnl the extent permitted by applicable law. You can redistribute it @@ -80,6 +80,8 @@ AC_ARG_ENABLE(experimental, AC_ARG_ENABLE(subproject, [ --enable-subproject build as a subproject (default no)]) +AC_ARG_ENABLE(gl, + [ --enable-gl build using OpenGL or OpenGL ES (default autodetected)]) AC_ARG_ENABLE(ffmpeg, [ --enable-ffmpeg build using FFmpeg (default autodetected)]) AC_ARG_ENABLE(sdl, diff --git a/src/gpu/framebuffer.cpp b/src/gpu/framebuffer.cpp index e3094281..43c845fa 100644 --- a/src/gpu/framebuffer.cpp +++ b/src/gpu/framebuffer.cpp @@ -12,6 +12,9 @@ #include +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + #include "lolgl.h" namespace lol @@ -391,3 +394,5 @@ void Framebuffer::Unbind() } /* namespace lol */ +#endif + diff --git a/src/gpu/indexbuffer.cpp b/src/gpu/indexbuffer.cpp index bec3de37..8ab29bb3 100644 --- a/src/gpu/indexbuffer.cpp +++ b/src/gpu/indexbuffer.cpp @@ -1,15 +1,20 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2017 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + #include "lolgl.h" namespace lol @@ -99,3 +104,5 @@ void IndexBuffer::Unbind() } /* namespace lol */ +#endif + diff --git a/src/gpu/renderer.cpp b/src/gpu/renderer.cpp index 7569a246..c6f3551f 100644 --- a/src/gpu/renderer.cpp +++ b/src/gpu/renderer.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2016 Sam Hocevar +// Copyright © 2010—2017 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -22,6 +22,9 @@ # undef far /* Fuck Microsoft again */ #endif +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + #include "lolgl.h" namespace lol @@ -592,3 +595,5 @@ vec4 Renderer::GetScissorRect() const } /* namespace lol */ +#endif + diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index 390e337b..5fa39dc0 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2015 Sam Hocevar +// Copyright © 2010—2017 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -25,6 +25,9 @@ #include "lolgl.h" +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + namespace lol { @@ -1066,3 +1069,5 @@ void ShaderBuilder::Build(String& code) } /* namespace lol */ +#endif + diff --git a/src/gpu/texture.cpp b/src/gpu/texture.cpp index 11f62e6c..e22eebb3 100644 --- a/src/gpu/texture.cpp +++ b/src/gpu/texture.cpp @@ -1,17 +1,22 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2017 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #include #include "lolgl.h" +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + namespace lol { @@ -176,3 +181,5 @@ Texture::~Texture() } /* namespace lol */ +#endif + diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index d5746020..199fd4a6 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2016 Sam Hocevar +// Copyright © 2010—2017 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -14,6 +14,9 @@ #include "lolgl.h" +// FIXME: fine-tune this define +#if defined LOL_USE_GLEW || defined HAVE_GL_2X || defined HAVE_GLES_2X + namespace lol { @@ -389,3 +392,5 @@ void VertexBuffer::Unlock() } /* namespace lol */ +#endif +