mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Don't load WGL
Depend on SDL and wxWidgets doing the necessary work. Also remove WGL from glad. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
d082c9bfdd
commit
c08b6ef3cb
10 changed files with 0 additions and 478 deletions
|
|
@ -1065,9 +1065,6 @@ function setup_all_libs ()
|
|||
files { glad_path.."src/gles2.cpp" }
|
||||
else
|
||||
files { glad_path.."src/gl.cpp" }
|
||||
if os.istarget("windows") then
|
||||
files { glad_path.."src/wgl.cpp" }
|
||||
end
|
||||
end
|
||||
-- on Windows, silence a build warning in vulkan.cpp
|
||||
filter "action:vs*"
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
|
||||
#if OS_WIN
|
||||
# include <glad/wgl.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// extensions
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -202,9 +198,6 @@ bool ogl_HaveExtension(const char* ext)
|
|||
}
|
||||
|
||||
static int GLVersion;
|
||||
#if OS_WIN
|
||||
static int WGLVersion;
|
||||
#endif
|
||||
|
||||
bool ogl_HaveVersion(int major, int minor)
|
||||
{
|
||||
|
|
@ -344,11 +337,7 @@ bool ogl_SquelchError(GLenum err_to_ignore)
|
|||
// feature and limit detect
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if OS_WIN
|
||||
bool ogl_Init(void* (load)(const char*), void* hdc)
|
||||
#else
|
||||
bool ogl_Init(void* (load)(const char*))
|
||||
#endif
|
||||
{
|
||||
GLADloadfunc loadFunc = reinterpret_cast<GLADloadfunc>(load);
|
||||
if (!loadFunc)
|
||||
|
|
@ -367,14 +356,6 @@ bool ogl_Init(void* (load)(const char*))
|
|||
LOAD_ERROR("Failed to load OpenGL functions.");
|
||||
return false;
|
||||
}
|
||||
# if OS_WIN
|
||||
WGLVersion = gladLoadWGL(reinterpret_cast<HDC>(hdc), loadFunc);
|
||||
if (!WGLVersion)
|
||||
{
|
||||
LOAD_ERROR("Failed to load WGL functions.");
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
GLVersion = gladLoadGLES2(loadFunc);
|
||||
if (!GLVersion)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "lib/code_annotation.h"
|
||||
#include "lib/config2.h" // CONFIG2_GLES
|
||||
#include "lib/sysdep/os.h" // OS_WIN
|
||||
|
||||
|
||||
#if CONFIG2_GLES
|
||||
|
|
@ -44,11 +43,7 @@
|
|||
* fails if OpenGL not ready for use.
|
||||
* TODO: move loading functionality to GL backend.
|
||||
**/
|
||||
#if OS_WIN
|
||||
extern bool ogl_Init(void* (load)(const char*), void* hdc);
|
||||
#else
|
||||
extern bool ogl_Init(void* (load)(const char*));
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// extensions
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "lib/hash.h"
|
||||
#include "lib/ogl.h"
|
||||
#include "lib/secure_crt.h"
|
||||
#include "lib/sysdep/os.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "ps/Profile.h"
|
||||
|
|
@ -56,12 +55,6 @@
|
|||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#if OS_WIN
|
||||
// We can't include wutil directly because GL headers conflict with Windows
|
||||
// until we use a proper GL loader.
|
||||
extern void* wutil_GetAppHDC();
|
||||
#endif
|
||||
|
||||
namespace Renderer
|
||||
{
|
||||
|
||||
|
|
@ -233,11 +226,7 @@ std::unique_ptr<IDevice> CDevice::Create(SDL_Window* window)
|
|||
SDL_GL_GetDrawableSize(window, &device->m_SurfaceDrawableWidth, &device->m_SurfaceDrawableHeight);
|
||||
}
|
||||
|
||||
#if OS_WIN
|
||||
ogl_Init(SDL_GL_GetProcAddress, wutil_GetAppHDC());
|
||||
#else
|
||||
ogl_Init(SDL_GL_GetProcAddress);
|
||||
#endif
|
||||
|
||||
if (!ogl_HaveVersion(2, 0)
|
||||
|| !ogl_HaveExtension("GL_ARB_vertex_buffer_object")
|
||||
|
|
|
|||
4
source/third_party/glad/README.md
vendored
4
source/third_party/glad/README.md
vendored
|
|
@ -33,10 +33,6 @@ Build the source files for all four backends with their respective extensions
|
|||
```sh
|
||||
python -m glad --api="gles2=2.0" --extensions="../extensions/gles2.txt" --out-path="../" c
|
||||
```
|
||||
- WGL
|
||||
```sh
|
||||
python -m glad --api="wgl=1.0" --extensions="../extensions/wgl.txt" --out-path="../" c
|
||||
```
|
||||
- Vulkan
|
||||
```sh
|
||||
python -m glad --api="vulkan=1.1" --extensions="../extensions/vulkan.txt" --out-path="../" c
|
||||
|
|
|
|||
1
source/third_party/glad/extensions/wgl.txt
vendored
1
source/third_party/glad/extensions/wgl.txt
vendored
|
|
@ -1 +0,0 @@
|
|||
WGL_EXT_swap_control
|
||||
301
source/third_party/glad/include/glad/wgl.h
vendored
301
source/third_party/glad/include/glad/wgl.h
vendored
|
|
@ -1,301 +0,0 @@
|
|||
/**
|
||||
* Loader generated by glad 2.0.8 on Sat May 16 09:06:56 2026
|
||||
*
|
||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||
*
|
||||
* Generator: C/C++
|
||||
* Specification: wgl
|
||||
* Extensions: 3
|
||||
*
|
||||
* APIs:
|
||||
* - wgl=1.0
|
||||
*
|
||||
* Options:
|
||||
* - ALIAS = False
|
||||
* - DEBUG = False
|
||||
* - HEADER_ONLY = False
|
||||
* - LOADER = False
|
||||
* - MX = False
|
||||
* - ON_DEMAND = False
|
||||
*
|
||||
* Commandline:
|
||||
* --api='wgl=1.0' --extensions='WGL_ARB_extensions_string,WGL_EXT_extensions_string,WGL_EXT_swap_control' c
|
||||
*
|
||||
* Online:
|
||||
* http://glad.sh/#api=wgl%3D1.0&extensions=WGL_ARB_extensions_string%2CWGL_EXT_extensions_string%2CWGL_EXT_swap_control&generator=c&options=
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLAD_WGL_H_
|
||||
#define GLAD_WGL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <glad/gl.h>
|
||||
|
||||
#define GLAD_WGL
|
||||
|
||||
#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
|
||||
|
||||
#define GLAD_UNUSED(x) (void)(x)
|
||||
|
||||
#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.8"
|
||||
|
||||
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 WGL_FONT_LINES 0
|
||||
#define WGL_FONT_POLYGONS 1
|
||||
#define WGL_SWAP_MAIN_PLANE 0x00000001
|
||||
#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_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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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 GLAD_WGL_VERSION_1_0;
|
||||
#define WGL_ARB_extensions_string 1
|
||||
GLAD_API_CALL int GLAD_WGL_ARB_extensions_string;
|
||||
#define WGL_EXT_extensions_string 1
|
||||
GLAD_API_CALL int GLAD_WGL_EXT_extensions_string;
|
||||
#define WGL_EXT_swap_control 1
|
||||
GLAD_API_CALL int 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, PIXELFORMATDESCRIPTOR * ppfd);
|
||||
typedef UINT (GLAD_API_PTR *PFNGETENHMETAFILEPIXELFORMATPROC)(HENHMETAFILE hemf, UINT cbBuffer, 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 *PFNWGLCOPYCONTEXTPROC)(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATECONTEXTPROC)(HDC hDc);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATELAYERCONTEXTPROC)(HDC hDc, int level);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLDELETECONTEXTPROC)(HGLRC oldContext);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLDESCRIBELAYERPLANEPROC)(HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, LAYERPLANEDESCRIPTOR * plpd);
|
||||
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, COLORREF * pcr);
|
||||
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 *PFNWGLREALIZELAYERPALETTEPROC)(HDC hdc, int iLayerPlane, BOOL bRealize);
|
||||
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 PFNWGLGETEXTENSIONSSTRINGARBPROC glad_wglGetExtensionsStringARB;
|
||||
#define wglGetExtensionsStringARB glad_wglGetExtensionsStringARB
|
||||
GLAD_API_CALL PFNWGLGETEXTENSIONSSTRINGEXTPROC glad_wglGetExtensionsStringEXT;
|
||||
#define wglGetExtensionsStringEXT glad_wglGetExtensionsStringEXT
|
||||
GLAD_API_CALL PFNWGLGETSWAPINTERVALEXTPROC glad_wglGetSwapIntervalEXT;
|
||||
#define wglGetSwapIntervalEXT glad_wglGetSwapIntervalEXT
|
||||
GLAD_API_CALL PFNWGLSWAPINTERVALEXTPROC glad_wglSwapIntervalEXT;
|
||||
#define wglSwapIntervalEXT glad_wglSwapIntervalEXT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GLAD_API_CALL int gladLoadWGLUserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoadWGL(HDC hdc, GLADloadfunc load);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
130
source/third_party/glad/src/wgl.cpp
vendored
130
source/third_party/glad/src/wgl.cpp
vendored
|
|
@ -1,130 +0,0 @@
|
|||
/**
|
||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glad/wgl.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_ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int GLAD_WGL_VERSION_1_0 = 0;
|
||||
int GLAD_WGL_ARB_extensions_string = 0;
|
||||
int GLAD_WGL_EXT_extensions_string = 0;
|
||||
int GLAD_WGL_EXT_swap_control = 0;
|
||||
|
||||
|
||||
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC glad_wglGetExtensionsStringARB = NULL;
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC glad_wglGetExtensionsStringEXT = NULL;
|
||||
PFNWGLGETSWAPINTERVALEXTPROC glad_wglGetSwapIntervalEXT = NULL;
|
||||
PFNWGLSWAPINTERVALEXTPROC glad_wglSwapIntervalEXT = NULL;
|
||||
|
||||
|
||||
static void glad_wgl_load_WGL_ARB_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!GLAD_WGL_ARB_extensions_string) return;
|
||||
glad_wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||
}
|
||||
static void glad_wgl_load_WGL_EXT_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!GLAD_WGL_EXT_extensions_string) return;
|
||||
glad_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||
}
|
||||
static void glad_wgl_load_WGL_EXT_swap_control(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!GLAD_WGL_EXT_swap_control) return;
|
||||
glad_wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) load(userptr, "wglGetSwapIntervalEXT");
|
||||
glad_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) load(userptr, "wglSwapIntervalEXT");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int 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 glad_wgl_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
static int glad_wgl_find_extensions_wgl(HDC hdc) {
|
||||
GLAD_WGL_ARB_extensions_string = glad_wgl_has_extension(hdc, "WGL_ARB_extensions_string");
|
||||
GLAD_WGL_EXT_extensions_string = glad_wgl_has_extension(hdc, "WGL_EXT_extensions_string");
|
||||
GLAD_WGL_EXT_swap_control = glad_wgl_has_extension(hdc, "WGL_EXT_swap_control");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_wgl_find_core_wgl(void) {
|
||||
int major = 1, minor = 0;
|
||||
GLAD_WGL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
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 = glad_wgl_find_core_wgl();
|
||||
|
||||
|
||||
if (!glad_wgl_find_extensions_wgl(hdc)) return 0;
|
||||
glad_wgl_load_WGL_ARB_extensions_string(load, userptr);
|
||||
glad_wgl_load_WGL_EXT_extensions_string(load, userptr);
|
||||
glad_wgl_load_WGL_EXT_swap_control(load, userptr);
|
||||
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
int gladLoadWGL(HDC hdc, GLADloadfunc load) {
|
||||
return gladLoadWGLUserPtr(hdc, glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
2
source/third_party/glad/update-headers.cmd
vendored
2
source/third_party/glad/update-headers.cmd
vendored
|
|
@ -2,11 +2,9 @@
|
|||
cd glad
|
||||
python -m glad --api="gl:core=2.1" --extensions="../extensions/gl.txt" --out-path="../" c
|
||||
python -m glad --api="gles2=2.0" --extensions="../extensions/gles2.txt" --out-path="../" c
|
||||
python -m glad --api="wgl=1.0" --extensions="../extensions/wgl.txt" --out-path="../" c
|
||||
python -m glad --api="vulkan=1.1" --extensions="../extensions/vulkan.txt" --out-path="../" c
|
||||
cd ..
|
||||
patch -p1 --ignore-whitespace --fuzz 1 < fix_macos.patch
|
||||
MOVE src\gl.c src\gl.cpp
|
||||
MOVE src\gles2.c src\gles2.cpp
|
||||
MOVE src\wgl.c src\wgl.cpp
|
||||
MOVE src\vulkan.c src\vulkan.cpp
|
||||
|
|
|
|||
2
source/third_party/glad/update-headers.sh
vendored
2
source/third_party/glad/update-headers.sh
vendored
|
|
@ -9,12 +9,10 @@ export PYTHONPATH="glad"
|
|||
|
||||
python -m glad --api="gl:core=2.1" --extensions="extensions/gl.txt" --out-path="." c
|
||||
python -m glad --api="gles2=2.0" --extensions="extensions/gles2.txt" --out-path="." c
|
||||
python -m glad --api="wgl=1.0" --extensions="extensions/wgl.txt" --out-path="." c
|
||||
python -m glad --api="vulkan=1.1" --extensions="extensions/vulkan.txt" --out-path="." c
|
||||
|
||||
patch -p1 --ignore-whitespace --fuzz 1 <fix_macos.patch
|
||||
|
||||
mv src/gl.c src/gl.cpp
|
||||
mv src/gles2.c src/gles2.cpp
|
||||
mv src/wgl.c src/wgl.cpp
|
||||
mv src/vulkan.c src/vulkan.cpp
|
||||
|
|
|
|||
Loading…
Reference in a new issue