Commit 46f54d88 authored by Chad Versace's avatar Chad Versace

Merge branch 'maint-1.5'

* maint-1.5:
  cmake: Add cmake PackageConfig files
  cmake: fix version search
  wgl: Verify the client area size matches the required size on window creation too.
  examples/gl_basic: Add option for window size.
  test/gl_basic_test: Address gcc format mismatch warning.
  wgl: Fix requirements for creation of ES2 context
parents cfa7afa2 792072c3
......@@ -128,7 +128,8 @@ if(waffle_build_examples)
endif()
# ------------------------------------------------------------------------------
# Install packaging files: waffle.pc, FindWaffle.cmake
# Install packaging files: waffle.pc, FindWaffle.cmake,
# WaffleConfigVersion.cmake, and WaffleConfig.cmake
# ------------------------------------------------------------------------------
configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
......@@ -145,6 +146,30 @@ install(
COMPONENT cmakefind
)
set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
VERSION "${waffle_version}"
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
cmake/Modules/WaffleConfig.cmake.in
cmake/Modules/WaffleConfig.cmake
INSTALL_DESTINATION "${ConfigPackageLocation}"
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES
"${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
"${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfig.cmake"
DESTINATION "${ConfigPackageLocation}"
COMPONENT devel
)
# ------------------------------------------------------------------------------
# Install core documentation
# ------------------------------------------------------------------------------
......
WaffleConfigVersion.cmake
WaffleConfig.cmake
......@@ -48,8 +48,8 @@ find_library(WAFFLE_LIBRARIES
NAMES "waffle-${WAFFLE_FIND_VERSION_MAJOR}"
)
if(WAFFLE_INCLUDE_DIR AND EXISTS "${WAFFLE_INCLUDE_DIR}/waffle_version.h")
file(STRINGS "${WAFFLE_INCLUDE_DIR}/waffle_version.h" WAFFLE_VERSION_H)
if(WAFFLE_INCLUDE_DIRS AND EXISTS "${WAFFLE_INCLUDE_DIRS}/waffle_version.h")
file(STRINGS "${WAFFLE_INCLUDE_DIRS}/waffle_version.h" WAFFLE_VERSION_H)
string(REGEX REPLACE "^.*WAFFLE_MAJOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MAJOR_VERSION "${WAFFLE_VERSION_H}")
string(REGEX REPLACE "^.*WAFFLE_MINOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MINOR_VERSION "${WAFFLE_VERSION_H}")
string(REGEX REPLACE "^.*WAFFLE_PATCH_VERSION ([0-9]+).*$" "\\1" WAFFLE_PATCH_VERSION "${WAFFLE_VERSION_H}")
......@@ -72,9 +72,7 @@ mark_as_advanced(WAFFLE_LIBRARIES WAFFLE_INCLUDE_DIRS)
# variables from the cache *and* local scope.
#
unset(WAFFLE_FIND_VERSION_MAJOR CACHE)
unset(WAFFLE_INCLUDE_DIR CACHE)
unset(WAFFLE_VERSION_H CACHE)
unset(WAFFLE_FIND_VERSION_MAJOR)
unset(WAFFLE_INCLUDE_DIR)
unset(WAFFLE_VERSION_H)
# Config module for Waffle
#
# Provides the following variables
# Waffle_INCLUDE_DIRS - Directories to include
# Waffle_LIBRARIES - Libraries to link
# Waffle_LIBRARY_DIRS - Library directories to search for link libraries
@PACKAGE_INIT@
set_and_check(Waffle_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@waffle_libname@")
set_and_check(Waffle_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
set(Waffle_LIBRARIES "@waffle_libname@")
......@@ -68,6 +68,7 @@ static const char *usage_message =
" [--forward-compatible]\n"
" [--debug]\n"
" [--resize-window]\n"
" [--window-size=WIDTHxHEIGHT]\n"
"\n"
"examples:\n"
" gl_basic --platform=glx --api=gl\n"
......@@ -96,6 +97,7 @@ enum {
OPT_DEBUG,
OPT_FORWARD_COMPATIBLE,
OPT_RESIZE_WINDOW,
OPT_WINDOW_SIZE,
};
static const struct option get_opts[] = {
......@@ -106,6 +108,7 @@ static const struct option get_opts[] = {
{ .name = "debug", .has_arg = no_argument, .val = OPT_DEBUG },
{ .name = "forward-compatible", .has_arg = no_argument, .val = OPT_FORWARD_COMPATIBLE },
{ .name = "resize-window", .has_arg = no_argument, .val = OPT_RESIZE_WINDOW },
{ .name = "window-size", .has_arg = required_argument, .val = OPT_WINDOW_SIZE },
{ 0 },
};
......@@ -190,8 +193,8 @@ enum {
GL_CONTEXT_FLAG_DEBUG_BIT = 0x00000002,
};
#define WINDOW_WIDTH 320
#define WINDOW_HEIGHT 240
static int window_width = 320;
static int window_height = 240;
#ifndef _WIN32
#define APIENTRY
......@@ -348,6 +351,15 @@ parse_args(int argc, char *argv[], struct options *opts)
case OPT_RESIZE_WINDOW:
opts->resize_window = true;
break;
case OPT_WINDOW_SIZE: {
int match_count;
match_count = sscanf(optarg, "%dx%d", &window_width, &window_height);
if (match_count != 2) {
usage_error_printf("'%s' is not a valid window geometry",
optarg);
}
break;
}
default:
abort();
loop_get_opt = false;
......@@ -389,8 +401,8 @@ draw(struct waffle_window *window, bool resize)
{
bool ok;
unsigned char *colors;
int width = WINDOW_WIDTH;
int height = WINDOW_HEIGHT;
int width = window_width;
int height = window_height;
#if !defined(_WIN32)
static const struct timespec sleep_time = {
......@@ -616,7 +628,7 @@ main(int argc, char **argv)
if (!ctx)
error_waffle();
window = waffle_window_create(config, WINDOW_WIDTH, WINDOW_HEIGHT);
window = waffle_window_create(config, window_width, window_height);
if (!window)
error_waffle();
......
......@@ -118,8 +118,10 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
assert(attrs->context_major_version == 2);
assert(!attrs->context_forward_compatible);
if (!dpy->EXT_create_context_es2_profile) {
if (!dpy->EXT_create_context_es2_profile
&& !dpy->EXT_create_context_es_profile) {
wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
"WGL_EXT_create_context_es_profile or "
"WGL_EXT_create_context_es2_profile is required "
"to create an OpenGL ES2 context");
return false;
......
......@@ -127,6 +127,16 @@ wgl_window_priv_create(struct wcore_platform *wc_plat,
if (!self->hWnd)
goto error;
#ifndef NDEBUG
// Verify the client area size matches the required size.
GetClientRect(self->hWnd, &rect);
assert(rect.left == 0);
assert(rect.top == 0);
assert(rect.right - rect.left == width);
assert(rect.bottom - rect.top == height);
#endif
self->hDC = GetDC(self->hWnd);
if (!self->hDC)
goto error;
......@@ -178,7 +188,7 @@ wgl_window_resize(struct wcore_window *wc_self,
rect.bottom - rect.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
#ifdef DEBUG
#ifndef NDEBUG
// Verify the client area size matches the required size.
GetClientRect(self->hWnd, &rect);
......
......@@ -1129,7 +1129,7 @@ run_testsuite(void (*testsuite)(void))
}
else {
fprintf(stderr, "gl_basic_test: error: get thread exit status"
" failed (%d)\n", GetLastError());
" failed (%lu)\n", GetLastError());
abort();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment