summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2012-04-08 10:04:18 -0700
committerChad Versace <chad.versace@linux.intel.com>2012-04-08 12:37:34 -0700
commit69373a1731fc375eaa3f8eed8f253185e29d3385 (patch)
treebe3e8aaa0d94b14b6e9b3a578702296b46634633
parente069b60396f8e7726e824bdbd3745f30ec5c833b (diff)
waffle: Remove default values for platform and gl_api
The default values were chosen during CMake configuration time. This was a recipe for disaster. libwaffle built by different people would have significant behavioral differences. - Remove the CMake options waffle_default_{platform,gl_api}. - Remove the macros WAFFLE_{PLATFORM,GL_API}_DEFAULT. - Require the user provide attributes WAFFLE_{PLATFORM,GL_API} to waffle_init(). Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r--CMakeLists.txt75
-rw-r--r--include/waffle/waffle_init.h8
-rw-r--r--src/waffle/api/waffle_init.c20
3 files changed, 23 insertions, 80 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a73aab8..ba39a27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,26 +59,6 @@ set(waffle_install_docdir "${CMAKE_INSTALL_PREFIX}/share/doc/waffle"
CACHE PATH "Directory where documentation will be installed")
#
-# Set waffle_default_platform.
-#
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- set(waffle_default_platform_choices "x11_egl (just one choice for now)")
- set(waffle_default_platform_regex "x11_egl")
- set(waffle_default_platform "NOTFOUND"
- CACHE STRING "One of ${waffle_default_platform_choices}")
-endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
-
-#
-# Set waffle_default_gl_api.
-#
-
-set(waffle_default_gl_api_choices "gl, gles1, gles2")
-set(waffle_default_gl_api_regex "gl|gles1|gles2")
-set(waffle_default_gl_api "NOTFOUND"
- CACHE STRING "One of ${waffle_default_gl_api_choices}")
-
-#
# Set waffle_has_{platform}.
#
@@ -113,33 +93,6 @@ else(waffle_has_x11_egl)
set(waffle_has_x11 FALSE)
endif(waffle_has_x11_egl)
-# ----------------------------------------------
-# Validate waffle options
-# ----------------------------------------------
-
-#
-# Validate waffle_default_platform.
-#
-
-if(NOT DEFINED waffle_default_platform)
- message(FATAL_ERROR "Option waffle_default_platform is not defined. Must be one of ${waffle_default_platform_choices}.")
-endif(NOT DEFINED waffle_default_platform)
-
-if(NOT waffle_default_platform MATCHES ${waffle_default_platform_regex})
- message(FATAL_ERROR "Option waffle_default_platform has bad value '${waffle_default_platform}'. Must be one of ${waffle_default_platform_choices}.")
-endif(NOT waffle_default_platform MATCHES ${waffle_default_platform_regex})
-
-#
-# Validate waffle_default_gl_api.
-#
-
-if(NOT DEFINED waffle_default_gl_api)
- message(FATAL_ERROR "Option waffle_default_gl_api is not defined. Must be one of ${waffle_default_gl_api_choices}.")
-endif(NOT DEFINED waffle_default_gl_api)
-
-if(NOT waffle_default_gl_api MATCHES ${waffle_default_gl_api_regex})
- message(FATAL_ERROR "Option waffle_default_gl_api has bad value '${waffle_default_gl_api}'. Must be one of ${waffle_default_gl_api_choices}.")
-endif(NOT waffle_default_gl_api MATCHES ${waffle_default_gl_api_regex})
# ------------------------------------------------------------------------------
# Compiler Flags
@@ -155,30 +108,6 @@ set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-g1 -02 -DNDEBUG")
#
-# Define WAFFLE_PLATFORM_DEFAULT.
-#
-
-if(waffle_default_platform STREQUAL "glx")
- add_definitions(-DWAFFLE_PLATFORM_DEFAULT=WAFFLE_PLATFORM_GLX)
-elseif(waffle_default_platform STREQUAL "wayland")
- add_definitions(-DWAFFLE_PLATFORM_DEFAULT=WAFFLE_PLATFORM_WAYLAND)
-elseif(waffle_default_platform STREQUAL "x11_egl")
- add_definitions(-DWAFFLE_PLATFORM_DEFAULT=WAFFLE_PLATFORM_X11_EGL)
-endif(waffle_default_platform STREQUAL "glx")
-
-#
-# Define macro WAFFLE_GL_API_DEFAULT.
-#
-
-if(waffle_default_gl_api STREQUAL "gl")
- add_definitions(-DWAFFLE_GL_API_DEFAULT=WAFFLE_GL)
-elseif(waffle_default_gl_api STREQUAL "gles1")
- add_definitions(-DWAFFLE_GL_API_DEFAULT=WAFFLE_GLES1)
-elseif(waffle_default_gl_api STREQUAL "gles2")
- add_definitions(-DWAFFLE_GL_API_DEFAULT=WAFFLE_GLES2)
-endif(waffle_default_gl_api STREQUAL "gl")
-
-#
# Define macros WAFFLE_HAS_{PLATFORM}.
#
# Android is not in this list because it uses a separate build system.
@@ -243,10 +172,6 @@ if(DEFINED waffle_X11-xcb_library)
message(" X11-xcb: ${waffle_X11-xcb_library}")
endif(DEFINED waffle_X11-xcb_library)
message("")
-message("Defaults:")
-message(" default platform: ${waffle_default_platform}")
-message(" default GL API: ${waffle_default_gl_api}")
-message("")
message("Build type:")
message(" ${CMAKE_BUILD_TYPE}")
message("")
diff --git a/include/waffle/waffle_init.h b/include/waffle/waffle_init.h
index 544589e..a45155b 100644
--- a/include/waffle/waffle_init.h
+++ b/include/waffle/waffle_init.h
@@ -45,6 +45,11 @@ extern "C" {
/// inherently invalid due to platform or API incompatibilities; for
/// example, desktop OpenGL is not available on Android.
///
+/// @par Required Attributes
+///
+/// - WAFFLE_PLATFORM
+/// - WAFFLE_GL_API
+///
/// @par Example: Invalid Attribute List
///
/// The following is an invalid attribute list because desktop OpenGL is not
@@ -65,7 +70,8 @@ extern "C" {
/// to waffle_init(), but has not been reset with waffle_finish().
///
/// - WAFFLE_BAD_ATTRIBUTE @n
-/// An item in @a attrib_list is unrecognized or has an invalid value.
+/// An item in @a attrib_list is unrecognized, missing, or has an
+/// invalid value.
///
/// - WAFFLE_INCOMPATIBLE_ATTRIBUTES @n
/// The attribute list contains attributes that conflict with each
diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index 28cf00e..d266a41 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -27,10 +27,8 @@ waffle_init_parse_attrib_list(
int *gl_api)
{
const int32_t *i;
-
- // Set defaults.
- *platform = WAFFLE_PLATFORM_DEFAULT;
- *gl_api = WAFFLE_GL_API_DEFAULT;
+ bool found_platform = false;
+ bool found_gl_api = false;
for (i = attrib_list; *i != 0; i += 2) {
const int32_t attr = i[0];
@@ -54,6 +52,7 @@ waffle_init_parse_attrib_list(
#ifdef WAFFLE_HAS_X11_EGL
case WAFFLE_PLATFORM_X11_EGL:
#endif
+ found_platform = true;
*platform = value;
break;
default:
@@ -69,6 +68,7 @@ waffle_init_parse_attrib_list(
case WAFFLE_GL:
case WAFFLE_GLES1:
case WAFFLE_GLES2:
+ found_gl_api = true;
*gl_api = value;
break;
default:
@@ -85,6 +85,18 @@ waffle_init_parse_attrib_list(
}
}
+ if (!found_platform) {
+ wcore_errorf(WAFFLE_BAD_ATTRIBUTE,
+ "attribute list is missing WAFFLE_PLATFORM");
+ return false;
+ }
+
+ if (!found_gl_api) {
+ wcore_errorf(WAFFLE_BAD_ATTRIBUTE,
+ "attribute list is missing WAFFLE_GL_API");
+ return false;
+ }
+
return true;
}