Replaced glLoadGen loader with glad loader and dynamically load EGL and GLES extensions as is done for desktop GL.
This commit is contained in:
parent
f2b8e6397b
commit
2eb70c6537
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
# CLI based examples
|
# CLI based examples
|
||||||
if (NOT SFML_OS_IOS)
|
if (NOT SFML_OS_IOS)
|
||||||
if(SFML_BUILD_NETWORK)
|
if(SFML_BUILD_NETWORK)
|
||||||
|
@ -7,4 +7,4 @@ set(SRC ${SRCROOT}/X11.cpp)
|
|||||||
# define the X11 target
|
# define the X11 target
|
||||||
sfml_add_example(X11Example GUI_APP
|
sfml_add_example(X11Example GUI_APP
|
||||||
SOURCES ${SRC}
|
SOURCES ${SRC}
|
||||||
DEPENDS sfml-window OpenGL X11)
|
DEPENDS sfml-window X11)
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
|
#include "gl.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -23,7 +26,13 @@ void initialize(sf::Window& window)
|
|||||||
|
|
||||||
// Setup OpenGL states
|
// Setup OpenGL states
|
||||||
// Set color and depth clear value
|
// Set color and depth clear value
|
||||||
|
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glClearDepthf(1.f);
|
||||||
|
#else
|
||||||
glClearDepth(1.f);
|
glClearDepth(1.f);
|
||||||
|
#endif
|
||||||
|
|
||||||
glClearColor(0.f, 0.5f, 0.5f, 0.f);
|
glClearColor(0.f, 0.5f, 0.5f, 0.f);
|
||||||
|
|
||||||
// Enable Z-buffer read and write
|
// Enable Z-buffer read and write
|
||||||
@ -33,9 +42,14 @@ void initialize(sf::Window& window)
|
|||||||
// Setup a perspective projection
|
// Setup a perspective projection
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
static const double pi = 3.141592654;
|
static const float pi = 3.141592654f;
|
||||||
GLdouble extent = std::tan(90.0 * pi / 360.0);
|
float extent = std::tan(90.0f * pi / 360.0f);
|
||||||
glFrustum(-extent, extent, -extent, extent, 1.0, 500.0);
|
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||||
|
#else
|
||||||
|
glFrustum(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enable position and texture coordinates vertex components
|
// Enable position and texture coordinates vertex components
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
@ -177,6 +191,15 @@ int main()
|
|||||||
// Create a clock for measuring elapsed time
|
// Create a clock for measuring elapsed time
|
||||||
sf::Clock clock;
|
sf::Clock clock;
|
||||||
|
|
||||||
|
// Load OpenGL or OpenGL ES entry points using glad
|
||||||
|
sfmlView1.setActive();
|
||||||
|
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#else
|
||||||
|
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize our views
|
// Initialize our views
|
||||||
initialize(sfmlView1);
|
initialize(sfmlView1);
|
||||||
initialize(sfmlView2);
|
initialize(sfmlView2);
|
||||||
|
7837
examples/X11/gl.h
Normal file
7837
examples/X11/gl.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -16,5 +16,5 @@ endif()
|
|||||||
sfml_add_example(opengl GUI_APP
|
sfml_add_example(opengl GUI_APP
|
||||||
SOURCES ${SRC}
|
SOURCES ${SRC}
|
||||||
BUNDLE_RESOURCES ${RESOURCES}
|
BUNDLE_RESOURCES ${RESOURCES}
|
||||||
DEPENDS sfml-graphics OpenGL
|
DEPENDS sfml-graphics
|
||||||
RESOURCES_DIR resources)
|
RESOURCES_DIR resources)
|
||||||
|
@ -3,17 +3,14 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
|
#include "gl.h"
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
#include <SFML/Main.hpp>
|
#include <SFML/Main.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SFML_OPENGL_ES
|
|
||||||
#define glClearDepth glClearDepthf
|
|
||||||
#define glFrustum glFrustumf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GL_SRGB8_ALPHA8
|
#ifndef GL_SRGB8_ALPHA8
|
||||||
#define GL_SRGB8_ALPHA8 0x8C43
|
#define GL_SRGB8_ALPHA8 0x8C43
|
||||||
#endif
|
#endif
|
||||||
@ -83,10 +80,21 @@ int main()
|
|||||||
// Make the window the active window for OpenGL calls
|
// Make the window the active window for OpenGL calls
|
||||||
window.setActive(true);
|
window.setActive(true);
|
||||||
|
|
||||||
|
// Load OpenGL or OpenGL ES entry points using glad
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#else
|
||||||
|
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enable Z-buffer read and write
|
// Enable Z-buffer read and write
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glClearDepthf(1.f);
|
||||||
|
#else
|
||||||
glClearDepth(1.f);
|
glClearDepth(1.f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Disable lighting
|
// Disable lighting
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
@ -98,7 +106,11 @@ int main()
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#else
|
||||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Bind the texture
|
// Bind the texture
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -229,7 +241,11 @@ int main()
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#else
|
||||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make the window no longer the active window for OpenGL calls
|
// Make the window no longer the active window for OpenGL calls
|
||||||
window.setActive(false);
|
window.setActive(false);
|
||||||
|
7837
examples/opengl/gl.h
Normal file
7837
examples/opengl/gl.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,4 +7,4 @@ set(SRC ${SRCROOT}/Window.cpp)
|
|||||||
# define the window target
|
# define the window target
|
||||||
sfml_add_example(window GUI_APP
|
sfml_add_example(window GUI_APP
|
||||||
SOURCES ${SRC}
|
SOURCES ${SRC}
|
||||||
DEPENDS sfml-window OpenGL)
|
DEPENDS sfml-window)
|
||||||
|
@ -2,17 +2,14 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
|
#include "gl.h"
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
#include <SFML/Main.hpp>
|
#include <SFML/Main.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SFML_OPENGL_ES
|
|
||||||
#define glClearDepth glClearDepthf
|
|
||||||
#define glFrustum glFrustumf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Entry point of application
|
/// Entry point of application
|
||||||
///
|
///
|
||||||
@ -31,8 +28,19 @@ int main()
|
|||||||
// Make it the active window for OpenGL calls
|
// Make it the active window for OpenGL calls
|
||||||
window.setActive();
|
window.setActive();
|
||||||
|
|
||||||
|
// Load OpenGL or OpenGL ES entry points using glad
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#else
|
||||||
|
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set the color and depth clear values
|
// Set the color and depth clear values
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glClearDepthf(1.f);
|
||||||
|
#else
|
||||||
glClearDepth(1.f);
|
glClearDepth(1.f);
|
||||||
|
#endif
|
||||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
|
||||||
// Enable Z-buffer read and write
|
// Enable Z-buffer read and write
|
||||||
@ -50,7 +58,11 @@ int main()
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#else
|
||||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
||||||
GLfloat cube[] =
|
GLfloat cube[] =
|
||||||
@ -134,7 +146,11 @@ int main()
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
||||||
|
#ifdef SFML_OPENGL_ES
|
||||||
|
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#else
|
||||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7837
examples/window/gl.h
Normal file
7837
examples/window/gl.h
Normal file
File diff suppressed because it is too large
Load Diff
1497
extlibs/headers/glad/include/glad/egl.h
vendored
Normal file
1497
extlibs/headers/glad/include/glad/egl.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7839
extlibs/headers/glad/include/glad/gl.h
vendored
Normal file
7839
extlibs/headers/glad/include/glad/gl.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1043
extlibs/headers/glad/include/glad/glx.h
vendored
Normal file
1043
extlibs/headers/glad/include/glad/glx.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
586
extlibs/headers/glad/include/glad/wgl.h
vendored
Normal file
586
extlibs/headers/glad/include/glad/wgl.h
vendored
Normal file
@ -0,0 +1,586 @@
|
|||||||
|
/**
|
||||||
|
* Loader generated by glad 2.0.0-beta on Wed Jul 17 02:23:29 2019
|
||||||
|
*
|
||||||
|
* Generator: C/C++
|
||||||
|
* Specification: wgl
|
||||||
|
* Extensions: 10
|
||||||
|
*
|
||||||
|
* APIs:
|
||||||
|
* - wgl=1.0
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
* - MX_GLOBAL = False
|
||||||
|
* - ON_DEMAND = False
|
||||||
|
* - LOADER = True
|
||||||
|
* - ALIAS = True
|
||||||
|
* - HEADER_ONLY = True
|
||||||
|
* - DEBUG = False
|
||||||
|
* - MX = False
|
||||||
|
*
|
||||||
|
* Commandline:
|
||||||
|
* --api='wgl=1.0' --extensions='WGL_ARB_create_context,WGL_ARB_create_context_profile,WGL_ARB_extensions_string,WGL_ARB_framebuffer_sRGB,WGL_ARB_multisample,WGL_ARB_pbuffer,WGL_ARB_pixel_format,WGL_EXT_extensions_string,WGL_EXT_framebuffer_sRGB,WGL_EXT_swap_control' c --loader --alias --header-only
|
||||||
|
*
|
||||||
|
* Online:
|
||||||
|
* http://glad.sh/#api=wgl%3D1.0&extensions=WGL_ARB_create_context%2CWGL_ARB_create_context_profile%2CWGL_ARB_extensions_string%2CWGL_ARB_framebuffer_sRGB%2CWGL_ARB_multisample%2CWGL_ARB_pbuffer%2CWGL_ARB_pixel_format%2CWGL_EXT_extensions_string%2CWGL_EXT_framebuffer_sRGB%2CWGL_EXT_swap_control&generator=c&options=LOADER%2CALIAS%2CHEADER_ONLY
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SF_GLAD_WGL_H_
|
||||||
|
#define SF_GLAD_WGL_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <glad/gl.h>
|
||||||
|
|
||||||
|
#define SF_GLAD_WGL
|
||||||
|
#define GLAD_OPTION_WGL_LOADER
|
||||||
|
#define GLAD_OPTION_WGL_ALIAS
|
||||||
|
#define GLAD_OPTION_WGL_HEADER_ONLY
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_H_
|
||||||
|
#define GLAD_PLATFORM_H_
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_WIN32
|
||||||
|
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
|
||||||
|
#define GLAD_PLATFORM_WIN32 1
|
||||||
|
#else
|
||||||
|
#define GLAD_PLATFORM_WIN32 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_APPLE
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define GLAD_PLATFORM_APPLE 1
|
||||||
|
#else
|
||||||
|
#define GLAD_PLATFORM_APPLE 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_EMSCRIPTEN
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#define GLAD_PLATFORM_EMSCRIPTEN 1
|
||||||
|
#else
|
||||||
|
#define GLAD_PLATFORM_EMSCRIPTEN 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_UWP
|
||||||
|
#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
|
||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include(<winapifamily.h>)
|
||||||
|
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||||
|
#endif
|
||||||
|
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||||
|
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
|
||||||
|
#include <winapifamily.h>
|
||||||
|
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||||
|
#define GLAD_PLATFORM_UWP 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_PLATFORM_UWP
|
||||||
|
#define GLAD_PLATFORM_UWP 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define GLAD_GNUC_EXTENSION __extension__
|
||||||
|
#else
|
||||||
|
#define GLAD_GNUC_EXTENSION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAD_API_CALL
|
||||||
|
#if defined(GLAD_API_CALL_EXPORT)
|
||||||
|
#if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
|
||||||
|
#if defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define GLAD_API_CALL __attribute__ ((dllexport)) extern
|
||||||
|
#else
|
||||||
|
#define GLAD_API_CALL __declspec(dllexport) extern
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define GLAD_API_CALL __attribute__ ((dllimport)) extern
|
||||||
|
#else
|
||||||
|
#define GLAD_API_CALL __declspec(dllimport) extern
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||||
|
#define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
|
||||||
|
#else
|
||||||
|
#define GLAD_API_CALL extern
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define GLAD_API_CALL extern
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef APIENTRY
|
||||||
|
#define GLAD_API_PTR APIENTRY
|
||||||
|
#elif GLAD_PLATFORM_WIN32
|
||||||
|
#define GLAD_API_PTR __stdcall
|
||||||
|
#else
|
||||||
|
#define GLAD_API_PTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAPI
|
||||||
|
#define GLAPI GLAD_API_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLAPIENTRY
|
||||||
|
#define GLAPIENTRY GLAD_API_PTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
|
||||||
|
#define GLAD_VERSION_MAJOR(version) (version / 10000)
|
||||||
|
#define GLAD_VERSION_MINOR(version) (version % 10000)
|
||||||
|
|
||||||
|
#define GLAD_GENERATOR_VERSION "2.0.0-beta"
|
||||||
|
|
||||||
|
typedef void (*GLADapiproc)(void);
|
||||||
|
|
||||||
|
typedef GLADapiproc (*GLADloadfunc)(const char *name);
|
||||||
|
typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
|
||||||
|
|
||||||
|
typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||||
|
typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||||
|
|
||||||
|
#endif /* GLAD_PLATFORM_H_ */
|
||||||
|
|
||||||
|
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||||
|
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||||
|
#define WGL_ACCELERATION_ARB 0x2003
|
||||||
|
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||||
|
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||||
|
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||||
|
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||||
|
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||||
|
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||||
|
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||||
|
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||||
|
#define WGL_BLUE_BITS_ARB 0x2019
|
||||||
|
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||||
|
#define WGL_COLOR_BITS_ARB 0x2014
|
||||||
|
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||||
|
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||||
|
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||||
|
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||||
|
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||||
|
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||||
|
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||||
|
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||||
|
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||||
|
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||||
|
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||||
|
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||||
|
#define WGL_FONT_LINES 0
|
||||||
|
#define WGL_FONT_POLYGONS 1
|
||||||
|
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||||
|
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||||
|
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||||
|
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||||
|
#define WGL_GREEN_BITS_ARB 0x2017
|
||||||
|
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||||
|
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||||
|
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||||
|
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||||
|
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||||
|
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||||
|
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||||
|
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||||
|
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||||
|
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||||
|
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||||
|
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||||
|
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||||
|
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||||
|
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||||
|
#define WGL_RED_BITS_ARB 0x2015
|
||||||
|
#define WGL_RED_SHIFT_ARB 0x2016
|
||||||
|
#define WGL_SAMPLES_ARB 0x2042
|
||||||
|
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||||
|
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||||
|
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||||
|
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||||
|
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||||
|
#define WGL_STEREO_ARB 0x2012
|
||||||
|
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||||
|
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||||
|
#define WGL_SWAP_COPY_ARB 0x2029
|
||||||
|
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||||
|
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||||
|
#define WGL_SWAP_MAIN_PLANE 0x00000001
|
||||||
|
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||||
|
#define WGL_SWAP_OVERLAY1 0x00000002
|
||||||
|
#define WGL_SWAP_OVERLAY10 0x00000400
|
||||||
|
#define WGL_SWAP_OVERLAY11 0x00000800
|
||||||
|
#define WGL_SWAP_OVERLAY12 0x00001000
|
||||||
|
#define WGL_SWAP_OVERLAY13 0x00002000
|
||||||
|
#define WGL_SWAP_OVERLAY14 0x00004000
|
||||||
|
#define WGL_SWAP_OVERLAY15 0x00008000
|
||||||
|
#define WGL_SWAP_OVERLAY2 0x00000004
|
||||||
|
#define WGL_SWAP_OVERLAY3 0x00000008
|
||||||
|
#define WGL_SWAP_OVERLAY4 0x00000010
|
||||||
|
#define WGL_SWAP_OVERLAY5 0x00000020
|
||||||
|
#define WGL_SWAP_OVERLAY6 0x00000040
|
||||||
|
#define WGL_SWAP_OVERLAY7 0x00000080
|
||||||
|
#define WGL_SWAP_OVERLAY8 0x00000100
|
||||||
|
#define WGL_SWAP_OVERLAY9 0x00000200
|
||||||
|
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||||
|
#define WGL_SWAP_UNDERLAY1 0x00010000
|
||||||
|
#define WGL_SWAP_UNDERLAY10 0x02000000
|
||||||
|
#define WGL_SWAP_UNDERLAY11 0x04000000
|
||||||
|
#define WGL_SWAP_UNDERLAY12 0x08000000
|
||||||
|
#define WGL_SWAP_UNDERLAY13 0x10000000
|
||||||
|
#define WGL_SWAP_UNDERLAY14 0x20000000
|
||||||
|
#define WGL_SWAP_UNDERLAY15 0x40000000
|
||||||
|
#define WGL_SWAP_UNDERLAY2 0x00020000
|
||||||
|
#define WGL_SWAP_UNDERLAY3 0x00040000
|
||||||
|
#define WGL_SWAP_UNDERLAY4 0x00080000
|
||||||
|
#define WGL_SWAP_UNDERLAY5 0x00100000
|
||||||
|
#define WGL_SWAP_UNDERLAY6 0x00200000
|
||||||
|
#define WGL_SWAP_UNDERLAY7 0x00400000
|
||||||
|
#define WGL_SWAP_UNDERLAY8 0x00800000
|
||||||
|
#define WGL_SWAP_UNDERLAY9 0x01000000
|
||||||
|
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||||
|
#define WGL_TRANSPARENT_ARB 0x200A
|
||||||
|
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||||
|
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||||
|
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||||
|
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||||
|
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||||
|
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct _GPU_DEVICE {
|
||||||
|
DWORD cb;
|
||||||
|
CHAR DeviceName[32];
|
||||||
|
CHAR DeviceString[128];
|
||||||
|
DWORD Flags;
|
||||||
|
RECT rcVirtualScreen;
|
||||||
|
};
|
||||||
|
DECLARE_HANDLE(HPBUFFERARB);
|
||||||
|
DECLARE_HANDLE(HPBUFFEREXT);
|
||||||
|
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||||
|
DECLARE_HANDLE(HPVIDEODEV);
|
||||||
|
DECLARE_HANDLE(HPGPUNV);
|
||||||
|
DECLARE_HANDLE(HGPUNV);
|
||||||
|
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||||
|
typedef struct _GPU_DEVICE GPU_DEVICE;
|
||||||
|
typedef struct _GPU_DEVICE *PGPU_DEVICE;
|
||||||
|
|
||||||
|
|
||||||
|
#define WGL_VERSION_1_0 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_VERSION_1_0;
|
||||||
|
#define WGL_ARB_create_context 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_create_context;
|
||||||
|
#define WGL_ARB_create_context_profile 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_create_context_profile;
|
||||||
|
#define WGL_ARB_extensions_string 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_extensions_string;
|
||||||
|
#define WGL_ARB_framebuffer_sRGB 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_framebuffer_sRGB;
|
||||||
|
#define WGL_ARB_multisample 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_multisample;
|
||||||
|
#define WGL_ARB_pbuffer 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_pbuffer;
|
||||||
|
#define WGL_ARB_pixel_format 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_ARB_pixel_format;
|
||||||
|
#define WGL_EXT_extensions_string 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_EXT_extensions_string;
|
||||||
|
#define WGL_EXT_framebuffer_sRGB 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_EXT_framebuffer_sRGB;
|
||||||
|
#define WGL_EXT_swap_control 1
|
||||||
|
GLAD_API_CALL int SF_GLAD_WGL_EXT_swap_control;
|
||||||
|
|
||||||
|
|
||||||
|
typedef int (GLAD_API_PTR *PFNCHOOSEPIXELFORMATPROC)(HDC hDc, const PIXELFORMATDESCRIPTOR * pPfd);
|
||||||
|
typedef int (GLAD_API_PTR *PFNDESCRIBEPIXELFORMATPROC)(HDC hdc, int ipfd, UINT cjpfd, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||||
|
typedef UINT (GLAD_API_PTR *PFNGETENHMETAFILEPIXELFORMATPROC)(HENHMETAFILE hemf, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||||
|
typedef int (GLAD_API_PTR *PFNGETPIXELFORMATPROC)(HDC hdc);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNSETPIXELFORMATPROC)(HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNSWAPBUFFERSPROC)(HDC hdc);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int * piAttribIList, const FLOAT * pfAttribFList, UINT nMaxFormats, int * piFormats, UINT * nNumFormats);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLCOPYCONTEXTPROC)(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask);
|
||||||
|
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATECONTEXTPROC)(HDC hDc);
|
||||||
|
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, HGLRC hShareContext, const int * attribList);
|
||||||
|
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATELAYERCONTEXTPROC)(HDC hDc, int level);
|
||||||
|
typedef HPBUFFERARB (GLAD_API_PTR *PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int * piAttribList);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLDELETECONTEXTPROC)(HGLRC oldContext);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLDESCRIBELAYERPLANEPROC)(HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, const LAYERPLANEDESCRIPTOR * plpd);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer);
|
||||||
|
typedef HGLRC (GLAD_API_PTR *PFNWGLGETCURRENTCONTEXTPROC)(void);
|
||||||
|
typedef HDC (GLAD_API_PTR *PFNWGLGETCURRENTDCPROC)(void);
|
||||||
|
typedef const char * (GLAD_API_PTR *PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
|
||||||
|
typedef const char * (GLAD_API_PTR *PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||||
|
typedef int (GLAD_API_PTR *PFNWGLGETLAYERPALETTEENTRIESPROC)(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF * pcr);
|
||||||
|
typedef HDC (GLAD_API_PTR *PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int * piAttributes, FLOAT * pfValues);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int * piAttributes, int * piValues);
|
||||||
|
typedef PROC (GLAD_API_PTR *PFNWGLGETPROCADDRESSPROC)(LPCSTR lpszProc);
|
||||||
|
typedef int (GLAD_API_PTR *PFNWGLGETSWAPINTERVALEXTPROC)(void);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLMAKECURRENTPROC)(HDC hDc, HGLRC newContext);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int * piValue);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLREALIZELAYERPALETTEPROC)(HDC hdc, int iLayerPlane, BOOL bRealize);
|
||||||
|
typedef int (GLAD_API_PTR *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC);
|
||||||
|
typedef int (GLAD_API_PTR *PFNWGLSETLAYERPALETTEENTRIESPROC)(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF * pcr);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLSHARELISTSPROC)(HGLRC hrcSrvShare, HGLRC hrcSrvSource);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLSWAPINTERVALEXTPROC)(int interval);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLSWAPLAYERBUFFERSPROC)(HDC hdc, UINT fuFlags);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSAPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSWPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESAPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||||
|
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESWPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||||
|
|
||||||
|
GLAD_API_CALL PFNWGLCHOOSEPIXELFORMATARBPROC sf_glad_wglChoosePixelFormatARB;
|
||||||
|
#define wglChoosePixelFormatARB sf_glad_wglChoosePixelFormatARB
|
||||||
|
GLAD_API_CALL PFNWGLCREATECONTEXTATTRIBSARBPROC sf_glad_wglCreateContextAttribsARB;
|
||||||
|
#define wglCreateContextAttribsARB sf_glad_wglCreateContextAttribsARB
|
||||||
|
GLAD_API_CALL PFNWGLCREATEPBUFFERARBPROC sf_glad_wglCreatePbufferARB;
|
||||||
|
#define wglCreatePbufferARB sf_glad_wglCreatePbufferARB
|
||||||
|
GLAD_API_CALL PFNWGLDESTROYPBUFFERARBPROC sf_glad_wglDestroyPbufferARB;
|
||||||
|
#define wglDestroyPbufferARB sf_glad_wglDestroyPbufferARB
|
||||||
|
GLAD_API_CALL PFNWGLGETEXTENSIONSSTRINGARBPROC sf_glad_wglGetExtensionsStringARB;
|
||||||
|
#define wglGetExtensionsStringARB sf_glad_wglGetExtensionsStringARB
|
||||||
|
GLAD_API_CALL PFNWGLGETEXTENSIONSSTRINGEXTPROC sf_glad_wglGetExtensionsStringEXT;
|
||||||
|
#define wglGetExtensionsStringEXT sf_glad_wglGetExtensionsStringEXT
|
||||||
|
GLAD_API_CALL PFNWGLGETPBUFFERDCARBPROC sf_glad_wglGetPbufferDCARB;
|
||||||
|
#define wglGetPbufferDCARB sf_glad_wglGetPbufferDCARB
|
||||||
|
GLAD_API_CALL PFNWGLGETPIXELFORMATATTRIBFVARBPROC sf_glad_wglGetPixelFormatAttribfvARB;
|
||||||
|
#define wglGetPixelFormatAttribfvARB sf_glad_wglGetPixelFormatAttribfvARB
|
||||||
|
GLAD_API_CALL PFNWGLGETPIXELFORMATATTRIBIVARBPROC sf_glad_wglGetPixelFormatAttribivARB;
|
||||||
|
#define wglGetPixelFormatAttribivARB sf_glad_wglGetPixelFormatAttribivARB
|
||||||
|
GLAD_API_CALL PFNWGLGETSWAPINTERVALEXTPROC sf_glad_wglGetSwapIntervalEXT;
|
||||||
|
#define wglGetSwapIntervalEXT sf_glad_wglGetSwapIntervalEXT
|
||||||
|
GLAD_API_CALL PFNWGLQUERYPBUFFERARBPROC sf_glad_wglQueryPbufferARB;
|
||||||
|
#define wglQueryPbufferARB sf_glad_wglQueryPbufferARB
|
||||||
|
GLAD_API_CALL PFNWGLRELEASEPBUFFERDCARBPROC sf_glad_wglReleasePbufferDCARB;
|
||||||
|
#define wglReleasePbufferDCARB sf_glad_wglReleasePbufferDCARB
|
||||||
|
GLAD_API_CALL PFNWGLSWAPINTERVALEXTPROC sf_glad_wglSwapIntervalEXT;
|
||||||
|
#define wglSwapIntervalEXT sf_glad_wglSwapIntervalEXT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Source */
|
||||||
|
#ifdef SF_GLAD_WGL_IMPLEMENTATION
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef GLAD_IMPL_UTIL_C_
|
||||||
|
#define GLAD_IMPL_UTIL_C_
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define GLAD_IMPL_UTIL_SSCANF sscanf_s
|
||||||
|
#else
|
||||||
|
#define GLAD_IMPL_UTIL_SSCANF sscanf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* GLAD_IMPL_UTIL_C_ */
|
||||||
|
|
||||||
|
|
||||||
|
int SF_GLAD_WGL_VERSION_1_0 = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_create_context = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_create_context_profile = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_extensions_string = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_framebuffer_sRGB = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_multisample = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_pbuffer = 0;
|
||||||
|
int SF_GLAD_WGL_ARB_pixel_format = 0;
|
||||||
|
int SF_GLAD_WGL_EXT_extensions_string = 0;
|
||||||
|
int SF_GLAD_WGL_EXT_framebuffer_sRGB = 0;
|
||||||
|
int SF_GLAD_WGL_EXT_swap_control = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PFNWGLCHOOSEPIXELFORMATARBPROC sf_glad_wglChoosePixelFormatARB = NULL;
|
||||||
|
PFNWGLCREATECONTEXTATTRIBSARBPROC sf_glad_wglCreateContextAttribsARB = NULL;
|
||||||
|
PFNWGLCREATEPBUFFERARBPROC sf_glad_wglCreatePbufferARB = NULL;
|
||||||
|
PFNWGLDESTROYPBUFFERARBPROC sf_glad_wglDestroyPbufferARB = NULL;
|
||||||
|
PFNWGLGETEXTENSIONSSTRINGARBPROC sf_glad_wglGetExtensionsStringARB = NULL;
|
||||||
|
PFNWGLGETEXTENSIONSSTRINGEXTPROC sf_glad_wglGetExtensionsStringEXT = NULL;
|
||||||
|
PFNWGLGETPBUFFERDCARBPROC sf_glad_wglGetPbufferDCARB = NULL;
|
||||||
|
PFNWGLGETPIXELFORMATATTRIBFVARBPROC sf_glad_wglGetPixelFormatAttribfvARB = NULL;
|
||||||
|
PFNWGLGETPIXELFORMATATTRIBIVARBPROC sf_glad_wglGetPixelFormatAttribivARB = NULL;
|
||||||
|
PFNWGLGETSWAPINTERVALEXTPROC sf_glad_wglGetSwapIntervalEXT = NULL;
|
||||||
|
PFNWGLQUERYPBUFFERARBPROC sf_glad_wglQueryPbufferARB = NULL;
|
||||||
|
PFNWGLRELEASEPBUFFERDCARBPROC sf_glad_wglReleasePbufferDCARB = NULL;
|
||||||
|
PFNWGLSWAPINTERVALEXTPROC sf_glad_wglSwapIntervalEXT = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
static void sf_glad_wgl_load_WGL_ARB_create_context(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_ARB_create_context) return;
|
||||||
|
sf_glad_wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) load(userptr, "wglCreateContextAttribsARB");
|
||||||
|
}
|
||||||
|
static void sf_glad_wgl_load_WGL_ARB_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_ARB_extensions_string) return;
|
||||||
|
sf_glad_wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||||
|
}
|
||||||
|
static void sf_glad_wgl_load_WGL_ARB_pbuffer(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_ARB_pbuffer) return;
|
||||||
|
sf_glad_wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) load(userptr, "wglCreatePbufferARB");
|
||||||
|
sf_glad_wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC) load(userptr, "wglDestroyPbufferARB");
|
||||||
|
sf_glad_wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC) load(userptr, "wglGetPbufferDCARB");
|
||||||
|
sf_glad_wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC) load(userptr, "wglQueryPbufferARB");
|
||||||
|
sf_glad_wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC) load(userptr, "wglReleasePbufferDCARB");
|
||||||
|
}
|
||||||
|
static void sf_glad_wgl_load_WGL_ARB_pixel_format(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_ARB_pixel_format) return;
|
||||||
|
sf_glad_wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) load(userptr, "wglChoosePixelFormatARB");
|
||||||
|
sf_glad_wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC) load(userptr, "wglGetPixelFormatAttribfvARB");
|
||||||
|
sf_glad_wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC) load(userptr, "wglGetPixelFormatAttribivARB");
|
||||||
|
}
|
||||||
|
static void sf_glad_wgl_load_WGL_EXT_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_EXT_extensions_string) return;
|
||||||
|
sf_glad_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||||
|
}
|
||||||
|
static void sf_glad_wgl_load_WGL_EXT_swap_control(GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
if(!SF_GLAD_WGL_EXT_swap_control) return;
|
||||||
|
sf_glad_wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) load(userptr, "wglGetSwapIntervalEXT");
|
||||||
|
sf_glad_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) load(userptr, "wglSwapIntervalEXT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void sf_glad_wgl_resolve_aliases(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sf_glad_wgl_has_extension(HDC hdc, const char *ext) {
|
||||||
|
const char *terminator;
|
||||||
|
const char *loc;
|
||||||
|
const char *extensions;
|
||||||
|
|
||||||
|
if(wglGetExtensionsStringEXT == NULL && wglGetExtensionsStringARB == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(wglGetExtensionsStringARB == NULL || hdc == INVALID_HANDLE_VALUE)
|
||||||
|
extensions = wglGetExtensionsStringEXT();
|
||||||
|
else
|
||||||
|
extensions = wglGetExtensionsStringARB(hdc);
|
||||||
|
|
||||||
|
if(extensions == NULL || ext == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
loc = strstr(extensions, ext);
|
||||||
|
if(loc == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
terminator = loc + strlen(ext);
|
||||||
|
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||||
|
(*terminator == ' ' || *terminator == '\0'))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
extensions = terminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLADapiproc sf_glad_wgl_get_proc_from_userptr(void *userptr, const char* name) {
|
||||||
|
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sf_glad_wgl_find_extensions_wgl(HDC hdc) {
|
||||||
|
SF_GLAD_WGL_ARB_create_context = sf_glad_wgl_has_extension(hdc, "WGL_ARB_create_context");
|
||||||
|
SF_GLAD_WGL_ARB_create_context_profile = sf_glad_wgl_has_extension(hdc, "WGL_ARB_create_context_profile");
|
||||||
|
SF_GLAD_WGL_ARB_extensions_string = sf_glad_wgl_has_extension(hdc, "WGL_ARB_extensions_string");
|
||||||
|
SF_GLAD_WGL_ARB_framebuffer_sRGB = sf_glad_wgl_has_extension(hdc, "WGL_ARB_framebuffer_sRGB");
|
||||||
|
SF_GLAD_WGL_ARB_multisample = sf_glad_wgl_has_extension(hdc, "WGL_ARB_multisample");
|
||||||
|
SF_GLAD_WGL_ARB_pbuffer = sf_glad_wgl_has_extension(hdc, "WGL_ARB_pbuffer");
|
||||||
|
SF_GLAD_WGL_ARB_pixel_format = sf_glad_wgl_has_extension(hdc, "WGL_ARB_pixel_format");
|
||||||
|
SF_GLAD_WGL_EXT_extensions_string = sf_glad_wgl_has_extension(hdc, "WGL_EXT_extensions_string");
|
||||||
|
SF_GLAD_WGL_EXT_framebuffer_sRGB = sf_glad_wgl_has_extension(hdc, "WGL_EXT_framebuffer_sRGB");
|
||||||
|
SF_GLAD_WGL_EXT_swap_control = sf_glad_wgl_has_extension(hdc, "WGL_EXT_swap_control");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sf_glad_wgl_find_core_wgl(void) {
|
||||||
|
int major = 1, minor = 0;
|
||||||
|
SF_GLAD_WGL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||||
|
return GLAD_MAKE_VERSION(major, minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gladLoadWGLUserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr) {
|
||||||
|
int version;
|
||||||
|
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||||
|
wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||||
|
if(wglGetExtensionsStringARB == NULL && wglGetExtensionsStringEXT == NULL) return 0;
|
||||||
|
version = sf_glad_wgl_find_core_wgl();
|
||||||
|
|
||||||
|
|
||||||
|
if (!sf_glad_wgl_find_extensions_wgl(hdc)) return 0;
|
||||||
|
sf_glad_wgl_load_WGL_ARB_create_context(load, userptr);
|
||||||
|
sf_glad_wgl_load_WGL_ARB_extensions_string(load, userptr);
|
||||||
|
sf_glad_wgl_load_WGL_ARB_pbuffer(load, userptr);
|
||||||
|
sf_glad_wgl_load_WGL_ARB_pixel_format(load, userptr);
|
||||||
|
sf_glad_wgl_load_WGL_EXT_extensions_string(load, userptr);
|
||||||
|
sf_glad_wgl_load_WGL_EXT_swap_control(load, userptr);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gladLoadWGL(HDC hdc, GLADloadfunc load) {
|
||||||
|
return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SF_GLAD_WGL
|
||||||
|
|
||||||
|
static int gladLoaderLoadWGL(HDC hdc) {
|
||||||
|
return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) wglGetProcAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SF_GLAD_WGL */
|
||||||
|
|
||||||
|
#endif /* SF_GLAD_WGL_IMPLEMENTATION */
|
||||||
|
|
@ -49,10 +49,6 @@ set(SRC
|
|||||||
${SRCROOT}/Vertex.cpp
|
${SRCROOT}/Vertex.cpp
|
||||||
${INCROOT}/Vertex.hpp
|
${INCROOT}/Vertex.hpp
|
||||||
)
|
)
|
||||||
if(NOT SFML_OPENGL_ES)
|
|
||||||
list(APPEND SRC ${SRCROOT}/GLLoader.cpp)
|
|
||||||
list(APPEND SRC ${SRCROOT}/GLLoader.hpp)
|
|
||||||
endif()
|
|
||||||
source_group("" FILES ${SRC})
|
source_group("" FILES ${SRC})
|
||||||
|
|
||||||
# drawables sources
|
# drawables sources
|
||||||
@ -99,6 +95,9 @@ target_link_libraries(sfml-graphics PUBLIC sfml-window)
|
|||||||
# stb_image sources
|
# stb_image sources
|
||||||
target_include_directories(sfml-graphics PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/stb_image")
|
target_include_directories(sfml-graphics PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/stb_image")
|
||||||
|
|
||||||
|
# glad sources
|
||||||
|
target_include_directories(sfml-graphics PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
|
||||||
|
|
||||||
# let CMake know about our additional graphics libraries paths
|
# let CMake know about our additional graphics libraries paths
|
||||||
if(SFML_OS_WINDOWS)
|
if(SFML_OS_WINDOWS)
|
||||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/freetype2")
|
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/freetype2")
|
||||||
@ -112,26 +111,8 @@ elseif(SFML_OS_ANDROID)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# find external libraries
|
# find external libraries
|
||||||
if(SFML_OPENGL_ES)
|
|
||||||
if(SFML_OS_LINUX)
|
|
||||||
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
|
|
||||||
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
|
|
||||||
target_link_libraries(sfml-graphics PRIVATE EGL GLES)
|
|
||||||
elseif(SFML_OS_IOS)
|
|
||||||
target_link_libraries(sfml-graphics PRIVATE "-framework OpenGLES")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# Target OpenGL already defined for Window component so no sfml_find_package() here
|
|
||||||
target_link_libraries(sfml-graphics PRIVATE OpenGL)
|
|
||||||
|
|
||||||
if(SFML_OS_LINUX)
|
|
||||||
# Target X11 already defined for Window component so no sfml_find_package() here
|
|
||||||
target_link_libraries(sfml-graphics PRIVATE X11)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SFML_OS_ANDROID)
|
if(SFML_OS_ANDROID)
|
||||||
target_link_libraries(sfml-graphics PRIVATE z EGL GLESv1_CM)
|
target_link_libraries(sfml-graphics PRIVATE z)
|
||||||
elseif(SFML_OS_IOS)
|
elseif(SFML_OS_IOS)
|
||||||
target_link_libraries(sfml-graphics PRIVATE z bz2)
|
target_link_libraries(sfml-graphics PRIVATE z bz2)
|
||||||
endif()
|
endif()
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#define SF_GLAD_GL_IMPLEMENTATION
|
||||||
#include <SFML/Graphics/GLExtensions.hpp>
|
#include <SFML/Graphics/GLExtensions.hpp>
|
||||||
#include <SFML/Window/Context.hpp>
|
#include <SFML/Window/Context.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
@ -45,13 +46,16 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void ensureExtensionsInit()
|
void ensureExtensionsInit()
|
||||||
{
|
{
|
||||||
#if !defined(SFML_OPENGL_ES)
|
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
sfogl_LoadFunctions();
|
#ifdef SFML_OPENGL_ES
|
||||||
|
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#else
|
||||||
|
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Retrieve the context version number
|
// Retrieve the context version number
|
||||||
int majorVersion = 0;
|
int majorVersion = 0;
|
||||||
@ -85,7 +89,6 @@ void ensureExtensionsInit()
|
|||||||
err() << "Ensure that hardware acceleration is enabled if available" << std::endl;
|
err() << "Ensure that hardware acceleration is enabled if available" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -29,11 +29,10 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
#include <glad/gl.h>
|
||||||
|
|
||||||
#ifdef SFML_OPENGL_ES
|
#ifdef SFML_OPENGL_ES
|
||||||
|
|
||||||
#include <SFML/OpenGL.hpp>
|
|
||||||
|
|
||||||
// SFML requires at a bare minimum OpenGL ES 1.0 capability
|
// SFML requires at a bare minimum OpenGL ES 1.0 capability
|
||||||
// Some extensions only incorporated by 2.0 are also required
|
// Some extensions only incorporated by 2.0 are also required
|
||||||
// OpenGL ES 1.0 is defined relative to OpenGL 1.3
|
// OpenGL ES 1.0 is defined relative to OpenGL 1.3
|
||||||
@ -73,7 +72,7 @@
|
|||||||
// The following extensions are required.
|
// The following extensions are required.
|
||||||
|
|
||||||
// Core since 2.0 - OES_blend_subtract
|
// Core since 2.0 - OES_blend_subtract
|
||||||
#define GLEXT_blend_subtract GL_OES_blend_subtract
|
#define GLEXT_blend_subtract SF_GLAD_GL_OES_blend_subtract
|
||||||
#define GLEXT_glBlendEquation glBlendEquationOES
|
#define GLEXT_glBlendEquation glBlendEquationOES
|
||||||
#define GLEXT_GL_FUNC_ADD GL_FUNC_ADD_OES
|
#define GLEXT_GL_FUNC_ADD GL_FUNC_ADD_OES
|
||||||
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_OES
|
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_OES
|
||||||
@ -82,28 +81,18 @@
|
|||||||
// The following extensions are optional.
|
// The following extensions are optional.
|
||||||
|
|
||||||
// Core since 2.0 - OES_blend_func_separate
|
// Core since 2.0 - OES_blend_func_separate
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#define GLEXT_blend_func_separate SF_GLAD_GL_OES_blend_func_separate
|
||||||
// Hack to make transparency working on some Android devices
|
|
||||||
#define GLEXT_blend_func_separate false
|
|
||||||
#else
|
|
||||||
#define GLEXT_blend_func_separate GL_OES_blend_func_separate
|
|
||||||
#endif
|
|
||||||
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateOES
|
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateOES
|
||||||
|
|
||||||
// Core since 2.0 - OES_blend_equation_separate
|
// Core since 2.0 - OES_blend_equation_separate
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#define GLEXT_blend_equation_separate SF_GLAD_GL_OES_blend_equation_separate
|
||||||
// Hack to make transparency working on some Android devices
|
|
||||||
#define GLEXT_blend_equation_separate false
|
|
||||||
#else
|
|
||||||
#define GLEXT_blend_equation_separate GL_OES_blend_equation_separate
|
|
||||||
#endif
|
|
||||||
#define GLEXT_glBlendEquationSeparate glBlendEquationSeparateOES
|
#define GLEXT_glBlendEquationSeparate glBlendEquationSeparateOES
|
||||||
|
|
||||||
// Core since 2.0 - OES_texture_npot
|
// Core since 2.0 - OES_texture_npot
|
||||||
#define GLEXT_texture_non_power_of_two false
|
#define GLEXT_texture_non_power_of_two false
|
||||||
|
|
||||||
// Core since 2.0 - OES_framebuffer_object
|
// Core since 2.0 - OES_framebuffer_object
|
||||||
#define GLEXT_framebuffer_object GL_OES_framebuffer_object
|
#define GLEXT_framebuffer_object SF_GLAD_GL_OES_framebuffer_object
|
||||||
#define GLEXT_glBindRenderbuffer glBindRenderbufferOES
|
#define GLEXT_glBindRenderbuffer glBindRenderbufferOES
|
||||||
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersOES
|
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||||
#define GLEXT_glGenRenderbuffers glGenRenderbuffersOES
|
#define GLEXT_glGenRenderbuffers glGenRenderbuffersOES
|
||||||
@ -125,30 +114,34 @@
|
|||||||
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
|
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
|
||||||
|
|
||||||
// Core since 3.0
|
// Core since 3.0
|
||||||
#define GLEXT_packed_depth_stencil false
|
#define GLEXT_packed_depth_stencil SF_GLAD_GL_OES_packed_depth_stencil
|
||||||
|
#define GLEXT_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
||||||
|
|
||||||
// Core since 3.0
|
// Core since 3.0
|
||||||
#define GLEXT_framebuffer_blit false
|
#define GLEXT_framebuffer_blit false
|
||||||
|
#define GLEXT_glBlitFramebuffer glBlitFramebufferEXT // Placeholder to satisfy the compiler, entry point is not loaded in GLES
|
||||||
|
#define GLEXT_GL_READ_FRAMEBUFFER 0
|
||||||
|
#define GLEXT_GL_DRAW_FRAMEBUFFER 0
|
||||||
|
#define GLEXT_GL_DRAW_FRAMEBUFFER_BINDING 0
|
||||||
|
#define GLEXT_GL_READ_FRAMEBUFFER_BINDING 0
|
||||||
|
|
||||||
// Core since 3.0
|
// Core since 3.0
|
||||||
#define GLEXT_framebuffer_multisample false
|
#define GLEXT_framebuffer_multisample false
|
||||||
|
#define GLEXT_glRenderbufferStorageMultisample glRenderbufferStorageMultisampleEXT // Placeholder to satisfy the compiler, entry point is not loaded in GLES
|
||||||
|
#define GLEXT_GL_MAX_SAMPLES 0
|
||||||
|
|
||||||
// Core since 3.0 - NV_copy_buffer
|
// Core since 3.0 - NV_copy_buffer
|
||||||
#define GLEXT_copy_buffer false
|
#define GLEXT_copy_buffer false
|
||||||
|
#define GLEXT_GL_COPY_READ_BUFFER 0
|
||||||
|
#define GLEXT_GL_COPY_WRITE_BUFFER 0
|
||||||
|
#define GLEXT_glCopyBufferSubData glCopyBufferSubData // Placeholder to satisfy the compiler, entry point is not loaded in GLES
|
||||||
|
|
||||||
// Core since 3.0 - EXT_sRGB
|
// Core since 3.0 - EXT_sRGB
|
||||||
#ifdef GL_EXT_sRGB
|
#define GLEXT_texture_sRGB false
|
||||||
#define GLEXT_texture_sRGB GL_EXT_sRGB
|
#define GLEXT_GL_SRGB8_ALPHA8 0
|
||||||
#define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
|
|
||||||
#else
|
|
||||||
#define GLEXT_texture_sRGB false
|
|
||||||
#define GLEXT_GL_SRGB8_ALPHA8 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <SFML/Graphics/GLLoader.hpp>
|
|
||||||
|
|
||||||
// SFML requires at a bare minimum OpenGL 1.1 capability
|
// SFML requires at a bare minimum OpenGL 1.1 capability
|
||||||
// All functionality beyond that is optional
|
// All functionality beyond that is optional
|
||||||
// and has to be checked for prior to use
|
// and has to be checked for prior to use
|
||||||
@ -163,35 +156,32 @@
|
|||||||
|
|
||||||
// The following extensions are optional.
|
// The following extensions are optional.
|
||||||
|
|
||||||
// Core since 1.2 - SGIS_texture_edge_clamp
|
// Core since 1.2 - SGIS_texture_edge_clamp / EXT_texture_edge_clamp
|
||||||
#define GLEXT_texture_edge_clamp sfogl_ext_SGIS_texture_edge_clamp
|
#define GLEXT_texture_edge_clamp SF_GLAD_GL_SGIS_texture_edge_clamp
|
||||||
#define GLEXT_GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE_SGIS
|
#define GLEXT_GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE_SGIS
|
||||||
|
|
||||||
// Core since 1.2 - EXT_texture_edge_clamp
|
|
||||||
#define GLEXT_EXT_texture_edge_clamp sfogl_ext_EXT_texture_edge_clamp
|
|
||||||
|
|
||||||
// Core since 1.2 - EXT_blend_minmax
|
// Core since 1.2 - EXT_blend_minmax
|
||||||
#define GLEXT_blend_minmax sfogl_ext_EXT_blend_minmax
|
#define GLEXT_blend_minmax SF_GLAD_GL_EXT_blend_minmax
|
||||||
#define GLEXT_glBlendEquation glBlendEquationEXT
|
#define GLEXT_glBlendEquation glBlendEquationEXT
|
||||||
#define GLEXT_GL_FUNC_ADD GL_FUNC_ADD_EXT
|
#define GLEXT_GL_FUNC_ADD GL_FUNC_ADD_EXT
|
||||||
|
|
||||||
// Core since 1.2 - EXT_blend_subtract
|
// Core since 1.2 - EXT_blend_subtract
|
||||||
#define GLEXT_blend_subtract sfogl_ext_EXT_blend_subtract
|
#define GLEXT_blend_subtract SF_GLAD_GL_EXT_blend_subtract
|
||||||
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_EXT
|
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_EXT
|
||||||
#define GLEXT_GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_EXT
|
#define GLEXT_GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_EXT
|
||||||
|
|
||||||
// Core since 1.3 - ARB_multitexture
|
// Core since 1.3 - ARB_multitexture
|
||||||
#define GLEXT_multitexture sfogl_ext_ARB_multitexture
|
#define GLEXT_multitexture SF_GLAD_GL_ARB_multitexture
|
||||||
#define GLEXT_glClientActiveTexture glClientActiveTextureARB
|
#define GLEXT_glClientActiveTexture glClientActiveTextureARB
|
||||||
#define GLEXT_glActiveTexture glActiveTextureARB
|
#define GLEXT_glActiveTexture glActiveTextureARB
|
||||||
#define GLEXT_GL_TEXTURE0 GL_TEXTURE0_ARB
|
#define GLEXT_GL_TEXTURE0 GL_TEXTURE0_ARB
|
||||||
|
|
||||||
// Core since 1.4 - EXT_blend_func_separate
|
// Core since 1.4 - EXT_blend_func_separate
|
||||||
#define GLEXT_blend_func_separate sfogl_ext_EXT_blend_func_separate
|
#define GLEXT_blend_func_separate SF_GLAD_GL_EXT_blend_func_separate
|
||||||
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateEXT
|
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateEXT
|
||||||
|
|
||||||
// Core since 1.5 - ARB_vertex_buffer_object
|
// Core since 1.5 - ARB_vertex_buffer_object
|
||||||
#define GLEXT_vertex_buffer_object sfogl_ext_ARB_vertex_buffer_object
|
#define GLEXT_vertex_buffer_object SF_GLAD_GL_ARB_vertex_buffer_object
|
||||||
#define GLEXT_GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB
|
#define GLEXT_GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB
|
||||||
#define GLEXT_GL_DYNAMIC_DRAW GL_DYNAMIC_DRAW_ARB
|
#define GLEXT_GL_DYNAMIC_DRAW GL_DYNAMIC_DRAW_ARB
|
||||||
#define GLEXT_GL_READ_ONLY GL_READ_ONLY_ARB
|
#define GLEXT_GL_READ_ONLY GL_READ_ONLY_ARB
|
||||||
@ -207,10 +197,10 @@
|
|||||||
#define GLEXT_glUnmapBuffer glUnmapBufferARB
|
#define GLEXT_glUnmapBuffer glUnmapBufferARB
|
||||||
|
|
||||||
// Core since 2.0 - ARB_shading_language_100
|
// Core since 2.0 - ARB_shading_language_100
|
||||||
#define GLEXT_shading_language_100 sfogl_ext_ARB_shading_language_100
|
#define GLEXT_shading_language_100 SF_GLAD_GL_ARB_shading_language_100
|
||||||
|
|
||||||
// Core since 2.0 - ARB_shader_objects
|
// Core since 2.0 - ARB_shader_objects
|
||||||
#define GLEXT_shader_objects sfogl_ext_ARB_shader_objects
|
#define GLEXT_shader_objects SF_GLAD_GL_ARB_shader_objects
|
||||||
#define GLEXT_glDeleteObject glDeleteObjectARB
|
#define GLEXT_glDeleteObject glDeleteObjectARB
|
||||||
#define GLEXT_glGetHandle glGetHandleARB
|
#define GLEXT_glGetHandle glGetHandleARB
|
||||||
#define GLEXT_glCreateShaderObject glCreateShaderObjectARB
|
#define GLEXT_glCreateShaderObject glCreateShaderObjectARB
|
||||||
@ -244,27 +234,27 @@
|
|||||||
#define GLEXT_GLhandle GLhandleARB
|
#define GLEXT_GLhandle GLhandleARB
|
||||||
|
|
||||||
// Core since 2.0 - ARB_vertex_shader
|
// Core since 2.0 - ARB_vertex_shader
|
||||||
#define GLEXT_vertex_shader sfogl_ext_ARB_vertex_shader
|
#define GLEXT_vertex_shader SF_GLAD_GL_ARB_vertex_shader
|
||||||
#define GLEXT_GL_VERTEX_SHADER GL_VERTEX_SHADER_ARB
|
#define GLEXT_GL_VERTEX_SHADER GL_VERTEX_SHADER_ARB
|
||||||
#define GLEXT_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
|
#define GLEXT_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
|
||||||
|
|
||||||
// Core since 2.0 - ARB_fragment_shader
|
// Core since 2.0 - ARB_fragment_shader
|
||||||
#define GLEXT_fragment_shader sfogl_ext_ARB_fragment_shader
|
#define GLEXT_fragment_shader SF_GLAD_GL_ARB_fragment_shader
|
||||||
#define GLEXT_GL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB
|
#define GLEXT_GL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB
|
||||||
|
|
||||||
// Core since 2.0 - ARB_texture_non_power_of_two
|
// Core since 2.0 - ARB_texture_non_power_of_two
|
||||||
#define GLEXT_texture_non_power_of_two sfogl_ext_ARB_texture_non_power_of_two
|
#define GLEXT_texture_non_power_of_two SF_GLAD_GL_ARB_texture_non_power_of_two
|
||||||
|
|
||||||
// Core since 2.0 - EXT_blend_equation_separate
|
// Core since 2.0 - EXT_blend_equation_separate
|
||||||
#define GLEXT_blend_equation_separate sfogl_ext_EXT_blend_equation_separate
|
#define GLEXT_blend_equation_separate SF_GLAD_GL_EXT_blend_equation_separate
|
||||||
#define GLEXT_glBlendEquationSeparate glBlendEquationSeparateEXT
|
#define GLEXT_glBlendEquationSeparate glBlendEquationSeparateEXT
|
||||||
|
|
||||||
// Core since 2.1 - EXT_texture_sRGB
|
// Core since 2.1 - EXT_texture_sRGB
|
||||||
#define GLEXT_texture_sRGB sfogl_ext_EXT_texture_sRGB
|
#define GLEXT_texture_sRGB SF_GLAD_GL_EXT_texture_sRGB
|
||||||
#define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
|
#define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
|
||||||
|
|
||||||
// Core since 3.0 - EXT_framebuffer_object
|
// Core since 3.0 - EXT_framebuffer_object
|
||||||
#define GLEXT_framebuffer_object sfogl_ext_EXT_framebuffer_object
|
#define GLEXT_framebuffer_object SF_GLAD_GL_EXT_framebuffer_object
|
||||||
#define GLEXT_glBindRenderbuffer glBindRenderbufferEXT
|
#define GLEXT_glBindRenderbuffer glBindRenderbufferEXT
|
||||||
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersEXT
|
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersEXT
|
||||||
#define GLEXT_glGenRenderbuffers glGenRenderbuffersEXT
|
#define GLEXT_glGenRenderbuffers glGenRenderbuffersEXT
|
||||||
@ -286,11 +276,11 @@
|
|||||||
#define GLEXT_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
#define GLEXT_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
||||||
|
|
||||||
// Core since 3.0 - EXT_packed_depth_stencil
|
// Core since 3.0 - EXT_packed_depth_stencil
|
||||||
#define GLEXT_packed_depth_stencil sfogl_ext_EXT_packed_depth_stencil
|
#define GLEXT_packed_depth_stencil SF_GLAD_GL_EXT_packed_depth_stencil
|
||||||
#define GLEXT_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
#define GLEXT_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
||||||
|
|
||||||
// Core since 3.0 - EXT_framebuffer_blit
|
// Core since 3.0 - EXT_framebuffer_blit
|
||||||
#define GLEXT_framebuffer_blit sfogl_ext_EXT_framebuffer_blit
|
#define GLEXT_framebuffer_blit SF_GLAD_GL_EXT_framebuffer_blit
|
||||||
#define GLEXT_glBlitFramebuffer glBlitFramebufferEXT
|
#define GLEXT_glBlitFramebuffer glBlitFramebufferEXT
|
||||||
#define GLEXT_GL_READ_FRAMEBUFFER GL_READ_FRAMEBUFFER_EXT
|
#define GLEXT_GL_READ_FRAMEBUFFER GL_READ_FRAMEBUFFER_EXT
|
||||||
#define GLEXT_GL_DRAW_FRAMEBUFFER GL_DRAW_FRAMEBUFFER_EXT
|
#define GLEXT_GL_DRAW_FRAMEBUFFER GL_DRAW_FRAMEBUFFER_EXT
|
||||||
@ -298,18 +288,18 @@
|
|||||||
#define GLEXT_GL_READ_FRAMEBUFFER_BINDING GL_READ_FRAMEBUFFER_BINDING_EXT
|
#define GLEXT_GL_READ_FRAMEBUFFER_BINDING GL_READ_FRAMEBUFFER_BINDING_EXT
|
||||||
|
|
||||||
// Core since 3.0 - EXT_framebuffer_multisample
|
// Core since 3.0 - EXT_framebuffer_multisample
|
||||||
#define GLEXT_framebuffer_multisample sfogl_ext_EXT_framebuffer_multisample
|
#define GLEXT_framebuffer_multisample SF_GLAD_GL_EXT_framebuffer_multisample
|
||||||
#define GLEXT_glRenderbufferStorageMultisample glRenderbufferStorageMultisampleEXT
|
#define GLEXT_glRenderbufferStorageMultisample glRenderbufferStorageMultisampleEXT
|
||||||
#define GLEXT_GL_MAX_SAMPLES GL_MAX_SAMPLES_EXT
|
#define GLEXT_GL_MAX_SAMPLES GL_MAX_SAMPLES_EXT
|
||||||
|
|
||||||
// Core since 3.1 - ARB_copy_buffer
|
// Core since 3.1 - ARB_copy_buffer
|
||||||
#define GLEXT_copy_buffer sfogl_ext_ARB_copy_buffer
|
#define GLEXT_copy_buffer SF_GLAD_GL_ARB_copy_buffer
|
||||||
#define GLEXT_GL_COPY_READ_BUFFER GL_COPY_READ_BUFFER
|
#define GLEXT_GL_COPY_READ_BUFFER GL_COPY_READ_BUFFER
|
||||||
#define GLEXT_GL_COPY_WRITE_BUFFER GL_COPY_WRITE_BUFFER
|
#define GLEXT_GL_COPY_WRITE_BUFFER GL_COPY_WRITE_BUFFER
|
||||||
#define GLEXT_glCopyBufferSubData glCopyBufferSubData
|
#define GLEXT_glCopyBufferSubData glCopyBufferSubData
|
||||||
|
|
||||||
// Core since 3.2 - ARB_geometry_shader4
|
// Core since 3.2 - ARB_geometry_shader4
|
||||||
#define GLEXT_geometry_shader4 sfogl_ext_ARB_geometry_shader4
|
#define GLEXT_geometry_shader4 SF_GLAD_GL_ARB_geometry_shader4
|
||||||
#define GLEXT_GL_GEOMETRY_SHADER GL_GEOMETRY_SHADER_ARB
|
#define GLEXT_GL_GEOMETRY_SHADER GL_GEOMETRY_SHADER_ARB
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -43,11 +43,11 @@
|
|||||||
|
|
||||||
|
|
||||||
// GL_QUADS is unavailable on OpenGL ES, thus we need to define GL_QUADS ourselves
|
// GL_QUADS is unavailable on OpenGL ES, thus we need to define GL_QUADS ourselves
|
||||||
#ifdef SFML_OPENGL_ES
|
#ifndef GL_QUADS
|
||||||
|
|
||||||
#define GL_QUADS 0
|
#define GL_QUADS 0
|
||||||
|
|
||||||
#endif // SFML_OPENGL_ES
|
#endif // GL_QUADS
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -162,7 +162,7 @@ bool Texture::create(unsigned int width, unsigned int height)
|
|||||||
// Make sure that the current texture binding will be preserved
|
// Make sure that the current texture binding will be preserved
|
||||||
priv::TextureSaver save;
|
priv::TextureSaver save;
|
||||||
|
|
||||||
static bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_EXT_texture_edge_clamp;
|
static bool textureEdgeClamp = GLEXT_texture_edge_clamp;
|
||||||
|
|
||||||
if (!m_isRepeated && !textureEdgeClamp)
|
if (!m_isRepeated && !textureEdgeClamp)
|
||||||
{
|
{
|
||||||
@ -655,7 +655,7 @@ void Texture::setRepeated(bool repeated)
|
|||||||
// Make sure that the current texture binding will be preserved
|
// Make sure that the current texture binding will be preserved
|
||||||
priv::TextureSaver save;
|
priv::TextureSaver save;
|
||||||
|
|
||||||
static bool textureEdgeClamp = GLEXT_texture_edge_clamp || GLEXT_EXT_texture_edge_clamp;
|
static bool textureEdgeClamp = GLEXT_texture_edge_clamp;
|
||||||
|
|
||||||
if (!m_isRepeated && !textureEdgeClamp)
|
if (!m_isRepeated && !textureEdgeClamp)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,11 @@ endif()
|
|||||||
# define the sfml-main target
|
# define the sfml-main target
|
||||||
sfml_add_library(sfml-main STATIC SOURCES ${SRC})
|
sfml_add_library(sfml-main STATIC SOURCES ${SRC})
|
||||||
|
|
||||||
|
if(SFML_OS_ANDROID)
|
||||||
|
# glad sources
|
||||||
|
target_include_directories(sfml-main PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
# overwrite sfml-main suffix for backward compatibility with FindSFML.cmake
|
# overwrite sfml-main suffix for backward compatibility with FindSFML.cmake
|
||||||
set_target_properties(sfml-main PROPERTIES
|
set_target_properties(sfml-main PROPERTIES
|
||||||
DEBUG_POSTFIX -d
|
DEBUG_POSTFIX -d
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
#include <android/native_activity.h>
|
#include <android/native_activity.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#define SF_GLAD_EGL_IMPLEMENTATION
|
||||||
|
#include <glad/egl.h>
|
||||||
|
|
||||||
|
|
||||||
extern int main(int argc, char *argv[]);
|
extern int main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <SFML/System/Mutex.hpp>
|
#include <SFML/System/Mutex.hpp>
|
||||||
#include <android/native_activity.h>
|
#include <android/native_activity.h>
|
||||||
#include <android/configuration.h>
|
#include <android/configuration.h>
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -89,6 +89,11 @@ endif()
|
|||||||
sfml_add_library(sfml-system
|
sfml_add_library(sfml-system
|
||||||
SOURCES ${SRC} ${PLATFORM_SRC})
|
SOURCES ${SRC} ${PLATFORM_SRC})
|
||||||
|
|
||||||
|
if(SFML_OS_ANDROID)
|
||||||
|
# glad sources
|
||||||
|
target_include_directories(sfml-system PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
# setup dependencies
|
# setup dependencies
|
||||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||||
target_link_libraries(sfml-system PRIVATE pthread)
|
target_link_libraries(sfml-system PRIVATE pthread)
|
||||||
|
@ -12,6 +12,10 @@ set(SRC
|
|||||||
${SRCROOT}/Cursor.cpp
|
${SRCROOT}/Cursor.cpp
|
||||||
${INCROOT}/Cursor.hpp
|
${INCROOT}/Cursor.hpp
|
||||||
${SRCROOT}/CursorImpl.hpp
|
${SRCROOT}/CursorImpl.hpp
|
||||||
|
${SRCROOT}/EGLCheck.cpp
|
||||||
|
${SRCROOT}/EGLCheck.hpp
|
||||||
|
${SRCROOT}/EglContext.cpp
|
||||||
|
${SRCROOT}/EglContext.hpp
|
||||||
${INCROOT}/Export.hpp
|
${INCROOT}/Export.hpp
|
||||||
${SRCROOT}/GlContext.cpp
|
${SRCROOT}/GlContext.cpp
|
||||||
${SRCROOT}/GlContext.hpp
|
${SRCROOT}/GlContext.hpp
|
||||||
@ -48,12 +52,6 @@ set(SRC
|
|||||||
${SRCROOT}/WindowImpl.hpp
|
${SRCROOT}/WindowImpl.hpp
|
||||||
${INCROOT}/WindowStyle.hpp
|
${INCROOT}/WindowStyle.hpp
|
||||||
)
|
)
|
||||||
if(SFML_OPENGL_ES AND NOT SFML_OS_IOS)
|
|
||||||
list(APPEND SRC ${SRCROOT}/EGLCheck.cpp)
|
|
||||||
list(APPEND SRC ${SRCROOT}/EGLCheck.hpp)
|
|
||||||
list(APPEND SRC ${SRCROOT}/EglContext.cpp)
|
|
||||||
list(APPEND SRC ${SRCROOT}/EglContext.hpp)
|
|
||||||
endif()
|
|
||||||
source_group("" FILES ${SRC})
|
source_group("" FILES ${SRC})
|
||||||
|
|
||||||
# add platform specific sources
|
# add platform specific sources
|
||||||
@ -65,8 +63,6 @@ if(SFML_OS_WINDOWS)
|
|||||||
${SRCROOT}/Win32/ClipboardImpl.cpp
|
${SRCROOT}/Win32/ClipboardImpl.cpp
|
||||||
${SRCROOT}/Win32/WglContext.cpp
|
${SRCROOT}/Win32/WglContext.cpp
|
||||||
${SRCROOT}/Win32/WglContext.hpp
|
${SRCROOT}/Win32/WglContext.hpp
|
||||||
${SRCROOT}/Win32/WglExtensions.cpp
|
|
||||||
${SRCROOT}/Win32/WglExtensions.hpp
|
|
||||||
${SRCROOT}/Win32/InputImpl.cpp
|
${SRCROOT}/Win32/InputImpl.cpp
|
||||||
${SRCROOT}/Win32/InputImpl.hpp
|
${SRCROOT}/Win32/InputImpl.hpp
|
||||||
${SRCROOT}/Win32/JoystickImpl.cpp
|
${SRCROOT}/Win32/JoystickImpl.cpp
|
||||||
@ -97,13 +93,11 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
|
|||||||
${SRCROOT}/Unix/WindowImplX11.cpp
|
${SRCROOT}/Unix/WindowImplX11.cpp
|
||||||
${SRCROOT}/Unix/WindowImplX11.hpp
|
${SRCROOT}/Unix/WindowImplX11.hpp
|
||||||
)
|
)
|
||||||
if(NOT SFML_OPENGL_ES)
|
if(NOT SFML_OS_ANDROID)
|
||||||
set(PLATFORM_SRC
|
set(PLATFORM_SRC
|
||||||
${PLATFORM_SRC}
|
${PLATFORM_SRC}
|
||||||
${SRCROOT}/Unix/GlxContext.cpp
|
${SRCROOT}/Unix/GlxContext.cpp
|
||||||
${SRCROOT}/Unix/GlxContext.hpp
|
${SRCROOT}/Unix/GlxContext.hpp
|
||||||
${SRCROOT}/Unix/GlxExtensions.cpp
|
|
||||||
${SRCROOT}/Unix/GlxExtensions.hpp
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(SFML_OS_LINUX)
|
if(SFML_OS_LINUX)
|
||||||
@ -231,6 +225,9 @@ sfml_add_library(sfml-window
|
|||||||
SOURCES ${SRC} ${PLATFORM_SRC})
|
SOURCES ${SRC} ${PLATFORM_SRC})
|
||||||
target_link_libraries(sfml-window PUBLIC sfml-system)
|
target_link_libraries(sfml-window PUBLIC sfml-system)
|
||||||
|
|
||||||
|
# glad sources
|
||||||
|
target_include_directories(sfml-window PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/glad/include")
|
||||||
|
|
||||||
# When static linking on macOS, we need to add this flag for objective C to work
|
# When static linking on macOS, we need to add this flag for objective C to work
|
||||||
if ((NOT BUILD_SHARED_LIBS) AND SFML_OS_MACOSX)
|
if ((NOT BUILD_SHARED_LIBS) AND SFML_OS_MACOSX)
|
||||||
target_link_libraries(sfml-window PRIVATE -ObjC)
|
target_link_libraries(sfml-window PRIVATE -ObjC)
|
||||||
@ -249,16 +246,20 @@ if ((NOT ${CMAKE_VERSION} VERSION_LESS 3.11) AND (NOT OpenGL_GL_PREFERENCE))
|
|||||||
set(OpenGL_GL_PREFERENCE "LEGACY")
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OPENGL_ES)
|
if(SFML_OS_IOS)
|
||||||
if(SFML_OS_IOS)
|
sfml_add_external(GLES LINK "-framework OpenGLES")
|
||||||
sfml_add_external(OpenGL LINK "-framework OpenGLES")
|
|
||||||
elseif(SFML_OS_ANDROID)
|
target_link_libraries(sfml-window PRIVATE GLES)
|
||||||
sfml_add_external(OpenGL LINK "EGL" "GLESv1_CM")
|
elseif(SFML_OS_ANDROID)
|
||||||
endif()
|
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
|
||||||
|
|
||||||
|
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
|
||||||
|
target_link_libraries(sfml-window PRIVATE EGL)
|
||||||
|
target_link_libraries(sfml-window PRIVATE GLES)
|
||||||
else()
|
else()
|
||||||
sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_gl_LIBRARY")
|
sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_gl_LIBRARY")
|
||||||
|
target_link_libraries(sfml-window PRIVATE OpenGL)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(sfml-window PRIVATE OpenGL)
|
|
||||||
|
|
||||||
if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
@ -268,15 +269,9 @@ if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OPENGL_ES AND SFML_OS_LINUX)
|
|
||||||
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
|
|
||||||
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
|
|
||||||
target_link_libraries(sfml-window PRIVATE EGL GLES)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SFML_OS_LINUX)
|
if(SFML_OS_LINUX)
|
||||||
sfml_find_package(UDev INCLUDE "UDEV_INCLUDE_DIR" LINK "UDEV_LIBRARIES")
|
sfml_find_package(UDev INCLUDE "UDEV_INCLUDE_DIR" LINK "UDEV_LIBRARIES")
|
||||||
target_link_libraries(sfml-window PRIVATE UDev)
|
target_link_libraries(sfml-window PRIVATE UDev dl)
|
||||||
elseif(SFML_OS_WINDOWS)
|
elseif(SFML_OS_WINDOWS)
|
||||||
target_link_libraries(sfml-window PRIVATE winmm gdi32)
|
target_link_libraries(sfml-window PRIVATE winmm gdi32)
|
||||||
elseif(SFML_OS_FREEBSD)
|
elseif(SFML_OS_FREEBSD)
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/EGLCheck.hpp>
|
#include <SFML/Window/EGLCheck.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
|
#include <glad/egl.h>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -35,7 +36,7 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void eglCheckError(const char* file, unsigned int line)
|
void eglCheckError(const char* file, unsigned int line, const char* expression)
|
||||||
{
|
{
|
||||||
// Obtain information about the success or failure of the most recent EGL
|
// Obtain information about the success or failure of the most recent EGL
|
||||||
// function called in the current thread
|
// function called in the current thread
|
||||||
@ -152,7 +153,8 @@ void eglCheckError(const char* file, unsigned int line)
|
|||||||
// Log the error
|
// Log the error
|
||||||
err() << "An internal EGL call failed in "
|
err() << "An internal EGL call failed in "
|
||||||
<< fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : "
|
<< fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : "
|
||||||
<< error << ", " << description
|
<< "\nExpression:\n " << expression
|
||||||
|
<< "\nError description:\n " << error << "\n " << description << "\n"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@ -42,8 +41,9 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#ifdef SFML_DEBUG
|
#ifdef SFML_DEBUG
|
||||||
|
|
||||||
//// In debug mode, perform a test on every EGL call
|
// In debug mode, perform a test on every EGL call
|
||||||
#define eglCheck(x) x; sf::priv::eglCheckError(__FILE__, __LINE__);
|
// The do-while loop is needed so that glCheck can be used as a single statement in if/else branches
|
||||||
|
#define eglCheck(expr) do { expr; sf::priv::eglCheckError(__FILE__, __LINE__, #expr); } while (false)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -57,9 +57,10 @@ namespace priv
|
|||||||
///
|
///
|
||||||
/// \param file Source file where the call is located
|
/// \param file Source file where the call is located
|
||||||
/// \param line Line number of the source file where the call is located
|
/// \param line Line number of the source file where the call is located
|
||||||
|
/// \param expression The evaluated expression as a string
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void eglCheckError(const char* file, unsigned int line);
|
void eglCheckError(const char* file, unsigned int line, const char* expression);
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/EglContext.hpp>
|
#include <SFML/Window/EglContext.hpp>
|
||||||
#include <SFML/Window/WindowImpl.hpp>
|
#include <SFML/Window/WindowImpl.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <SFML/System/Sleep.hpp>
|
#include <SFML/System/Sleep.hpp>
|
||||||
#include <SFML/System/Mutex.hpp>
|
#include <SFML/System/Mutex.hpp>
|
||||||
@ -40,31 +39,50 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SF_GLAD_EGL_IMPLEMENTATION
|
||||||
|
#include <glad/egl.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
EGLDisplay getInitializedDisplay()
|
EGLDisplay getInitializedDisplay()
|
||||||
{
|
{
|
||||||
#if defined(SFML_SYSTEM_LINUX)
|
#if defined(SFML_SYSTEM_ANDROID)
|
||||||
|
|
||||||
|
// On Android, its native activity handles this for us
|
||||||
|
sf::priv::ActivityStates* states = sf::priv::getActivity(NULL);
|
||||||
|
sf::Lock lock(states->mutex);
|
||||||
|
|
||||||
|
return states->display;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static EGLDisplay display = EGL_NO_DISPLAY;
|
static EGLDisplay display = EGL_NO_DISPLAY;
|
||||||
|
|
||||||
if (display == EGL_NO_DISPLAY)
|
if (display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
display = eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
|
eglCheck(display = eglGetDisplay(EGL_DEFAULT_DISPLAY));
|
||||||
eglCheck(eglInitialize(display, NULL, NULL));
|
eglCheck(eglInitialize(display, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(SFML_SYSTEM_ANDROID)
|
|
||||||
|
|
||||||
// On Android, its native activity handles this for us
|
////////////////////////////////////////////////////////////
|
||||||
sf::priv::ActivityStates* states = sf::priv::getActivity(NULL);
|
void ensureInit()
|
||||||
sf::Lock lock(states->mutex);
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
return states->display;
|
// We don't check the return value since the extension
|
||||||
|
// flags are cleared even if loading fails
|
||||||
|
gladLoaderLoadEGL(EGL_NO_DISPLAY);
|
||||||
|
|
||||||
#endif
|
// Continue loading with a display
|
||||||
|
gladLoaderLoadEGL(getInitializedDisplay());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +98,8 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Get the initialized EGL display
|
// Get the initialized EGL display
|
||||||
m_display = getInitializedDisplay();
|
m_display = getInitializedDisplay();
|
||||||
|
|
||||||
@ -95,7 +115,7 @@ m_config (NULL)
|
|||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
m_surface = eglCheck(eglCreatePbufferSurface(m_display, m_config, attrib_list));
|
eglCheck(m_surface = eglCreatePbufferSurface(m_display, m_config, attrib_list));
|
||||||
|
|
||||||
// Create EGL context
|
// Create EGL context
|
||||||
createContext(shared);
|
createContext(shared);
|
||||||
@ -109,6 +129,8 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#ifdef SFML_SYSTEM_ANDROID
|
||||||
|
|
||||||
// On Android, we must save the created context
|
// On Android, we must save the created context
|
||||||
@ -144,6 +166,7 @@ m_context (EGL_NO_CONTEXT),
|
|||||||
m_surface (EGL_NO_SURFACE),
|
m_surface (EGL_NO_SURFACE),
|
||||||
m_config (NULL)
|
m_config (NULL)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +177,8 @@ EglContext::~EglContext()
|
|||||||
cleanupUnsharedResources();
|
cleanupUnsharedResources();
|
||||||
|
|
||||||
// Deactivate the current context
|
// Deactivate the current context
|
||||||
EGLContext currentContext = eglCheck(eglGetCurrentContext());
|
EGLContext currentContext = EGL_NO_CONTEXT;
|
||||||
|
eglCheck(currentContext = eglGetCurrentContext());
|
||||||
|
|
||||||
if (currentContext == m_context)
|
if (currentContext == m_context)
|
||||||
{
|
{
|
||||||
@ -175,13 +199,33 @@ EglContext::~EglContext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
GlFunctionPointer EglContext::getFunction(const char* name)
|
||||||
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
|
return reinterpret_cast<GlFunctionPointer>(eglGetProcAddress(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool EglContext::makeCurrent(bool current)
|
bool EglContext::makeCurrent(bool current)
|
||||||
{
|
{
|
||||||
if (current)
|
if (m_surface == EGL_NO_SURFACE)
|
||||||
return m_surface != EGL_NO_SURFACE && eglCheck(eglMakeCurrent(m_display, m_surface, m_surface, m_context));
|
return false;
|
||||||
|
|
||||||
return m_surface != EGL_NO_SURFACE && eglCheck(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
|
EGLBoolean result = EGL_FALSE;
|
||||||
|
|
||||||
|
if (current)
|
||||||
|
{
|
||||||
|
eglCheck(result = eglMakeCurrent(m_display, m_surface, m_surface, m_context));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eglCheck(result = eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (result != EGL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -219,14 +263,14 @@ void EglContext::createContext(EglContext* shared)
|
|||||||
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
// Create EGL context
|
// Create EGL context
|
||||||
m_context = eglCheck(eglCreateContext(m_display, m_config, toShared, contextVersion));
|
eglCheck(m_context = eglCreateContext(m_display, m_config, toShared, contextVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void EglContext::createSurface(EGLNativeWindowType window)
|
void EglContext::createSurface(EGLNativeWindowType window)
|
||||||
{
|
{
|
||||||
m_surface = eglCheck(eglCreateWindowSurface(m_display, m_config, window, NULL));
|
eglCheck(m_surface = eglCreateWindowSurface(m_display, m_config, window, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,6 +288,8 @@ void EglContext::destroySurface()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixel, const ContextSettings& settings)
|
EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixel, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Set our video settings constraint
|
// Set our video settings constraint
|
||||||
const EGLint attributes[] = {
|
const EGLint attributes[] = {
|
||||||
EGL_BUFFER_SIZE, static_cast<EGLint>(bitsPerPixel),
|
EGL_BUFFER_SIZE, static_cast<EGLint>(bitsPerPixel),
|
||||||
@ -271,16 +317,29 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void EglContext::updateSettings()
|
void EglContext::updateSettings()
|
||||||
{
|
{
|
||||||
EGLint tmp;
|
EGLBoolean result = EGL_FALSE;
|
||||||
|
EGLint tmp = 0;
|
||||||
|
|
||||||
// Update the internal context settings with the current config
|
// Update the internal context settings with the current config
|
||||||
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp));
|
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp));
|
||||||
|
|
||||||
|
if (result == EGL_FALSE)
|
||||||
|
err() << "Failed to retrieve EGL_DEPTH_SIZE" << std::endl;
|
||||||
|
|
||||||
m_settings.depthBits = tmp;
|
m_settings.depthBits = tmp;
|
||||||
|
|
||||||
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
|
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
|
||||||
|
|
||||||
|
if (result == EGL_FALSE)
|
||||||
|
err() << "Failed to retrieve EGL_STENCIL_SIZE" << std::endl;
|
||||||
|
|
||||||
m_settings.stencilBits = tmp;
|
m_settings.stencilBits = tmp;
|
||||||
|
|
||||||
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
|
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
|
||||||
|
|
||||||
|
if (result == EGL_FALSE)
|
||||||
|
err() << "Failed to retrieve EGL_SAMPLES" << std::endl;
|
||||||
|
|
||||||
m_settings.antialiasingLevel = tmp;
|
m_settings.antialiasingLevel = tmp;
|
||||||
|
|
||||||
m_settings.majorVersion = 1;
|
m_settings.majorVersion = 1;
|
||||||
@ -293,6 +352,8 @@ void EglContext::updateSettings()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
|
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Get the initialized EGL display
|
// Get the initialized EGL display
|
||||||
EGLDisplay display = getInitializedDisplay();
|
EGLDisplay display = getInitializedDisplay();
|
||||||
|
|
||||||
|
@ -32,8 +32,11 @@
|
|||||||
#include <SFML/Window/ContextSettings.hpp>
|
#include <SFML/Window/ContextSettings.hpp>
|
||||||
#include <SFML/Window/EGLCheck.hpp>
|
#include <SFML/Window/EGLCheck.hpp>
|
||||||
#include <SFML/Window/GlContext.hpp>
|
#include <SFML/Window/GlContext.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
#include <SFML/Window/WindowStyle.hpp> // Prevent conflict with macro None from Xlib
|
||||||
|
#include <glad/egl.h>
|
||||||
|
#ifdef SFML_SYSTEM_LINUX
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -79,6 +82,16 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
~EglContext();
|
~EglContext();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the address of an OpenGL function
|
||||||
|
///
|
||||||
|
/// \param name Name of the function to get the address of
|
||||||
|
///
|
||||||
|
/// \return Address of the OpenGL function, 0 on failure
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
static GlFunctionPointer getFunction(const char* name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Activate the context as the current target
|
/// \brief Activate the context as the current target
|
||||||
/// for rendering
|
/// for rendering
|
||||||
|
@ -27,11 +27,12 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/GlContext.hpp>
|
#include <SFML/Window/GlContext.hpp>
|
||||||
#include <SFML/Window/Context.hpp>
|
#include <SFML/Window/Context.hpp>
|
||||||
|
#include <SFML/Window/EglContext.hpp>
|
||||||
#include <SFML/System/ThreadLocalPtr.hpp>
|
#include <SFML/System/ThreadLocalPtr.hpp>
|
||||||
#include <SFML/System/Mutex.hpp>
|
#include <SFML/System/Mutex.hpp>
|
||||||
#include <SFML/System/Lock.hpp>
|
#include <SFML/System/Lock.hpp>
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <SFML/OpenGL.hpp>
|
#include <glad/gl.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -42,48 +43,66 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#if !defined(SFML_OPENGL_ES)
|
|
||||||
|
|
||||||
#if defined(SFML_SYSTEM_WINDOWS)
|
#if defined(SFML_SYSTEM_WINDOWS)
|
||||||
|
|
||||||
|
#if defined(SFML_OPENGL_ES)
|
||||||
|
|
||||||
|
typedef sf::priv::EglContext ContextType;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include <SFML/Window/Win32/WglContext.hpp>
|
#include <SFML/Window/Win32/WglContext.hpp>
|
||||||
typedef sf::priv::WglContext ContextType;
|
typedef sf::priv::WglContext ContextType;
|
||||||
|
|
||||||
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
|
#endif
|
||||||
|
|
||||||
|
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD)
|
||||||
|
|
||||||
|
#if defined(SFML_OPENGL_ES)
|
||||||
|
|
||||||
|
typedef sf::priv::EglContext ContextType;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include <SFML/Window/Unix/GlxContext.hpp>
|
#include <SFML/Window/Unix/GlxContext.hpp>
|
||||||
typedef sf::priv::GlxContext ContextType;
|
typedef sf::priv::GlxContext ContextType;
|
||||||
|
|
||||||
#elif defined(SFML_SYSTEM_MACOS)
|
|
||||||
|
|
||||||
#include <SFML/Window/OSX/SFContext.hpp>
|
|
||||||
typedef sf::priv::SFContext ContextType;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#elif defined(SFML_SYSTEM_MACOS)
|
||||||
|
|
||||||
#if defined(SFML_SYSTEM_IOS)
|
#include <SFML/Window/OSX/SFContext.hpp>
|
||||||
|
typedef sf::priv::SFContext ContextType;
|
||||||
|
|
||||||
#include <SFML/Window/iOS/EaglContext.hpp>
|
#elif defined(SFML_SYSTEM_IOS)
|
||||||
typedef sf::priv::EaglContext ContextType;
|
|
||||||
|
|
||||||
#else
|
#include <SFML/Window/iOS/EaglContext.hpp>
|
||||||
|
typedef sf::priv::EaglContext ContextType;
|
||||||
|
|
||||||
#include <SFML/Window/EglContext.hpp>
|
#elif defined(SFML_SYSTEM_ANDROID)
|
||||||
typedef sf::priv::EglContext ContextType;
|
|
||||||
|
|
||||||
#endif
|
typedef sf::priv::EglContext ContextType;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SFML_SYSTEM_WINDOWS)
|
#if defined(SFML_SYSTEM_WINDOWS)
|
||||||
|
|
||||||
|
typedef void (APIENTRY *glEnableFuncType)(GLenum);
|
||||||
|
typedef GLenum (APIENTRY *glGetErrorFuncType)();
|
||||||
|
typedef void (APIENTRY *glGetIntegervFuncType)(GLenum, GLint*);
|
||||||
|
typedef const GLubyte* (APIENTRY *glGetStringFuncType)(GLenum);
|
||||||
typedef const GLubyte* (APIENTRY *glGetStringiFuncType)(GLenum, GLuint);
|
typedef const GLubyte* (APIENTRY *glGetStringiFuncType)(GLenum, GLuint);
|
||||||
|
typedef GLboolean (APIENTRY *glIsEnabledFuncType)(GLenum);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
typedef void (*glEnableFuncType)(GLenum);
|
||||||
|
typedef GLenum (*glGetErrorFuncType)();
|
||||||
|
typedef void (*glGetIntegervFuncType)(GLenum, GLint*);
|
||||||
|
typedef const GLubyte* (*glGetStringFuncType)(GLenum);
|
||||||
typedef const GLubyte* (*glGetStringiFuncType)(GLenum, GLuint);
|
typedef const GLubyte* (*glGetStringiFuncType)(GLenum, GLuint);
|
||||||
|
typedef GLboolean (*glIsEnabledFuncType)(GLenum);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -217,16 +236,23 @@ namespace
|
|||||||
{
|
{
|
||||||
extensions.clear();
|
extensions.clear();
|
||||||
|
|
||||||
// Check whether a >= 3.0 context is available
|
glGetErrorFuncType glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(sf::priv::GlContext::getFunction("glGetError"));
|
||||||
glGetStringiFuncType glGetStringiFunc = NULL;
|
glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(sf::priv::GlContext::getFunction("glGetIntegerv"));
|
||||||
glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
|
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(sf::priv::GlContext::getFunction("glGetString"));
|
||||||
int majorVersion = 0;
|
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
|
|
||||||
|
|
||||||
if (glGetError() == GL_INVALID_ENUM || !glGetStringiFunc)
|
if (!glGetErrorFunc || !glGetIntegervFunc || !glGetStringFunc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check whether a >= 3.0 context is available
|
||||||
|
int majorVersion = 0;
|
||||||
|
glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion);
|
||||||
|
|
||||||
|
glGetStringiFuncType glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
|
||||||
|
|
||||||
|
if (glGetErrorFunc() == GL_INVALID_ENUM || !glGetStringiFunc)
|
||||||
{
|
{
|
||||||
// Try to load the < 3.0 way
|
// Try to load the < 3.0 way
|
||||||
const char* extensionString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
|
const char* extensionString = reinterpret_cast<const char*>(glGetStringFunc(GL_EXTENSIONS));
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -243,7 +269,7 @@ namespace
|
|||||||
{
|
{
|
||||||
// Try to load the >= 3.0 way
|
// Try to load the >= 3.0 way
|
||||||
int numExtensions = 0;
|
int numExtensions = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
glGetIntegervFunc(GL_NUM_EXTENSIONS, &numExtensions);
|
||||||
|
|
||||||
if (numExtensions)
|
if (numExtensions)
|
||||||
{
|
{
|
||||||
@ -517,17 +543,9 @@ bool GlContext::isExtensionAvailable(const char* name)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer GlContext::getFunction(const char* name)
|
GlFunctionPointer GlContext::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
#if !defined(SFML_OPENGL_ES)
|
|
||||||
|
|
||||||
Lock lock(mutex);
|
Lock lock(mutex);
|
||||||
|
|
||||||
return ContextType::getFunction(name);
|
return ContextType::getFunction(name);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -681,10 +699,22 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
int minorVersion = 0;
|
int minorVersion = 0;
|
||||||
|
|
||||||
// Try the new way first
|
// Try the new way first
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
|
glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(getFunction("glGetIntegerv"));
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
|
glGetErrorFuncType glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(getFunction("glGetError"));
|
||||||
|
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
||||||
|
glEnableFuncType glEnableFunc = reinterpret_cast<glEnableFuncType>(getFunction("glEnable"));
|
||||||
|
glIsEnabledFuncType glIsEnabledFunc = reinterpret_cast<glIsEnabledFuncType>(getFunction("glIsEnabled"));
|
||||||
|
|
||||||
if (glGetError() != GL_INVALID_ENUM)
|
if (!glGetIntegervFunc || !glGetErrorFunc || !glGetStringFunc || !glEnableFunc || !glIsEnabledFunc)
|
||||||
|
{
|
||||||
|
err() << "Could not load necessary function to initialize OpenGL context" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion);
|
||||||
|
glGetIntegervFunc(GL_MINOR_VERSION, &minorVersion);
|
||||||
|
|
||||||
|
if (glGetErrorFunc() != GL_INVALID_ENUM)
|
||||||
{
|
{
|
||||||
m_settings.majorVersion = static_cast<unsigned int>(majorVersion);
|
m_settings.majorVersion = static_cast<unsigned int>(majorVersion);
|
||||||
m_settings.minorVersion = static_cast<unsigned int>(minorVersion);
|
m_settings.minorVersion = static_cast<unsigned int>(minorVersion);
|
||||||
@ -697,7 +727,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
m_settings.majorVersion = 1;
|
m_settings.majorVersion = 1;
|
||||||
m_settings.minorVersion = 1;
|
m_settings.minorVersion = 1;
|
||||||
|
|
||||||
const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
const char* version = reinterpret_cast<const char*>(glGetStringFunc(GL_VERSION));
|
||||||
if (version)
|
if (version)
|
||||||
{
|
{
|
||||||
// OpenGL ES Common Lite profile: The beginning of the returned string is "OpenGL ES-CL major.minor"
|
// OpenGL ES Common Lite profile: The beginning of the returned string is "OpenGL ES-CL major.minor"
|
||||||
@ -741,7 +771,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
{
|
{
|
||||||
// Retrieve the context flags
|
// Retrieve the context flags
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
glGetIntegervFunc(GL_CONTEXT_FLAGS, &flags);
|
||||||
|
|
||||||
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||||
m_settings.attributeFlags |= ContextSettings::Debug;
|
m_settings.attributeFlags |= ContextSettings::Debug;
|
||||||
@ -755,7 +785,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
if (glGetStringiFunc)
|
if (glGetStringiFunc)
|
||||||
{
|
{
|
||||||
int numExtensions = 0;
|
int numExtensions = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
glGetIntegervFunc(GL_NUM_EXTENSIONS, &numExtensions);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
|
for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
|
||||||
{
|
{
|
||||||
@ -773,7 +803,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
{
|
{
|
||||||
// Retrieve the context profile
|
// Retrieve the context profile
|
||||||
int profile = 0;
|
int profile = 0;
|
||||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
|
glGetIntegervFunc(GL_CONTEXT_PROFILE_MASK, &profile);
|
||||||
|
|
||||||
if (profile & GL_CONTEXT_CORE_PROFILE_BIT)
|
if (profile & GL_CONTEXT_CORE_PROFILE_BIT)
|
||||||
m_settings.attributeFlags |= ContextSettings::Core;
|
m_settings.attributeFlags |= ContextSettings::Core;
|
||||||
@ -783,7 +813,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
// Enable anti-aliasing if requested by the user and supported
|
// Enable anti-aliasing if requested by the user and supported
|
||||||
if ((requestedSettings.antialiasingLevel > 0) && (m_settings.antialiasingLevel > 0))
|
if ((requestedSettings.antialiasingLevel > 0) && (m_settings.antialiasingLevel > 0))
|
||||||
{
|
{
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnableFunc(GL_MULTISAMPLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -793,10 +823,10 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
// Enable sRGB if requested by the user and supported
|
// Enable sRGB if requested by the user and supported
|
||||||
if (requestedSettings.sRgbCapable && m_settings.sRgbCapable)
|
if (requestedSettings.sRgbCapable && m_settings.sRgbCapable)
|
||||||
{
|
{
|
||||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
glEnableFunc(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
||||||
// Check to see if the enable was successful
|
// Check to see if the enable was successful
|
||||||
if (glIsEnabled(GL_FRAMEBUFFER_SRGB) == GL_FALSE)
|
if (glIsEnabledFunc(GL_FRAMEBUFFER_SRGB) == GL_FALSE)
|
||||||
{
|
{
|
||||||
err() << "Warning: Failed to enable GL_FRAMEBUFFER_SRGB" << std::endl;
|
err() << "Warning: Failed to enable GL_FRAMEBUFFER_SRGB" << std::endl;
|
||||||
m_settings.sRgbCapable = false;
|
m_settings.sRgbCapable = false;
|
||||||
@ -814,9 +844,18 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
|
|||||||
{
|
{
|
||||||
// Perform checks to inform the user if they are getting a context they might not have expected
|
// Perform checks to inform the user if they are getting a context they might not have expected
|
||||||
|
|
||||||
|
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
||||||
|
|
||||||
|
if (!glGetStringFunc)
|
||||||
|
{
|
||||||
|
err() << "Could not load glGetString function" << std::endl;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Detect any known non-accelerated implementations and warn
|
// Detect any known non-accelerated implementations and warn
|
||||||
const char* vendorName = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
|
const char* vendorName = reinterpret_cast<const char*>(glGetStringFunc(GL_VENDOR));
|
||||||
const char* rendererName = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
const char* rendererName = reinterpret_cast<const char*>(glGetStringFunc(GL_RENDERER));
|
||||||
|
|
||||||
if (vendorName && rendererName)
|
if (vendorName && rendererName)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#define SF_GLAD_GLX_IMPLEMENTATION
|
||||||
#include <SFML/Window/Unix/WindowImplX11.hpp> // important to be included first (conflict with None)
|
#include <SFML/Window/Unix/WindowImplX11.hpp> // important to be included first (conflict with None)
|
||||||
#include <SFML/Window/Unix/GlxContext.hpp>
|
#include <SFML/Window/Unix/GlxContext.hpp>
|
||||||
#include <SFML/Window/Unix/Display.hpp>
|
#include <SFML/Window/Unix/Display.hpp>
|
||||||
@ -43,12 +44,31 @@ namespace
|
|||||||
sf::Mutex glxErrorMutex;
|
sf::Mutex glxErrorMutex;
|
||||||
bool glxErrorOccurred = false;
|
bool glxErrorOccurred = false;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void ensureExtensionsInit(::Display* display, int screen)
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
// We don't check the return value since the extension
|
||||||
|
// flags are cleared even if loading fails
|
||||||
|
gladLoaderLoadGLX(display, screen);
|
||||||
|
|
||||||
|
gladLoadGLX(display, screen, sf::priv::GlxContext::getFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int HandleXError(::Display*, XErrorEvent*)
|
int HandleXError(::Display*, XErrorEvent*)
|
||||||
{
|
{
|
||||||
glxErrorOccurred = true;
|
glxErrorOccurred = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class GlxErrorHandler
|
class GlxErrorHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -79,21 +99,6 @@ namespace sf
|
|||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void ensureExtensionsInit(::Display* display, int screen)
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
// We don't check the return value since the extension
|
|
||||||
// flags are cleared even if loading fails
|
|
||||||
sfglx_LoadFunctions(display, screen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlxContext::GlxContext(GlxContext* shared) :
|
GlxContext::GlxContext(GlxContext* shared) :
|
||||||
m_display (NULL),
|
m_display (NULL),
|
||||||
@ -212,7 +217,7 @@ GlxContext::~GlxContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer GlxContext::getFunction(const char* name)
|
GlFunctionPointer GlxContext::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<GlFunctionPointer>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(name)));
|
return reinterpret_cast<GlFunctionPointer>(glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -281,15 +286,15 @@ void GlxContext::setVerticalSyncEnabled(bool enabled)
|
|||||||
// We use the direct pointer to the MESA entry point instead of the alias
|
// We use the direct pointer to the MESA entry point instead of the alias
|
||||||
// because glx.h declares the entry point as an external function
|
// because glx.h declares the entry point as an external function
|
||||||
// which would require us to link in an additional library
|
// which would require us to link in an additional library
|
||||||
if (sfglx_ext_EXT_swap_control == sfglx_LOAD_SUCCEEDED)
|
if (SF_GLAD_GLX_EXT_swap_control)
|
||||||
{
|
{
|
||||||
glXSwapIntervalEXT(m_display, m_pbuffer ? m_pbuffer : m_window, enabled ? 1 : 0);
|
glXSwapIntervalEXT(m_display, m_pbuffer ? m_pbuffer : m_window, enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
else if (sfglx_ext_MESA_swap_control == sfglx_LOAD_SUCCEEDED)
|
else if (SF_GLAD_GLX_MESA_swap_control)
|
||||||
{
|
{
|
||||||
result = sf_ptrc_glXSwapIntervalMESA(enabled ? 1 : 0);
|
result = glXSwapIntervalMESA(enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
else if (sfglx_ext_SGI_swap_control == sfglx_LOAD_SUCCEEDED)
|
else if (SF_GLAD_GLX_SGI_swap_control)
|
||||||
{
|
{
|
||||||
result = glXSwapIntervalSGI(enabled ? 1 : 0);
|
result = glXSwapIntervalSGI(enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
@ -347,7 +352,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth);
|
glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth);
|
||||||
glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil);
|
glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil);
|
||||||
|
|
||||||
if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
|
if (SF_GLAD_GLX_ARB_multisample)
|
||||||
{
|
{
|
||||||
glXGetConfig(display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
|
glXGetConfig(display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
|
||||||
glXGetConfig(display, &visuals[i], GLX_SAMPLES_ARB, &samples);
|
glXGetConfig(display, &visuals[i], GLX_SAMPLES_ARB, &samples);
|
||||||
@ -358,7 +363,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
samples = 0;
|
samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sfglx_ext_EXT_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED) || (sfglx_ext_ARB_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED))
|
if (SF_GLAD_GLX_EXT_framebuffer_sRGB || SF_GLAD_GLX_ARB_framebuffer_sRGB)
|
||||||
{
|
{
|
||||||
glXGetConfig(display, &visuals[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
|
glXGetConfig(display, &visuals[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
|
||||||
}
|
}
|
||||||
@ -405,7 +410,7 @@ void GlxContext::updateSettingsFromVisualInfo(XVisualInfo* visualInfo)
|
|||||||
glXGetConfig(m_display, visualInfo, GLX_DEPTH_SIZE, &depth);
|
glXGetConfig(m_display, visualInfo, GLX_DEPTH_SIZE, &depth);
|
||||||
glXGetConfig(m_display, visualInfo, GLX_STENCIL_SIZE, &stencil);
|
glXGetConfig(m_display, visualInfo, GLX_STENCIL_SIZE, &stencil);
|
||||||
|
|
||||||
if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
|
if (SF_GLAD_GLX_ARB_multisample)
|
||||||
{
|
{
|
||||||
glXGetConfig(m_display, visualInfo, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
|
glXGetConfig(m_display, visualInfo, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
|
||||||
glXGetConfig(m_display, visualInfo, GLX_SAMPLES_ARB, &samples);
|
glXGetConfig(m_display, visualInfo, GLX_SAMPLES_ARB, &samples);
|
||||||
@ -416,7 +421,7 @@ void GlxContext::updateSettingsFromVisualInfo(XVisualInfo* visualInfo)
|
|||||||
samples = 0;
|
samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sfglx_ext_EXT_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED) || (sfglx_ext_ARB_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED))
|
if (SF_GLAD_GLX_EXT_framebuffer_sRGB || SF_GLAD_GLX_ARB_framebuffer_sRGB)
|
||||||
{
|
{
|
||||||
glXGetConfig(m_display, visualInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
|
glXGetConfig(m_display, visualInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
|
||||||
}
|
}
|
||||||
@ -466,7 +471,7 @@ void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned
|
|||||||
XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);
|
XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);
|
||||||
|
|
||||||
// Check if the shared context already exists and pbuffers are supported
|
// Check if the shared context already exists and pbuffers are supported
|
||||||
if (shared && (sfglx_ext_SGIX_pbuffer == sfglx_LOAD_SUCCEEDED))
|
if (shared && SF_GLAD_GLX_SGIX_pbuffer)
|
||||||
{
|
{
|
||||||
// There are no GLX versions prior to 1.0
|
// There are no GLX versions prior to 1.0
|
||||||
int major = 0;
|
int major = 0;
|
||||||
@ -626,7 +631,7 @@ void GlxContext::createContext(GlxContext* shared)
|
|||||||
err() << "Failed to query GLX version, limited to legacy context creation" << std::endl;
|
err() << "Failed to query GLX version, limited to legacy context creation" << std::endl;
|
||||||
|
|
||||||
// Check if glXCreateContextAttribsARB is available (requires GLX 1.3 or greater)
|
// Check if glXCreateContextAttribsARB is available (requires GLX 1.3 or greater)
|
||||||
bool hasCreateContextArb = (sfglx_ext_ARB_create_context == sfglx_LOAD_SUCCEEDED) && ((major > 1) || (minor >= 3));
|
bool hasCreateContextArb = SF_GLAD_GLX_ARB_create_context && ((major > 1) || (minor >= 3));
|
||||||
|
|
||||||
// Create the OpenGL context -- first try using glXCreateContextAttribsARB
|
// Create the OpenGL context -- first try using glXCreateContextAttribsARB
|
||||||
if (hasCreateContextArb)
|
if (hasCreateContextArb)
|
||||||
@ -674,7 +679,7 @@ void GlxContext::createContext(GlxContext* shared)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if setting the profile is supported
|
// Check if setting the profile is supported
|
||||||
if (sfglx_ext_ARB_create_context_profile == sfglx_LOAD_SUCCEEDED)
|
if (SF_GLAD_GLX_ARB_create_context_profile)
|
||||||
{
|
{
|
||||||
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? GLX_CONTEXT_DEBUG_BIT_ARB : 0;
|
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? GLX_CONTEXT_DEBUG_BIT_ARB : 0;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/GlContext.hpp>
|
#include <SFML/Window/GlContext.hpp>
|
||||||
#include <SFML/Window/Unix/GlxExtensions.hpp>
|
#include <glad/glx.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,218 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SFML - Simple and Fast Multimedia Library
|
|
||||||
// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org)
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
// subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented;
|
|
||||||
// you must not claim that you wrote the original software.
|
|
||||||
// If you use this software in a product, an acknowledgment
|
|
||||||
// in the product documentation would be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such,
|
|
||||||
// and must not be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
// Headers
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
#include <SFML/Window/Unix/GlxExtensions.hpp>
|
|
||||||
#include <SFML/Window/Context.hpp>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
static sf::GlFunctionPointer IntGetProcAddress(const char* name)
|
|
||||||
{
|
|
||||||
return sf::Context::getFunction(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sfglx_ext_EXT_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_MESA_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_SGI_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_EXT_framebuffer_sRGB = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_ARB_framebuffer_sRGB = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_ARB_multisample = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_SGIX_pbuffer = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_ARB_create_context = sfglx_LOAD_FAILED;
|
|
||||||
int sfglx_ext_ARB_create_context_profile = sfglx_LOAD_FAILED;
|
|
||||||
|
|
||||||
void (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalEXT)(Display*, GLXDrawable, int) = NULL;
|
|
||||||
|
|
||||||
static int Load_EXT_swap_control(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_glXSwapIntervalEXT = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, int)>(IntGetProcAddress("glXSwapIntervalEXT"));
|
|
||||||
if (!sf_ptrc_glXSwapIntervalEXT)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalMESA)(int) = NULL;
|
|
||||||
|
|
||||||
static int Load_MESA_swap_control(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_glXSwapIntervalMESA = reinterpret_cast<int (CODEGEN_FUNCPTR*)(int)>(IntGetProcAddress("glXSwapIntervalMESA"));
|
|
||||||
if (!sf_ptrc_glXSwapIntervalMESA)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalSGI)(int) = NULL;
|
|
||||||
|
|
||||||
static int Load_SGI_swap_control(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_glXSwapIntervalSGI = reinterpret_cast<int (CODEGEN_FUNCPTR *)(int)>(IntGetProcAddress("glXSwapIntervalSGI"));
|
|
||||||
if (!sf_ptrc_glXSwapIntervalSGI)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLXPbufferSGIX (CODEGEN_FUNCPTR *sf_ptrc_glXCreateGLXPbufferSGIX)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*) = NULL;
|
|
||||||
void (CODEGEN_FUNCPTR *sf_ptrc_glXDestroyGLXPbufferSGIX)(Display*, GLXPbufferSGIX) = NULL;
|
|
||||||
void (CODEGEN_FUNCPTR *sf_ptrc_glXGetSelectedEventSGIX)(Display*, GLXDrawable, unsigned long*) = NULL;
|
|
||||||
int (CODEGEN_FUNCPTR *sf_ptrc_glXQueryGLXPbufferSGIX)(Display*, GLXPbufferSGIX, int, unsigned int*) = NULL;
|
|
||||||
void (CODEGEN_FUNCPTR *sf_ptrc_glXSelectEventSGIX)(Display*, GLXDrawable, unsigned long) = NULL;
|
|
||||||
|
|
||||||
static int Load_SGIX_pbuffer(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_glXCreateGLXPbufferSGIX = reinterpret_cast<GLXPbufferSGIX (CODEGEN_FUNCPTR*)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*)>(IntGetProcAddress("glXCreateGLXPbufferSGIX"));
|
|
||||||
if (!sf_ptrc_glXCreateGLXPbufferSGIX)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_glXDestroyGLXPbufferSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXPbufferSGIX)>(IntGetProcAddress("glXDestroyGLXPbufferSGIX"));
|
|
||||||
if (!sf_ptrc_glXDestroyGLXPbufferSGIX)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_glXGetSelectedEventSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, unsigned long*)>(IntGetProcAddress("glXGetSelectedEventSGIX"));
|
|
||||||
if (!sf_ptrc_glXGetSelectedEventSGIX)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_glXQueryGLXPbufferSGIX = reinterpret_cast<int (CODEGEN_FUNCPTR*)(Display*, GLXPbufferSGIX, int, unsigned int*)>(IntGetProcAddress("glXQueryGLXPbufferSGIX"));
|
|
||||||
if (!sf_ptrc_glXQueryGLXPbufferSGIX)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_glXSelectEventSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, unsigned long)>(IntGetProcAddress("glXSelectEventSGIX"));
|
|
||||||
if (!sf_ptrc_glXSelectEventSGIX)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*) = NULL;
|
|
||||||
|
|
||||||
static int Load_ARB_create_context(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_glXCreateContextAttribsARB = reinterpret_cast<GLXContext (CODEGEN_FUNCPTR*)(Display*, GLXFBConfig, GLXContext, Bool, const int*)>(IntGetProcAddress("glXCreateContextAttribsARB"));
|
|
||||||
if (!sf_ptrc_glXCreateContextAttribsARB)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef int (*PFN_LOADFUNCPOINTERS)(void);
|
|
||||||
typedef struct sfglx_StrToExtMap_s
|
|
||||||
{
|
|
||||||
const char* extensionName;
|
|
||||||
int* extensionVariable;
|
|
||||||
PFN_LOADFUNCPOINTERS LoadExtension;
|
|
||||||
} sfglx_StrToExtMap;
|
|
||||||
|
|
||||||
static sfglx_StrToExtMap ExtensionMap[9] = {
|
|
||||||
{"GLX_EXT_swap_control", &sfglx_ext_EXT_swap_control, Load_EXT_swap_control},
|
|
||||||
{"GLX_MESA_swap_control", &sfglx_ext_MESA_swap_control, Load_MESA_swap_control},
|
|
||||||
{"GLX_SGI_swap_control", &sfglx_ext_SGI_swap_control, Load_SGI_swap_control},
|
|
||||||
{"GLX_EXT_framebuffer_sRGB", &sfglx_ext_EXT_framebuffer_sRGB, NULL},
|
|
||||||
{"GLX_ARB_framebuffer_sRGB", &sfglx_ext_ARB_framebuffer_sRGB, NULL},
|
|
||||||
{"GLX_ARB_multisample", &sfglx_ext_ARB_multisample, NULL},
|
|
||||||
{"GLX_SGIX_pbuffer", &sfglx_ext_SGIX_pbuffer, Load_SGIX_pbuffer},
|
|
||||||
{"GLX_ARB_create_context", &sfglx_ext_ARB_create_context, Load_ARB_create_context},
|
|
||||||
{"GLX_ARB_create_context_profile", &sfglx_ext_ARB_create_context_profile, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int g_extensionMapSize = 9;
|
|
||||||
|
|
||||||
|
|
||||||
static sfglx_StrToExtMap* FindExtEntry(const char* extensionName)
|
|
||||||
{
|
|
||||||
sfglx_StrToExtMap* currLoc = ExtensionMap;
|
|
||||||
for (int loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
|
|
||||||
{
|
|
||||||
if (std::strcmp(extensionName, currLoc->extensionName) == 0)
|
|
||||||
return currLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void ClearExtensionVars(void)
|
|
||||||
{
|
|
||||||
sfglx_ext_EXT_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_MESA_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_SGI_swap_control = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_EXT_framebuffer_sRGB = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_ARB_framebuffer_sRGB = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_ARB_multisample = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_SGIX_pbuffer = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_ARB_create_context = sfglx_LOAD_FAILED;
|
|
||||||
sfglx_ext_ARB_create_context_profile = sfglx_LOAD_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void LoadExtByName(const char* extensionName)
|
|
||||||
{
|
|
||||||
sfglx_StrToExtMap* entry = NULL;
|
|
||||||
entry = FindExtEntry(extensionName);
|
|
||||||
if (entry)
|
|
||||||
{
|
|
||||||
if (entry->LoadExtension)
|
|
||||||
{
|
|
||||||
int numFailed = entry->LoadExtension();
|
|
||||||
if (numFailed == 0)
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfglx_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfglx_LOAD_SUCCEEDED + numFailed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfglx_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void ProcExtsFromExtString(const char* strExtList)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const char* begin = strExtList;
|
|
||||||
|
|
||||||
while ((*strExtList != ' ') && *strExtList)
|
|
||||||
strExtList++;
|
|
||||||
|
|
||||||
LoadExtByName(std::string(begin, strExtList).c_str());
|
|
||||||
} while (*strExtList++);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int sfglx_LoadFunctions(Display* display, int screen)
|
|
||||||
{
|
|
||||||
ClearExtensionVars();
|
|
||||||
|
|
||||||
|
|
||||||
ProcExtsFromExtString(reinterpret_cast<const char*>(glXQueryExtensionsString(display, screen)));
|
|
||||||
return sfglx_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
@ -1,251 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SFML - Simple and Fast Multimedia Library
|
|
||||||
// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org)
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
// subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented;
|
|
||||||
// you must not claim that you wrote the original software.
|
|
||||||
// If you use this software in a product, an acknowledgment
|
|
||||||
// in the product documentation would be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such,
|
|
||||||
// and must not be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef SF_POINTER_C_GENERATED_HEADER_GLXWIN_HPP
|
|
||||||
#define SF_POINTER_C_GENERATED_HEADER_GLXWIN_HPP
|
|
||||||
|
|
||||||
#if defined(__glxext_h_) || defined(__glx_glxext_h_)
|
|
||||||
#error Attempt to include glx_exts after including glxext.h
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __glxext_h_
|
|
||||||
#define __glx_glxext_h_
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <GL/glx.h>
|
|
||||||
#ifdef CODEGEN_FUNCPTR
|
|
||||||
#undef CODEGEN_FUNCPTR
|
|
||||||
#endif // CODEGEN_FUNCPTR
|
|
||||||
#define CODEGEN_FUNCPTR
|
|
||||||
|
|
||||||
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
typedef unsigned int GLenum;
|
|
||||||
typedef unsigned char GLboolean;
|
|
||||||
typedef unsigned int GLbitfield;
|
|
||||||
typedef signed char GLbyte;
|
|
||||||
typedef short GLshort;
|
|
||||||
typedef int GLint;
|
|
||||||
typedef int GLsizei;
|
|
||||||
typedef unsigned char GLubyte;
|
|
||||||
typedef unsigned short GLushort;
|
|
||||||
typedef unsigned int GLuint;
|
|
||||||
typedef float GLfloat;
|
|
||||||
typedef float GLclampf;
|
|
||||||
typedef double GLdouble;
|
|
||||||
typedef double GLclampd;
|
|
||||||
#define GLvoid void
|
|
||||||
|
|
||||||
#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GLEXT_64_TYPES_DEFINED
|
|
||||||
// This code block is duplicated in glext.h, so must be protected
|
|
||||||
#define GLEXT_64_TYPES_DEFINED
|
|
||||||
// Define int32_t, int64_t, and uint64_t types for UST/MSC
|
|
||||||
// (as used in the GLX_OML_sync_control extension).
|
|
||||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
|
||||||
#include <inttypes.h>
|
|
||||||
#elif defined(__sun__) || defined(__digital__)
|
|
||||||
#include <inttypes.h>
|
|
||||||
#if defined(__STDC__)
|
|
||||||
#if defined(__arch64__) || defined(_LP64)
|
|
||||||
typedef long int int64_t;
|
|
||||||
typedef unsigned long int uint64_t;
|
|
||||||
#else
|
|
||||||
typedef long long int int64_t;
|
|
||||||
typedef unsigned long long int uint64_t;
|
|
||||||
#endif // __arch64__
|
|
||||||
#endif // __STDC__
|
|
||||||
#elif defined( __VMS ) || defined(__sgi)
|
|
||||||
#include <inttypes.h>
|
|
||||||
#elif defined(__SCO__) || defined(__USLC__)
|
|
||||||
#include <stdint.h>
|
|
||||||
#elif defined(__UNIXOS2__) || defined(__SOL64__)
|
|
||||||
typedef long int int32_t;
|
|
||||||
typedef long long int int64_t;
|
|
||||||
typedef unsigned long long int uint64_t;
|
|
||||||
#elif defined(_WIN32) && defined(__GNUC__)
|
|
||||||
#include <stdint.h>
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
typedef __int32 int32_t;
|
|
||||||
typedef __int64 int64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
#else
|
|
||||||
// Fallback if nothing above works
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
typedef struct __GLXFBConfigRec *GLXFBConfig;
|
|
||||||
typedef XID GLXContextID;
|
|
||||||
typedef struct __GLXcontextRec *GLXContext;
|
|
||||||
typedef XID GLXPixmap;
|
|
||||||
typedef XID GLXDrawable;
|
|
||||||
typedef XID GLXPbuffer;
|
|
||||||
typedef void (APIENTRY *__GLXextFuncPtr)(void);
|
|
||||||
typedef XID GLXVideoCaptureDeviceNV;
|
|
||||||
typedef unsigned int GLXVideoDeviceNV;
|
|
||||||
typedef XID GLXVideoSourceSGIX;
|
|
||||||
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
|
|
||||||
typedef XID GLXPbufferSGIX;
|
|
||||||
typedef struct {
|
|
||||||
char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
|
|
||||||
int networkId;
|
|
||||||
} GLXHyperpipeNetworkSGIX;
|
|
||||||
typedef struct {
|
|
||||||
char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
|
|
||||||
int channel;
|
|
||||||
unsigned int participationType;
|
|
||||||
int timeSlice;
|
|
||||||
} GLXHyperpipeConfigSGIX;
|
|
||||||
typedef struct {
|
|
||||||
char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
|
|
||||||
int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
|
|
||||||
int destXOrigin, destYOrigin, destWidth, destHeight;
|
|
||||||
} GLXPipeRect;
|
|
||||||
typedef struct {
|
|
||||||
char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
|
|
||||||
int XOrigin, YOrigin, maxHeight, maxWidth;
|
|
||||||
} GLXPipeRectLimits;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
extern int sfglx_ext_EXT_swap_control;
|
|
||||||
extern int sfglx_ext_MESA_swap_control;
|
|
||||||
extern int sfglx_ext_SGI_swap_control;
|
|
||||||
extern int sfglx_ext_EXT_framebuffer_sRGB;
|
|
||||||
extern int sfglx_ext_ARB_framebuffer_sRGB;
|
|
||||||
extern int sfglx_ext_ARB_multisample;
|
|
||||||
extern int sfglx_ext_SGIX_pbuffer;
|
|
||||||
extern int sfglx_ext_ARB_create_context;
|
|
||||||
extern int sfglx_ext_ARB_create_context_profile;
|
|
||||||
|
|
||||||
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
|
|
||||||
#define GLX_SWAP_INTERVAL_EXT 0x20F1
|
|
||||||
|
|
||||||
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2
|
|
||||||
|
|
||||||
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
|
|
||||||
|
|
||||||
#define GLX_SAMPLES_ARB 100001
|
|
||||||
#define GLX_SAMPLE_BUFFERS_ARB 100000
|
|
||||||
|
|
||||||
#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080
|
|
||||||
#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
|
|
||||||
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
|
|
||||||
#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
|
|
||||||
#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000
|
|
||||||
#define GLX_DAMAGED_SGIX 0x8020
|
|
||||||
#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
|
|
||||||
#define GLX_EVENT_MASK_SGIX 0x801F
|
|
||||||
#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
|
|
||||||
#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
|
|
||||||
#define GLX_HEIGHT_SGIX 0x801E
|
|
||||||
#define GLX_LARGEST_PBUFFER_SGIX 0x801C
|
|
||||||
#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017
|
|
||||||
#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018
|
|
||||||
#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016
|
|
||||||
#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
|
|
||||||
#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
|
|
||||||
#define GLX_PBUFFER_BIT_SGIX 0x00000004
|
|
||||||
#define GLX_PBUFFER_SGIX 0x8023
|
|
||||||
#define GLX_PRESERVED_CONTENTS_SGIX 0x801B
|
|
||||||
#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100
|
|
||||||
#define GLX_SAVED_SGIX 0x8021
|
|
||||||
#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040
|
|
||||||
#define GLX_WIDTH_SGIX 0x801D
|
|
||||||
#define GLX_WINDOW_SGIX 0x8022
|
|
||||||
|
|
||||||
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
|
||||||
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
|
||||||
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
|
||||||
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
|
||||||
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
|
||||||
|
|
||||||
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
|
||||||
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
|
||||||
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
|
||||||
|
|
||||||
#ifndef GLX_EXT_swap_control
|
|
||||||
#define GLX_EXT_swap_control 1
|
|
||||||
extern void (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalEXT)(Display *, GLXDrawable, int);
|
|
||||||
#define glXSwapIntervalEXT sf_ptrc_glXSwapIntervalEXT
|
|
||||||
#endif // GLX_EXT_swap_control
|
|
||||||
|
|
||||||
// Declare entry point even if GLX header already provides glXSwapIntervalMESA
|
|
||||||
// We won't make use of an alias here
|
|
||||||
extern int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalMESA)(int);
|
|
||||||
|
|
||||||
#ifndef GLX_SGI_swap_control
|
|
||||||
#define GLX_SGI_swap_control 1
|
|
||||||
extern int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalSGI)(int);
|
|
||||||
#define glXSwapIntervalSGI sf_ptrc_glXSwapIntervalSGI
|
|
||||||
#endif // GLX_SGI_swap_control
|
|
||||||
|
|
||||||
#ifndef GLX_SGIX_pbuffer
|
|
||||||
#define GLX_SGIX_pbuffer 1
|
|
||||||
extern GLXPbufferSGIX (CODEGEN_FUNCPTR *sf_ptrc_glXCreateGLXPbufferSGIX)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*);
|
|
||||||
#define glXCreateGLXPbufferSGIX sf_ptrc_glXCreateGLXPbufferSGIX
|
|
||||||
extern void (CODEGEN_FUNCPTR *sf_ptrc_glXDestroyGLXPbufferSGIX)(Display*, GLXPbufferSGIX);
|
|
||||||
#define glXDestroyGLXPbufferSGIX sf_ptrc_glXDestroyGLXPbufferSGIX
|
|
||||||
extern void (CODEGEN_FUNCPTR *sf_ptrc_glXGetSelectedEventSGIX)(Display*, GLXDrawable, unsigned long*);
|
|
||||||
#define glXGetSelectedEventSGIX sf_ptrc_glXGetSelectedEventSGIX
|
|
||||||
extern int (CODEGEN_FUNCPTR *sf_ptrc_glXQueryGLXPbufferSGIX)(Display*, GLXPbufferSGIX, int, unsigned int*);
|
|
||||||
#define glXQueryGLXPbufferSGIX sf_ptrc_glXQueryGLXPbufferSGIX
|
|
||||||
extern void (CODEGEN_FUNCPTR *sf_ptrc_glXSelectEventSGIX)(Display*, GLXDrawable, unsigned long);
|
|
||||||
#define glXSelectEventSGIX sf_ptrc_glXSelectEventSGIX
|
|
||||||
#endif // GLX_SGIX_pbuffer
|
|
||||||
|
|
||||||
#ifndef GLX_ARB_create_context
|
|
||||||
#define GLX_ARB_create_context 1
|
|
||||||
extern GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
|
||||||
#define glXCreateContextAttribsARB sf_ptrc_glXCreateContextAttribsARB
|
|
||||||
#endif // GLX_ARB_create_context
|
|
||||||
|
|
||||||
|
|
||||||
enum sfglx_LoadStatus
|
|
||||||
{
|
|
||||||
sfglx_LOAD_FAILED = 0,
|
|
||||||
sfglx_LOAD_SUCCEEDED = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
int sfglx_LoadFunctions(Display *display, int screen);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif // SF_POINTER_C_GENERATED_HEADER_GLXWIN_HPP
|
|
@ -1,14 +0,0 @@
|
|||||||
// Created with:
|
|
||||||
// https://bitbucket.org/KhronosGroup/glloadgen
|
|
||||||
// Commit d143d66ac90d538ed06f806188714861b8e8e2f9
|
|
||||||
// lua LoadGen.lua -style=pointer_c -spec=glX -indent=space -prefix=sf -extfile=GlxExtensions.txt GlxExtensions
|
|
||||||
|
|
||||||
EXT_swap_control
|
|
||||||
// MESA_swap_control
|
|
||||||
SGI_swap_control
|
|
||||||
EXT_framebuffer_sRGB
|
|
||||||
ARB_framebuffer_sRGB
|
|
||||||
GLX_ARB_multisample
|
|
||||||
GLX_SGIX_pbuffer
|
|
||||||
GLX_ARB_create_context
|
|
||||||
GLX_ARB_create_context_profile
|
|
@ -25,8 +25,8 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#define SF_GLAD_WGL_IMPLEMENTATION
|
||||||
#include <SFML/Window/WindowImpl.hpp> // included first to avoid a warning about macro redefinition
|
#include <SFML/Window/WindowImpl.hpp> // included first to avoid a warning about macro redefinition
|
||||||
#include <SFML/OpenGL.hpp> // included second to avoid an error in WglExtensions.hpp
|
|
||||||
#include <SFML/Window/Win32/WglContext.hpp>
|
#include <SFML/Window/Win32/WglContext.hpp>
|
||||||
#include <SFML/System/ThreadLocalPtr.hpp>
|
#include <SFML/System/ThreadLocalPtr.hpp>
|
||||||
#include <SFML/System/Lock.hpp>
|
#include <SFML/System/Lock.hpp>
|
||||||
@ -41,6 +41,34 @@ namespace
|
|||||||
// Some drivers are bugged and don't track the current HDC/HGLRC properly
|
// Some drivers are bugged and don't track the current HDC/HGLRC properly
|
||||||
// In order to deactivate successfully, we need to track it ourselves as well
|
// In order to deactivate successfully, we need to track it ourselves as well
|
||||||
sf::ThreadLocalPtr<sf::priv::WglContext> currentContext(NULL);
|
sf::ThreadLocalPtr<sf::priv::WglContext> currentContext(NULL);
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void ensureInit()
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
gladLoadWGL(NULL, sf::priv::WglContext::getFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void ensureExtensionsInit(HDC deviceContext)
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
// We don't check the return value since the extension
|
||||||
|
// flags are cleared even if loading fails
|
||||||
|
gladLoadWGL(deviceContext, sf::priv::WglContext::getFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,21 +76,6 @@ namespace sf
|
|||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void ensureExtensionsInit(HDC deviceContext)
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
// We don't check the return value since the extension
|
|
||||||
// flags are cleared even if loading fails
|
|
||||||
sfwgl_LoadFunctions(deviceContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String getErrorString(DWORD errorCode)
|
String getErrorString(DWORD errorCode)
|
||||||
{
|
{
|
||||||
@ -88,6 +101,8 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// TODO: Delegate to the other constructor in C++11
|
// TODO: Delegate to the other constructor in C++11
|
||||||
|
|
||||||
// Save the creation settings
|
// Save the creation settings
|
||||||
@ -109,6 +124,8 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Save the creation settings
|
// Save the creation settings
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
@ -128,6 +145,8 @@ m_deviceContext(NULL),
|
|||||||
m_context (NULL),
|
m_context (NULL),
|
||||||
m_ownsWindow (false)
|
m_ownsWindow (false)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Save the creation settings
|
// Save the creation settings
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
@ -235,7 +254,7 @@ void WglContext::setVerticalSyncEnabled(bool enabled)
|
|||||||
// Make sure that extensions are initialized
|
// Make sure that extensions are initialized
|
||||||
ensureExtensionsInit(m_deviceContext);
|
ensureExtensionsInit(m_deviceContext);
|
||||||
|
|
||||||
if (sfwgl_ext_EXT_swap_control == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_EXT_swap_control)
|
||||||
{
|
{
|
||||||
if (wglSwapIntervalEXT(enabled ? 1 : 0) == FALSE)
|
if (wglSwapIntervalEXT(enabled ? 1 : 0) == FALSE)
|
||||||
err() << "Setting vertical sync failed: " << getErrorString(GetLastError()).toAnsiString() << std::endl;
|
err() << "Setting vertical sync failed: " << getErrorString(GetLastError()).toAnsiString() << std::endl;
|
||||||
@ -258,9 +277,11 @@ void WglContext::setVerticalSyncEnabled(bool enabled)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer)
|
int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer)
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Let's find a suitable pixel format -- first try with wglChoosePixelFormatARB
|
// Let's find a suitable pixel format -- first try with wglChoosePixelFormatARB
|
||||||
int bestFormat = 0;
|
int bestFormat = 0;
|
||||||
if (sfwgl_ext_ARB_pixel_format == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_pixel_format)
|
||||||
{
|
{
|
||||||
// Define the basic attributes we want for our window
|
// Define the basic attributes we want for our window
|
||||||
int intAttributes[] =
|
int intAttributes[] =
|
||||||
@ -306,7 +327,7 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
|
|||||||
}
|
}
|
||||||
|
|
||||||
int sampleValues[2] = {0, 0};
|
int sampleValues[2] = {0, 0};
|
||||||
if (sfwgl_ext_ARB_multisample == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_multisample)
|
||||||
{
|
{
|
||||||
const int sampleAttributes[] =
|
const int sampleAttributes[] =
|
||||||
{
|
{
|
||||||
@ -322,7 +343,7 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
|
|||||||
}
|
}
|
||||||
|
|
||||||
int sRgbCapableValue = 0;
|
int sRgbCapableValue = 0;
|
||||||
if ((sfwgl_ext_ARB_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED) || (sfwgl_ext_EXT_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED))
|
if (SF_GLAD_WGL_ARB_framebuffer_sRGB || SF_GLAD_WGL_EXT_framebuffer_sRGB)
|
||||||
{
|
{
|
||||||
const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
|
const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
|
||||||
|
|
||||||
@ -443,7 +464,7 @@ void WglContext::updateSettingsFromPixelFormat()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfwgl_ext_ARB_pixel_format == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_pixel_format)
|
||||||
{
|
{
|
||||||
const int attributes[] = {WGL_DEPTH_BITS_ARB, WGL_STENCIL_BITS_ARB};
|
const int attributes[] = {WGL_DEPTH_BITS_ARB, WGL_STENCIL_BITS_ARB};
|
||||||
int values[2];
|
int values[2];
|
||||||
@ -460,7 +481,7 @@ void WglContext::updateSettingsFromPixelFormat()
|
|||||||
m_settings.stencilBits = actualFormat.cStencilBits;
|
m_settings.stencilBits = actualFormat.cStencilBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfwgl_ext_ARB_multisample == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_multisample)
|
||||||
{
|
{
|
||||||
const int sampleAttributes[] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
|
const int sampleAttributes[] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
|
||||||
int sampleValues[2];
|
int sampleValues[2];
|
||||||
@ -480,7 +501,7 @@ void WglContext::updateSettingsFromPixelFormat()
|
|||||||
m_settings.antialiasingLevel = 0;
|
m_settings.antialiasingLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sfwgl_ext_ARB_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED) || (sfwgl_ext_EXT_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED))
|
if (SF_GLAD_WGL_ARB_framebuffer_sRGB || SF_GLAD_WGL_EXT_framebuffer_sRGB)
|
||||||
{
|
{
|
||||||
const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
|
const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
|
||||||
int sRgbCapableValue = 0;
|
int sRgbCapableValue = 0;
|
||||||
@ -513,7 +534,7 @@ void WglContext::updateSettingsFromPixelFormat()
|
|||||||
void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
|
void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
|
||||||
{
|
{
|
||||||
// Check if the shared context already exists and pbuffers are supported
|
// Check if the shared context already exists and pbuffers are supported
|
||||||
if (shared && shared->m_deviceContext && (sfwgl_ext_ARB_pbuffer == sfwgl_LOAD_SUCCEEDED))
|
if (shared && shared->m_deviceContext && SF_GLAD_WGL_ARB_pbuffer)
|
||||||
{
|
{
|
||||||
int bestFormat = selectBestPixelFormat(shared->m_deviceContext, bitsPerPixel, m_settings, true);
|
int bestFormat = selectBestPixelFormat(shared->m_deviceContext, bitsPerPixel, m_settings, true);
|
||||||
|
|
||||||
@ -595,7 +616,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
// Create the OpenGL context -- first try using wglCreateContextAttribsARB
|
// Create the OpenGL context -- first try using wglCreateContextAttribsARB
|
||||||
while (!m_context && m_settings.majorVersion)
|
while (!m_context && m_settings.majorVersion)
|
||||||
{
|
{
|
||||||
if (sfwgl_ext_ARB_create_context == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_create_context)
|
||||||
{
|
{
|
||||||
std::vector<int> attributes;
|
std::vector<int> attributes;
|
||||||
|
|
||||||
@ -609,7 +630,7 @@ void WglContext::createContext(WglContext* shared)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if setting the profile is supported
|
// Check if setting the profile is supported
|
||||||
if (sfwgl_ext_ARB_create_context_profile == sfwgl_LOAD_SUCCEEDED)
|
if (SF_GLAD_WGL_ARB_create_context_profile)
|
||||||
{
|
{
|
||||||
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
|
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/GlContext.hpp>
|
#include <SFML/Window/GlContext.hpp>
|
||||||
#include <SFML/Window/Win32/WglExtensions.hpp>
|
#include <glad/wgl.h>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
|
@ -1,223 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SFML - Simple and Fast Multimedia Library
|
|
||||||
// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org)
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
// subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented;
|
|
||||||
// you must not claim that you wrote the original software.
|
|
||||||
// If you use this software in a product, an acknowledgment
|
|
||||||
// in the product documentation would be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such,
|
|
||||||
// and must not be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
// Headers
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
#include <SFML/Window/Win32/WglExtensions.hpp>
|
|
||||||
#include <SFML/Window/Context.hpp>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
static sf::GlFunctionPointer IntGetProcAddress(const char* name)
|
|
||||||
{
|
|
||||||
return sf::Context::getFunction(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sfwgl_ext_EXT_swap_control = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_EXT_framebuffer_sRGB = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_framebuffer_sRGB = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_multisample = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_pixel_format = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_pbuffer = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_create_context = sfwgl_LOAD_FAILED;
|
|
||||||
int sfwgl_ext_ARB_create_context_profile = sfwgl_LOAD_FAILED;
|
|
||||||
|
|
||||||
int (CODEGEN_FUNCPTR *sf_ptrc_wglGetSwapIntervalEXT)(void) = NULL;
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglSwapIntervalEXT)(int) = NULL;
|
|
||||||
|
|
||||||
static int Load_EXT_swap_control(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_wglGetSwapIntervalEXT = reinterpret_cast<int (CODEGEN_FUNCPTR*)(void)>(IntGetProcAddress("wglGetSwapIntervalEXT"));
|
|
||||||
if (!sf_ptrc_wglGetSwapIntervalEXT)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglSwapIntervalEXT = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(int)>(IntGetProcAddress("wglSwapIntervalEXT"));
|
|
||||||
if (!sf_ptrc_wglSwapIntervalEXT)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int*, const FLOAT*, UINT, int*, UINT*) = NULL;
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int*, FLOAT*) = NULL;
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int*, int*) = NULL;
|
|
||||||
|
|
||||||
static int Load_ARB_pixel_format(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_wglChoosePixelFormatARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HDC, const int*, const FLOAT*, UINT, int*, UINT*)>(IntGetProcAddress("wglChoosePixelFormatARB"));
|
|
||||||
if (!sf_ptrc_wglChoosePixelFormatARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglGetPixelFormatAttribfvARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR *)(HDC, int, int, UINT, const int*, FLOAT*)>(IntGetProcAddress("wglGetPixelFormatAttribfvARB"));
|
|
||||||
if (!sf_ptrc_wglGetPixelFormatAttribfvARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglGetPixelFormatAttribivARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HDC, int, int, UINT, const int*, int*)>(IntGetProcAddress("wglGetPixelFormatAttribivARB"));
|
|
||||||
if (!sf_ptrc_wglGetPixelFormatAttribivARB)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
HPBUFFERARB (CODEGEN_FUNCPTR *sf_ptrc_wglCreatePbufferARB)(HDC, int, int, int, const int*) = NULL;
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglDestroyPbufferARB)(HPBUFFERARB) = NULL;
|
|
||||||
HDC (CODEGEN_FUNCPTR *sf_ptrc_wglGetPbufferDCARB)(HPBUFFERARB) = NULL;
|
|
||||||
BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglQueryPbufferARB)(HPBUFFERARB, int, int*) = NULL;
|
|
||||||
int (CODEGEN_FUNCPTR *sf_ptrc_wglReleasePbufferDCARB)(HPBUFFERARB, HDC) = NULL;
|
|
||||||
|
|
||||||
static int Load_ARB_pbuffer()
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_wglCreatePbufferARB = reinterpret_cast<HPBUFFERARB (CODEGEN_FUNCPTR*)(HDC, int, int, int, const int*)>(IntGetProcAddress("wglCreatePbufferARB"));
|
|
||||||
if (!sf_ptrc_wglCreatePbufferARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglDestroyPbufferARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HPBUFFERARB)>(IntGetProcAddress("wglDestroyPbufferARB"));
|
|
||||||
if (!sf_ptrc_wglDestroyPbufferARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglGetPbufferDCARB = reinterpret_cast<HDC (CODEGEN_FUNCPTR*)(HPBUFFERARB)>(IntGetProcAddress("wglGetPbufferDCARB"));
|
|
||||||
if (!sf_ptrc_wglGetPbufferDCARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglQueryPbufferARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HPBUFFERARB, int, int*)>(IntGetProcAddress("wglQueryPbufferARB"));
|
|
||||||
if (!sf_ptrc_wglQueryPbufferARB)
|
|
||||||
numFailed++;
|
|
||||||
sf_ptrc_wglReleasePbufferDCARB = reinterpret_cast<int (CODEGEN_FUNCPTR*)(HPBUFFERARB, HDC)>(IntGetProcAddress("wglReleasePbufferDCARB"));
|
|
||||||
if (!sf_ptrc_wglReleasePbufferDCARB)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int*) = NULL;
|
|
||||||
|
|
||||||
static int Load_ARB_create_context(void)
|
|
||||||
{
|
|
||||||
int numFailed = 0;
|
|
||||||
sf_ptrc_wglCreateContextAttribsARB = reinterpret_cast<HGLRC (CODEGEN_FUNCPTR*)(HDC, HGLRC, const int*)>(IntGetProcAddress("wglCreateContextAttribsARB"));
|
|
||||||
if (!sf_ptrc_wglCreateContextAttribsARB)
|
|
||||||
numFailed++;
|
|
||||||
return numFailed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char* (CODEGEN_FUNCPTR *sf_ptrc_wglGetExtensionsStringARB)(HDC) = NULL;
|
|
||||||
|
|
||||||
typedef int (*PFN_LOADFUNCPOINTERS)(void);
|
|
||||||
typedef struct sfwgl_StrToExtMap_s
|
|
||||||
{
|
|
||||||
const char* extensionName;
|
|
||||||
int* extensionVariable;
|
|
||||||
PFN_LOADFUNCPOINTERS LoadExtension;
|
|
||||||
} sfwgl_StrToExtMap;
|
|
||||||
|
|
||||||
static sfwgl_StrToExtMap ExtensionMap[8] = {
|
|
||||||
{"WGL_EXT_swap_control", &sfwgl_ext_EXT_swap_control, Load_EXT_swap_control},
|
|
||||||
{"WGL_EXT_framebuffer_sRGB", &sfwgl_ext_EXT_framebuffer_sRGB, NULL},
|
|
||||||
{"WGL_ARB_framebuffer_sRGB", &sfwgl_ext_ARB_framebuffer_sRGB, NULL},
|
|
||||||
{"WGL_ARB_multisample", &sfwgl_ext_ARB_multisample, NULL},
|
|
||||||
{"WGL_ARB_pixel_format", &sfwgl_ext_ARB_pixel_format, Load_ARB_pixel_format},
|
|
||||||
{"WGL_ARB_pbuffer", &sfwgl_ext_ARB_pbuffer, Load_ARB_pbuffer},
|
|
||||||
{"WGL_ARB_create_context", &sfwgl_ext_ARB_create_context, Load_ARB_create_context},
|
|
||||||
{"WGL_ARB_create_context_profile", &sfwgl_ext_ARB_create_context_profile, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int g_extensionMapSize = 8;
|
|
||||||
|
|
||||||
|
|
||||||
static sfwgl_StrToExtMap* FindExtEntry(const char* extensionName)
|
|
||||||
{
|
|
||||||
sfwgl_StrToExtMap* currLoc = ExtensionMap;
|
|
||||||
for (int loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
|
|
||||||
{
|
|
||||||
if (std::strcmp(extensionName, currLoc->extensionName) == 0)
|
|
||||||
return currLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void ClearExtensionVars(void)
|
|
||||||
{
|
|
||||||
sfwgl_ext_EXT_swap_control = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_EXT_framebuffer_sRGB = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_framebuffer_sRGB = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_multisample = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_pixel_format = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_pbuffer = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_create_context = sfwgl_LOAD_FAILED;
|
|
||||||
sfwgl_ext_ARB_create_context_profile = sfwgl_LOAD_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void LoadExtByName(const char* extensionName)
|
|
||||||
{
|
|
||||||
sfwgl_StrToExtMap* entry = NULL;
|
|
||||||
entry = FindExtEntry(extensionName);
|
|
||||||
if (entry)
|
|
||||||
{
|
|
||||||
if (entry->LoadExtension)
|
|
||||||
{
|
|
||||||
int numFailed = entry->LoadExtension();
|
|
||||||
if (numFailed == 0)
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfwgl_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfwgl_LOAD_SUCCEEDED + numFailed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(entry->extensionVariable) = sfwgl_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void ProcExtsFromExtString(const char* strExtList)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const char* begin = strExtList;
|
|
||||||
|
|
||||||
while ((*strExtList != ' ') && *strExtList)
|
|
||||||
strExtList++;
|
|
||||||
|
|
||||||
LoadExtByName(std::string(begin, strExtList).c_str());
|
|
||||||
} while (*strExtList++);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int sfwgl_LoadFunctions(HDC hdc)
|
|
||||||
{
|
|
||||||
ClearExtensionVars();
|
|
||||||
|
|
||||||
sf_ptrc_wglGetExtensionsStringARB = reinterpret_cast<const char* (CODEGEN_FUNCPTR*)(HDC)>(IntGetProcAddress("wglGetExtensionsStringARB"));
|
|
||||||
if (!sf_ptrc_wglGetExtensionsStringARB)
|
|
||||||
return sfwgl_LOAD_FAILED;
|
|
||||||
|
|
||||||
ProcExtsFromExtString(reinterpret_cast<const char*>(sf_ptrc_wglGetExtensionsStringARB(hdc)));
|
|
||||||
return sfwgl_LOAD_SUCCEEDED;
|
|
||||||
}
|
|
||||||
|
|
@ -1,236 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SFML - Simple and Fast Multimedia Library
|
|
||||||
// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org)
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
// subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented;
|
|
||||||
// you must not claim that you wrote the original software.
|
|
||||||
// If you use this software in a product, an acknowledgment
|
|
||||||
// in the product documentation would be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such,
|
|
||||||
// and must not be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef SF_POINTER_C_GENERATED_HEADER_WINDOWSGL_HPP
|
|
||||||
#define SF_POINTER_C_GENERATED_HEADER_WINDOWSGL_HPP
|
|
||||||
|
|
||||||
#ifdef __wglext_h_
|
|
||||||
#error Attempt to include auto-generated WGL header after wglext.h
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __wglext_h_
|
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
|
||||||
#endif
|
|
||||||
#ifndef NOMINMAX
|
|
||||||
#define NOMINMAX
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#ifdef CODEGEN_FUNCPTR
|
|
||||||
#undef CODEGEN_FUNCPTR
|
|
||||||
#endif // CODEGEN_FUNCPTR
|
|
||||||
#define CODEGEN_FUNCPTR WINAPI
|
|
||||||
|
|
||||||
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
typedef unsigned int GLenum;
|
|
||||||
typedef unsigned char GLboolean;
|
|
||||||
typedef unsigned int GLbitfield;
|
|
||||||
typedef signed char GLbyte;
|
|
||||||
typedef short GLshort;
|
|
||||||
typedef int GLint;
|
|
||||||
typedef int GLsizei;
|
|
||||||
typedef unsigned char GLubyte;
|
|
||||||
typedef unsigned short GLushort;
|
|
||||||
typedef unsigned int GLuint;
|
|
||||||
typedef float GLfloat;
|
|
||||||
typedef float GLclampf;
|
|
||||||
typedef double GLdouble;
|
|
||||||
typedef double GLclampd;
|
|
||||||
#define GLvoid void
|
|
||||||
|
|
||||||
#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
|
|
||||||
|
|
||||||
|
|
||||||
struct _GPU_DEVICE {
|
|
||||||
DWORD cb;
|
|
||||||
CHAR DeviceName[32];
|
|
||||||
CHAR DeviceString[128];
|
|
||||||
DWORD Flags;
|
|
||||||
RECT rcVirtualScreen;
|
|
||||||
};
|
|
||||||
DECLARE_HANDLE(HPBUFFERARB);
|
|
||||||
DECLARE_HANDLE(HPBUFFEREXT);
|
|
||||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
|
||||||
DECLARE_HANDLE(HPVIDEODEV);
|
|
||||||
DECLARE_HANDLE(HGPUNV);
|
|
||||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
|
||||||
typedef struct _GPU_DEVICE *PGPU_DEVICE;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
extern int sfwgl_ext_EXT_swap_control;
|
|
||||||
extern int sfwgl_ext_EXT_framebuffer_sRGB;
|
|
||||||
extern int sfwgl_ext_ARB_framebuffer_sRGB;
|
|
||||||
extern int sfwgl_ext_ARB_multisample;
|
|
||||||
extern int sfwgl_ext_ARB_pixel_format;
|
|
||||||
extern int sfwgl_ext_ARB_pbuffer;
|
|
||||||
extern int sfwgl_ext_ARB_create_context;
|
|
||||||
extern int sfwgl_ext_ARB_create_context_profile;
|
|
||||||
|
|
||||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
|
||||||
|
|
||||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
|
||||||
|
|
||||||
#define WGL_SAMPLES_ARB 0x2042
|
|
||||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
|
||||||
|
|
||||||
#define WGL_ACCELERATION_ARB 0x2003
|
|
||||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
|
||||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
|
||||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
|
||||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
|
||||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
|
||||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
|
||||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
|
||||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
|
||||||
#define WGL_BLUE_BITS_ARB 0x2019
|
|
||||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
|
||||||
#define WGL_COLOR_BITS_ARB 0x2014
|
|
||||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
|
||||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
|
||||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
|
||||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
|
||||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
|
||||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
|
||||||
#define WGL_GREEN_BITS_ARB 0x2017
|
|
||||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
|
||||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
|
||||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
|
||||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
|
||||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
|
||||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
|
||||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
|
||||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
|
||||||
#define WGL_RED_BITS_ARB 0x2015
|
|
||||||
#define WGL_RED_SHIFT_ARB 0x2017
|
|
||||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
|
||||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
|
||||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
|
||||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
|
||||||
#define WGL_STEREO_ARB 0x2012
|
|
||||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
|
||||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
|
||||||
#define WGL_SWAP_COPY_ARB 0x2029
|
|
||||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
|
||||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
|
||||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
|
||||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
|
||||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
|
||||||
#define WGL_TRANSPARENT_ARB 0x200A
|
|
||||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
|
||||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
|
||||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
|
||||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
|
||||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
|
||||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
|
||||||
|
|
||||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
|
||||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
|
||||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
|
||||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
|
||||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
|
||||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
|
||||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
|
||||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
|
||||||
|
|
||||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
|
||||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
|
||||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
|
||||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
|
||||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
|
||||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
|
||||||
#define WGL_ERROR_INVALID_VERSION_ARB 0x2095
|
|
||||||
|
|
||||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
|
||||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
|
||||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
|
||||||
#define WGL_ERROR_INVALID_PROFILE_ARB 0x2096
|
|
||||||
|
|
||||||
#ifndef WGL_EXT_swap_control
|
|
||||||
#define WGL_EXT_swap_control 1
|
|
||||||
extern int (CODEGEN_FUNCPTR *sf_ptrc_wglGetSwapIntervalEXT)(void);
|
|
||||||
#define wglGetSwapIntervalEXT sf_ptrc_wglGetSwapIntervalEXT
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglSwapIntervalEXT)(int);
|
|
||||||
#define wglSwapIntervalEXT sf_ptrc_wglSwapIntervalEXT
|
|
||||||
#endif // WGL_EXT_swap_control
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef WGL_ARB_pixel_format
|
|
||||||
#define WGL_ARB_pixel_format 1
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int*, const FLOAT*, UINT, int*, UINT*);
|
|
||||||
#define wglChoosePixelFormatARB sf_ptrc_wglChoosePixelFormatARB
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int*, FLOAT*);
|
|
||||||
#define wglGetPixelFormatAttribfvARB sf_ptrc_wglGetPixelFormatAttribfvARB
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int*, int*);
|
|
||||||
#define wglGetPixelFormatAttribivARB sf_ptrc_wglGetPixelFormatAttribivARB
|
|
||||||
#endif // WGL_ARB_pixel_format
|
|
||||||
|
|
||||||
#ifndef WGL_ARB_pbuffer
|
|
||||||
#define WGL_ARB_pbuffer 1
|
|
||||||
extern HPBUFFERARB (CODEGEN_FUNCPTR *sf_ptrc_wglCreatePbufferARB)(HDC, int, int, int, const int*);
|
|
||||||
#define wglCreatePbufferARB sf_ptrc_wglCreatePbufferARB
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglDestroyPbufferARB)(HPBUFFERARB);
|
|
||||||
#define wglDestroyPbufferARB sf_ptrc_wglDestroyPbufferARB
|
|
||||||
extern HDC (CODEGEN_FUNCPTR *sf_ptrc_wglGetPbufferDCARB)(HPBUFFERARB);
|
|
||||||
#define wglGetPbufferDCARB sf_ptrc_wglGetPbufferDCARB
|
|
||||||
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglQueryPbufferARB)(HPBUFFERARB, int, int*);
|
|
||||||
#define wglQueryPbufferARB sf_ptrc_wglQueryPbufferARB
|
|
||||||
extern int (CODEGEN_FUNCPTR *sf_ptrc_wglReleasePbufferDCARB)(HPBUFFERARB, HDC);
|
|
||||||
#define wglReleasePbufferDCARB sf_ptrc_wglReleasePbufferDCARB
|
|
||||||
#endif // WGL_ARB_pbuffer
|
|
||||||
|
|
||||||
#ifndef WGL_ARB_create_context
|
|
||||||
#define WGL_ARB_create_context 1
|
|
||||||
extern HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int*);
|
|
||||||
#define wglCreateContextAttribsARB sf_ptrc_wglCreateContextAttribsARB
|
|
||||||
#endif // WGL_ARB_create_context
|
|
||||||
|
|
||||||
|
|
||||||
enum sfwgl_LoadStatus
|
|
||||||
{
|
|
||||||
sfwgl_LOAD_FAILED = 0,
|
|
||||||
sfwgl_LOAD_SUCCEEDED = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
int sfwgl_LoadFunctions(HDC hdc);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif // SF_POINTER_C_GENERATED_HEADER_WINDOWSGL_HPP
|
|
@ -1,13 +0,0 @@
|
|||||||
// Created with:
|
|
||||||
// https://bitbucket.org/KhronosGroup/glloadgen
|
|
||||||
// Commit d143d66ac90d538ed06f806188714861b8e8e2f9
|
|
||||||
// lua LoadGen.lua -style=pointer_c -spec=wgl -indent=space -prefix=sf -extfile=WglExtensions.txt WglExtensions
|
|
||||||
|
|
||||||
EXT_swap_control
|
|
||||||
EXT_framebuffer_sRGB
|
|
||||||
ARB_framebuffer_sRGB
|
|
||||||
WGL_ARB_multisample
|
|
||||||
WGL_ARB_pixel_format
|
|
||||||
WGL_ARB_pbuffer
|
|
||||||
WGL_ARB_create_context
|
|
||||||
WGL_ARB_create_context_profile
|
|
@ -36,7 +36,6 @@
|
|||||||
#define WINVER 0x0501
|
#define WINVER 0x0501
|
||||||
#include <SFML/Window/Win32/WindowImplWin32.hpp>
|
#include <SFML/Window/Win32/WindowImplWin32.hpp>
|
||||||
#include <SFML/Window/WindowStyle.hpp>
|
#include <SFML/Window/WindowStyle.hpp>
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
#include <SFML/System/Utf.hpp>
|
#include <SFML/System/Utf.hpp>
|
||||||
// dbt.h is lowercase here, as a cross-compile on linux with mingw-w64
|
// dbt.h is lowercase here, as a cross-compile on linux with mingw-w64
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <SFML/Window/iOS/ObjCType.hpp>
|
#include <SFML/Window/iOS/ObjCType.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/System/Clock.hpp>
|
#include <SFML/System/Clock.hpp>
|
||||||
#include <OpenGLES/ES1/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
|
|
||||||
SFML_DECLARE_OBJC_CLASS(EAGLContext);
|
SFML_DECLARE_OBJC_CLASS(EAGLContext);
|
||||||
@ -90,6 +90,16 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
~EaglContext();
|
~EaglContext();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the address of an OpenGL function
|
||||||
|
///
|
||||||
|
/// \param name Name of the function to get the address of
|
||||||
|
///
|
||||||
|
/// \return Address of the OpenGL function, 0 on failure
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
static GlFunctionPointer getFunction(const char* name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Recreate the render buffers of the context
|
/// \brief Recreate the render buffers of the context
|
||||||
///
|
///
|
||||||
|
@ -32,8 +32,44 @@
|
|||||||
#include <SFML/System/Sleep.hpp>
|
#include <SFML/System/Sleep.hpp>
|
||||||
#include <OpenGLES/EAGL.h>
|
#include <OpenGLES/EAGL.h>
|
||||||
#include <OpenGLES/EAGLDrawable.h>
|
#include <OpenGLES/EAGLDrawable.h>
|
||||||
#include <OpenGLES/ES1/glext.h>
|
|
||||||
#include <QuartzCore/CAEAGLLayer.h>
|
#include <QuartzCore/CAEAGLLayer.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOESFunc = 0;
|
||||||
|
PFNGLBINDRENDERBUFFEROESPROC glBindRenderbufferOESFunc = 0;
|
||||||
|
PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOESFunc = 0;
|
||||||
|
PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOESFunc = 0;
|
||||||
|
PFNGLDELETERENDERBUFFERSOESPROC glDeleteRenderbuffersOESFunc = 0;
|
||||||
|
PFNGLFRAMEBUFFERRENDERBUFFEROESPROC glFramebufferRenderbufferOESFunc = 0;
|
||||||
|
PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOESFunc = 0;
|
||||||
|
PFNGLGENRENDERBUFFERSOESPROC glGenRenderbuffersOESFunc = 0;
|
||||||
|
PFNGLGETRENDERBUFFERPARAMETERIVOESPROC glGetRenderbufferParameterivOESFunc = 0;
|
||||||
|
PFNGLRENDERBUFFERSTORAGEOESPROC glRenderbufferStorageOESFunc = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void ensureInit()
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
glBindFramebufferOESFunc = reinterpret_cast<PFNGLBINDFRAMEBUFFEROESPROC> (sf::priv::EaglContext::getFunction("glBindFramebufferOES"));
|
||||||
|
glBindRenderbufferOESFunc = reinterpret_cast<PFNGLBINDRENDERBUFFEROESPROC> (sf::priv::EaglContext::getFunction("glBindRenderbufferOES"));
|
||||||
|
glCheckFramebufferStatusOESFunc = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSOESPROC> (sf::priv::EaglContext::getFunction("glCheckFramebufferStatusOES"));
|
||||||
|
glDeleteFramebuffersOESFunc = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSOESPROC> (sf::priv::EaglContext::getFunction("glDeleteFramebuffersOES"));
|
||||||
|
glDeleteRenderbuffersOESFunc = reinterpret_cast<PFNGLDELETERENDERBUFFERSOESPROC> (sf::priv::EaglContext::getFunction("glDeleteRenderbuffersOES"));
|
||||||
|
glFramebufferRenderbufferOESFunc = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFEROESPROC> (sf::priv::EaglContext::getFunction("glFramebufferRenderbufferOES"));
|
||||||
|
glGenFramebuffersOESFunc = reinterpret_cast<PFNGLGENFRAMEBUFFERSOESPROC> (sf::priv::EaglContext::getFunction("glGenFramebuffersOES"));
|
||||||
|
glGenRenderbuffersOESFunc = reinterpret_cast<PFNGLGENRENDERBUFFERSOESPROC> (sf::priv::EaglContext::getFunction("glGenRenderbuffersOES"));
|
||||||
|
glGetRenderbufferParameterivOESFunc = reinterpret_cast<PFNGLGETRENDERBUFFERPARAMETERIVOESPROC>(sf::priv::EaglContext::getFunction("glGetRenderbufferParameterivOES"));
|
||||||
|
glRenderbufferStorageOESFunc = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEOESPROC> (sf::priv::EaglContext::getFunction("glRenderbufferStorageOES"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -49,6 +85,8 @@ m_depthbuffer (0),
|
|||||||
m_vsyncEnabled(false),
|
m_vsyncEnabled(false),
|
||||||
m_clock ()
|
m_clock ()
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
if (shared)
|
if (shared)
|
||||||
m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:[shared->m_context sharegroup]];
|
m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:[shared->m_context sharegroup]];
|
||||||
@ -67,6 +105,8 @@ m_depthbuffer (0),
|
|||||||
m_vsyncEnabled(false),
|
m_vsyncEnabled(false),
|
||||||
m_clock ()
|
m_clock ()
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
const WindowImplUIKit* window = static_cast<const WindowImplUIKit*>(owner);
|
const WindowImplUIKit* window = static_cast<const WindowImplUIKit*>(owner);
|
||||||
|
|
||||||
createContext(shared, window, bitsPerPixel, settings);
|
createContext(shared, window, bitsPerPixel, settings);
|
||||||
@ -83,6 +123,8 @@ m_depthbuffer (0),
|
|||||||
m_vsyncEnabled(false),
|
m_vsyncEnabled(false),
|
||||||
m_clock ()
|
m_clock ()
|
||||||
{
|
{
|
||||||
|
ensureInit();
|
||||||
|
|
||||||
// This constructor should never be used by implementation
|
// This constructor should never be used by implementation
|
||||||
err() << "Calling bad EaglContext constructor, please contact your developer :)" << std::endl;
|
err() << "Calling bad EaglContext constructor, please contact your developer :)" << std::endl;
|
||||||
}
|
}
|
||||||
@ -102,11 +144,11 @@ EaglContext::~EaglContext()
|
|||||||
|
|
||||||
// Destroy the buffers
|
// Destroy the buffers
|
||||||
if (m_framebuffer)
|
if (m_framebuffer)
|
||||||
glDeleteFramebuffersOES(1, &m_framebuffer);
|
glDeleteFramebuffersOESFunc(1, &m_framebuffer);
|
||||||
if (m_colorbuffer)
|
if (m_colorbuffer)
|
||||||
glDeleteRenderbuffersOES(1, &m_colorbuffer);
|
glDeleteRenderbuffersOESFunc(1, &m_colorbuffer);
|
||||||
if (m_depthbuffer)
|
if (m_depthbuffer)
|
||||||
glDeleteRenderbuffersOES(1, &m_depthbuffer);
|
glDeleteRenderbuffersOESFunc(1, &m_depthbuffer);
|
||||||
|
|
||||||
// Restore the previous context
|
// Restore the previous context
|
||||||
[EAGLContext setCurrentContext:previousContext];
|
[EAGLContext setCurrentContext:previousContext];
|
||||||
@ -117,6 +159,21 @@ EaglContext::~EaglContext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
GlFunctionPointer EaglContext::getFunction(const char* name)
|
||||||
|
{
|
||||||
|
static void* module = 0;
|
||||||
|
|
||||||
|
if (!module)
|
||||||
|
module = dlopen("libGLESv1_CM.dylib", RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
|
||||||
|
if (module)
|
||||||
|
return reinterpret_cast<GlFunctionPointer>(dlsym(module, name));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void EaglContext::recreateRenderBuffers(SFView* glView)
|
void EaglContext::recreateRenderBuffers(SFView* glView)
|
||||||
{
|
{
|
||||||
@ -125,20 +182,20 @@ void EaglContext::recreateRenderBuffers(SFView* glView)
|
|||||||
[EAGLContext setCurrentContext:m_context];
|
[EAGLContext setCurrentContext:m_context];
|
||||||
|
|
||||||
// Bind the frame buffer
|
// Bind the frame buffer
|
||||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_framebuffer);
|
glBindFramebufferOESFunc(GL_FRAMEBUFFER_OES, m_framebuffer);
|
||||||
|
|
||||||
// Destroy previous render-buffers
|
// Destroy previous render-buffers
|
||||||
if (m_colorbuffer)
|
if (m_colorbuffer)
|
||||||
glDeleteRenderbuffersOES(1, &m_colorbuffer);
|
glDeleteRenderbuffersOESFunc(1, &m_colorbuffer);
|
||||||
if (m_depthbuffer)
|
if (m_depthbuffer)
|
||||||
glDeleteRenderbuffersOES(1, &m_depthbuffer);
|
glDeleteRenderbuffersOESFunc(1, &m_depthbuffer);
|
||||||
|
|
||||||
// Create the color buffer
|
// Create the color buffer
|
||||||
glGenRenderbuffersOES(1, &m_colorbuffer);
|
glGenRenderbuffersOESFunc(1, &m_colorbuffer);
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorbuffer);
|
glBindRenderbufferOESFunc(GL_RENDERBUFFER_OES, m_colorbuffer);
|
||||||
if (glView)
|
if (glView)
|
||||||
[m_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)glView.layer];
|
[m_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)glView.layer];
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_colorbuffer);
|
glFramebufferRenderbufferOESFunc(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_colorbuffer);
|
||||||
|
|
||||||
// Create a depth buffer if requested
|
// Create a depth buffer if requested
|
||||||
if (m_settings.depthBits > 0)
|
if (m_settings.depthBits > 0)
|
||||||
@ -150,20 +207,20 @@ void EaglContext::recreateRenderBuffers(SFView* glView)
|
|||||||
|
|
||||||
// Get the size of the color-buffer (which fits the current size of the GL view)
|
// Get the size of the color-buffer (which fits the current size of the GL view)
|
||||||
GLint width, height;
|
GLint width, height;
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &width);
|
glGetRenderbufferParameterivOESFunc(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &width);
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &height);
|
glGetRenderbufferParameterivOESFunc(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &height);
|
||||||
|
|
||||||
// Create the depth buffer
|
// Create the depth buffer
|
||||||
glGenRenderbuffersOES(1, &m_depthbuffer);
|
glGenRenderbuffersOESFunc(1, &m_depthbuffer);
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_depthbuffer);
|
glBindRenderbufferOESFunc(GL_RENDERBUFFER_OES, m_depthbuffer);
|
||||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, format, width, height);
|
glRenderbufferStorageOESFunc(GL_RENDERBUFFER_OES, format, width, height);
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthbuffer);
|
glFramebufferRenderbufferOESFunc(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthbuffer);
|
||||||
if (m_settings.stencilBits > 0)
|
if (m_settings.stencilBits > 0)
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthbuffer);
|
glFramebufferRenderbufferOESFunc(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that everything's ok
|
// Make sure that everything's ok
|
||||||
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
GLenum status = glCheckFramebufferStatusOESFunc(GL_FRAMEBUFFER_OES);
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_OES)
|
if (status != GL_FRAMEBUFFER_COMPLETE_OES)
|
||||||
err() << "Failed to create a valid frame buffer (error code: " << status << ")" << std::endl;
|
err() << "Failed to create a valid frame buffer (error code: " << status << ")" << std::endl;
|
||||||
|
|
||||||
@ -185,7 +242,7 @@ bool EaglContext::makeCurrent(bool current)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void EaglContext::display()
|
void EaglContext::display()
|
||||||
{
|
{
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorbuffer);
|
glBindRenderbufferOESFunc(GL_RENDERBUFFER_OES, m_colorbuffer);
|
||||||
[m_context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
[m_context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
||||||
|
|
||||||
// The proper way of doing v-sync on iOS would be to use CADisplayLink
|
// The proper way of doing v-sync on iOS would be to use CADisplayLink
|
||||||
@ -238,7 +295,7 @@ void EaglContext::createContext(EaglContext* shared,
|
|||||||
makeCurrent(true);
|
makeCurrent(true);
|
||||||
|
|
||||||
// Create the framebuffer (this is the only allowed drawable on iOS)
|
// Create the framebuffer (this is the only allowed drawable on iOS)
|
||||||
glGenFramebuffersOES(1, &m_framebuffer);
|
glGenFramebuffersOESFunc(1, &m_framebuffer);
|
||||||
|
|
||||||
// Create the render buffers
|
// Create the render buffers
|
||||||
recreateRenderBuffers(window->getGlView());
|
recreateRenderBuffers(window->getGlView());
|
||||||
|
Loading…
Reference in New Issue
Block a user