1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 12:18:51 -05:00

Added support for GLESv1_CM and GLESv2 client libraries.

This commit is contained in:
Camilla Berglund 2013-01-15 04:26:11 +01:00
parent f8df91d815
commit 0517a82467
6 changed files with 104 additions and 15 deletions

View File

@ -0,0 +1,16 @@
# Find GLESv1
#
# GLESv1_INCLUDE_DIR
# GLESv1_LIBRARY
# GLESv1_FOUND
find_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h)
set(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM)
find_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLESv1 DEFAULT_MSG GLESv1_LIBRARY GLESv1_INCLUDE_DIR)
mark_as_advanced(GLESv1_INCLUDE_DIR GLESv1_LIBRARY)

View File

@ -0,0 +1,16 @@
# Find GLESv2
#
# GLESv2_INCLUDE_DIR
# GLESv2_LIBRARY
# GLESv2_FOUND
find_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h)
set(GLESv2_NAMES ${GLESv2_NAMES} GLESv2)
find_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_LIBRARY GLESv2_INCLUDE_DIR)
mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY)

View File

@ -20,6 +20,19 @@ if (NOT APPLE)
endif() endif()
if (GLFW_USE_EGL) if (GLFW_USE_EGL)
set(GLFW_CLIENT_LIBRARY "opengl" CACHE STRING
"The client library to use; one of: opengl, glesv1 or glesv2")
if (${GLFW_CLIENT_LIBRARY} STREQUAL "opengl")
set(_GLFW_USE_OPENGL 1)
elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "glesv1")
set(_GLFW_USE_GLESV1 1)
elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "glesv2")
set(_GLFW_USE_GLESV2 1)
else()
message(FATAL_ERROR "Unsupported client library")
endif()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/modules) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/modules)
find_package(EGL REQUIRED) find_package(EGL REQUIRED)
@ -27,7 +40,15 @@ if (GLFW_USE_EGL)
set(GLFW_BUILD_TESTS OFF) set(GLFW_BUILD_TESTS OFF)
message(STATUS "NOTE: Examples and tests are disabled for EGL") message(STATUS "NOTE: Examples and tests are disabled for EGL")
else() else()
set(_GLFW_USE_OPENGL 1)
endif()
if (_GLFW_USE_OPENGL)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
elseif (_GLFW_USE_GLESV1)
find_package(GLESv1 REQUIRED)
elseif (_GLFW_USE_GLESV2)
find_package(GLESv2 REQUIRED)
endif() endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
@ -86,14 +107,10 @@ else()
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set up GLFW for Win32 and WGL on Windows # Set up GLFW for Win32
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_WIN32) if (_GLFW_WIN32)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
if (MSVC) if (MSVC)
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON) option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
@ -116,6 +133,14 @@ if (_GLFW_WIN32)
endif() endif()
endif() endif()
#--------------------------------------------------------------------
# Set up GLFW for WGL
#--------------------------------------------------------------------
if (_GLFW_WGL)
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set up GLFW for Xlib and GLX or EGL on Unix-like systems with X Windows # Set up GLFW for Xlib and GLX or EGL on Unix-like systems with X Windows
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -123,8 +148,7 @@ if (_GLFW_X11)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
set(GLFW_PKG_LIBS "") set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} x11")
set(GLFW_PKG_DEPS "x11")
# Set up library and include paths # Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH}) list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH})
@ -183,7 +207,6 @@ endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_GLX) if (_GLFW_GLX)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY}) list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
@ -233,11 +256,10 @@ if (_GLFW_GLX)
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# EGL Context # Use EGL for context creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_EGL) if (_GLFW_EGL)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${EGL_LIBRARY}) list(APPEND glfw_LIBRARIES ${EGL_LIBRARY})
@ -247,10 +269,24 @@ if (_GLFW_EGL)
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl") set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl")
endif() endif()
if (_GLFW_USE_OPENGL)
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} gl")
elseif (_GLFW_USE_GLESV1)
list(APPEND glfw_LIBRARIES ${GLESv1_LIBRARY})
list(APPEND glfw_INCLUDE_DIRS ${GLESv1_INCLUDE_DIR})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} glesv1_cm")
elseif (_GLFW_USE_GLESV2)
list(APPEND glfw_LIBRARIES ${GLESv2_LIBRARY})
list(APPEND glfw_INCLUDE_DIRS ${GLESv2_INCLUDE_DIR})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} glesv2")
endif()
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X # Use Cocoa for window creation and NSOpenGL for context creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_COCOA AND _GLFW_NSGL) if (_GLFW_COCOA AND _GLFW_NSGL)

View File

@ -64,6 +64,13 @@
// Define this to 1 if glXGetProcAddressEXT is available // Define this to 1 if glXGetProcAddressEXT is available
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT
// Define this to 1 if using OpenGL as the client library
#cmakedefine _GLFW_USE_OPENGL
// Define this to 1 if using OpenGL ES 1.1 as the client library
#cmakedefine _GLFW_USE_GLESV1
// Define this to 1 if using OpenGL ES 2.0 as the client library
#cmakedefine _GLFW_USE_GLESV2
// The GLFW version as used by glfwGetVersionString // The GLFW version as used by glfwGetVersionString
#define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@" #define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@"

View File

@ -390,6 +390,7 @@ GLboolean _glfwRefreshContextParams(void)
return GL_FALSE; return GL_FALSE;
} }
#if defined(_GLFW_USE_OPENGL)
if (window->glMajor > 2) if (window->glMajor > 2)
{ {
// OpenGL 3.0+ uses a different function for extension string retrieval // OpenGL 3.0+ uses a different function for extension string retrieval
@ -472,6 +473,7 @@ GLboolean _glfwRefreshContextParams(void)
window->glRobustness = GLFW_NO_RESET_NOTIFICATION; window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
} }
} }
#endif // _GLFW_USE_OPENGL
return GL_TRUE; return GL_TRUE;
} }
@ -659,6 +661,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
return GL_TRUE; return GL_TRUE;
} }
} }
#if defined(_GLFW_USE_OPENGL)
else else
{ {
int i; int i;
@ -677,6 +680,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
} }
} }
} }
#endif // _GLFW_USE_OPENGL
// Check if extension is in the platform-specific string // Check if extension is in the platform-specific string
return _glfwPlatformExtensionSupported(extension); return _glfwPlatformExtensionSupported(extension);

View File

@ -81,16 +81,24 @@ typedef struct _GLFWmonitor _GLFWmonitor;
#include "config.h" #include "config.h"
#if defined(_GLFW_USE_GLESV1)
#define GLFW_INCLUDE_ES1
#elif defined(_GLFW_USE_GLESV2)
#define GLFW_INCLUDE_ES2
#endif
// Disable the inclusion of the platform glext.h by gl.h to allow proper // Disable the inclusion of the platform glext.h by gl.h to allow proper
// inclusion of our own, newer glext.h below // inclusion of our own, newer glext.h below
#define GL_GLEXT_LEGACY #define GL_GLEXT_LEGACY
#include "../include/GL/glfw3.h" #include "../include/GL/glfw3.h"
// This path may need to be changed if you build GLFW using your own setup #if defined(_GLFW_USE_OPENGL)
// We ship and use our own copy of glext.h since GLFW uses fairly new // This path may need to be changed if you build GLFW using your own setup
// extensions and not all operating systems come with an up-to-date version // GLFW comes with its own copy of glext.h since it uses fairly new extensions
#include "../support/GL/glext.h" // and not all development environments come with an up-to-date version
#include "../support/GL/glext.h"
#endif
#if defined(_GLFW_COCOA) #if defined(_GLFW_COCOA)
#include "cocoa_platform.h" #include "cocoa_platform.h"
@ -227,7 +235,9 @@ struct _GLFWwindow
GLboolean glForward, glDebug; GLboolean glForward, glDebug;
int glProfile; int glProfile;
int glRobustness; int glRobustness;
#if defined(_GLFW_USE_OPENGL)
PFNGLGETSTRINGIPROC GetStringi; PFNGLGETSTRINGIPROC GetStringi;
#endif
GLFWwindowposfun windowPosCallback; GLFWwindowposfun windowPosCallback;
GLFWwindowsizefun windowSizeCallback; GLFWwindowsizefun windowSizeCallback;