WIP: use Duckstation's context code to directly render into QT Widget from separate thread without two OpenGL contexts
currently only works on Windows
This commit is contained in:
parent
ce68e883c4
commit
ef763aa569
|
@ -115,11 +115,20 @@ if (MATH_LIBRARY)
|
|||
endif()
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(Epoxy REQUIRED IMPORTED_TARGET epoxy)
|
||||
fix_interface_includes(PkgConfig::Epoxy)
|
||||
target_sources(core PRIVATE
|
||||
glad/glad.c
|
||||
|
||||
duckstation/gl/context.cpp)
|
||||
|
||||
target_link_libraries(core PUBLIC PkgConfig::Epoxy)
|
||||
if (WIN32)
|
||||
target_link_libraries(core PUBLIC opengl32)
|
||||
|
||||
target_sources(core PRIVATE
|
||||
duckstation/gl/context_wgl.cpp
|
||||
|
||||
glad/glad_wgl.c)
|
||||
endif()
|
||||
# TODO: figure this out for Linux
|
||||
|
||||
target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED)
|
||||
endif()
|
||||
|
@ -127,7 +136,6 @@ endif()
|
|||
if (ENABLE_JIT)
|
||||
target_compile_definitions(core PUBLIC JIT_ENABLED)
|
||||
|
||||
|
||||
if (ENABLE_JIT_PROFILING)
|
||||
include(cmake/FindVTune.cmake)
|
||||
add_definitions(-DJIT_PROFILING_ENABLED)
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef DUCKSTATION_COMPAT_H
|
||||
#define DUCKSTATION_COMPAT_H
|
||||
|
||||
#include "../types.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
#define AssertMsg(cond, msg) assert(cond && msg)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,217 @@
|
|||
#include "context.h"
|
||||
#include "../log.h"
|
||||
#include "loader.h"
|
||||
#include <cstdlib>
|
||||
#ifdef __APPLE__
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
Log_SetChannel(GL::Context);
|
||||
|
||||
#if defined(_WIN32) && !defined(_M_ARM64)
|
||||
#include "context_wgl.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include "context_agl.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_EGL
|
||||
#if defined(USE_WAYLAND) || defined(USE_GBM) || defined(USE_FBDEV) || defined(USE_X11)
|
||||
#if defined(USE_WAYLAND)
|
||||
#include "context_egl_wayland.h"
|
||||
#endif
|
||||
#if defined(USE_GBM)
|
||||
#include "context_egl_gbm.h"
|
||||
#endif
|
||||
#if defined(USE_FBDEV)
|
||||
#include "context_egl_fbdev.h"
|
||||
#endif
|
||||
#if defined(USE_X11)
|
||||
#include "context_egl_x11.h"
|
||||
#endif
|
||||
#elif defined(ANDROID)
|
||||
#include "context_egl_android.h"
|
||||
#else
|
||||
#error Unknown EGL platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_GLX
|
||||
#include "context_glx.h"
|
||||
#endif
|
||||
|
||||
namespace GL {
|
||||
|
||||
static bool ShouldPreferESContext()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
const char* value = std::getenv("PREFER_GLES_CONTEXT");
|
||||
return (value && strcmp(value, "1") == 0);
|
||||
#else
|
||||
char buffer[2] = {};
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
getenv_s(&buffer_size, buffer, "PREFER_GLES_CONTEXT");
|
||||
return (std::strcmp(buffer, "1") == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
Context::Context(const WindowInfo& wi) : m_wi(wi) {}
|
||||
|
||||
Context::~Context() = default;
|
||||
|
||||
std::vector<Context::FullscreenModeInfo> Context::EnumerateFullscreenModes()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version* versions_to_try,
|
||||
size_t num_versions_to_try)
|
||||
{
|
||||
if (ShouldPreferESContext())
|
||||
{
|
||||
// move ES versions to the front
|
||||
Version* new_versions_to_try = static_cast<Version*>(alloca(sizeof(Version) * num_versions_to_try));
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < num_versions_to_try; i++)
|
||||
{
|
||||
if (versions_to_try[i].profile == Profile::ES)
|
||||
new_versions_to_try[count++] = versions_to_try[i];
|
||||
}
|
||||
for (size_t i = 0; i < num_versions_to_try; i++)
|
||||
{
|
||||
if (versions_to_try[i].profile != Profile::ES)
|
||||
new_versions_to_try[count++] = versions_to_try[i];
|
||||
}
|
||||
versions_to_try = new_versions_to_try;
|
||||
}
|
||||
|
||||
std::unique_ptr<Context> context;
|
||||
#if defined(_WIN32) && !defined(_M_ARM64)
|
||||
context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#elif defined(__APPLE__)
|
||||
context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#elif defined(ANDROID)
|
||||
#ifdef USE_EGL
|
||||
context = ContextEGLAndroid::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
if (wi.type == WindowInfo::Type::X11)
|
||||
{
|
||||
#ifdef USE_EGL
|
||||
const char* use_egl_x11 = std::getenv("USE_EGL_X11");
|
||||
if (use_egl_x11 && std::strcmp(use_egl_x11, "1") == 0)
|
||||
context = ContextEGLX11::Create(wi, versions_to_try, num_versions_to_try);
|
||||
else
|
||||
context = ContextGLX::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#else
|
||||
context = ContextGLX::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_WAYLAND)
|
||||
if (wi.type == WindowInfo::Type::Wayland)
|
||||
context = ContextEGLWayland::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#endif
|
||||
|
||||
#if defined(USE_GBM)
|
||||
if (wi.type == WindowInfo::Type::Display)
|
||||
context = ContextEGLGBM::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#endif
|
||||
|
||||
#if defined(USE_FBDEV)
|
||||
if (wi.type == WindowInfo::Type::Display)
|
||||
context = ContextEGLFBDev::Create(wi, versions_to_try, num_versions_to_try);
|
||||
#endif
|
||||
|
||||
if (!context)
|
||||
return nullptr;
|
||||
|
||||
Log_InfoPrintf("Created a %s context", context->IsGLES() ? "OpenGL ES" : "OpenGL");
|
||||
|
||||
// TODO: Not thread-safe.
|
||||
static Context* context_being_created;
|
||||
context_being_created = context.get();
|
||||
|
||||
if (!gladLoadGLLoader([](const char* name) { return context_being_created->GetProcAddress(name); }))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to load GL functions for GLAD");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* gl_vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
|
||||
const char* gl_renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
const char* gl_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
const char* gl_shading_language_version = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
Log_InfoPrintf("GL_VENDOR: %s", gl_vendor);
|
||||
Log_InfoPrintf("GL_RENDERER: %s", gl_renderer);
|
||||
Log_InfoPrintf("GL_VERSION: %s", gl_version);
|
||||
Log_InfoPrintf("GL_SHADING_LANGUAGE_VERSION: %s", gl_shading_language_version);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
const std::array<Context::Version, 11>& Context::GetAllDesktopVersionsList()
|
||||
{
|
||||
static constexpr std::array<Version, 11> vlist = {{{Profile::Core, 4, 6},
|
||||
{Profile::Core, 4, 5},
|
||||
{Profile::Core, 4, 4},
|
||||
{Profile::Core, 4, 3},
|
||||
{Profile::Core, 4, 2},
|
||||
{Profile::Core, 4, 1},
|
||||
{Profile::Core, 4, 0},
|
||||
{Profile::Core, 3, 3},
|
||||
{Profile::Core, 3, 2},
|
||||
{Profile::Core, 3, 1},
|
||||
{Profile::Core, 3, 0}}};
|
||||
return vlist;
|
||||
}
|
||||
|
||||
const std::array<Context::Version, 12>& Context::GetAllDesktopVersionsListWithFallback()
|
||||
{
|
||||
static constexpr std::array<Version, 12> vlist = {{{Profile::Core, 4, 6},
|
||||
{Profile::Core, 4, 5},
|
||||
{Profile::Core, 4, 4},
|
||||
{Profile::Core, 4, 3},
|
||||
{Profile::Core, 4, 2},
|
||||
{Profile::Core, 4, 1},
|
||||
{Profile::Core, 4, 0},
|
||||
{Profile::Core, 3, 3},
|
||||
{Profile::Core, 3, 2},
|
||||
{Profile::Core, 3, 1},
|
||||
{Profile::Core, 3, 0},
|
||||
{Profile::NoProfile, 0, 0}}};
|
||||
return vlist;
|
||||
}
|
||||
|
||||
const std::array<Context::Version, 4>& Context::GetAllESVersionsList()
|
||||
{
|
||||
static constexpr std::array<Version, 4> vlist = {
|
||||
{{Profile::ES, 3, 2}, {Profile::ES, 3, 1}, {Profile::ES, 3, 0}, {Profile::ES, 2, 0}}};
|
||||
return vlist;
|
||||
}
|
||||
|
||||
const std::array<Context::Version, 16>& Context::GetAllVersionsList()
|
||||
{
|
||||
static constexpr std::array<Version, 16> vlist = {{{Profile::Core, 4, 6},
|
||||
{Profile::Core, 4, 5},
|
||||
{Profile::Core, 4, 4},
|
||||
{Profile::Core, 4, 3},
|
||||
{Profile::Core, 4, 2},
|
||||
{Profile::Core, 4, 1},
|
||||
{Profile::Core, 4, 0},
|
||||
{Profile::Core, 3, 3},
|
||||
{Profile::Core, 3, 2},
|
||||
{Profile::Core, 3, 1},
|
||||
{Profile::Core, 3, 0},
|
||||
{Profile::ES, 3, 2},
|
||||
{Profile::ES, 3, 1},
|
||||
{Profile::ES, 3, 0},
|
||||
{Profile::ES, 2, 0},
|
||||
{Profile::NoProfile, 0, 0}}};
|
||||
return vlist;
|
||||
}
|
||||
|
||||
} // namespace GL
|
|
@ -0,0 +1,76 @@
|
|||
#pragma once
|
||||
#include "../duckstation_compat.h"
|
||||
#include "../window_info.h"
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace GL {
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
Context(const WindowInfo& wi);
|
||||
virtual ~Context();
|
||||
|
||||
enum class Profile
|
||||
{
|
||||
NoProfile,
|
||||
Core,
|
||||
ES
|
||||
};
|
||||
|
||||
struct Version
|
||||
{
|
||||
Profile profile;
|
||||
int major_version;
|
||||
int minor_version;
|
||||
};
|
||||
|
||||
struct FullscreenModeInfo
|
||||
{
|
||||
u32 width;
|
||||
u32 height;
|
||||
float refresh_rate;
|
||||
};
|
||||
|
||||
ALWAYS_INLINE const WindowInfo& GetWindowInfo() const { return m_wi; }
|
||||
ALWAYS_INLINE bool IsGLES() const { return (m_version.profile == Profile::ES); }
|
||||
ALWAYS_INLINE u32 GetSurfaceWidth() const { return m_wi.surface_width; }
|
||||
ALWAYS_INLINE u32 GetSurfaceHeight() const { return m_wi.surface_height; }
|
||||
ALWAYS_INLINE WindowInfo::SurfaceFormat GetSurfaceFormat() const { return m_wi.surface_format; }
|
||||
|
||||
virtual void* GetProcAddress(const char* name) = 0;
|
||||
virtual bool ChangeSurface(const WindowInfo& new_wi) = 0;
|
||||
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) = 0;
|
||||
virtual bool SwapBuffers() = 0;
|
||||
virtual bool MakeCurrent() = 0;
|
||||
virtual bool DoneCurrent() = 0;
|
||||
virtual bool SetSwapInterval(s32 interval) = 0;
|
||||
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) = 0;
|
||||
|
||||
virtual std::vector<FullscreenModeInfo> EnumerateFullscreenModes();
|
||||
|
||||
static std::unique_ptr<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
|
||||
size_t num_versions_to_try);
|
||||
|
||||
template<size_t N>
|
||||
static std::unique_ptr<Context> Create(const WindowInfo& wi, const std::array<Version, N>& versions_to_try)
|
||||
{
|
||||
return Create(wi, versions_to_try.data(), versions_to_try.size());
|
||||
}
|
||||
|
||||
static std::unique_ptr<Context> Create(const WindowInfo& wi) { return Create(wi, GetAllVersionsList()); }
|
||||
|
||||
static const std::array<Version, 11>& GetAllDesktopVersionsList();
|
||||
static const std::array<Version, 12>& GetAllDesktopVersionsListWithFallback();
|
||||
static const std::array<Version, 4>& GetAllESVersionsList();
|
||||
static const std::array<Version, 16>& GetAllVersionsList();
|
||||
|
||||
protected:
|
||||
#ifdef _WIN32
|
||||
#endif
|
||||
|
||||
WindowInfo m_wi;
|
||||
Version m_version = {};
|
||||
};
|
||||
} // namespace GL
|
|
@ -0,0 +1,452 @@
|
|||
#include "context_wgl.h"
|
||||
#include "../duckstation_compat.h"
|
||||
#include "../log.h"
|
||||
#include "../scoped_guard.h"
|
||||
#include "loader.h"
|
||||
Log_SetChannel(GL::ContextWGL);
|
||||
|
||||
// TODO: get rid of this
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
|
||||
static void* GetProcAddressCallback(const char* name)
|
||||
{
|
||||
void* addr = reinterpret_cast<void*>(wglGetProcAddress(name));
|
||||
if (addr)
|
||||
return addr;
|
||||
|
||||
// try opengl32.dll
|
||||
return reinterpret_cast<void*>(::GetProcAddress(GetModuleHandleA("opengl32.dll"), name));
|
||||
}
|
||||
|
||||
namespace GL {
|
||||
ContextWGL::ContextWGL(const WindowInfo& wi) : Context(wi) {}
|
||||
|
||||
ContextWGL::~ContextWGL()
|
||||
{
|
||||
if (wglGetCurrentContext() == m_rc)
|
||||
wglMakeCurrent(m_dc, nullptr);
|
||||
|
||||
if (m_rc)
|
||||
wglDeleteContext(m_rc);
|
||||
|
||||
ReleaseDC();
|
||||
}
|
||||
|
||||
std::unique_ptr<Context> ContextWGL::Create(const WindowInfo& wi, const Version* versions_to_try,
|
||||
size_t num_versions_to_try)
|
||||
{
|
||||
std::unique_ptr<ContextWGL> context = std::make_unique<ContextWGL>(wi);
|
||||
if (!context->Initialize(versions_to_try, num_versions_to_try))
|
||||
return nullptr;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
bool ContextWGL::Initialize(const Version* versions_to_try, size_t num_versions_to_try)
|
||||
{
|
||||
if (m_wi.type == WindowInfo::Type::Win32)
|
||||
{
|
||||
if (!InitializeDC())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("ContextWGL must always start with a valid surface.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything including core/ES requires a dummy profile to load the WGL extensions.
|
||||
if (!CreateAnyContext(nullptr, true))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < num_versions_to_try; i++)
|
||||
{
|
||||
const Version& cv = versions_to_try[i];
|
||||
if (cv.profile == Profile::NoProfile)
|
||||
{
|
||||
// we already have the dummy context, so just use that
|
||||
m_version = cv;
|
||||
return true;
|
||||
}
|
||||
else if (CreateVersionContext(cv, nullptr, true))
|
||||
{
|
||||
m_version = cv;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void* ContextWGL::GetProcAddress(const char* name)
|
||||
{
|
||||
return GetProcAddressCallback(name);
|
||||
}
|
||||
|
||||
bool ContextWGL::ChangeSurface(const WindowInfo& new_wi)
|
||||
{
|
||||
const bool was_current = (wglGetCurrentContext() == m_rc);
|
||||
|
||||
ReleaseDC();
|
||||
|
||||
m_wi = new_wi;
|
||||
if (!InitializeDC())
|
||||
return false;
|
||||
|
||||
if (was_current && !wglMakeCurrent(m_dc, m_rc))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to make context current again after surface change: 0x%08X", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContextWGL::ResizeSurface(u32 new_surface_width /*= 0*/, u32 new_surface_height /*= 0*/)
|
||||
{
|
||||
RECT client_rc = {};
|
||||
GetClientRect(GetHWND(), &client_rc);
|
||||
m_wi.surface_width = static_cast<u32>(client_rc.right - client_rc.left);
|
||||
m_wi.surface_height = static_cast<u32>(client_rc.bottom - client_rc.top);
|
||||
}
|
||||
|
||||
bool ContextWGL::SwapBuffers()
|
||||
{
|
||||
return ::SwapBuffers(m_dc);
|
||||
}
|
||||
|
||||
bool ContextWGL::MakeCurrent()
|
||||
{
|
||||
if (!wglMakeCurrent(m_dc, m_rc))
|
||||
{
|
||||
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContextWGL::DoneCurrent()
|
||||
{
|
||||
return wglMakeCurrent(m_dc, nullptr);
|
||||
}
|
||||
|
||||
bool ContextWGL::SetSwapInterval(s32 interval)
|
||||
{
|
||||
if (!GLAD_WGL_EXT_swap_control)
|
||||
return false;
|
||||
|
||||
return wglSwapIntervalEXT(interval);
|
||||
}
|
||||
|
||||
std::unique_ptr<Context> ContextWGL::CreateSharedContext(const WindowInfo& wi)
|
||||
{
|
||||
std::unique_ptr<ContextWGL> context = std::make_unique<ContextWGL>(wi);
|
||||
if (wi.type == WindowInfo::Type::Win32)
|
||||
{
|
||||
if (!context->InitializeDC())
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("PBuffer not implemented");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_version.profile == Profile::NoProfile)
|
||||
{
|
||||
if (!context->CreateAnyContext(m_rc, false))
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!context->CreateVersionContext(m_version, m_rc, false))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->m_version = m_version;
|
||||
return context;
|
||||
}
|
||||
|
||||
HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd = {};
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.dwLayerMask = PFD_MAIN_PLANE;
|
||||
pfd.cRedBits = 8;
|
||||
pfd.cGreenBits = 8;
|
||||
pfd.cBlueBits = 8;
|
||||
pfd.cColorBits = 24;
|
||||
|
||||
HDC hDC = ::GetDC(hwnd);
|
||||
if (!hDC)
|
||||
{
|
||||
Log_ErrorPrintf("GetDC() failed: 0x%08X", GetLastError());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!m_pixel_format.has_value())
|
||||
{
|
||||
const int pf = ChoosePixelFormat(hDC, &pfd);
|
||||
if (pf == 0)
|
||||
{
|
||||
Log_ErrorPrintf("ChoosePixelFormat() failed: 0x%08X", GetLastError());
|
||||
::ReleaseDC(hwnd, hDC);
|
||||
return {};
|
||||
}
|
||||
|
||||
m_pixel_format = pf;
|
||||
}
|
||||
|
||||
if (!SetPixelFormat(hDC, m_pixel_format.value(), &pfd))
|
||||
{
|
||||
Log_ErrorPrintf("SetPixelFormat() failed: 0x%08X", GetLastError());
|
||||
::ReleaseDC(hwnd, hDC);
|
||||
return {};
|
||||
}
|
||||
|
||||
return hDC;
|
||||
}
|
||||
|
||||
bool ContextWGL::InitializeDC()
|
||||
{
|
||||
if (m_wi.type == WindowInfo::Type::Win32)
|
||||
{
|
||||
m_dc = GetDCAndSetPixelFormat(GetHWND());
|
||||
if (!m_dc)
|
||||
{
|
||||
Log_ErrorPrint("Failed to get DC for window");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (m_wi.type == WindowInfo::Type::Surfaceless)
|
||||
{
|
||||
return CreatePBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Unknown window info type %u", static_cast<unsigned>(m_wi.type));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ContextWGL::ReleaseDC()
|
||||
{
|
||||
if (m_pbuffer)
|
||||
{
|
||||
wglReleasePbufferDCARB(m_pbuffer, m_dc);
|
||||
m_dc = {};
|
||||
|
||||
wglDestroyPbufferARB(m_pbuffer);
|
||||
m_pbuffer = {};
|
||||
|
||||
::ReleaseDC(m_dummy_window, m_dummy_dc);
|
||||
m_dummy_dc = {};
|
||||
|
||||
DestroyWindow(m_dummy_window);
|
||||
m_dummy_window = {};
|
||||
}
|
||||
else if (m_dc)
|
||||
{
|
||||
::ReleaseDC(GetHWND(), m_dc);
|
||||
m_dc = {};
|
||||
}
|
||||
}
|
||||
|
||||
bool ContextWGL::CreatePBuffer()
|
||||
{
|
||||
static bool window_class_registered = false;
|
||||
static const wchar_t* window_class_name = L"ContextWGLPBuffer";
|
||||
|
||||
if (!window_class_registered)
|
||||
{
|
||||
WNDCLASSEXW wc = {};
|
||||
wc.cbSize = sizeof(WNDCLASSEXW);
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = DefWindowProcW;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = GetModuleHandle(nullptr);
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = window_class_name;
|
||||
wc.hIconSm = NULL;
|
||||
|
||||
if (!RegisterClassExW(&wc))
|
||||
{
|
||||
Log_ErrorPrint("(ContextWGL::CreatePBuffer) RegisterClassExW() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
window_class_registered = true;
|
||||
}
|
||||
|
||||
HWND hwnd = CreateWindowExW(0, window_class_name, window_class_name, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||
if (!hwnd)
|
||||
{
|
||||
Log_ErrorPrint("(ContextWGL::CreatePBuffer) CreateWindowEx() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedGuard hwnd_guard([hwnd]() { DestroyWindow(hwnd); });
|
||||
|
||||
HDC hdc = GetDCAndSetPixelFormat(hwnd);
|
||||
if (!hdc)
|
||||
return false;
|
||||
|
||||
ScopedGuard hdc_guard([hdc, hwnd]() { ::ReleaseDC(hwnd, hdc); });
|
||||
|
||||
static constexpr const int pb_attribs[] = {0, 0};
|
||||
|
||||
AssertMsg(m_pixel_format.has_value(), "Has pixel format for pbuffer");
|
||||
HPBUFFERARB pbuffer = wglCreatePbufferARB(hdc, m_pixel_format.value(), 1, 1, pb_attribs);
|
||||
if (!pbuffer)
|
||||
{
|
||||
Log_ErrorPrint("(ContextWGL::CreatePBuffer) wglCreatePbufferARB() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedGuard pbuffer_guard([pbuffer]() { wglDestroyPbufferARB(pbuffer); });
|
||||
|
||||
m_dc = wglGetPbufferDCARB(pbuffer);
|
||||
if (!m_dc)
|
||||
{
|
||||
Log_ErrorPrint("(ContextWGL::CreatePbuffer) wglGetPbufferDCARB() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dummy_window = hwnd;
|
||||
m_dummy_dc = hdc;
|
||||
m_pbuffer = pbuffer;
|
||||
|
||||
pbuffer_guard.Cancel();
|
||||
hdc_guard.Cancel();
|
||||
hwnd_guard.Cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContextWGL::CreateAnyContext(HGLRC share_context, bool make_current)
|
||||
{
|
||||
m_rc = wglCreateContext(m_dc);
|
||||
if (!m_rc)
|
||||
{
|
||||
Log_ErrorPrintf("wglCreateContext() failed: 0x%08X", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (make_current)
|
||||
{
|
||||
if (!wglMakeCurrent(m_dc, m_rc))
|
||||
{
|
||||
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// re-init glad-wgl
|
||||
if (!gladLoadWGLLoader([](const char* name) -> void* { return reinterpret_cast<void*>(wglGetProcAddress(name)); }, m_dc))
|
||||
{
|
||||
Log_ErrorPrint("Loading GLAD WGL functions failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (share_context && !wglShareLists(share_context, m_rc))
|
||||
{
|
||||
Log_ErrorPrintf("wglShareLists() failed: 0x%08X", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_context, bool make_current)
|
||||
{
|
||||
// we need create context attribs
|
||||
if (!GLAD_WGL_ARB_create_context)
|
||||
{
|
||||
Log_ErrorPrint("Missing GLAD_WGL_ARB_create_context.");
|
||||
return false;
|
||||
}
|
||||
|
||||
HGLRC new_rc;
|
||||
if (version.profile == Profile::Core)
|
||||
{
|
||||
const int attribs[] = {WGL_CONTEXT_PROFILE_MASK_ARB,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB,
|
||||
version.major_version,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB,
|
||||
version.minor_version,
|
||||
#ifdef _DEBUG
|
||||
WGL_CONTEXT_FLAGS_ARB,
|
||||
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
#else
|
||||
WGL_CONTEXT_FLAGS_ARB,
|
||||
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
#endif
|
||||
0,
|
||||
0};
|
||||
|
||||
new_rc = wglCreateContextAttribsARB(m_dc, share_context, attribs);
|
||||
}
|
||||
else if (version.profile == Profile::ES)
|
||||
{
|
||||
if ((version.major_version >= 2 && !GLAD_WGL_EXT_create_context_es2_profile) ||
|
||||
(version.major_version < 2 && !GLAD_WGL_EXT_create_context_es_profile))
|
||||
{
|
||||
Log_ErrorPrint("WGL_EXT_create_context_es_profile not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
const int attribs[] = {
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB,
|
||||
((version.major_version >= 2) ? WGL_CONTEXT_ES2_PROFILE_BIT_EXT : WGL_CONTEXT_ES_PROFILE_BIT_EXT),
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB,
|
||||
version.major_version,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB,
|
||||
version.minor_version,
|
||||
0,
|
||||
0};
|
||||
|
||||
new_rc = wglCreateContextAttribsARB(m_dc, share_context, attribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("Unknown profile");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!new_rc)
|
||||
return false;
|
||||
|
||||
// destroy and swap contexts
|
||||
if (m_rc)
|
||||
{
|
||||
if (!wglMakeCurrent(m_dc, make_current ? new_rc : nullptr))
|
||||
{
|
||||
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
|
||||
wglDeleteContext(new_rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
// re-init glad-wgl
|
||||
if (make_current && !gladLoadWGLLoader([](const char* name) -> void* { return reinterpret_cast<void*>(wglGetProcAddress(name)); }, m_dc))
|
||||
{
|
||||
Log_ErrorPrint("Loading GLAD WGL functions failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
wglDeleteContext(m_rc);
|
||||
}
|
||||
|
||||
m_rc = new_rc;
|
||||
return true;
|
||||
}
|
||||
} // namespace GL
|
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
#include "../windows_headers.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "../../glad/glad_wgl.h"
|
||||
#include "loader.h"
|
||||
#include <optional>
|
||||
|
||||
namespace GL {
|
||||
|
||||
class ContextWGL final : public Context
|
||||
{
|
||||
public:
|
||||
ContextWGL(const WindowInfo& wi);
|
||||
~ContextWGL() override;
|
||||
|
||||
static std::unique_ptr<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
|
||||
size_t num_versions_to_try);
|
||||
|
||||
void* GetProcAddress(const char* name) override;
|
||||
bool ChangeSurface(const WindowInfo& new_wi) override;
|
||||
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
||||
bool SwapBuffers() override;
|
||||
bool MakeCurrent() override;
|
||||
bool DoneCurrent() override;
|
||||
bool SetSwapInterval(s32 interval) override;
|
||||
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
|
||||
|
||||
private:
|
||||
ALWAYS_INLINE HWND GetHWND() const { return static_cast<HWND>(m_wi.window_handle); }
|
||||
|
||||
HDC GetDCAndSetPixelFormat(HWND hwnd);
|
||||
|
||||
bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
|
||||
bool InitializeDC();
|
||||
void ReleaseDC();
|
||||
bool CreatePBuffer();
|
||||
bool CreateAnyContext(HGLRC share_context, bool make_current);
|
||||
bool CreateVersionContext(const Version& version, HGLRC share_context, bool make_current);
|
||||
|
||||
HDC m_dc = {};
|
||||
HGLRC m_rc = {};
|
||||
|
||||
// Can't change pixel format once it's set for a RC.
|
||||
std::optional<int> m_pixel_format;
|
||||
|
||||
// Dummy window for creating a PBuffer off when we're surfaceless.
|
||||
HWND m_dummy_window = {};
|
||||
HDC m_dummy_dc = {};
|
||||
HPBUFFERARB m_pbuffer = {};
|
||||
};
|
||||
|
||||
} // namespace GL
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
// Fix glad.h including windows.h
|
||||
#ifdef _WIN32
|
||||
#include "../windows_headers.h"
|
||||
#endif
|
||||
|
||||
#include "../../glad/glad.h"
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define Log_SetChannel(ChannelName)
|
||||
#define Log_ErrorPrint(msg) puts(msg "\n");
|
||||
#define Log_ErrorPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_WarningPrint(msg) puts(msg)
|
||||
#define Log_WarningPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_PerfPrint(msg) puts(msg)
|
||||
#define Log_PerfPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_InfoPrint(msg) puts(msg)
|
||||
#define Log_InfoPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_VerbosePrint(msg) puts(msg)
|
||||
#define Log_VerbosePrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_DevPrint(msg) puts(msg)
|
||||
#define Log_DevPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_ProfilePrint(msg) puts(msg)
|
||||
#define Log_ProfilePrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define Log_DebugPrint(msg) puts(msg)
|
||||
#define Log_DebugPrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#define Log_TracePrint(msg) puts(msg)
|
||||
#define Log_TracePrintf(...) do { printf(__VA_ARGS__); putchar('\n'); } while (0)
|
||||
#else
|
||||
#define Log_DebugPrint(msg) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define Log_DebugPrintf(...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define Log_TracePrint(msg) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define Log_TracePrintf(...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
/// ScopedGuard provides an object which runs a function (usually a lambda) when
|
||||
/// it goes out of scope. This can be useful for releasing resources or handles
|
||||
/// which do not normally have C++ types to automatically release.
|
||||
template<typename T>
|
||||
class ScopedGuard final
|
||||
{
|
||||
public:
|
||||
ALWAYS_INLINE ScopedGuard(T&& func) : m_func(std::forward<T>(func)) {}
|
||||
ALWAYS_INLINE ScopedGuard(ScopedGuard&& other) : m_func(std::move(other.m_func)) { other.m_func = nullptr; }
|
||||
ALWAYS_INLINE ~ScopedGuard() { Invoke(); }
|
||||
|
||||
ScopedGuard(const ScopedGuard&) = delete;
|
||||
void operator=(const ScopedGuard&) = delete;
|
||||
|
||||
/// Prevents the function from being invoked when we go out of scope.
|
||||
ALWAYS_INLINE void Cancel() { m_func.reset(); }
|
||||
|
||||
/// Explicitly fires the function.
|
||||
ALWAYS_INLINE void Invoke()
|
||||
{
|
||||
if (!m_func.has_value())
|
||||
return;
|
||||
|
||||
m_func.value()();
|
||||
m_func.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
std::optional<T> m_func;
|
||||
};
|
|
@ -0,0 +1,191 @@
|
|||
#include "window_info.h"
|
||||
#include "common/log.h"
|
||||
Log_SetChannel(WindowInfo);
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "common/windows_headers.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
static bool GetRefreshRateFromDWM(HWND hwnd, float* refresh_rate)
|
||||
{
|
||||
static HMODULE dwm_module = nullptr;
|
||||
static HRESULT(STDAPICALLTYPE * is_composition_enabled)(BOOL * pfEnabled) = nullptr;
|
||||
static HRESULT(STDAPICALLTYPE * get_timing_info)(HWND hwnd, DWM_TIMING_INFO * pTimingInfo) = nullptr;
|
||||
static bool load_tried = false;
|
||||
if (!load_tried)
|
||||
{
|
||||
load_tried = true;
|
||||
dwm_module = LoadLibrary("dwmapi.dll");
|
||||
if (dwm_module)
|
||||
{
|
||||
std::atexit([]() {
|
||||
FreeLibrary(dwm_module);
|
||||
dwm_module = nullptr;
|
||||
});
|
||||
is_composition_enabled =
|
||||
reinterpret_cast<decltype(is_composition_enabled)>(GetProcAddress(dwm_module, "DwmIsCompositionEnabled"));
|
||||
get_timing_info =
|
||||
reinterpret_cast<decltype(get_timing_info)>(GetProcAddress(dwm_module, "DwmGetCompositionTimingInfo"));
|
||||
}
|
||||
}
|
||||
|
||||
BOOL composition_enabled;
|
||||
if (!is_composition_enabled || FAILED(is_composition_enabled(&composition_enabled) || !get_timing_info))
|
||||
return false;
|
||||
|
||||
DWM_TIMING_INFO ti = {};
|
||||
ti.cbSize = sizeof(ti);
|
||||
HRESULT hr = get_timing_info(nullptr, &ti);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0)
|
||||
return false;
|
||||
|
||||
*refresh_rate = static_cast<float>(ti.rateRefresh.uiNumerator) / static_cast<float>(ti.rateRefresh.uiDenominator);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool GetRefreshRateFromMonitor(HWND hwnd, float* refresh_rate)
|
||||
{
|
||||
HMONITOR mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
if (!mon)
|
||||
return false;
|
||||
|
||||
MONITORINFOEXW mi = {};
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (GetMonitorInfoW(mon, &mi))
|
||||
{
|
||||
DEVMODEW dm = {};
|
||||
dm.dmSize = sizeof(dm);
|
||||
|
||||
// 0/1 are reserved for "defaults".
|
||||
if (EnumDisplaySettingsW(mi.szDevice, ENUM_CURRENT_SETTINGS, &dm) && dm.dmDisplayFrequency > 1)
|
||||
{
|
||||
*refresh_rate = static_cast<float>(dm.dmDisplayFrequency);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, float* refresh_rate)
|
||||
{
|
||||
if (wi.type != Type::Win32 || !wi.window_handle)
|
||||
return false;
|
||||
|
||||
// Try DWM first, then fall back to integer values.
|
||||
const HWND hwnd = static_cast<HWND>(wi.window_handle);
|
||||
return GetRefreshRateFromDWM(hwnd, refresh_rate) || GetRefreshRateFromMonitor(hwnd, refresh_rate);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef USE_X11
|
||||
|
||||
#include "common/scoped_guard.h"
|
||||
#include "gl/x11_window.h"
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
static bool GetRefreshRateFromXRandR(const WindowInfo& wi, float* refresh_rate)
|
||||
{
|
||||
Display* display = static_cast<Display*>(wi.display_connection);
|
||||
Window window = static_cast<Window>(reinterpret_cast<uintptr_t>(wi.window_handle));
|
||||
if (!display || !window)
|
||||
return false;
|
||||
|
||||
GL::X11InhibitErrors inhibiter;
|
||||
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, window);
|
||||
if (!res)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetScreenResources() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedGuard res_guard([res]() { XRRFreeScreenResources(res); });
|
||||
|
||||
int num_monitors;
|
||||
XRRMonitorInfo* mi = XRRGetMonitors(display, window, True, &num_monitors);
|
||||
if (num_monitors < 0)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetMonitors() failed");
|
||||
return false;
|
||||
}
|
||||
else if (num_monitors > 1)
|
||||
{
|
||||
Log_WarningPrintf("XRRGetMonitors() returned %d monitors, using first", num_monitors);
|
||||
}
|
||||
|
||||
ScopedGuard mi_guard([mi]() { XRRFreeMonitors(mi); });
|
||||
if (mi->noutput <= 0)
|
||||
{
|
||||
Log_ErrorPrint("Monitor has no outputs");
|
||||
return false;
|
||||
}
|
||||
else if (mi->noutput > 1)
|
||||
{
|
||||
Log_WarningPrintf("Monitor has %d outputs, using first", mi->noutput);
|
||||
}
|
||||
|
||||
XRROutputInfo* oi = XRRGetOutputInfo(display, res, mi->outputs[0]);
|
||||
if (!oi)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetOutputInfo() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedGuard oi_guard([oi]() { XRRFreeOutputInfo(oi); });
|
||||
|
||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(display, res, oi->crtc);
|
||||
if (!ci)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetCrtcInfo() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ScopedGuard ci_guard([ci]() { XRRFreeCrtcInfo(ci); });
|
||||
|
||||
XRRModeInfo* mode = nullptr;
|
||||
for (int i = 0; i < res->nmode; i++)
|
||||
{
|
||||
if (res->modes[i].id == ci->mode)
|
||||
{
|
||||
mode = &res->modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mode)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to look up mode %d (of %d)", static_cast<int>(ci->mode), res->nmode);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode->dotClock == 0 || mode->hTotal == 0 || mode->vTotal == 0)
|
||||
{
|
||||
Log_ErrorPrintf("Modeline is invalid: %ld/%d/%d", mode->dotClock, mode->hTotal, mode->vTotal);
|
||||
return false;
|
||||
}
|
||||
|
||||
*refresh_rate =
|
||||
static_cast<double>(mode->dotClock) / (static_cast<double>(mode->hTotal) * static_cast<double>(mode->vTotal));
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // USE_X11
|
||||
|
||||
bool WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, float* refresh_rate)
|
||||
{
|
||||
#if defined(USE_X11)
|
||||
if (wi.type == WindowInfo::Type::X11)
|
||||
return GetRefreshRateFromXRandR(wi, refresh_rate);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "../types.h"
|
||||
|
||||
// Contains the information required to create a graphics context in a window.
|
||||
struct WindowInfo
|
||||
{
|
||||
enum class Type
|
||||
{
|
||||
Surfaceless,
|
||||
Win32,
|
||||
X11,
|
||||
Wayland,
|
||||
MacOS,
|
||||
Android,
|
||||
Display,
|
||||
};
|
||||
|
||||
enum class SurfaceFormat
|
||||
{
|
||||
None,
|
||||
Auto,
|
||||
RGB8,
|
||||
RGBA8,
|
||||
RGB565,
|
||||
Count
|
||||
};
|
||||
|
||||
Type type = Type::Surfaceless;
|
||||
void* display_connection = nullptr;
|
||||
void* window_handle = nullptr;
|
||||
u32 surface_width = 0;
|
||||
u32 surface_height = 0;
|
||||
float surface_refresh_rate = 0.0f;
|
||||
float surface_scale = 1.0f;
|
||||
SurfaceFormat surface_format = SurfaceFormat::RGB8;
|
||||
|
||||
// Needed for macOS.
|
||||
#ifdef __APPLE__
|
||||
void* surface_handle = nullptr;
|
||||
#endif
|
||||
|
||||
static bool QueryRefreshRateForWindow(const WindowInfo& wi, float* refresh_rate);
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX 1
|
||||
#endif
|
||||
|
||||
// require vista+
|
||||
#ifdef _WIN32_WINNT
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
#define _WIN32_WINNT _WIN32_WINNT_VISTA
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
#if defined(CopyFile)
|
||||
#undef CopyFile
|
||||
#endif
|
||||
#if defined(DeleteFile)
|
||||
#undef DeleteFile
|
||||
#endif
|
|
@ -51,24 +51,24 @@ struct Item
|
|||
QImage NativeBitmap;
|
||||
|
||||
bool GLTextureLoaded;
|
||||
GLuint GLTexture;
|
||||
//GLuint GLTexture;
|
||||
|
||||
};
|
||||
|
||||
std::deque<Item> ItemQueue;
|
||||
|
||||
/*
|
||||
QOpenGLShaderProgram* Shader;
|
||||
GLint uScreenSize, uOSDPos, uOSDSize;
|
||||
GLfloat uScaleFactor;
|
||||
GLuint OSDVertexArray;
|
||||
GLuint OSDVertexBuffer;
|
||||
|
||||
*/
|
||||
volatile bool Rendering;
|
||||
|
||||
|
||||
bool Init(QOpenGLFunctions_3_2_Core* f)
|
||||
bool Init()
|
||||
{
|
||||
if (f)
|
||||
/*if (f)
|
||||
{
|
||||
Shader = new QOpenGLShaderProgram();
|
||||
Shader->addShaderFromSourceCode(QOpenGLShader::Vertex, kScreenVS_OSD);
|
||||
|
@ -107,24 +107,22 @@ bool Init(QOpenGLFunctions_3_2_Core* f)
|
|||
f->glBindVertexArray(OSDVertexArray);
|
||||
f->glEnableVertexAttribArray(0); // position
|
||||
f->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (void*)(0));
|
||||
}
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInit(QOpenGLFunctions_3_2_Core* f)
|
||||
void DeInit()
|
||||
{
|
||||
for (auto it = ItemQueue.begin(); it != ItemQueue.end(); )
|
||||
{
|
||||
Item& item = *it;
|
||||
|
||||
if (item.GLTextureLoaded && f) f->glDeleteTextures(1, &item.GLTexture);
|
||||
//if (item.GLTextureLoaded && f) f->glDeleteTextures(1, &item.GLTexture);
|
||||
if (item.Bitmap) delete[] item.Bitmap;
|
||||
|
||||
it = ItemQueue.erase(it);
|
||||
}
|
||||
|
||||
if (f) delete Shader;
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,7 +141,7 @@ int FindBreakPoint(const char* text, int i)
|
|||
|
||||
void LayoutText(const char* text, u32* width, u32* height, int* breaks)
|
||||
{
|
||||
u32 w = 0;
|
||||
/*u32 w = 0;
|
||||
u32 h = 14;
|
||||
u32 totalw = 0;
|
||||
u32 maxw = mainWindow->panelWidget->width() - (kOSDMargin*2);
|
||||
|
@ -202,7 +200,7 @@ void LayoutText(const char* text, u32* width, u32* height, int* breaks)
|
|||
}
|
||||
|
||||
*width = totalw;
|
||||
*height = h;
|
||||
*height = h;*/
|
||||
}
|
||||
|
||||
u32 RainbowColor(u32 inc)
|
||||
|
@ -219,7 +217,7 @@ u32 RainbowColor(u32 inc)
|
|||
|
||||
void RenderText(u32 color, const char* text, Item* item)
|
||||
{
|
||||
u32 w, h;
|
||||
/*u32 w, h;
|
||||
int breaks[64];
|
||||
|
||||
bool rainbow = (color == 0);
|
||||
|
@ -321,7 +319,7 @@ void RenderText(u32 color, const char* text, Item* item)
|
|||
if ((val >> 24) == 0xFF)
|
||||
item->Bitmap[(y * w) + x] = shadow;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -344,9 +342,9 @@ void AddMessage(u32 color, const char* text)
|
|||
ItemQueue.push_back(item);
|
||||
}
|
||||
|
||||
void Update(QOpenGLFunctions_3_2_Core* f)
|
||||
void Update()
|
||||
{
|
||||
if (!Config::ShowOSD)
|
||||
/*if (!Config::ShowOSD)
|
||||
{
|
||||
Rendering = true;
|
||||
for (auto it = ItemQueue.begin(); it != ItemQueue.end(); )
|
||||
|
@ -386,7 +384,7 @@ void Update(QOpenGLFunctions_3_2_Core* f)
|
|||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}*/
|
||||
|
||||
Rendering = false;
|
||||
}
|
||||
|
@ -419,7 +417,7 @@ void DrawNative(QPainter& painter)
|
|||
|
||||
Rendering = false;
|
||||
}
|
||||
|
||||
/*
|
||||
void DrawGL(QOpenGLFunctions_3_2_Core* f, float w, float h)
|
||||
{
|
||||
if (!Config::ShowOSD) return;
|
||||
|
@ -472,6 +470,6 @@ void DrawGL(QOpenGLFunctions_3_2_Core* f, float w, float h)
|
|||
Shader->release();
|
||||
|
||||
Rendering = false;
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
namespace OSD
|
||||
{
|
||||
|
||||
bool Init(QOpenGLFunctions_3_2_Core* f);
|
||||
void DeInit(QOpenGLFunctions_3_2_Core* f);
|
||||
bool Init();
|
||||
void DeInit();
|
||||
|
||||
void AddMessage(u32 color, const char* text);
|
||||
|
||||
void Update(QOpenGLFunctions_3_2_Core* f);
|
||||
void Update();
|
||||
void DrawNative(QPainter& painter);
|
||||
void DrawGL(QOpenGLFunctions_3_2_Core* f, float w, float h);
|
||||
void DrawGL(float w, float h);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,8 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
#include "OpenGLSupport.h"
|
||||
#endif
|
||||
#include "duckstation/gl/context.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "Input.h"
|
||||
|
@ -341,52 +340,107 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent)
|
|||
connect(this, SIGNAL(screenLayoutChange()), mainWindow->panelWidget, SLOT(onScreenLayoutChanged()));
|
||||
connect(this, SIGNAL(windowFullscreenToggle()), mainWindow, SLOT(onFullscreenToggled()));
|
||||
connect(this, SIGNAL(swapScreensToggle()), mainWindow->actScreenSwap, SLOT(trigger()));
|
||||
}
|
||||
|
||||
if (mainWindow->hasOGL) initOpenGL();
|
||||
void EmuThread::updateScreenSettings(bool filter, const WindowInfo& windowInfo, int numScreens, int* screenKind, float* screenMatrix)
|
||||
{
|
||||
screenSettingsLock.lock();
|
||||
|
||||
this->filter = filter;
|
||||
this->windowInfo = windowInfo;
|
||||
this->numScreens = numScreens;
|
||||
memcpy(this->screenKind, screenKind, sizeof(int)*numScreens);
|
||||
memcpy(this->screenMatrix, screenMatrix, sizeof(float)*numScreens*6);
|
||||
|
||||
screenSettingsLock.unlock();
|
||||
}
|
||||
|
||||
void EmuThread::initOpenGL()
|
||||
{
|
||||
QOpenGLContext* windowctx = mainWindow->getOGLContext();
|
||||
QSurfaceFormat format = windowctx->format();
|
||||
GL::Context* windowctx = mainWindow->getOGLContext();
|
||||
|
||||
format.setSwapInterval(0);
|
||||
oglContext = windowctx;
|
||||
oglContext->MakeCurrent();
|
||||
|
||||
oglSurface = new QOffscreenSurface();
|
||||
oglSurface->setFormat(format);
|
||||
oglSurface->create();
|
||||
if (!oglSurface->isValid())
|
||||
OpenGL::BuildShaderProgram(kScreenVS, kScreenFS, screenShaderProgram, "ScreenShader");
|
||||
GLuint pid = screenShaderProgram[2];
|
||||
glBindAttribLocation(pid, 0, "vPosition");
|
||||
glBindAttribLocation(pid, 1, "vTexcoord");
|
||||
glBindFragDataLocation(pid, 0, "oColor");
|
||||
|
||||
OpenGL::LinkShaderProgram(screenShaderProgram);
|
||||
|
||||
glUseProgram(pid);
|
||||
glUniform1i(glGetUniformLocation(pid, "ScreenTex"), 0);
|
||||
|
||||
screenShaderScreenSizeULoc = glGetUniformLocation(pid, "uScreenSize");
|
||||
screenShaderScaleFactorULoc = glGetUniformLocation(pid, "uScaleFactor");
|
||||
screenShaderTransformULoc = glGetUniformLocation(pid, "uTransform");
|
||||
|
||||
// to prevent bleeding between both parts of the screen
|
||||
// with bilinear filtering enabled
|
||||
const int paddedHeight = 192*2+2;
|
||||
const float padPixels = 1.f / paddedHeight;
|
||||
|
||||
const float vertices[] =
|
||||
{
|
||||
// TODO handle this!
|
||||
printf("oglSurface shat itself :(\n");
|
||||
delete oglSurface;
|
||||
return;
|
||||
}
|
||||
0.f, 0.f, 0.f, 0.f,
|
||||
0.f, 192.f, 0.f, 0.5f - padPixels,
|
||||
256.f, 192.f, 1.f, 0.5f - padPixels,
|
||||
0.f, 0.f, 0.f, 0.f,
|
||||
256.f, 192.f, 1.f, 0.5f - padPixels,
|
||||
256.f, 0.f, 1.f, 0.f,
|
||||
|
||||
oglContext = new QOpenGLContext();
|
||||
oglContext->setFormat(oglSurface->format());
|
||||
oglContext->setShareContext(windowctx);
|
||||
if (!oglContext->create())
|
||||
{
|
||||
// TODO handle this!
|
||||
printf("oglContext shat itself :(\n");
|
||||
delete oglContext;
|
||||
delete oglSurface;
|
||||
return;
|
||||
}
|
||||
0.f, 0.f, 0.f, 0.5f + padPixels,
|
||||
0.f, 192.f, 0.f, 1.f,
|
||||
256.f, 192.f, 1.f, 1.f,
|
||||
0.f, 0.f, 0.f, 0.5f + padPixels,
|
||||
256.f, 192.f, 1.f, 1.f,
|
||||
256.f, 0.f, 1.f, 0.5f + padPixels
|
||||
};
|
||||
|
||||
oglContext->moveToThread(this);
|
||||
glGenBuffers(1, &screenVertexBuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
glGenVertexArrays(1, &screenVertexArray);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
glEnableVertexAttribArray(0); // position
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(0));
|
||||
glEnableVertexAttribArray(1); // texcoord
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(2*4));
|
||||
|
||||
glGenTextures(1, &screenTexture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, paddedHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
// fill the padding
|
||||
u8 zeroData[256*4*4];
|
||||
memset(zeroData, 0, sizeof(zeroData));
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192, 256, 2, GL_RGBA, GL_UNSIGNED_BYTE, zeroData);
|
||||
|
||||
static_cast<ScreenPanelGL*>(mainWindow->panel)->transferLayout(this);
|
||||
}
|
||||
|
||||
void EmuThread::deinitOpenGL()
|
||||
{
|
||||
delete oglContext;
|
||||
delete oglSurface;
|
||||
glDeleteTextures(1, &screenTexture);
|
||||
|
||||
glDeleteVertexArrays(1, &screenVertexArray);
|
||||
glDeleteBuffers(1, &screenVertexBuffer);
|
||||
|
||||
OpenGL::DeleteShaderProgram(screenShaderProgram);
|
||||
|
||||
oglContext->DoneCurrent();
|
||||
oglContext = nullptr;
|
||||
}
|
||||
|
||||
void EmuThread::run()
|
||||
{
|
||||
bool hasOGL = mainWindow->hasOGL;
|
||||
u32 mainScreenPos[3];
|
||||
|
||||
NDS::Init();
|
||||
|
@ -401,10 +455,11 @@ void EmuThread::run()
|
|||
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
|
||||
videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons;
|
||||
|
||||
bool hasOGL = mainWindow->hasOGL;
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (hasOGL)
|
||||
{
|
||||
oglContext->makeCurrent(oglSurface);
|
||||
initOpenGL();
|
||||
videoRenderer = Config::_3DRenderer;
|
||||
}
|
||||
else
|
||||
|
@ -478,15 +533,10 @@ void EmuThread::run()
|
|||
hasOGL = mainWindow->hasOGL;
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (hasOGL)
|
||||
{
|
||||
oglContext->makeCurrent(oglSurface);
|
||||
videoRenderer = Config::_3DRenderer;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
videoRenderer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
videoRenderer = hasOGL ? Config::_3DRenderer : 0;
|
||||
|
@ -543,15 +593,6 @@ void EmuThread::run()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (videoRenderer == 1)
|
||||
{
|
||||
FrontBufferLock.lock();
|
||||
if (FrontBufferReverseSyncs[FrontBuffer ^ 1])
|
||||
glWaitSync(FrontBufferReverseSyncs[FrontBuffer ^ 1], 0, GL_TIMEOUT_IGNORED);
|
||||
FrontBufferLock.unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
// emulate
|
||||
u32 nlines = NDS::RunFrame();
|
||||
|
@ -562,21 +603,17 @@ void EmuThread::run()
|
|||
if (ROMManager::GBASave)
|
||||
ROMManager::GBASave->CheckFlush();
|
||||
|
||||
FrontBufferLock.lock();
|
||||
FrontBuffer = GPU::FrontBuffer;
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (videoRenderer == 1)
|
||||
if (!hasOGL)
|
||||
{
|
||||
if (FrontBufferSyncs[FrontBuffer])
|
||||
glDeleteSync(FrontBufferSyncs[FrontBuffer]);
|
||||
FrontBufferSyncs[FrontBuffer] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
// this is hacky but this is the easiest way to call
|
||||
// this function without dealling with a ton of
|
||||
// macro mess
|
||||
epoxy_glFlush();
|
||||
FrontBufferLock.lock();
|
||||
FrontBuffer = GPU::FrontBuffer;
|
||||
FrontBufferLock.unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
FrontBuffer = GPU::FrontBuffer;
|
||||
drawScreenGL();
|
||||
}
|
||||
#endif
|
||||
FrontBufferLock.unlock();
|
||||
|
||||
#ifdef MELONCAP
|
||||
MelonCap::Update();
|
||||
|
@ -665,6 +702,21 @@ void EmuThread::run()
|
|||
changeWindowTitle(melontitle);
|
||||
|
||||
SDL_Delay(75);
|
||||
|
||||
if (oglContext)
|
||||
drawScreenGL();
|
||||
|
||||
int contextRequest = ContextRequest;
|
||||
if (contextRequest == 1)
|
||||
{
|
||||
initOpenGL();
|
||||
ContextRequest = 0;
|
||||
}
|
||||
else if (contextRequest == 2)
|
||||
{
|
||||
deinitOpenGL();
|
||||
ContextRequest = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,10 +727,7 @@ void EmuThread::run()
|
|||
//Platform::LAN_DeInit();
|
||||
|
||||
if (hasOGL)
|
||||
{
|
||||
oglContext->doneCurrent();
|
||||
deinitOpenGL();
|
||||
}
|
||||
}
|
||||
|
||||
void EmuThread::changeWindowTitle(char* title)
|
||||
|
@ -698,6 +747,18 @@ void EmuThread::emuRun()
|
|||
micOpen();
|
||||
}
|
||||
|
||||
void EmuThread::initContext()
|
||||
{
|
||||
ContextRequest = 1;
|
||||
while (ContextRequest != 0);
|
||||
}
|
||||
|
||||
void EmuThread::deinitContext()
|
||||
{
|
||||
ContextRequest = 2;
|
||||
while (ContextRequest != 0);
|
||||
}
|
||||
|
||||
void EmuThread::emuPause()
|
||||
{
|
||||
EmuPause++;
|
||||
|
@ -749,6 +810,72 @@ bool EmuThread::emuIsActive()
|
|||
return (RunningSomething == 1);
|
||||
}
|
||||
|
||||
void EmuThread::drawScreenGL()
|
||||
{
|
||||
int w = windowInfo.surface_width;
|
||||
int h = windowInfo.surface_height;
|
||||
float factor = windowInfo.surface_scale;
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, w*factor, h*factor);
|
||||
|
||||
glUseProgram(screenShaderProgram[2]);
|
||||
glUniform2f(screenShaderScreenSizeULoc, w, h);
|
||||
glUniform1f(screenShaderScaleFactorULoc, factor);
|
||||
|
||||
int frontbuf = FrontBuffer;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (GPU::Renderer != 0)
|
||||
{
|
||||
// hardware-accelerated render
|
||||
GPU::CurGLCompositor->BindOutputTexture(frontbuf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// regular render
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
if (GPU::Framebuffer[frontbuf][0] && GPU::Framebuffer[frontbuf][1])
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][0]);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192+2, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]);
|
||||
}
|
||||
}
|
||||
|
||||
screenSettingsLock.lock();
|
||||
|
||||
GLint filter = filter ? GL_LINEAR : GL_NEAREST;
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
glUniformMatrix2x3fv(screenShaderTransformULoc, 1, GL_TRUE, screenMatrix[i]);
|
||||
glDrawArrays(GL_TRIANGLES, screenKind[i] == 0 ? 0 : 2*3, 2*3);
|
||||
}
|
||||
|
||||
screenSettingsLock.unlock();
|
||||
|
||||
//OSD::Update(this);
|
||||
//OSD::DrawGL(this, w*factor, h*factor);
|
||||
|
||||
oglContext->SwapBuffers();
|
||||
}
|
||||
|
||||
ScreenHandler::ScreenHandler(QWidget* widget)
|
||||
{
|
||||
widget->setMouseTracking(true);
|
||||
|
@ -966,12 +1093,12 @@ ScreenPanelNative::ScreenPanelNative(QWidget* parent) : QWidget(parent), ScreenH
|
|||
screenTrans[0].reset();
|
||||
screenTrans[1].reset();
|
||||
|
||||
OSD::Init(nullptr);
|
||||
OSD::Init();
|
||||
}
|
||||
|
||||
ScreenPanelNative::~ScreenPanelNative()
|
||||
{
|
||||
OSD::DeInit(nullptr);
|
||||
OSD::DeInit();
|
||||
}
|
||||
|
||||
void ScreenPanelNative::setupScreenLayout()
|
||||
|
@ -1022,7 +1149,7 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
OSD::Update(nullptr);
|
||||
OSD::Update();
|
||||
OSD::DrawNative(painter);
|
||||
}
|
||||
|
||||
|
@ -1070,23 +1197,97 @@ void ScreenPanelNative::onScreenLayoutChanged()
|
|||
}
|
||||
|
||||
|
||||
ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent), ScreenHandler(this)
|
||||
{}
|
||||
ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QWidget(parent), ScreenHandler(this)
|
||||
{
|
||||
setAutoFillBackground(false);
|
||||
setAttribute(Qt::WA_NativeWindow, true);
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
setAttribute(Qt::WA_PaintOnScreen, true);
|
||||
setAttribute(Qt::WA_KeyCompression, false);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
ScreenPanelGL::~ScreenPanelGL()
|
||||
{}
|
||||
|
||||
bool ScreenPanelGL::createContext()
|
||||
{
|
||||
makeCurrent();
|
||||
std::optional<WindowInfo> windowInfo = getWindowInfo();
|
||||
std::array<GL::Context::Version, 2> versionsToTry = {
|
||||
GL::Context::Version{GL::Context::Profile::Core, 3, 2},
|
||||
GL::Context::Version{GL::Context::Profile::Core, 4, 3}};
|
||||
if (windowInfo.has_value())
|
||||
{
|
||||
glContext = GL::Context::Create(*getWindowInfo(), versionsToTry);
|
||||
glContext->DoneCurrent();
|
||||
}
|
||||
|
||||
OSD::DeInit(this);
|
||||
return glContext != nullptr;
|
||||
}
|
||||
|
||||
glDeleteTextures(1, &screenTexture);
|
||||
qreal ScreenPanelGL::devicePixelRatioFromScreen() const
|
||||
{
|
||||
const QScreen* screen_for_ratio = screen();
|
||||
if (!screen_for_ratio)
|
||||
screen_for_ratio = QGuiApplication::primaryScreen();
|
||||
|
||||
glDeleteVertexArrays(1, &screenVertexArray);
|
||||
glDeleteBuffers(1, &screenVertexBuffer);
|
||||
return screen_for_ratio ? screen_for_ratio->devicePixelRatio() : static_cast<qreal>(1);
|
||||
}
|
||||
|
||||
delete screenShader;
|
||||
int ScreenPanelGL::scaledWindowWidth() const
|
||||
{
|
||||
return std::max(static_cast<int>(std::ceil(static_cast<qreal>(width()) * devicePixelRatioFromScreen())), 1);
|
||||
}
|
||||
|
||||
doneCurrent();
|
||||
int ScreenPanelGL::scaledWindowHeight() const
|
||||
{
|
||||
return std::max(static_cast<int>(std::ceil(static_cast<qreal>(height()) * devicePixelRatioFromScreen())), 1);
|
||||
}
|
||||
|
||||
std::optional<WindowInfo> ScreenPanelGL::getWindowInfo()
|
||||
{
|
||||
WindowInfo wi;
|
||||
|
||||
// Windows and Apple are easy here since there's no display connection.
|
||||
#if defined(_WIN32)
|
||||
wi.type = WindowInfo::Type::Win32;
|
||||
wi.window_handle = reinterpret_cast<void*>(winId());
|
||||
#elif defined(__APPLE__)
|
||||
wi.type = WindowInfo::Type::MacOS;
|
||||
wi.window_handle = reinterpret_cast<void*>(winId());
|
||||
#else
|
||||
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
||||
const QString platform_name = QGuiApplication::platformName();
|
||||
if (platform_name == QStringLiteral("xcb"))
|
||||
{
|
||||
wi.type = WindowInfo::Type::X11;
|
||||
wi.display_connection = pni->nativeResourceForWindow("display", windowHandle());
|
||||
wi.window_handle = reinterpret_cast<void*>(winId());
|
||||
}
|
||||
else if (platform_name == QStringLiteral("wayland"))
|
||||
{
|
||||
wi.type = WindowInfo::Type::Wayland;
|
||||
wi.display_connection = pni->nativeResourceForWindow("display", windowHandle());
|
||||
wi.window_handle = pni->nativeResourceForWindow("surface", windowHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Unknown PNI platform " << platform_name;
|
||||
return std::nullopt;
|
||||
}
|
||||
#endif
|
||||
|
||||
wi.surface_width = static_cast<u32>(scaledWindowWidth());
|
||||
wi.surface_height = static_cast<u32>(scaledWindowHeight());
|
||||
wi.surface_scale = static_cast<float>(devicePixelRatioFromScreen());
|
||||
|
||||
return wi;
|
||||
}
|
||||
|
||||
|
||||
QPaintEngine* ScreenPanelGL::paintEngine() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ScreenPanelGL::setupScreenLayout()
|
||||
|
@ -1095,163 +1296,15 @@ void ScreenPanelGL::setupScreenLayout()
|
|||
int h = height();
|
||||
|
||||
screenSetupLayout(w, h);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::initializeGL()
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER); // get renderer string
|
||||
const GLubyte* version = glGetString(GL_VERSION); // version as a string
|
||||
printf("OpenGL: renderer: %s\n", renderer);
|
||||
printf("OpenGL: version: %s\n", version);
|
||||
|
||||
glClearColor(0, 0, 0, 1);
|
||||
|
||||
screenShader = new QOpenGLShaderProgram(this);
|
||||
screenShader->addShaderFromSourceCode(QOpenGLShader::Vertex, kScreenVS);
|
||||
screenShader->addShaderFromSourceCode(QOpenGLShader::Fragment, kScreenFS);
|
||||
|
||||
GLuint pid = screenShader->programId();
|
||||
glBindAttribLocation(pid, 0, "vPosition");
|
||||
glBindAttribLocation(pid, 1, "vTexcoord");
|
||||
glBindFragDataLocation(pid, 0, "oColor");
|
||||
|
||||
screenShader->link();
|
||||
|
||||
screenShader->bind();
|
||||
screenShader->setUniformValue("ScreenTex", (GLint)0);
|
||||
screenShader->release();
|
||||
|
||||
// to prevent bleeding between both parts of the screen
|
||||
// with bilinear filtering enabled
|
||||
const int paddedHeight = 192*2+2;
|
||||
const float padPixels = 1.f / paddedHeight;
|
||||
|
||||
const float vertices[] =
|
||||
{
|
||||
0.f, 0.f, 0.f, 0.f,
|
||||
0.f, 192.f, 0.f, 0.5f - padPixels,
|
||||
256.f, 192.f, 1.f, 0.5f - padPixels,
|
||||
0.f, 0.f, 0.f, 0.f,
|
||||
256.f, 192.f, 1.f, 0.5f - padPixels,
|
||||
256.f, 0.f, 1.f, 0.f,
|
||||
|
||||
0.f, 0.f, 0.f, 0.5f + padPixels,
|
||||
0.f, 192.f, 0.f, 1.f,
|
||||
256.f, 192.f, 1.f, 1.f,
|
||||
0.f, 0.f, 0.f, 0.5f + padPixels,
|
||||
256.f, 192.f, 1.f, 1.f,
|
||||
256.f, 0.f, 1.f, 0.5f + padPixels
|
||||
};
|
||||
|
||||
glGenBuffers(1, &screenVertexBuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
glGenVertexArrays(1, &screenVertexArray);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
glEnableVertexAttribArray(0); // position
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(0));
|
||||
glEnableVertexAttribArray(1); // texcoord
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*4, (void*)(2*4));
|
||||
|
||||
glGenTextures(1, &screenTexture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, paddedHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
// fill the padding
|
||||
u8 zeroData[256*4*4];
|
||||
memset(zeroData, 0, sizeof(zeroData));
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192, 256, 2, GL_RGBA, GL_UNSIGNED_BYTE, zeroData);
|
||||
|
||||
OSD::Init(this);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::paintGL()
|
||||
{
|
||||
int w = width();
|
||||
int h = height();
|
||||
float factor = devicePixelRatioF();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glViewport(0, 0, w*factor, h*factor);
|
||||
|
||||
if (emuThread)
|
||||
{
|
||||
screenShader->bind();
|
||||
|
||||
screenShader->setUniformValue("uScreenSize", (float)w, (float)h);
|
||||
screenShader->setUniformValue("uScaleFactor", factor);
|
||||
|
||||
emuThread->FrontBufferLock.lock();
|
||||
int frontbuf = emuThread->FrontBuffer;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (GPU::Renderer != 0)
|
||||
{
|
||||
if (emuThread->FrontBufferSyncs[emuThread->FrontBuffer])
|
||||
glWaitSync(emuThread->FrontBufferSyncs[emuThread->FrontBuffer], 0, GL_TIMEOUT_IGNORED);
|
||||
// hardware-accelerated render
|
||||
GPU::CurGLCompositor->BindOutputTexture(frontbuf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// regular render
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
if (GPU::Framebuffer[frontbuf][0] && GPU::Framebuffer[frontbuf][1])
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][0]);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192+2, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]);
|
||||
}
|
||||
}
|
||||
|
||||
GLint filter = Config::ScreenFilter ? GL_LINEAR : GL_NEAREST;
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
|
||||
GLint transloc = screenShader->uniformLocation("uTransform");
|
||||
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
glUniformMatrix2x3fv(transloc, 1, GL_TRUE, screenMatrix[i]);
|
||||
glDrawArrays(GL_TRIANGLES, screenKind[i] == 0 ? 0 : 2*3, 2*3);
|
||||
}
|
||||
|
||||
screenShader->release();
|
||||
|
||||
if (emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer])
|
||||
glDeleteSync(emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer]);
|
||||
emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
emuThread->FrontBufferLock.unlock();
|
||||
}
|
||||
|
||||
OSD::Update(this);
|
||||
OSD::DrawGL(this, w*factor, h*factor);
|
||||
transferLayout(emuThread);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
setupScreenLayout();
|
||||
|
||||
QOpenGLWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::resizeGL(int w, int h)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::mousePressEvent(QMouseEvent* event)
|
||||
|
@ -1286,6 +1339,13 @@ bool ScreenPanelGL::event(QEvent* event)
|
|||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::transferLayout(EmuThread* thread)
|
||||
{
|
||||
std::optional<WindowInfo> windowInfo = getWindowInfo();
|
||||
if (windowInfo.has_value())
|
||||
thread->updateScreenSettings(Config::ScreenFilter, *windowInfo, numScreens, screenKind, &screenMatrix[0][0]);
|
||||
}
|
||||
|
||||
void ScreenPanelGL::onScreenLayoutChanged()
|
||||
{
|
||||
setMinimumSize(screenGetMinSize());
|
||||
|
@ -1758,17 +1818,7 @@ void MainWindow::createScreenPanel()
|
|||
panel = panelGL;
|
||||
panelWidget = panelGL;
|
||||
|
||||
if (!panelGL->isValid())
|
||||
hasOGL = false;
|
||||
else
|
||||
{
|
||||
QSurfaceFormat fmt = panelGL->format();
|
||||
if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 2))
|
||||
hasOGL = false;
|
||||
}
|
||||
|
||||
if (!hasOGL)
|
||||
delete panelGL;
|
||||
panelGL->createContext();
|
||||
}
|
||||
|
||||
if (!hasOGL)
|
||||
|
@ -1784,12 +1834,12 @@ void MainWindow::createScreenPanel()
|
|||
emit screenLayoutChange();
|
||||
}
|
||||
|
||||
QOpenGLContext* MainWindow::getOGLContext()
|
||||
GL::Context* MainWindow::getOGLContext()
|
||||
{
|
||||
if (!hasOGL) return nullptr;
|
||||
|
||||
QOpenGLWidget* glpanel = dynamic_cast<QOpenGLWidget*>(panel);
|
||||
return glpanel->context();
|
||||
ScreenPanelGL* glpanel = static_cast<ScreenPanelGL*>(panel);
|
||||
return glpanel->getContext();
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent* event)
|
||||
|
@ -2959,19 +3009,20 @@ void MainWindow::onUpdateVideoSettings(bool glchange)
|
|||
if (glchange)
|
||||
{
|
||||
emuThread->emuPause();
|
||||
if (hasOGL) emuThread->deinitContext();
|
||||
|
||||
if (hasOGL)
|
||||
emuThread->deinitOpenGL();
|
||||
delete panel;
|
||||
createScreenPanel();
|
||||
connect(emuThread, SIGNAL(windowUpdate()), panelWidget, SLOT(repaint()));
|
||||
if (hasOGL) emuThread->initOpenGL();
|
||||
}
|
||||
|
||||
videoSettingsDirty = true;
|
||||
|
||||
if (glchange)
|
||||
{
|
||||
if (hasOGL) emuThread->initContext();
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3062,14 +3113,6 @@ int main(int argc, char** argv)
|
|||
SANITIZE(Config::ScreenAspectBot, 0, 4);
|
||||
#undef SANITIZE
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(24);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(3, 2);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
format.setSwapInterval(0);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
audioSync = SDL_CreateCond();
|
||||
audioSyncLock = SDL_CreateMutex();
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
|
@ -28,15 +30,14 @@
|
|||
#include <QActionGroup>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <QScreen>
|
||||
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <atomic>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "FrontendUtil.h"
|
||||
#include "duckstation/gl/context.h"
|
||||
|
||||
class EmuThread : public QThread
|
||||
{
|
||||
|
@ -61,11 +62,13 @@ public:
|
|||
bool emuIsRunning();
|
||||
bool emuIsActive();
|
||||
|
||||
void initContext();
|
||||
void deinitContext();
|
||||
|
||||
int FrontBuffer = 0;
|
||||
QMutex FrontBufferLock;
|
||||
|
||||
GLsync FrontBufferReverseSyncs[2] = {nullptr, nullptr};
|
||||
GLsync FrontBufferSyncs[2] = {nullptr, nullptr};
|
||||
void updateScreenSettings(bool filter, const WindowInfo& windowInfo, int numScreens, int* screenKind, float* screenMatrix);
|
||||
|
||||
signals:
|
||||
void windowUpdate();
|
||||
|
@ -86,13 +89,27 @@ signals:
|
|||
void swapScreensToggle();
|
||||
|
||||
private:
|
||||
volatile int EmuStatus;
|
||||
void drawScreenGL();
|
||||
|
||||
std::atomic<int> EmuStatus;
|
||||
int PrevEmuStatus;
|
||||
int EmuRunning;
|
||||
int EmuPause;
|
||||
|
||||
QOffscreenSurface* oglSurface;
|
||||
QOpenGLContext* oglContext;
|
||||
std::atomic<int> ContextRequest = 0;
|
||||
|
||||
GL::Context* oglContext = nullptr;
|
||||
GLuint screenVertexBuffer, screenVertexArray;
|
||||
GLuint screenTexture;
|
||||
GLuint screenShaderProgram[3];
|
||||
GLuint screenShaderTransformULoc, screenShaderScreenSizeULoc, screenShaderScaleFactorULoc;
|
||||
|
||||
QMutex screenSettingsLock;
|
||||
WindowInfo windowInfo;
|
||||
float screenMatrix[Frontend::MaxScreenTransforms][6];
|
||||
int screenKind[Frontend::MaxScreenTransforms];
|
||||
int numScreens;
|
||||
bool filter;
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,7 +175,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class ScreenPanelGL : public QOpenGLWidget, public ScreenHandler, protected QOpenGLFunctions_3_2_Core
|
||||
class ScreenPanelGL : public QWidget, public ScreenHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -166,13 +183,22 @@ public:
|
|||
explicit ScreenPanelGL(QWidget* parent);
|
||||
virtual ~ScreenPanelGL();
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
std::optional<WindowInfo> getWindowInfo();
|
||||
|
||||
void paintGL() override;
|
||||
bool createContext();
|
||||
|
||||
GL::Context* getContext() { return glContext.get(); }
|
||||
|
||||
void transferLayout(EmuThread* thread);
|
||||
protected:
|
||||
|
||||
qreal devicePixelRatioFromScreen() const;
|
||||
int scaledWindowWidth() const;
|
||||
int scaledWindowHeight() const;
|
||||
|
||||
QPaintEngine* paintEngine() const override;
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void resizeGL(int w, int h) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
@ -180,16 +206,14 @@ protected:
|
|||
|
||||
void tabletEvent(QTabletEvent* event) override;
|
||||
bool event(QEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void onScreenLayoutChanged();
|
||||
|
||||
private:
|
||||
void setupScreenLayout();
|
||||
|
||||
QOpenGLShaderProgram* screenShader;
|
||||
GLuint screenVertexBuffer;
|
||||
GLuint screenVertexArray;
|
||||
GLuint screenTexture;
|
||||
std::unique_ptr<GL::Context> glContext;
|
||||
};
|
||||
|
||||
class MelonApplication : public QApplication
|
||||
|
@ -210,7 +234,7 @@ public:
|
|||
~MainWindow();
|
||||
|
||||
bool hasOGL;
|
||||
QOpenGLContext* getOGLContext();
|
||||
GL::Context* getOGLContext();
|
||||
|
||||
bool preloadROMs(QString filename, QString gbafilename);
|
||||
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
#ifndef __eglplatform_h_
|
||||
#define __eglplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright 2007-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Platform-specific types and definitions for egl.h
|
||||
*
|
||||
* Adopters may modify khrplatform.h and this file to suit their platform.
|
||||
* You are encouraged to submit all modifications to the Khronos group so that
|
||||
* they can be included in future versions of this file. Please submit changes
|
||||
* by filing an issue or pull request on the public Khronos EGL Registry, at
|
||||
* https://www.github.com/KhronosGroup/EGL-Registry/
|
||||
*/
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
|
||||
/* Macros used in EGL function prototype declarations.
|
||||
*
|
||||
* EGL functions should be prototyped as:
|
||||
*
|
||||
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
|
||||
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
|
||||
*
|
||||
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
|
||||
*/
|
||||
|
||||
#ifndef EGLAPI
|
||||
#define EGLAPI KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
#ifndef EGLAPIENTRY
|
||||
#define EGLAPIENTRY KHRONOS_APIENTRY
|
||||
#endif
|
||||
#define EGLAPIENTRYP EGLAPIENTRY*
|
||||
|
||||
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
|
||||
* are aliases of window-system-dependent types, such as X Display * or
|
||||
* Windows Device Context. They must be defined in platform-specific
|
||||
* code below. The EGL-prefixed versions of Native*Type are the same
|
||||
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
|
||||
*
|
||||
* Khronos STRONGLY RECOMMENDS that you use the default definitions
|
||||
* provided below, since these changes affect both binary and source
|
||||
* portability of applications using EGL running on different EGL
|
||||
* implementations.
|
||||
*/
|
||||
|
||||
#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
typedef HDC EGLNativeDisplayType;
|
||||
typedef HBITMAP EGLNativePixmapType;
|
||||
typedef HWND EGLNativeWindowType;
|
||||
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef int EGLNativePixmapType;
|
||||
typedef int EGLNativeWindowType;
|
||||
|
||||
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(WL_EGL_PLATFORM)
|
||||
|
||||
typedef struct wl_display *EGLNativeDisplayType;
|
||||
typedef struct wl_egl_pixmap *EGLNativePixmapType;
|
||||
typedef struct wl_egl_window *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__GBM__)
|
||||
|
||||
typedef struct gbm_device *EGLNativeDisplayType;
|
||||
typedef struct gbm_bo *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||
|
||||
struct ANativeWindow;
|
||||
struct egl_native_pixmap_t;
|
||||
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
|
||||
typedef struct ANativeWindow* EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_OZONE)
|
||||
|
||||
typedef intptr_t EGLNativeDisplayType;
|
||||
typedef intptr_t EGLNativePixmapType;
|
||||
typedef intptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_X11)
|
||||
|
||||
/* X11 (tentative) */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
typedef Display *EGLNativeDisplayType;
|
||||
typedef Pixmap EGLNativePixmapType;
|
||||
typedef Window EGLNativeWindowType;
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__Fuchsia__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#else
|
||||
#error "Platform not recognized"
|
||||
#endif
|
||||
|
||||
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
|
||||
typedef EGLNativeDisplayType NativeDisplayType;
|
||||
typedef EGLNativePixmapType NativePixmapType;
|
||||
typedef EGLNativeWindowType NativeWindowType;
|
||||
|
||||
|
||||
/* Define EGLint. This must be a signed integral type large enough to contain
|
||||
* all legal attribute names and values passed into and out of EGL, whether
|
||||
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
|
||||
* handle, or other. While in general a 32-bit integer will suffice, if
|
||||
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
|
||||
* integer type.
|
||||
*/
|
||||
typedef khronos_int32_t EGLint;
|
||||
|
||||
|
||||
/* C++ / C typecast macros for special EGL handle values */
|
||||
#if defined(__cplusplus)
|
||||
#define EGL_CAST(type, value) (static_cast<type>(value))
|
||||
#else
|
||||
#define EGL_CAST(type, value) ((type) (value))
|
||||
#endif
|
||||
|
||||
#endif /* __eglplatform_h */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
|
||||
EGL loader generated by glad 0.1.36 on Thu Sep 15 11:06:51 2022.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: egl
|
||||
APIs: egl=1.5
|
||||
Profile: -
|
||||
Extensions:
|
||||
|
||||
Loader: True
|
||||
Local files: True
|
||||
Omit khrplatform: False
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--api="egl=1.5" --generator="c" --spec="egl" --local-files --extensions=""
|
||||
Online:
|
||||
https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glad_egl.h"
|
||||
|
||||
int gladLoadEGL(void) {
|
||||
return gladLoadEGLLoader((GLADloadproc)eglGetProcAddress);
|
||||
}
|
||||
|
||||
static int find_extensionsEGL(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void find_coreEGL(void) {
|
||||
}
|
||||
|
||||
int gladLoadEGLLoader(GLADloadproc load) {
|
||||
(void) load;
|
||||
find_coreEGL();
|
||||
|
||||
if (!find_extensionsEGL()) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,317 @@
|
|||
/*
|
||||
|
||||
EGL loader generated by glad 0.1.36 on Thu Sep 15 11:06:51 2022.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: egl
|
||||
APIs: egl=1.5
|
||||
Profile: -
|
||||
Extensions:
|
||||
|
||||
Loader: True
|
||||
Local files: True
|
||||
Omit khrplatform: False
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--api="egl=1.5" --generator="c" --spec="egl" --local-files --extensions=""
|
||||
Online:
|
||||
https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __glad_egl_h_
|
||||
|
||||
#ifdef __egl_h_
|
||||
#error EGL header already included, remove this include, glad already provides it
|
||||
#endif
|
||||
|
||||
#define __glad_egl_h_
|
||||
#define __egl_h_
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#define APIENTRY __stdcall
|
||||
#endif
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#ifndef APIENTRYP
|
||||
#define APIENTRYP APIENTRY *
|
||||
#endif
|
||||
#ifndef GLAPI
|
||||
#define GLAPI extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* (* GLADloadproc)(const char *name);
|
||||
|
||||
GLAPI int gladLoadEGL(void);
|
||||
GLAPI int gladLoadEGLLoader(GLADloadproc);
|
||||
|
||||
#include "khrplatform.h"
|
||||
#include <EGL/eglplatform.h>
|
||||
struct AHardwareBuffer;
|
||||
struct wl_buffer;
|
||||
struct wl_display;
|
||||
struct wl_resource;
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef intptr_t EGLAttribKHR;
|
||||
typedef intptr_t EGLAttrib;
|
||||
typedef void *EGLClientBuffer;
|
||||
typedef void *EGLConfig;
|
||||
typedef void *EGLContext;
|
||||
typedef void *EGLDeviceEXT;
|
||||
typedef void *EGLDisplay;
|
||||
typedef void *EGLImage;
|
||||
typedef void *EGLImageKHR;
|
||||
typedef void *EGLLabelKHR;
|
||||
typedef void *EGLObjectKHR;
|
||||
typedef void *EGLOutputLayerEXT;
|
||||
typedef void *EGLOutputPortEXT;
|
||||
typedef void *EGLStreamKHR;
|
||||
typedef void *EGLSurface;
|
||||
typedef void *EGLSync;
|
||||
typedef void *EGLSyncKHR;
|
||||
typedef void *EGLSyncNV;
|
||||
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
|
||||
typedef khronos_utime_nanoseconds_t EGLTime;
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeNV;
|
||||
typedef khronos_utime_nanoseconds_t EGLuint64NV;
|
||||
typedef khronos_uint64_t EGLuint64KHR;
|
||||
typedef khronos_stime_nanoseconds_t EGLnsecsANDROID;
|
||||
typedef int EGLNativeFileDescriptorKHR;
|
||||
typedef khronos_ssize_t EGLsizeiANDROID;
|
||||
typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
|
||||
typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
|
||||
struct EGLClientPixmapHI {
|
||||
void *pData;
|
||||
EGLint iWidth;
|
||||
EGLint iHeight;
|
||||
EGLint iStride;
|
||||
};
|
||||
typedef void (APIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message);
|
||||
#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC
|
||||
#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC
|
||||
#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC
|
||||
#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BAD_ACCESS 0x3002
|
||||
#define EGL_BAD_ALLOC 0x3003
|
||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||
#define EGL_BAD_CONFIG 0x3005
|
||||
#define EGL_BAD_CONTEXT 0x3006
|
||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||
#define EGL_BAD_DISPLAY 0x3008
|
||||
#define EGL_BAD_MATCH 0x3009
|
||||
#define EGL_BAD_NATIVE_PIXMAP 0x300A
|
||||
#define EGL_BAD_NATIVE_WINDOW 0x300B
|
||||
#define EGL_BAD_PARAMETER 0x300C
|
||||
#define EGL_BAD_SURFACE 0x300D
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_BUFFER_SIZE 0x3020
|
||||
#define EGL_CONFIG_CAVEAT 0x3027
|
||||
#define EGL_CONFIG_ID 0x3028
|
||||
#define EGL_CORE_NATIVE_ENGINE 0x305B
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_DONT_CARE EGL_CAST(EGLint,-1)
|
||||
#define EGL_DRAW 0x3059
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_LARGEST_PBUFFER 0x3058
|
||||
#define EGL_LEVEL 0x3029
|
||||
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
|
||||
#define EGL_MAX_PBUFFER_PIXELS 0x302B
|
||||
#define EGL_MAX_PBUFFER_WIDTH 0x302C
|
||||
#define EGL_NATIVE_RENDERABLE 0x302D
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302E
|
||||
#define EGL_NATIVE_VISUAL_TYPE 0x302F
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_NON_CONFORMANT_CONFIG 0x3051
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0)
|
||||
#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0)
|
||||
#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0)
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_PIXMAP_BIT 0x0002
|
||||
#define EGL_READ 0x305A
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_SAMPLES 0x3031
|
||||
#define EGL_SAMPLE_BUFFERS 0x3032
|
||||
#define EGL_SLOW_CONFIG 0x3050
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
|
||||
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
|
||||
#define EGL_TRANSPARENT_RED_VALUE 0x3037
|
||||
#define EGL_TRANSPARENT_RGB 0x3052
|
||||
#define EGL_TRANSPARENT_TYPE 0x3034
|
||||
#define EGL_TRUE 1
|
||||
#define EGL_VENDOR 0x3053
|
||||
#define EGL_VERSION 0x3054
|
||||
#define EGL_WIDTH 0x3057
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
#define EGL_BACK_BUFFER 0x3084
|
||||
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
|
||||
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
|
||||
#define EGL_CONTEXT_LOST 0x300E
|
||||
#define EGL_MIN_SWAP_INTERVAL 0x303B
|
||||
#define EGL_MAX_SWAP_INTERVAL 0x303C
|
||||
#define EGL_MIPMAP_TEXTURE 0x3082
|
||||
#define EGL_MIPMAP_LEVEL 0x3083
|
||||
#define EGL_NO_TEXTURE 0x305C
|
||||
#define EGL_TEXTURE_2D 0x305F
|
||||
#define EGL_TEXTURE_FORMAT 0x3080
|
||||
#define EGL_TEXTURE_RGB 0x305D
|
||||
#define EGL_TEXTURE_RGBA 0x305E
|
||||
#define EGL_TEXTURE_TARGET 0x3081
|
||||
#define EGL_ALPHA_FORMAT 0x3088
|
||||
#define EGL_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_ALPHA_MASK_SIZE 0x303E
|
||||
#define EGL_BUFFER_PRESERVED 0x3094
|
||||
#define EGL_BUFFER_DESTROYED 0x3095
|
||||
#define EGL_CLIENT_APIS 0x308D
|
||||
#define EGL_COLORSPACE 0x3087
|
||||
#define EGL_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303F
|
||||
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
|
||||
#define EGL_DISPLAY_SCALING 10000
|
||||
#define EGL_HORIZONTAL_RESOLUTION 0x3090
|
||||
#define EGL_LUMINANCE_BUFFER 0x308F
|
||||
#define EGL_LUMINANCE_SIZE 0x303D
|
||||
#define EGL_OPENGL_ES_BIT 0x0001
|
||||
#define EGL_OPENVG_BIT 0x0002
|
||||
#define EGL_OPENGL_ES_API 0x30A0
|
||||
#define EGL_OPENVG_API 0x30A1
|
||||
#define EGL_OPENVG_IMAGE 0x3096
|
||||
#define EGL_PIXEL_ASPECT_RATIO 0x3092
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_RGB_BUFFER 0x308E
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
#define EGL_SWAP_BEHAVIOR 0x3093
|
||||
#define EGL_UNKNOWN EGL_CAST(EGLint,-1)
|
||||
#define EGL_VERTICAL_RESOLUTION 0x3091
|
||||
#define EGL_CONFORMANT 0x3042
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
#define EGL_MATCH_NATIVE_PIXMAP 0x3041
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||
#define EGL_VG_ALPHA_FORMAT 0x3088
|
||||
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040
|
||||
#define EGL_VG_COLORSPACE 0x3087
|
||||
#define EGL_VG_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_VG_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020
|
||||
#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0)
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200
|
||||
#define EGL_MULTISAMPLE_RESOLVE 0x3099
|
||||
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B
|
||||
#define EGL_OPENGL_API 0x30A2
|
||||
#define EGL_OPENGL_BIT 0x0008
|
||||
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400
|
||||
#define EGL_CONTEXT_MAJOR_VERSION 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION 0x30FB
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
|
||||
#define EGL_NO_RESET_NOTIFICATION 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2
|
||||
#define EGL_OPENGL_ES3_BIT 0x00000040
|
||||
#define EGL_CL_EVENT_HANDLE 0x309C
|
||||
#define EGL_SYNC_CL_EVENT 0x30FE
|
||||
#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0
|
||||
#define EGL_SYNC_TYPE 0x30F7
|
||||
#define EGL_SYNC_STATUS 0x30F1
|
||||
#define EGL_SYNC_CONDITION 0x30F8
|
||||
#define EGL_SIGNALED 0x30F2
|
||||
#define EGL_UNSIGNALED 0x30F3
|
||||
#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001
|
||||
#define EGL_FOREVER 0xFFFFFFFFFFFFFFFF
|
||||
#define EGL_TIMEOUT_EXPIRED 0x30F5
|
||||
#define EGL_CONDITION_SATISFIED 0x30F6
|
||||
#define EGL_NO_SYNC EGL_CAST(EGLSync,0)
|
||||
#define EGL_SYNC_FENCE 0x30F9
|
||||
#define EGL_GL_COLORSPACE 0x309D
|
||||
#define EGL_GL_COLORSPACE_SRGB 0x3089
|
||||
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_GL_RENDERBUFFER 0x30B9
|
||||
#define EGL_GL_TEXTURE_2D 0x30B1
|
||||
#define EGL_GL_TEXTURE_LEVEL 0x30BC
|
||||
#define EGL_GL_TEXTURE_3D 0x30B2
|
||||
#define EGL_GL_TEXTURE_ZOFFSET 0x30BD
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
|
||||
#define EGL_IMAGE_PRESERVED 0x30D2
|
||||
#define EGL_NO_IMAGE EGL_CAST(EGLImage,0)
|
||||
EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
||||
EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
|
||||
EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||
EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
|
||||
EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
|
||||
EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
|
||||
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
|
||||
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
||||
EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
EGLDisplay eglGetCurrentDisplay(void);
|
||||
EGLSurface eglGetCurrentSurface(EGLint readdraw);
|
||||
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id);
|
||||
EGLint eglGetError(void);
|
||||
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname);
|
||||
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
|
||||
const char *eglQueryString(EGLDisplay dpy, EGLint name);
|
||||
EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
|
||||
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
|
||||
EGLBoolean eglTerminate(EGLDisplay dpy);
|
||||
EGLBoolean eglWaitGL(void);
|
||||
EGLBoolean eglWaitNative(EGLint engine);
|
||||
EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
||||
EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval);
|
||||
EGLBoolean eglBindAPI(EGLenum api);
|
||||
EGLenum eglQueryAPI(void);
|
||||
EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
|
||||
EGLBoolean eglReleaseThread(void);
|
||||
EGLBoolean eglWaitClient(void);
|
||||
EGLContext eglGetCurrentContext(void);
|
||||
EGLSync eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
|
||||
EGLBoolean eglDestroySync(EGLDisplay dpy, EGLSync sync);
|
||||
EGLint eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
|
||||
EGLBoolean eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
|
||||
EGLImage eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
|
||||
EGLBoolean eglDestroyImage(EGLDisplay dpy, EGLImage image);
|
||||
EGLDisplay eglGetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
|
||||
EGLSurface eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
|
||||
EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
|
||||
EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,340 @@
|
|||
/*
|
||||
|
||||
GLX loader generated by glad 0.1.36 on Thu Sep 15 11:07:33 2022.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: glx
|
||||
APIs: glx=1.4
|
||||
Profile: -
|
||||
Extensions:
|
||||
|
||||
Loader: True
|
||||
Local files: True
|
||||
Omit khrplatform: False
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--api="glx=1.4" --generator="c" --spec="glx" --local-files --extensions=""
|
||||
Online:
|
||||
https://glad.dav1d.de/#language=c&specification=glx&loader=on&api=glx%3D1.4
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glad_glx.h"
|
||||
|
||||
static void* get_proc(const char *namez);
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#ifndef _WINDOWS_
|
||||
#undef APIENTRY
|
||||
#endif
|
||||
#include <windows.h>
|
||||
static HMODULE libGL;
|
||||
|
||||
typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*);
|
||||
static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef __has_include
|
||||
#if __has_include(<winapifamily.h>)
|
||||
#define HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||
#define HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINAPIFAMILY
|
||||
#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define IS_UWP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static
|
||||
int open_glx(void) {
|
||||
#ifndef IS_UWP
|
||||
libGL = LoadLibraryW(L"opengl32.dll");
|
||||
if(libGL != NULL) {
|
||||
void (* tmp)(void);
|
||||
tmp = (void(*)(void)) GetProcAddress(libGL, "wglGetProcAddress");
|
||||
gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE) tmp;
|
||||
return gladGetProcAddressPtr != NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void close_glx(void) {
|
||||
if(libGL != NULL) {
|
||||
FreeLibrary((HMODULE) libGL);
|
||||
libGL = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
static void* libGL;
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__HAIKU__)
|
||||
typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*);
|
||||
static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
|
||||
#endif
|
||||
|
||||
static
|
||||
int open_glx(void) {
|
||||
#ifdef __APPLE__
|
||||
static const char *NAMES[] = {
|
||||
"../Frameworks/OpenGL.framework/OpenGL",
|
||||
"/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
|
||||
};
|
||||
#else
|
||||
static const char *NAMES[] = {"libGL.so.1", "libGL.so"};
|
||||
#endif
|
||||
|
||||
unsigned int index = 0;
|
||||
for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) {
|
||||
libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
if(libGL != NULL) {
|
||||
#if defined(__APPLE__) || defined(__HAIKU__)
|
||||
return 1;
|
||||
#else
|
||||
gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL,
|
||||
"glXGetProcAddressARB");
|
||||
return gladGetProcAddressPtr != NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void close_glx(void) {
|
||||
if(libGL != NULL) {
|
||||
dlclose(libGL);
|
||||
libGL = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
void* get_proc(const char *namez) {
|
||||
void* result = NULL;
|
||||
if(libGL == NULL) return NULL;
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__HAIKU__)
|
||||
if(gladGetProcAddressPtr != NULL) {
|
||||
result = gladGetProcAddressPtr(namez);
|
||||
}
|
||||
#endif
|
||||
if(result == NULL) {
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
result = (void*)GetProcAddress((HMODULE) libGL, namez);
|
||||
#else
|
||||
result = dlsym(libGL, namez);
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int gladLoadGLX(Display *dpy, int screen) {
|
||||
int status = 0;
|
||||
|
||||
if(open_glx()) {
|
||||
status = gladLoadGLXLoader((GLADloadproc)get_proc, dpy, screen);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void gladUnloadGLX(void) {
|
||||
close_glx();
|
||||
}
|
||||
|
||||
static Display *GLADGLXDisplay = 0;
|
||||
static int GLADGLXscreen = 0;
|
||||
|
||||
static int get_exts(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void free_exts(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
static int has_ext(const char *ext) {
|
||||
const char *terminator;
|
||||
const char *loc;
|
||||
const char *extensions;
|
||||
|
||||
if(!GLAD_GLX_VERSION_1_1)
|
||||
return 0;
|
||||
|
||||
extensions = glXQueryExtensionsString(GLADGLXDisplay, GLADGLXscreen);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int GLAD_GLX_VERSION_1_0 = 0;
|
||||
int GLAD_GLX_VERSION_1_1 = 0;
|
||||
int GLAD_GLX_VERSION_1_2 = 0;
|
||||
int GLAD_GLX_VERSION_1_3 = 0;
|
||||
int GLAD_GLX_VERSION_1_4 = 0;
|
||||
PFNGLXCHOOSEFBCONFIGPROC glad_glXChooseFBConfig = NULL;
|
||||
PFNGLXCHOOSEVISUALPROC glad_glXChooseVisual = NULL;
|
||||
PFNGLXCOPYCONTEXTPROC glad_glXCopyContext = NULL;
|
||||
PFNGLXCREATECONTEXTPROC glad_glXCreateContext = NULL;
|
||||
PFNGLXCREATEGLXPIXMAPPROC glad_glXCreateGLXPixmap = NULL;
|
||||
PFNGLXCREATENEWCONTEXTPROC glad_glXCreateNewContext = NULL;
|
||||
PFNGLXCREATEPBUFFERPROC glad_glXCreatePbuffer = NULL;
|
||||
PFNGLXCREATEPIXMAPPROC glad_glXCreatePixmap = NULL;
|
||||
PFNGLXCREATEWINDOWPROC glad_glXCreateWindow = NULL;
|
||||
PFNGLXDESTROYCONTEXTPROC glad_glXDestroyContext = NULL;
|
||||
PFNGLXDESTROYGLXPIXMAPPROC glad_glXDestroyGLXPixmap = NULL;
|
||||
PFNGLXDESTROYPBUFFERPROC glad_glXDestroyPbuffer = NULL;
|
||||
PFNGLXDESTROYPIXMAPPROC glad_glXDestroyPixmap = NULL;
|
||||
PFNGLXDESTROYWINDOWPROC glad_glXDestroyWindow = NULL;
|
||||
PFNGLXGETCLIENTSTRINGPROC glad_glXGetClientString = NULL;
|
||||
PFNGLXGETCONFIGPROC glad_glXGetConfig = NULL;
|
||||
PFNGLXGETCURRENTCONTEXTPROC glad_glXGetCurrentContext = NULL;
|
||||
PFNGLXGETCURRENTDISPLAYPROC glad_glXGetCurrentDisplay = NULL;
|
||||
PFNGLXGETCURRENTDRAWABLEPROC glad_glXGetCurrentDrawable = NULL;
|
||||
PFNGLXGETCURRENTREADDRAWABLEPROC glad_glXGetCurrentReadDrawable = NULL;
|
||||
PFNGLXGETFBCONFIGATTRIBPROC glad_glXGetFBConfigAttrib = NULL;
|
||||
PFNGLXGETFBCONFIGSPROC glad_glXGetFBConfigs = NULL;
|
||||
PFNGLXGETPROCADDRESSPROC glad_glXGetProcAddress = NULL;
|
||||
PFNGLXGETSELECTEDEVENTPROC glad_glXGetSelectedEvent = NULL;
|
||||
PFNGLXGETVISUALFROMFBCONFIGPROC glad_glXGetVisualFromFBConfig = NULL;
|
||||
PFNGLXISDIRECTPROC glad_glXIsDirect = NULL;
|
||||
PFNGLXMAKECONTEXTCURRENTPROC glad_glXMakeContextCurrent = NULL;
|
||||
PFNGLXMAKECURRENTPROC glad_glXMakeCurrent = NULL;
|
||||
PFNGLXQUERYCONTEXTPROC glad_glXQueryContext = NULL;
|
||||
PFNGLXQUERYDRAWABLEPROC glad_glXQueryDrawable = NULL;
|
||||
PFNGLXQUERYEXTENSIONPROC glad_glXQueryExtension = NULL;
|
||||
PFNGLXQUERYEXTENSIONSSTRINGPROC glad_glXQueryExtensionsString = NULL;
|
||||
PFNGLXQUERYSERVERSTRINGPROC glad_glXQueryServerString = NULL;
|
||||
PFNGLXQUERYVERSIONPROC glad_glXQueryVersion = NULL;
|
||||
PFNGLXSELECTEVENTPROC glad_glXSelectEvent = NULL;
|
||||
PFNGLXSWAPBUFFERSPROC glad_glXSwapBuffers = NULL;
|
||||
PFNGLXUSEXFONTPROC glad_glXUseXFont = NULL;
|
||||
PFNGLXWAITGLPROC glad_glXWaitGL = NULL;
|
||||
PFNGLXWAITXPROC glad_glXWaitX = NULL;
|
||||
static void load_GLX_VERSION_1_0(GLADloadproc load) {
|
||||
if(!GLAD_GLX_VERSION_1_0) return;
|
||||
glad_glXChooseVisual = (PFNGLXCHOOSEVISUALPROC)load("glXChooseVisual");
|
||||
glad_glXCreateContext = (PFNGLXCREATECONTEXTPROC)load("glXCreateContext");
|
||||
glad_glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC)load("glXDestroyContext");
|
||||
glad_glXMakeCurrent = (PFNGLXMAKECURRENTPROC)load("glXMakeCurrent");
|
||||
glad_glXCopyContext = (PFNGLXCOPYCONTEXTPROC)load("glXCopyContext");
|
||||
glad_glXSwapBuffers = (PFNGLXSWAPBUFFERSPROC)load("glXSwapBuffers");
|
||||
glad_glXCreateGLXPixmap = (PFNGLXCREATEGLXPIXMAPPROC)load("glXCreateGLXPixmap");
|
||||
glad_glXDestroyGLXPixmap = (PFNGLXDESTROYGLXPIXMAPPROC)load("glXDestroyGLXPixmap");
|
||||
glad_glXQueryExtension = (PFNGLXQUERYEXTENSIONPROC)load("glXQueryExtension");
|
||||
glad_glXQueryVersion = (PFNGLXQUERYVERSIONPROC)load("glXQueryVersion");
|
||||
glad_glXIsDirect = (PFNGLXISDIRECTPROC)load("glXIsDirect");
|
||||
glad_glXGetConfig = (PFNGLXGETCONFIGPROC)load("glXGetConfig");
|
||||
glad_glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC)load("glXGetCurrentContext");
|
||||
glad_glXGetCurrentDrawable = (PFNGLXGETCURRENTDRAWABLEPROC)load("glXGetCurrentDrawable");
|
||||
glad_glXWaitGL = (PFNGLXWAITGLPROC)load("glXWaitGL");
|
||||
glad_glXWaitX = (PFNGLXWAITXPROC)load("glXWaitX");
|
||||
glad_glXUseXFont = (PFNGLXUSEXFONTPROC)load("glXUseXFont");
|
||||
}
|
||||
static void load_GLX_VERSION_1_1(GLADloadproc load) {
|
||||
if(!GLAD_GLX_VERSION_1_1) return;
|
||||
glad_glXQueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)load("glXQueryExtensionsString");
|
||||
glad_glXQueryServerString = (PFNGLXQUERYSERVERSTRINGPROC)load("glXQueryServerString");
|
||||
glad_glXGetClientString = (PFNGLXGETCLIENTSTRINGPROC)load("glXGetClientString");
|
||||
}
|
||||
static void load_GLX_VERSION_1_2(GLADloadproc load) {
|
||||
if(!GLAD_GLX_VERSION_1_2) return;
|
||||
glad_glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)load("glXGetCurrentDisplay");
|
||||
}
|
||||
static void load_GLX_VERSION_1_3(GLADloadproc load) {
|
||||
if(!GLAD_GLX_VERSION_1_3) return;
|
||||
glad_glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)load("glXGetFBConfigs");
|
||||
glad_glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)load("glXChooseFBConfig");
|
||||
glad_glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)load("glXGetFBConfigAttrib");
|
||||
glad_glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)load("glXGetVisualFromFBConfig");
|
||||
glad_glXCreateWindow = (PFNGLXCREATEWINDOWPROC)load("glXCreateWindow");
|
||||
glad_glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)load("glXDestroyWindow");
|
||||
glad_glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)load("glXCreatePixmap");
|
||||
glad_glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)load("glXDestroyPixmap");
|
||||
glad_glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)load("glXCreatePbuffer");
|
||||
glad_glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)load("glXDestroyPbuffer");
|
||||
glad_glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)load("glXQueryDrawable");
|
||||
glad_glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)load("glXCreateNewContext");
|
||||
glad_glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)load("glXMakeContextCurrent");
|
||||
glad_glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)load("glXGetCurrentReadDrawable");
|
||||
glad_glXQueryContext = (PFNGLXQUERYCONTEXTPROC)load("glXQueryContext");
|
||||
glad_glXSelectEvent = (PFNGLXSELECTEVENTPROC)load("glXSelectEvent");
|
||||
glad_glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)load("glXGetSelectedEvent");
|
||||
}
|
||||
static void load_GLX_VERSION_1_4(GLADloadproc load) {
|
||||
if(!GLAD_GLX_VERSION_1_4) return;
|
||||
glad_glXGetProcAddress = (PFNGLXGETPROCADDRESSPROC)load("glXGetProcAddress");
|
||||
}
|
||||
static int find_extensionsGLX(void) {
|
||||
if (!get_exts()) return 0;
|
||||
(void)&has_ext;
|
||||
free_exts();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void find_coreGLX(Display *dpy, int screen) {
|
||||
int major = 0, minor = 0;
|
||||
if(dpy == 0 && GLADGLXDisplay == 0) {
|
||||
dpy = XOpenDisplay(0);
|
||||
screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(dpy));
|
||||
} else if(dpy == 0) {
|
||||
dpy = GLADGLXDisplay;
|
||||
screen = GLADGLXscreen;
|
||||
}
|
||||
glXQueryVersion(dpy, &major, &minor);
|
||||
GLADGLXDisplay = dpy;
|
||||
GLADGLXscreen = screen;
|
||||
GLAD_GLX_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||
GLAD_GLX_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
|
||||
GLAD_GLX_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
|
||||
GLAD_GLX_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
|
||||
GLAD_GLX_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
|
||||
}
|
||||
|
||||
int gladLoadGLXLoader(GLADloadproc load, Display *dpy, int screen) {
|
||||
glXQueryVersion = (PFNGLXQUERYVERSIONPROC)load("glXQueryVersion");
|
||||
if(glXQueryVersion == NULL) return 0;
|
||||
find_coreGLX(dpy, screen);
|
||||
load_GLX_VERSION_1_0(load);
|
||||
load_GLX_VERSION_1_1(load);
|
||||
load_GLX_VERSION_1_2(load);
|
||||
load_GLX_VERSION_1_3(load);
|
||||
load_GLX_VERSION_1_4(load);
|
||||
|
||||
if (!find_extensionsGLX()) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,435 @@
|
|||
/*
|
||||
|
||||
GLX loader generated by glad 0.1.36 on Thu Sep 15 11:07:33 2022.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: glx
|
||||
APIs: glx=1.4
|
||||
Profile: -
|
||||
Extensions:
|
||||
|
||||
Loader: True
|
||||
Local files: True
|
||||
Omit khrplatform: False
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--api="glx=1.4" --generator="c" --spec="glx" --local-files --extensions=""
|
||||
Online:
|
||||
https://glad.dav1d.de/#language=c&specification=glx&loader=on&api=glx%3D1.4
|
||||
*/
|
||||
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "glad.h"
|
||||
|
||||
#ifndef __glad_glxext_h_
|
||||
|
||||
#ifdef __glxext_h_
|
||||
#error GLX header already included, remove this include, glad already provides it
|
||||
#endif
|
||||
|
||||
#define __glad_glxext_h_
|
||||
#define __glxext_h_
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#ifndef APIENTRYP
|
||||
#define APIENTRYP APIENTRY *
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* (* GLADloadproc)(const char *name);
|
||||
|
||||
#ifndef GLAPI
|
||||
# if defined(GLAD_GLAPI_EXPORT)
|
||||
# if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# if defined(GLAD_GLAPI_EXPORT_BUILD)
|
||||
# if defined(__GNUC__)
|
||||
# define GLAPI __attribute__ ((dllexport)) extern
|
||||
# else
|
||||
# define GLAPI __declspec(dllexport) extern
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__)
|
||||
# define GLAPI __attribute__ ((dllimport)) extern
|
||||
# else
|
||||
# define GLAPI __declspec(dllimport) extern
|
||||
# endif
|
||||
# endif
|
||||
# elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)
|
||||
# define GLAPI __attribute__ ((visibility ("default"))) extern
|
||||
# else
|
||||
# define GLAPI extern
|
||||
# endif
|
||||
# else
|
||||
# define GLAPI extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
GLAPI int gladLoadGLX(Display *dpy, int screen);
|
||||
GLAPI void gladUnloadGLX(void);
|
||||
|
||||
GLAPI int gladLoadGLXLoader(GLADloadproc, Display *dpy, int screen);
|
||||
|
||||
#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 XID GLXFBConfigID;
|
||||
typedef struct __GLXFBConfigRec *GLXFBConfig;
|
||||
typedef XID GLXContextID;
|
||||
typedef struct __GLXcontextRec *GLXContext;
|
||||
typedef XID GLXPixmap;
|
||||
typedef XID GLXDrawable;
|
||||
typedef XID GLXWindow;
|
||||
typedef XID GLXPbuffer;
|
||||
typedef void (APIENTRY *__GLXextFuncPtr)(void);
|
||||
typedef XID GLXVideoCaptureDeviceNV;
|
||||
typedef unsigned int GLXVideoDeviceNV;
|
||||
typedef XID GLXVideoSourceSGIX;
|
||||
typedef XID GLXFBConfigIDSGIX;
|
||||
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
|
||||
typedef XID GLXPbufferSGIX;
|
||||
typedef struct {
|
||||
int event_type; /* GLX_DAMAGED or GLX_SAVED */
|
||||
int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
|
||||
unsigned long serial; /* # of last request processed by server */
|
||||
Bool send_event; /* true if this came for SendEvent request */
|
||||
Display *display; /* display the event was read from */
|
||||
GLXDrawable drawable; /* XID of Drawable */
|
||||
unsigned int buffer_mask; /* mask indicating which buffers are affected */
|
||||
unsigned int aux_buffer; /* which aux buffer was affected */
|
||||
int x, y;
|
||||
int width, height;
|
||||
int count; /* if nonzero, at least this many more */
|
||||
} GLXPbufferClobberEvent;
|
||||
typedef struct {
|
||||
int type;
|
||||
unsigned long serial; /* # of last request processed by server */
|
||||
Bool send_event; /* true if this came from a SendEvent request */
|
||||
Display *display; /* Display the event was read from */
|
||||
GLXDrawable drawable; /* drawable on which event was requested in event mask */
|
||||
int event_type;
|
||||
int64_t ust;
|
||||
int64_t msc;
|
||||
int64_t sbc;
|
||||
} GLXBufferSwapComplete;
|
||||
typedef union __GLXEvent {
|
||||
GLXPbufferClobberEvent glxpbufferclobber;
|
||||
GLXBufferSwapComplete glxbufferswapcomplete;
|
||||
long pad[24];
|
||||
} GLXEvent;
|
||||
typedef struct {
|
||||
int type;
|
||||
unsigned long serial;
|
||||
Bool send_event;
|
||||
Display *display;
|
||||
int extension;
|
||||
int evtype;
|
||||
GLXDrawable window;
|
||||
Bool stereo_tree;
|
||||
} GLXStereoNotifyEventEXT;
|
||||
typedef struct {
|
||||
int type;
|
||||
unsigned long serial; /* # of last request processed by server */
|
||||
Bool send_event; /* true if this came for SendEvent request */
|
||||
Display *display; /* display the event was read from */
|
||||
GLXDrawable drawable; /* i.d. of Drawable */
|
||||
int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
|
||||
int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
|
||||
unsigned int mask; /* mask indicating which buffers are affected*/
|
||||
int x, y;
|
||||
int width, height;
|
||||
int count; /* if nonzero, at least this many more */
|
||||
} GLXBufferClobberEventSGIX;
|
||||
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;
|
||||
#define GLX_EXTENSION_NAME "GLX"
|
||||
#define GLX_PbufferClobber 0
|
||||
#define GLX_BufferSwapComplete 1
|
||||
#define __GLX_NUMBER_EVENTS 17
|
||||
#define GLX_BAD_SCREEN 1
|
||||
#define GLX_BAD_ATTRIBUTE 2
|
||||
#define GLX_NO_EXTENSION 3
|
||||
#define GLX_BAD_VISUAL 4
|
||||
#define GLX_BAD_CONTEXT 5
|
||||
#define GLX_BAD_VALUE 6
|
||||
#define GLX_BAD_ENUM 7
|
||||
#define GLX_USE_GL 1
|
||||
#define GLX_BUFFER_SIZE 2
|
||||
#define GLX_LEVEL 3
|
||||
#define GLX_RGBA 4
|
||||
#define GLX_DOUBLEBUFFER 5
|
||||
#define GLX_STEREO 6
|
||||
#define GLX_AUX_BUFFERS 7
|
||||
#define GLX_RED_SIZE 8
|
||||
#define GLX_GREEN_SIZE 9
|
||||
#define GLX_BLUE_SIZE 10
|
||||
#define GLX_ALPHA_SIZE 11
|
||||
#define GLX_DEPTH_SIZE 12
|
||||
#define GLX_STENCIL_SIZE 13
|
||||
#define GLX_ACCUM_RED_SIZE 14
|
||||
#define GLX_ACCUM_GREEN_SIZE 15
|
||||
#define GLX_ACCUM_BLUE_SIZE 16
|
||||
#define GLX_ACCUM_ALPHA_SIZE 17
|
||||
#define GLX_VENDOR 0x1
|
||||
#define GLX_VERSION 0x2
|
||||
#define GLX_EXTENSIONS 0x3
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
#define GLX_PIXMAP_BIT 0x00000002
|
||||
#define GLX_PBUFFER_BIT 0x00000004
|
||||
#define GLX_RGBA_BIT 0x00000001
|
||||
#define GLX_COLOR_INDEX_BIT 0x00000002
|
||||
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
|
||||
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
|
||||
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
|
||||
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
|
||||
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
|
||||
#define GLX_AUX_BUFFERS_BIT 0x00000010
|
||||
#define GLX_DEPTH_BUFFER_BIT 0x00000020
|
||||
#define GLX_STENCIL_BUFFER_BIT 0x00000040
|
||||
#define GLX_ACCUM_BUFFER_BIT 0x00000080
|
||||
#define GLX_CONFIG_CAVEAT 0x20
|
||||
#define GLX_X_VISUAL_TYPE 0x22
|
||||
#define GLX_TRANSPARENT_TYPE 0x23
|
||||
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
|
||||
#define GLX_TRANSPARENT_RED_VALUE 0x25
|
||||
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
|
||||
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
|
||||
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
|
||||
#define GLX_DONT_CARE 0xFFFFFFFF
|
||||
#define GLX_NONE 0x8000
|
||||
#define GLX_SLOW_CONFIG 0x8001
|
||||
#define GLX_TRUE_COLOR 0x8002
|
||||
#define GLX_DIRECT_COLOR 0x8003
|
||||
#define GLX_PSEUDO_COLOR 0x8004
|
||||
#define GLX_STATIC_COLOR 0x8005
|
||||
#define GLX_GRAY_SCALE 0x8006
|
||||
#define GLX_STATIC_GRAY 0x8007
|
||||
#define GLX_TRANSPARENT_RGB 0x8008
|
||||
#define GLX_TRANSPARENT_INDEX 0x8009
|
||||
#define GLX_VISUAL_ID 0x800B
|
||||
#define GLX_SCREEN 0x800C
|
||||
#define GLX_NON_CONFORMANT_CONFIG 0x800D
|
||||
#define GLX_DRAWABLE_TYPE 0x8010
|
||||
#define GLX_RENDER_TYPE 0x8011
|
||||
#define GLX_X_RENDERABLE 0x8012
|
||||
#define GLX_FBCONFIG_ID 0x8013
|
||||
#define GLX_RGBA_TYPE 0x8014
|
||||
#define GLX_COLOR_INDEX_TYPE 0x8015
|
||||
#define GLX_MAX_PBUFFER_WIDTH 0x8016
|
||||
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
|
||||
#define GLX_MAX_PBUFFER_PIXELS 0x8018
|
||||
#define GLX_PRESERVED_CONTENTS 0x801B
|
||||
#define GLX_LARGEST_PBUFFER 0x801C
|
||||
#define GLX_WIDTH 0x801D
|
||||
#define GLX_HEIGHT 0x801E
|
||||
#define GLX_EVENT_MASK 0x801F
|
||||
#define GLX_DAMAGED 0x8020
|
||||
#define GLX_SAVED 0x8021
|
||||
#define GLX_WINDOW 0x8022
|
||||
#define GLX_PBUFFER 0x8023
|
||||
#define GLX_PBUFFER_HEIGHT 0x8040
|
||||
#define GLX_PBUFFER_WIDTH 0x8041
|
||||
#define GLX_SAMPLE_BUFFERS 100000
|
||||
#define GLX_SAMPLES 100001
|
||||
#ifndef GLX_VERSION_1_0
|
||||
#define GLX_VERSION_1_0 1
|
||||
GLAPI int GLAD_GLX_VERSION_1_0;
|
||||
typedef XVisualInfo * (APIENTRYP PFNGLXCHOOSEVISUALPROC)(Display *dpy, int screen, int *attribList);
|
||||
GLAPI PFNGLXCHOOSEVISUALPROC glad_glXChooseVisual;
|
||||
#define glXChooseVisual glad_glXChooseVisual
|
||||
typedef GLXContext (APIENTRYP PFNGLXCREATECONTEXTPROC)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
|
||||
GLAPI PFNGLXCREATECONTEXTPROC glad_glXCreateContext;
|
||||
#define glXCreateContext glad_glXCreateContext
|
||||
typedef void (APIENTRYP PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx);
|
||||
GLAPI PFNGLXDESTROYCONTEXTPROC glad_glXDestroyContext;
|
||||
#define glXDestroyContext glad_glXDestroyContext
|
||||
typedef Bool (APIENTRYP PFNGLXMAKECURRENTPROC)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
|
||||
GLAPI PFNGLXMAKECURRENTPROC glad_glXMakeCurrent;
|
||||
#define glXMakeCurrent glad_glXMakeCurrent
|
||||
typedef void (APIENTRYP PFNGLXCOPYCONTEXTPROC)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
|
||||
GLAPI PFNGLXCOPYCONTEXTPROC glad_glXCopyContext;
|
||||
#define glXCopyContext glad_glXCopyContext
|
||||
typedef void (APIENTRYP PFNGLXSWAPBUFFERSPROC)(Display *dpy, GLXDrawable drawable);
|
||||
GLAPI PFNGLXSWAPBUFFERSPROC glad_glXSwapBuffers;
|
||||
#define glXSwapBuffers glad_glXSwapBuffers
|
||||
typedef GLXPixmap (APIENTRYP PFNGLXCREATEGLXPIXMAPPROC)(Display *dpy, XVisualInfo *visual, Pixmap pixmap);
|
||||
GLAPI PFNGLXCREATEGLXPIXMAPPROC glad_glXCreateGLXPixmap;
|
||||
#define glXCreateGLXPixmap glad_glXCreateGLXPixmap
|
||||
typedef void (APIENTRYP PFNGLXDESTROYGLXPIXMAPPROC)(Display *dpy, GLXPixmap pixmap);
|
||||
GLAPI PFNGLXDESTROYGLXPIXMAPPROC glad_glXDestroyGLXPixmap;
|
||||
#define glXDestroyGLXPixmap glad_glXDestroyGLXPixmap
|
||||
typedef Bool (APIENTRYP PFNGLXQUERYEXTENSIONPROC)(Display *dpy, int *errorb, int *event);
|
||||
GLAPI PFNGLXQUERYEXTENSIONPROC glad_glXQueryExtension;
|
||||
#define glXQueryExtension glad_glXQueryExtension
|
||||
typedef Bool (APIENTRYP PFNGLXQUERYVERSIONPROC)(Display *dpy, int *maj, int *min);
|
||||
GLAPI PFNGLXQUERYVERSIONPROC glad_glXQueryVersion;
|
||||
#define glXQueryVersion glad_glXQueryVersion
|
||||
typedef Bool (APIENTRYP PFNGLXISDIRECTPROC)(Display *dpy, GLXContext ctx);
|
||||
GLAPI PFNGLXISDIRECTPROC glad_glXIsDirect;
|
||||
#define glXIsDirect glad_glXIsDirect
|
||||
typedef int (APIENTRYP PFNGLXGETCONFIGPROC)(Display *dpy, XVisualInfo *visual, int attrib, int *value);
|
||||
GLAPI PFNGLXGETCONFIGPROC glad_glXGetConfig;
|
||||
#define glXGetConfig glad_glXGetConfig
|
||||
typedef GLXContext (APIENTRYP PFNGLXGETCURRENTCONTEXTPROC)(void);
|
||||
GLAPI PFNGLXGETCURRENTCONTEXTPROC glad_glXGetCurrentContext;
|
||||
#define glXGetCurrentContext glad_glXGetCurrentContext
|
||||
typedef GLXDrawable (APIENTRYP PFNGLXGETCURRENTDRAWABLEPROC)(void);
|
||||
GLAPI PFNGLXGETCURRENTDRAWABLEPROC glad_glXGetCurrentDrawable;
|
||||
#define glXGetCurrentDrawable glad_glXGetCurrentDrawable
|
||||
typedef void (APIENTRYP PFNGLXWAITGLPROC)(void);
|
||||
GLAPI PFNGLXWAITGLPROC glad_glXWaitGL;
|
||||
#define glXWaitGL glad_glXWaitGL
|
||||
typedef void (APIENTRYP PFNGLXWAITXPROC)(void);
|
||||
GLAPI PFNGLXWAITXPROC glad_glXWaitX;
|
||||
#define glXWaitX glad_glXWaitX
|
||||
typedef void (APIENTRYP PFNGLXUSEXFONTPROC)(Font font, int first, int count, int list);
|
||||
GLAPI PFNGLXUSEXFONTPROC glad_glXUseXFont;
|
||||
#define glXUseXFont glad_glXUseXFont
|
||||
#endif
|
||||
#ifndef GLX_VERSION_1_1
|
||||
#define GLX_VERSION_1_1 1
|
||||
GLAPI int GLAD_GLX_VERSION_1_1;
|
||||
typedef const char * (APIENTRYP PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display *dpy, int screen);
|
||||
GLAPI PFNGLXQUERYEXTENSIONSSTRINGPROC glad_glXQueryExtensionsString;
|
||||
#define glXQueryExtensionsString glad_glXQueryExtensionsString
|
||||
typedef const char * (APIENTRYP PFNGLXQUERYSERVERSTRINGPROC)(Display *dpy, int screen, int name);
|
||||
GLAPI PFNGLXQUERYSERVERSTRINGPROC glad_glXQueryServerString;
|
||||
#define glXQueryServerString glad_glXQueryServerString
|
||||
typedef const char * (APIENTRYP PFNGLXGETCLIENTSTRINGPROC)(Display *dpy, int name);
|
||||
GLAPI PFNGLXGETCLIENTSTRINGPROC glad_glXGetClientString;
|
||||
#define glXGetClientString glad_glXGetClientString
|
||||
#endif
|
||||
#ifndef GLX_VERSION_1_2
|
||||
#define GLX_VERSION_1_2 1
|
||||
GLAPI int GLAD_GLX_VERSION_1_2;
|
||||
typedef Display * (APIENTRYP PFNGLXGETCURRENTDISPLAYPROC)(void);
|
||||
GLAPI PFNGLXGETCURRENTDISPLAYPROC glad_glXGetCurrentDisplay;
|
||||
#define glXGetCurrentDisplay glad_glXGetCurrentDisplay
|
||||
#endif
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_VERSION_1_3 1
|
||||
GLAPI int GLAD_GLX_VERSION_1_3;
|
||||
typedef GLXFBConfig * (APIENTRYP PFNGLXGETFBCONFIGSPROC)(Display *dpy, int screen, int *nelements);
|
||||
GLAPI PFNGLXGETFBCONFIGSPROC glad_glXGetFBConfigs;
|
||||
#define glXGetFBConfigs glad_glXGetFBConfigs
|
||||
typedef GLXFBConfig * (APIENTRYP PFNGLXCHOOSEFBCONFIGPROC)(Display *dpy, int screen, const int *attrib_list, int *nelements);
|
||||
GLAPI PFNGLXCHOOSEFBCONFIGPROC glad_glXChooseFBConfig;
|
||||
#define glXChooseFBConfig glad_glXChooseFBConfig
|
||||
typedef int (APIENTRYP PFNGLXGETFBCONFIGATTRIBPROC)(Display *dpy, GLXFBConfig config, int attribute, int *value);
|
||||
GLAPI PFNGLXGETFBCONFIGATTRIBPROC glad_glXGetFBConfigAttrib;
|
||||
#define glXGetFBConfigAttrib glad_glXGetFBConfigAttrib
|
||||
typedef XVisualInfo * (APIENTRYP PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfig config);
|
||||
GLAPI PFNGLXGETVISUALFROMFBCONFIGPROC glad_glXGetVisualFromFBConfig;
|
||||
#define glXGetVisualFromFBConfig glad_glXGetVisualFromFBConfig
|
||||
typedef GLXWindow (APIENTRYP PFNGLXCREATEWINDOWPROC)(Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
|
||||
GLAPI PFNGLXCREATEWINDOWPROC glad_glXCreateWindow;
|
||||
#define glXCreateWindow glad_glXCreateWindow
|
||||
typedef void (APIENTRYP PFNGLXDESTROYWINDOWPROC)(Display *dpy, GLXWindow win);
|
||||
GLAPI PFNGLXDESTROYWINDOWPROC glad_glXDestroyWindow;
|
||||
#define glXDestroyWindow glad_glXDestroyWindow
|
||||
typedef GLXPixmap (APIENTRYP PFNGLXCREATEPIXMAPPROC)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
|
||||
GLAPI PFNGLXCREATEPIXMAPPROC glad_glXCreatePixmap;
|
||||
#define glXCreatePixmap glad_glXCreatePixmap
|
||||
typedef void (APIENTRYP PFNGLXDESTROYPIXMAPPROC)(Display *dpy, GLXPixmap pixmap);
|
||||
GLAPI PFNGLXDESTROYPIXMAPPROC glad_glXDestroyPixmap;
|
||||
#define glXDestroyPixmap glad_glXDestroyPixmap
|
||||
typedef GLXPbuffer (APIENTRYP PFNGLXCREATEPBUFFERPROC)(Display *dpy, GLXFBConfig config, const int *attrib_list);
|
||||
GLAPI PFNGLXCREATEPBUFFERPROC glad_glXCreatePbuffer;
|
||||
#define glXCreatePbuffer glad_glXCreatePbuffer
|
||||
typedef void (APIENTRYP PFNGLXDESTROYPBUFFERPROC)(Display *dpy, GLXPbuffer pbuf);
|
||||
GLAPI PFNGLXDESTROYPBUFFERPROC glad_glXDestroyPbuffer;
|
||||
#define glXDestroyPbuffer glad_glXDestroyPbuffer
|
||||
typedef void (APIENTRYP PFNGLXQUERYDRAWABLEPROC)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
|
||||
GLAPI PFNGLXQUERYDRAWABLEPROC glad_glXQueryDrawable;
|
||||
#define glXQueryDrawable glad_glXQueryDrawable
|
||||
typedef GLXContext (APIENTRYP PFNGLXCREATENEWCONTEXTPROC)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
|
||||
GLAPI PFNGLXCREATENEWCONTEXTPROC glad_glXCreateNewContext;
|
||||
#define glXCreateNewContext glad_glXCreateNewContext
|
||||
typedef Bool (APIENTRYP PFNGLXMAKECONTEXTCURRENTPROC)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
|
||||
GLAPI PFNGLXMAKECONTEXTCURRENTPROC glad_glXMakeContextCurrent;
|
||||
#define glXMakeContextCurrent glad_glXMakeContextCurrent
|
||||
typedef GLXDrawable (APIENTRYP PFNGLXGETCURRENTREADDRAWABLEPROC)(void);
|
||||
GLAPI PFNGLXGETCURRENTREADDRAWABLEPROC glad_glXGetCurrentReadDrawable;
|
||||
#define glXGetCurrentReadDrawable glad_glXGetCurrentReadDrawable
|
||||
typedef int (APIENTRYP PFNGLXQUERYCONTEXTPROC)(Display *dpy, GLXContext ctx, int attribute, int *value);
|
||||
GLAPI PFNGLXQUERYCONTEXTPROC glad_glXQueryContext;
|
||||
#define glXQueryContext glad_glXQueryContext
|
||||
typedef void (APIENTRYP PFNGLXSELECTEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long event_mask);
|
||||
GLAPI PFNGLXSELECTEVENTPROC glad_glXSelectEvent;
|
||||
#define glXSelectEvent glad_glXSelectEvent
|
||||
typedef void (APIENTRYP PFNGLXGETSELECTEDEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long *event_mask);
|
||||
GLAPI PFNGLXGETSELECTEDEVENTPROC glad_glXGetSelectedEvent;
|
||||
#define glXGetSelectedEvent glad_glXGetSelectedEvent
|
||||
#endif
|
||||
#ifndef GLX_VERSION_1_4
|
||||
#define GLX_VERSION_1_4 1
|
||||
GLAPI int GLAD_GLX_VERSION_1_4;
|
||||
typedef __GLXextFuncPtr (APIENTRYP PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
|
||||
GLAPI PFNGLXGETPROCADDRESSPROC glad_glXGetProcAddress;
|
||||
#define glXGetProcAddress glad_glXGetProcAddress
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,756 @@
|
|||
/*
|
||||
|
||||
WGL loader generated by glad 0.1.36 on Thu Sep 15 11:18:46 2022.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: wgl
|
||||
APIs: wgl=1.0
|
||||
Profile: -
|
||||
Extensions:
|
||||
WGL_3DFX_multisample,
|
||||
WGL_3DL_stereo_control,
|
||||
WGL_AMD_gpu_association,
|
||||
WGL_ARB_buffer_region,
|
||||
WGL_ARB_context_flush_control,
|
||||
WGL_ARB_create_context,
|
||||
WGL_ARB_create_context_no_error,
|
||||
WGL_ARB_create_context_profile,
|
||||
WGL_ARB_create_context_robustness,
|
||||
WGL_ARB_extensions_string,
|
||||
WGL_ARB_framebuffer_sRGB,
|
||||
WGL_ARB_make_current_read,
|
||||
WGL_ARB_multisample,
|
||||
WGL_ARB_pbuffer,
|
||||
WGL_ARB_pixel_format,
|
||||
WGL_ARB_pixel_format_float,
|
||||
WGL_ARB_render_texture,
|
||||
WGL_ARB_robustness_application_isolation,
|
||||
WGL_ARB_robustness_share_group_isolation,
|
||||
WGL_ATI_pixel_format_float,
|
||||
WGL_ATI_render_texture_rectangle,
|
||||
WGL_EXT_colorspace,
|
||||
WGL_EXT_create_context_es2_profile,
|
||||
WGL_EXT_create_context_es_profile,
|
||||
WGL_EXT_depth_float,
|
||||
WGL_EXT_display_color_table,
|
||||
WGL_EXT_extensions_string,
|
||||
WGL_EXT_framebuffer_sRGB,
|
||||
WGL_EXT_make_current_read,
|
||||
WGL_EXT_multisample,
|
||||
WGL_EXT_pbuffer,
|
||||
WGL_EXT_pixel_format,
|
||||
WGL_EXT_pixel_format_packed_float,
|
||||
WGL_EXT_swap_control,
|
||||
WGL_EXT_swap_control_tear,
|
||||
WGL_I3D_digital_video_control,
|
||||
WGL_I3D_gamma,
|
||||
WGL_I3D_genlock,
|
||||
WGL_I3D_image_buffer,
|
||||
WGL_I3D_swap_frame_lock,
|
||||
WGL_I3D_swap_frame_usage,
|
||||
WGL_NV_DX_interop,
|
||||
WGL_NV_DX_interop2,
|
||||
WGL_NV_copy_image,
|
||||
WGL_NV_delay_before_swap,
|
||||
WGL_NV_float_buffer,
|
||||
WGL_NV_gpu_affinity,
|
||||
WGL_NV_multigpu_context,
|
||||
WGL_NV_multisample_coverage,
|
||||
WGL_NV_present_video,
|
||||
WGL_NV_render_depth_texture,
|
||||
WGL_NV_render_texture_rectangle,
|
||||
WGL_NV_swap_group,
|
||||
WGL_NV_vertex_array_range,
|
||||
WGL_NV_video_capture,
|
||||
WGL_NV_video_output,
|
||||
WGL_OML_sync_control
|
||||
Loader: True
|
||||
Local files: True
|
||||
Omit khrplatform: False
|
||||
Reproducible: False
|
||||
|
||||
Commandline:
|
||||
--api="wgl=1.0" --generator="c" --spec="wgl" --local-files --extensions="WGL_3DFX_multisample,WGL_3DL_stereo_control,WGL_AMD_gpu_association,WGL_ARB_buffer_region,WGL_ARB_context_flush_control,WGL_ARB_create_context,WGL_ARB_create_context_no_error,WGL_ARB_create_context_profile,WGL_ARB_create_context_robustness,WGL_ARB_extensions_string,WGL_ARB_framebuffer_sRGB,WGL_ARB_make_current_read,WGL_ARB_multisample,WGL_ARB_pbuffer,WGL_ARB_pixel_format,WGL_ARB_pixel_format_float,WGL_ARB_render_texture,WGL_ARB_robustness_application_isolation,WGL_ARB_robustness_share_group_isolation,WGL_ATI_pixel_format_float,WGL_ATI_render_texture_rectangle,WGL_EXT_colorspace,WGL_EXT_create_context_es2_profile,WGL_EXT_create_context_es_profile,WGL_EXT_depth_float,WGL_EXT_display_color_table,WGL_EXT_extensions_string,WGL_EXT_framebuffer_sRGB,WGL_EXT_make_current_read,WGL_EXT_multisample,WGL_EXT_pbuffer,WGL_EXT_pixel_format,WGL_EXT_pixel_format_packed_float,WGL_EXT_swap_control,WGL_EXT_swap_control_tear,WGL_I3D_digital_video_control,WGL_I3D_gamma,WGL_I3D_genlock,WGL_I3D_image_buffer,WGL_I3D_swap_frame_lock,WGL_I3D_swap_frame_usage,WGL_NV_DX_interop,WGL_NV_DX_interop2,WGL_NV_copy_image,WGL_NV_delay_before_swap,WGL_NV_float_buffer,WGL_NV_gpu_affinity,WGL_NV_multigpu_context,WGL_NV_multisample_coverage,WGL_NV_present_video,WGL_NV_render_depth_texture,WGL_NV_render_texture_rectangle,WGL_NV_swap_group,WGL_NV_vertex_array_range,WGL_NV_video_capture,WGL_NV_video_output,WGL_OML_sync_control"
|
||||
Online:
|
||||
Too many extensions
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glad_wgl.h"
|
||||
|
||||
static void* get_proc(const char *namez);
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#ifndef _WINDOWS_
|
||||
#undef APIENTRY
|
||||
#endif
|
||||
#include <windows.h>
|
||||
static HMODULE libGL;
|
||||
|
||||
typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*);
|
||||
static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef __has_include
|
||||
#if __has_include(<winapifamily.h>)
|
||||
#define HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||
#define HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINAPIFAMILY
|
||||
#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define IS_UWP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static
|
||||
int open_wgl(void) {
|
||||
#ifndef IS_UWP
|
||||
libGL = LoadLibraryW(L"opengl32.dll");
|
||||
if(libGL != NULL) {
|
||||
void (* tmp)(void);
|
||||
tmp = (void(*)(void)) GetProcAddress(libGL, "wglGetProcAddress");
|
||||
gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE) tmp;
|
||||
return gladGetProcAddressPtr != NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void close_wgl(void) {
|
||||
if(libGL != NULL) {
|
||||
FreeLibrary((HMODULE) libGL);
|
||||
libGL = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
static void* libGL;
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__HAIKU__)
|
||||
typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*);
|
||||
static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
|
||||
#endif
|
||||
|
||||
static
|
||||
int open_wgl(void) {
|
||||
#ifdef __APPLE__
|
||||
static const char *NAMES[] = {
|
||||
"../Frameworks/OpenGL.framework/OpenGL",
|
||||
"/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
|
||||
};
|
||||
#else
|
||||
static const char *NAMES[] = {"libGL.so.1", "libGL.so"};
|
||||
#endif
|
||||
|
||||
unsigned int index = 0;
|
||||
for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) {
|
||||
libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
if(libGL != NULL) {
|
||||
#if defined(__APPLE__) || defined(__HAIKU__)
|
||||
return 1;
|
||||
#else
|
||||
gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL,
|
||||
"glXGetProcAddressARB");
|
||||
return gladGetProcAddressPtr != NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void close_wgl(void) {
|
||||
if(libGL != NULL) {
|
||||
dlclose(libGL);
|
||||
libGL = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
void* get_proc(const char *namez) {
|
||||
void* result = NULL;
|
||||
if(libGL == NULL) return NULL;
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__HAIKU__)
|
||||
if(gladGetProcAddressPtr != NULL) {
|
||||
result = gladGetProcAddressPtr(namez);
|
||||
}
|
||||
#endif
|
||||
if(result == NULL) {
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
result = (void*)GetProcAddress((HMODULE) libGL, namez);
|
||||
#else
|
||||
result = dlsym(libGL, namez);
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int gladLoadWGL(HDC hdc) {
|
||||
int status = 0;
|
||||
|
||||
if(open_wgl()) {
|
||||
status = gladLoadWGLLoader((GLADloadproc)get_proc, hdc);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void gladUnloadGLX(void) {
|
||||
close_wgl();
|
||||
}
|
||||
|
||||
static HDC GLADWGLhdc = (HDC)INVALID_HANDLE_VALUE;
|
||||
|
||||
static int get_exts(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void free_exts(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
static int has_ext(const char *ext) {
|
||||
const char *terminator;
|
||||
const char *loc;
|
||||
const char *extensions;
|
||||
|
||||
if(wglGetExtensionsStringEXT == NULL && wglGetExtensionsStringARB == NULL)
|
||||
return 0;
|
||||
|
||||
if(wglGetExtensionsStringARB == NULL || GLADWGLhdc == INVALID_HANDLE_VALUE)
|
||||
extensions = wglGetExtensionsStringEXT();
|
||||
else
|
||||
extensions = wglGetExtensionsStringARB(GLADWGLhdc);
|
||||
|
||||
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;
|
||||
}
|
||||
int GLAD_WGL_VERSION_1_0 = 0;
|
||||
int GLAD_WGL_3DFX_multisample = 0;
|
||||
int GLAD_WGL_3DL_stereo_control = 0;
|
||||
int GLAD_WGL_AMD_gpu_association = 0;
|
||||
int GLAD_WGL_ARB_buffer_region = 0;
|
||||
int GLAD_WGL_ARB_context_flush_control = 0;
|
||||
int GLAD_WGL_ARB_create_context = 0;
|
||||
int GLAD_WGL_ARB_create_context_no_error = 0;
|
||||
int GLAD_WGL_ARB_create_context_profile = 0;
|
||||
int GLAD_WGL_ARB_create_context_robustness = 0;
|
||||
int GLAD_WGL_ARB_extensions_string = 0;
|
||||
int GLAD_WGL_ARB_framebuffer_sRGB = 0;
|
||||
int GLAD_WGL_ARB_make_current_read = 0;
|
||||
int GLAD_WGL_ARB_multisample = 0;
|
||||
int GLAD_WGL_ARB_pbuffer = 0;
|
||||
int GLAD_WGL_ARB_pixel_format = 0;
|
||||
int GLAD_WGL_ARB_pixel_format_float = 0;
|
||||
int GLAD_WGL_ARB_render_texture = 0;
|
||||
int GLAD_WGL_ARB_robustness_application_isolation = 0;
|
||||
int GLAD_WGL_ARB_robustness_share_group_isolation = 0;
|
||||
int GLAD_WGL_ATI_pixel_format_float = 0;
|
||||
int GLAD_WGL_ATI_render_texture_rectangle = 0;
|
||||
int GLAD_WGL_EXT_colorspace = 0;
|
||||
int GLAD_WGL_EXT_create_context_es2_profile = 0;
|
||||
int GLAD_WGL_EXT_create_context_es_profile = 0;
|
||||
int GLAD_WGL_EXT_depth_float = 0;
|
||||
int GLAD_WGL_EXT_display_color_table = 0;
|
||||
int GLAD_WGL_EXT_extensions_string = 0;
|
||||
int GLAD_WGL_EXT_framebuffer_sRGB = 0;
|
||||
int GLAD_WGL_EXT_make_current_read = 0;
|
||||
int GLAD_WGL_EXT_multisample = 0;
|
||||
int GLAD_WGL_EXT_pbuffer = 0;
|
||||
int GLAD_WGL_EXT_pixel_format = 0;
|
||||
int GLAD_WGL_EXT_pixel_format_packed_float = 0;
|
||||
int GLAD_WGL_EXT_swap_control = 0;
|
||||
int GLAD_WGL_EXT_swap_control_tear = 0;
|
||||
int GLAD_WGL_I3D_digital_video_control = 0;
|
||||
int GLAD_WGL_I3D_gamma = 0;
|
||||
int GLAD_WGL_I3D_genlock = 0;
|
||||
int GLAD_WGL_I3D_image_buffer = 0;
|
||||
int GLAD_WGL_I3D_swap_frame_lock = 0;
|
||||
int GLAD_WGL_I3D_swap_frame_usage = 0;
|
||||
int GLAD_WGL_NV_DX_interop = 0;
|
||||
int GLAD_WGL_NV_DX_interop2 = 0;
|
||||
int GLAD_WGL_NV_copy_image = 0;
|
||||
int GLAD_WGL_NV_delay_before_swap = 0;
|
||||
int GLAD_WGL_NV_float_buffer = 0;
|
||||
int GLAD_WGL_NV_gpu_affinity = 0;
|
||||
int GLAD_WGL_NV_multigpu_context = 0;
|
||||
int GLAD_WGL_NV_multisample_coverage = 0;
|
||||
int GLAD_WGL_NV_present_video = 0;
|
||||
int GLAD_WGL_NV_render_depth_texture = 0;
|
||||
int GLAD_WGL_NV_render_texture_rectangle = 0;
|
||||
int GLAD_WGL_NV_swap_group = 0;
|
||||
int GLAD_WGL_NV_vertex_array_range = 0;
|
||||
int GLAD_WGL_NV_video_capture = 0;
|
||||
int GLAD_WGL_NV_video_output = 0;
|
||||
int GLAD_WGL_OML_sync_control = 0;
|
||||
PFNWGLSETSTEREOEMITTERSTATE3DLPROC glad_wglSetStereoEmitterState3DL = NULL;
|
||||
PFNWGLGETGPUIDSAMDPROC glad_wglGetGPUIDsAMD = NULL;
|
||||
PFNWGLGETGPUINFOAMDPROC glad_wglGetGPUInfoAMD = NULL;
|
||||
PFNWGLGETCONTEXTGPUIDAMDPROC glad_wglGetContextGPUIDAMD = NULL;
|
||||
PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC glad_wglCreateAssociatedContextAMD = NULL;
|
||||
PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC glad_wglCreateAssociatedContextAttribsAMD = NULL;
|
||||
PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC glad_wglDeleteAssociatedContextAMD = NULL;
|
||||
PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC glad_wglMakeAssociatedContextCurrentAMD = NULL;
|
||||
PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC glad_wglGetCurrentAssociatedContextAMD = NULL;
|
||||
PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC glad_wglBlitContextFramebufferAMD = NULL;
|
||||
PFNWGLCREATEBUFFERREGIONARBPROC glad_wglCreateBufferRegionARB = NULL;
|
||||
PFNWGLDELETEBUFFERREGIONARBPROC glad_wglDeleteBufferRegionARB = NULL;
|
||||
PFNWGLSAVEBUFFERREGIONARBPROC glad_wglSaveBufferRegionARB = NULL;
|
||||
PFNWGLRESTOREBUFFERREGIONARBPROC glad_wglRestoreBufferRegionARB = NULL;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC glad_wglCreateContextAttribsARB = NULL;
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC glad_wglGetExtensionsStringARB = NULL;
|
||||
PFNWGLMAKECONTEXTCURRENTARBPROC glad_wglMakeContextCurrentARB = NULL;
|
||||
PFNWGLGETCURRENTREADDCARBPROC glad_wglGetCurrentReadDCARB = NULL;
|
||||
PFNWGLCREATEPBUFFERARBPROC glad_wglCreatePbufferARB = NULL;
|
||||
PFNWGLGETPBUFFERDCARBPROC glad_wglGetPbufferDCARB = NULL;
|
||||
PFNWGLRELEASEPBUFFERDCARBPROC glad_wglReleasePbufferDCARB = NULL;
|
||||
PFNWGLDESTROYPBUFFERARBPROC glad_wglDestroyPbufferARB = NULL;
|
||||
PFNWGLQUERYPBUFFERARBPROC glad_wglQueryPbufferARB = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC glad_wglGetPixelFormatAttribivARB = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBFVARBPROC glad_wglGetPixelFormatAttribfvARB = NULL;
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC glad_wglChoosePixelFormatARB = NULL;
|
||||
PFNWGLBINDTEXIMAGEARBPROC glad_wglBindTexImageARB = NULL;
|
||||
PFNWGLRELEASETEXIMAGEARBPROC glad_wglReleaseTexImageARB = NULL;
|
||||
PFNWGLSETPBUFFERATTRIBARBPROC glad_wglSetPbufferAttribARB = NULL;
|
||||
PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC glad_wglCreateDisplayColorTableEXT = NULL;
|
||||
PFNWGLLOADDISPLAYCOLORTABLEEXTPROC glad_wglLoadDisplayColorTableEXT = NULL;
|
||||
PFNWGLBINDDISPLAYCOLORTABLEEXTPROC glad_wglBindDisplayColorTableEXT = NULL;
|
||||
PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC glad_wglDestroyDisplayColorTableEXT = NULL;
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC glad_wglGetExtensionsStringEXT = NULL;
|
||||
PFNWGLMAKECONTEXTCURRENTEXTPROC glad_wglMakeContextCurrentEXT = NULL;
|
||||
PFNWGLGETCURRENTREADDCEXTPROC glad_wglGetCurrentReadDCEXT = NULL;
|
||||
PFNWGLCREATEPBUFFEREXTPROC glad_wglCreatePbufferEXT = NULL;
|
||||
PFNWGLGETPBUFFERDCEXTPROC glad_wglGetPbufferDCEXT = NULL;
|
||||
PFNWGLRELEASEPBUFFERDCEXTPROC glad_wglReleasePbufferDCEXT = NULL;
|
||||
PFNWGLDESTROYPBUFFEREXTPROC glad_wglDestroyPbufferEXT = NULL;
|
||||
PFNWGLQUERYPBUFFEREXTPROC glad_wglQueryPbufferEXT = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVEXTPROC glad_wglGetPixelFormatAttribivEXT = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBFVEXTPROC glad_wglGetPixelFormatAttribfvEXT = NULL;
|
||||
PFNWGLCHOOSEPIXELFORMATEXTPROC glad_wglChoosePixelFormatEXT = NULL;
|
||||
PFNWGLSWAPINTERVALEXTPROC glad_wglSwapIntervalEXT = NULL;
|
||||
PFNWGLGETSWAPINTERVALEXTPROC glad_wglGetSwapIntervalEXT = NULL;
|
||||
PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC glad_wglGetDigitalVideoParametersI3D = NULL;
|
||||
PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC glad_wglSetDigitalVideoParametersI3D = NULL;
|
||||
PFNWGLGETGAMMATABLEPARAMETERSI3DPROC glad_wglGetGammaTableParametersI3D = NULL;
|
||||
PFNWGLSETGAMMATABLEPARAMETERSI3DPROC glad_wglSetGammaTableParametersI3D = NULL;
|
||||
PFNWGLGETGAMMATABLEI3DPROC glad_wglGetGammaTableI3D = NULL;
|
||||
PFNWGLSETGAMMATABLEI3DPROC glad_wglSetGammaTableI3D = NULL;
|
||||
PFNWGLENABLEGENLOCKI3DPROC glad_wglEnableGenlockI3D = NULL;
|
||||
PFNWGLDISABLEGENLOCKI3DPROC glad_wglDisableGenlockI3D = NULL;
|
||||
PFNWGLISENABLEDGENLOCKI3DPROC glad_wglIsEnabledGenlockI3D = NULL;
|
||||
PFNWGLGENLOCKSOURCEI3DPROC glad_wglGenlockSourceI3D = NULL;
|
||||
PFNWGLGETGENLOCKSOURCEI3DPROC glad_wglGetGenlockSourceI3D = NULL;
|
||||
PFNWGLGENLOCKSOURCEEDGEI3DPROC glad_wglGenlockSourceEdgeI3D = NULL;
|
||||
PFNWGLGETGENLOCKSOURCEEDGEI3DPROC glad_wglGetGenlockSourceEdgeI3D = NULL;
|
||||
PFNWGLGENLOCKSAMPLERATEI3DPROC glad_wglGenlockSampleRateI3D = NULL;
|
||||
PFNWGLGETGENLOCKSAMPLERATEI3DPROC glad_wglGetGenlockSampleRateI3D = NULL;
|
||||
PFNWGLGENLOCKSOURCEDELAYI3DPROC glad_wglGenlockSourceDelayI3D = NULL;
|
||||
PFNWGLGETGENLOCKSOURCEDELAYI3DPROC glad_wglGetGenlockSourceDelayI3D = NULL;
|
||||
PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC glad_wglQueryGenlockMaxSourceDelayI3D = NULL;
|
||||
PFNWGLCREATEIMAGEBUFFERI3DPROC glad_wglCreateImageBufferI3D = NULL;
|
||||
PFNWGLDESTROYIMAGEBUFFERI3DPROC glad_wglDestroyImageBufferI3D = NULL;
|
||||
PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC glad_wglAssociateImageBufferEventsI3D = NULL;
|
||||
PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC glad_wglReleaseImageBufferEventsI3D = NULL;
|
||||
PFNWGLENABLEFRAMELOCKI3DPROC glad_wglEnableFrameLockI3D = NULL;
|
||||
PFNWGLDISABLEFRAMELOCKI3DPROC glad_wglDisableFrameLockI3D = NULL;
|
||||
PFNWGLISENABLEDFRAMELOCKI3DPROC glad_wglIsEnabledFrameLockI3D = NULL;
|
||||
PFNWGLQUERYFRAMELOCKMASTERI3DPROC glad_wglQueryFrameLockMasterI3D = NULL;
|
||||
PFNWGLGETFRAMEUSAGEI3DPROC glad_wglGetFrameUsageI3D = NULL;
|
||||
PFNWGLBEGINFRAMETRACKINGI3DPROC glad_wglBeginFrameTrackingI3D = NULL;
|
||||
PFNWGLENDFRAMETRACKINGI3DPROC glad_wglEndFrameTrackingI3D = NULL;
|
||||
PFNWGLQUERYFRAMETRACKINGI3DPROC glad_wglQueryFrameTrackingI3D = NULL;
|
||||
PFNWGLDXSETRESOURCESHAREHANDLENVPROC glad_wglDXSetResourceShareHandleNV = NULL;
|
||||
PFNWGLDXOPENDEVICENVPROC glad_wglDXOpenDeviceNV = NULL;
|
||||
PFNWGLDXCLOSEDEVICENVPROC glad_wglDXCloseDeviceNV = NULL;
|
||||
PFNWGLDXREGISTEROBJECTNVPROC glad_wglDXRegisterObjectNV = NULL;
|
||||
PFNWGLDXUNREGISTEROBJECTNVPROC glad_wglDXUnregisterObjectNV = NULL;
|
||||
PFNWGLDXOBJECTACCESSNVPROC glad_wglDXObjectAccessNV = NULL;
|
||||
PFNWGLDXLOCKOBJECTSNVPROC glad_wglDXLockObjectsNV = NULL;
|
||||
PFNWGLDXUNLOCKOBJECTSNVPROC glad_wglDXUnlockObjectsNV = NULL;
|
||||
PFNWGLCOPYIMAGESUBDATANVPROC glad_wglCopyImageSubDataNV = NULL;
|
||||
PFNWGLDELAYBEFORESWAPNVPROC glad_wglDelayBeforeSwapNV = NULL;
|
||||
PFNWGLENUMGPUSNVPROC glad_wglEnumGpusNV = NULL;
|
||||
PFNWGLENUMGPUDEVICESNVPROC glad_wglEnumGpuDevicesNV = NULL;
|
||||
PFNWGLCREATEAFFINITYDCNVPROC glad_wglCreateAffinityDCNV = NULL;
|
||||
PFNWGLENUMGPUSFROMAFFINITYDCNVPROC glad_wglEnumGpusFromAffinityDCNV = NULL;
|
||||
PFNWGLDELETEDCNVPROC glad_wglDeleteDCNV = NULL;
|
||||
PFNWGLENUMERATEVIDEODEVICESNVPROC glad_wglEnumerateVideoDevicesNV = NULL;
|
||||
PFNWGLBINDVIDEODEVICENVPROC glad_wglBindVideoDeviceNV = NULL;
|
||||
PFNWGLQUERYCURRENTCONTEXTNVPROC glad_wglQueryCurrentContextNV = NULL;
|
||||
PFNWGLJOINSWAPGROUPNVPROC glad_wglJoinSwapGroupNV = NULL;
|
||||
PFNWGLBINDSWAPBARRIERNVPROC glad_wglBindSwapBarrierNV = NULL;
|
||||
PFNWGLQUERYSWAPGROUPNVPROC glad_wglQuerySwapGroupNV = NULL;
|
||||
PFNWGLQUERYMAXSWAPGROUPSNVPROC glad_wglQueryMaxSwapGroupsNV = NULL;
|
||||
PFNWGLQUERYFRAMECOUNTNVPROC glad_wglQueryFrameCountNV = NULL;
|
||||
PFNWGLRESETFRAMECOUNTNVPROC glad_wglResetFrameCountNV = NULL;
|
||||
PFNWGLALLOCATEMEMORYNVPROC glad_wglAllocateMemoryNV = NULL;
|
||||
PFNWGLFREEMEMORYNVPROC glad_wglFreeMemoryNV = NULL;
|
||||
PFNWGLBINDVIDEOCAPTUREDEVICENVPROC glad_wglBindVideoCaptureDeviceNV = NULL;
|
||||
PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC glad_wglEnumerateVideoCaptureDevicesNV = NULL;
|
||||
PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC glad_wglLockVideoCaptureDeviceNV = NULL;
|
||||
PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC glad_wglQueryVideoCaptureDeviceNV = NULL;
|
||||
PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC glad_wglReleaseVideoCaptureDeviceNV = NULL;
|
||||
PFNWGLGETVIDEODEVICENVPROC glad_wglGetVideoDeviceNV = NULL;
|
||||
PFNWGLRELEASEVIDEODEVICENVPROC glad_wglReleaseVideoDeviceNV = NULL;
|
||||
PFNWGLBINDVIDEOIMAGENVPROC glad_wglBindVideoImageNV = NULL;
|
||||
PFNWGLRELEASEVIDEOIMAGENVPROC glad_wglReleaseVideoImageNV = NULL;
|
||||
PFNWGLSENDPBUFFERTOVIDEONVPROC glad_wglSendPbufferToVideoNV = NULL;
|
||||
PFNWGLGETVIDEOINFONVPROC glad_wglGetVideoInfoNV = NULL;
|
||||
PFNWGLGETSYNCVALUESOMLPROC glad_wglGetSyncValuesOML = NULL;
|
||||
PFNWGLGETMSCRATEOMLPROC glad_wglGetMscRateOML = NULL;
|
||||
PFNWGLSWAPBUFFERSMSCOMLPROC glad_wglSwapBuffersMscOML = NULL;
|
||||
PFNWGLSWAPLAYERBUFFERSMSCOMLPROC glad_wglSwapLayerBuffersMscOML = NULL;
|
||||
PFNWGLWAITFORMSCOMLPROC glad_wglWaitForMscOML = NULL;
|
||||
PFNWGLWAITFORSBCOMLPROC glad_wglWaitForSbcOML = NULL;
|
||||
static void load_WGL_3DL_stereo_control(GLADloadproc load) {
|
||||
if(!GLAD_WGL_3DL_stereo_control) return;
|
||||
glad_wglSetStereoEmitterState3DL = (PFNWGLSETSTEREOEMITTERSTATE3DLPROC)load("wglSetStereoEmitterState3DL");
|
||||
}
|
||||
static void load_WGL_AMD_gpu_association(GLADloadproc load) {
|
||||
if(!GLAD_WGL_AMD_gpu_association) return;
|
||||
glad_wglGetGPUIDsAMD = (PFNWGLGETGPUIDSAMDPROC)load("wglGetGPUIDsAMD");
|
||||
glad_wglGetGPUInfoAMD = (PFNWGLGETGPUINFOAMDPROC)load("wglGetGPUInfoAMD");
|
||||
glad_wglGetContextGPUIDAMD = (PFNWGLGETCONTEXTGPUIDAMDPROC)load("wglGetContextGPUIDAMD");
|
||||
glad_wglCreateAssociatedContextAMD = (PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC)load("wglCreateAssociatedContextAMD");
|
||||
glad_wglCreateAssociatedContextAttribsAMD = (PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)load("wglCreateAssociatedContextAttribsAMD");
|
||||
glad_wglDeleteAssociatedContextAMD = (PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC)load("wglDeleteAssociatedContextAMD");
|
||||
glad_wglMakeAssociatedContextCurrentAMD = (PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)load("wglMakeAssociatedContextCurrentAMD");
|
||||
glad_wglGetCurrentAssociatedContextAMD = (PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC)load("wglGetCurrentAssociatedContextAMD");
|
||||
glad_wglBlitContextFramebufferAMD = (PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC)load("wglBlitContextFramebufferAMD");
|
||||
}
|
||||
static void load_WGL_ARB_buffer_region(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_buffer_region) return;
|
||||
glad_wglCreateBufferRegionARB = (PFNWGLCREATEBUFFERREGIONARBPROC)load("wglCreateBufferRegionARB");
|
||||
glad_wglDeleteBufferRegionARB = (PFNWGLDELETEBUFFERREGIONARBPROC)load("wglDeleteBufferRegionARB");
|
||||
glad_wglSaveBufferRegionARB = (PFNWGLSAVEBUFFERREGIONARBPROC)load("wglSaveBufferRegionARB");
|
||||
glad_wglRestoreBufferRegionARB = (PFNWGLRESTOREBUFFERREGIONARBPROC)load("wglRestoreBufferRegionARB");
|
||||
}
|
||||
static void load_WGL_ARB_create_context(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_create_context) return;
|
||||
glad_wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)load("wglCreateContextAttribsARB");
|
||||
}
|
||||
static void load_WGL_ARB_extensions_string(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_extensions_string) return;
|
||||
glad_wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)load("wglGetExtensionsStringARB");
|
||||
}
|
||||
static void load_WGL_ARB_make_current_read(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_make_current_read) return;
|
||||
glad_wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)load("wglMakeContextCurrentARB");
|
||||
glad_wglGetCurrentReadDCARB = (PFNWGLGETCURRENTREADDCARBPROC)load("wglGetCurrentReadDCARB");
|
||||
}
|
||||
static void load_WGL_ARB_pbuffer(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_pbuffer) return;
|
||||
glad_wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)load("wglCreatePbufferARB");
|
||||
glad_wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)load("wglGetPbufferDCARB");
|
||||
glad_wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)load("wglReleasePbufferDCARB");
|
||||
glad_wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)load("wglDestroyPbufferARB");
|
||||
glad_wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)load("wglQueryPbufferARB");
|
||||
}
|
||||
static void load_WGL_ARB_pixel_format(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_pixel_format) return;
|
||||
glad_wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)load("wglGetPixelFormatAttribivARB");
|
||||
glad_wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)load("wglGetPixelFormatAttribfvARB");
|
||||
glad_wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)load("wglChoosePixelFormatARB");
|
||||
}
|
||||
static void load_WGL_ARB_render_texture(GLADloadproc load) {
|
||||
if(!GLAD_WGL_ARB_render_texture) return;
|
||||
glad_wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)load("wglBindTexImageARB");
|
||||
glad_wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)load("wglReleaseTexImageARB");
|
||||
glad_wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)load("wglSetPbufferAttribARB");
|
||||
}
|
||||
static void load_WGL_EXT_display_color_table(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_display_color_table) return;
|
||||
glad_wglCreateDisplayColorTableEXT = (PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC)load("wglCreateDisplayColorTableEXT");
|
||||
glad_wglLoadDisplayColorTableEXT = (PFNWGLLOADDISPLAYCOLORTABLEEXTPROC)load("wglLoadDisplayColorTableEXT");
|
||||
glad_wglBindDisplayColorTableEXT = (PFNWGLBINDDISPLAYCOLORTABLEEXTPROC)load("wglBindDisplayColorTableEXT");
|
||||
glad_wglDestroyDisplayColorTableEXT = (PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC)load("wglDestroyDisplayColorTableEXT");
|
||||
}
|
||||
static void load_WGL_EXT_extensions_string(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_extensions_string) return;
|
||||
glad_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)load("wglGetExtensionsStringEXT");
|
||||
}
|
||||
static void load_WGL_EXT_make_current_read(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_make_current_read) return;
|
||||
glad_wglMakeContextCurrentEXT = (PFNWGLMAKECONTEXTCURRENTEXTPROC)load("wglMakeContextCurrentEXT");
|
||||
glad_wglGetCurrentReadDCEXT = (PFNWGLGETCURRENTREADDCEXTPROC)load("wglGetCurrentReadDCEXT");
|
||||
}
|
||||
static void load_WGL_EXT_pbuffer(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_pbuffer) return;
|
||||
glad_wglCreatePbufferEXT = (PFNWGLCREATEPBUFFEREXTPROC)load("wglCreatePbufferEXT");
|
||||
glad_wglGetPbufferDCEXT = (PFNWGLGETPBUFFERDCEXTPROC)load("wglGetPbufferDCEXT");
|
||||
glad_wglReleasePbufferDCEXT = (PFNWGLRELEASEPBUFFERDCEXTPROC)load("wglReleasePbufferDCEXT");
|
||||
glad_wglDestroyPbufferEXT = (PFNWGLDESTROYPBUFFEREXTPROC)load("wglDestroyPbufferEXT");
|
||||
glad_wglQueryPbufferEXT = (PFNWGLQUERYPBUFFEREXTPROC)load("wglQueryPbufferEXT");
|
||||
}
|
||||
static void load_WGL_EXT_pixel_format(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_pixel_format) return;
|
||||
glad_wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)load("wglGetPixelFormatAttribivEXT");
|
||||
glad_wglGetPixelFormatAttribfvEXT = (PFNWGLGETPIXELFORMATATTRIBFVEXTPROC)load("wglGetPixelFormatAttribfvEXT");
|
||||
glad_wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)load("wglChoosePixelFormatEXT");
|
||||
}
|
||||
static void load_WGL_EXT_swap_control(GLADloadproc load) {
|
||||
if(!GLAD_WGL_EXT_swap_control) return;
|
||||
glad_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)load("wglSwapIntervalEXT");
|
||||
glad_wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)load("wglGetSwapIntervalEXT");
|
||||
}
|
||||
static void load_WGL_I3D_digital_video_control(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_digital_video_control) return;
|
||||
glad_wglGetDigitalVideoParametersI3D = (PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC)load("wglGetDigitalVideoParametersI3D");
|
||||
glad_wglSetDigitalVideoParametersI3D = (PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC)load("wglSetDigitalVideoParametersI3D");
|
||||
}
|
||||
static void load_WGL_I3D_gamma(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_gamma) return;
|
||||
glad_wglGetGammaTableParametersI3D = (PFNWGLGETGAMMATABLEPARAMETERSI3DPROC)load("wglGetGammaTableParametersI3D");
|
||||
glad_wglSetGammaTableParametersI3D = (PFNWGLSETGAMMATABLEPARAMETERSI3DPROC)load("wglSetGammaTableParametersI3D");
|
||||
glad_wglGetGammaTableI3D = (PFNWGLGETGAMMATABLEI3DPROC)load("wglGetGammaTableI3D");
|
||||
glad_wglSetGammaTableI3D = (PFNWGLSETGAMMATABLEI3DPROC)load("wglSetGammaTableI3D");
|
||||
}
|
||||
static void load_WGL_I3D_genlock(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_genlock) return;
|
||||
glad_wglEnableGenlockI3D = (PFNWGLENABLEGENLOCKI3DPROC)load("wglEnableGenlockI3D");
|
||||
glad_wglDisableGenlockI3D = (PFNWGLDISABLEGENLOCKI3DPROC)load("wglDisableGenlockI3D");
|
||||
glad_wglIsEnabledGenlockI3D = (PFNWGLISENABLEDGENLOCKI3DPROC)load("wglIsEnabledGenlockI3D");
|
||||
glad_wglGenlockSourceI3D = (PFNWGLGENLOCKSOURCEI3DPROC)load("wglGenlockSourceI3D");
|
||||
glad_wglGetGenlockSourceI3D = (PFNWGLGETGENLOCKSOURCEI3DPROC)load("wglGetGenlockSourceI3D");
|
||||
glad_wglGenlockSourceEdgeI3D = (PFNWGLGENLOCKSOURCEEDGEI3DPROC)load("wglGenlockSourceEdgeI3D");
|
||||
glad_wglGetGenlockSourceEdgeI3D = (PFNWGLGETGENLOCKSOURCEEDGEI3DPROC)load("wglGetGenlockSourceEdgeI3D");
|
||||
glad_wglGenlockSampleRateI3D = (PFNWGLGENLOCKSAMPLERATEI3DPROC)load("wglGenlockSampleRateI3D");
|
||||
glad_wglGetGenlockSampleRateI3D = (PFNWGLGETGENLOCKSAMPLERATEI3DPROC)load("wglGetGenlockSampleRateI3D");
|
||||
glad_wglGenlockSourceDelayI3D = (PFNWGLGENLOCKSOURCEDELAYI3DPROC)load("wglGenlockSourceDelayI3D");
|
||||
glad_wglGetGenlockSourceDelayI3D = (PFNWGLGETGENLOCKSOURCEDELAYI3DPROC)load("wglGetGenlockSourceDelayI3D");
|
||||
glad_wglQueryGenlockMaxSourceDelayI3D = (PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC)load("wglQueryGenlockMaxSourceDelayI3D");
|
||||
}
|
||||
static void load_WGL_I3D_image_buffer(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_image_buffer) return;
|
||||
glad_wglCreateImageBufferI3D = (PFNWGLCREATEIMAGEBUFFERI3DPROC)load("wglCreateImageBufferI3D");
|
||||
glad_wglDestroyImageBufferI3D = (PFNWGLDESTROYIMAGEBUFFERI3DPROC)load("wglDestroyImageBufferI3D");
|
||||
glad_wglAssociateImageBufferEventsI3D = (PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC)load("wglAssociateImageBufferEventsI3D");
|
||||
glad_wglReleaseImageBufferEventsI3D = (PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC)load("wglReleaseImageBufferEventsI3D");
|
||||
}
|
||||
static void load_WGL_I3D_swap_frame_lock(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_swap_frame_lock) return;
|
||||
glad_wglEnableFrameLockI3D = (PFNWGLENABLEFRAMELOCKI3DPROC)load("wglEnableFrameLockI3D");
|
||||
glad_wglDisableFrameLockI3D = (PFNWGLDISABLEFRAMELOCKI3DPROC)load("wglDisableFrameLockI3D");
|
||||
glad_wglIsEnabledFrameLockI3D = (PFNWGLISENABLEDFRAMELOCKI3DPROC)load("wglIsEnabledFrameLockI3D");
|
||||
glad_wglQueryFrameLockMasterI3D = (PFNWGLQUERYFRAMELOCKMASTERI3DPROC)load("wglQueryFrameLockMasterI3D");
|
||||
}
|
||||
static void load_WGL_I3D_swap_frame_usage(GLADloadproc load) {
|
||||
if(!GLAD_WGL_I3D_swap_frame_usage) return;
|
||||
glad_wglGetFrameUsageI3D = (PFNWGLGETFRAMEUSAGEI3DPROC)load("wglGetFrameUsageI3D");
|
||||
glad_wglBeginFrameTrackingI3D = (PFNWGLBEGINFRAMETRACKINGI3DPROC)load("wglBeginFrameTrackingI3D");
|
||||
glad_wglEndFrameTrackingI3D = (PFNWGLENDFRAMETRACKINGI3DPROC)load("wglEndFrameTrackingI3D");
|
||||
glad_wglQueryFrameTrackingI3D = (PFNWGLQUERYFRAMETRACKINGI3DPROC)load("wglQueryFrameTrackingI3D");
|
||||
}
|
||||
static void load_WGL_NV_DX_interop(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_DX_interop) return;
|
||||
glad_wglDXSetResourceShareHandleNV = (PFNWGLDXSETRESOURCESHAREHANDLENVPROC)load("wglDXSetResourceShareHandleNV");
|
||||
glad_wglDXOpenDeviceNV = (PFNWGLDXOPENDEVICENVPROC)load("wglDXOpenDeviceNV");
|
||||
glad_wglDXCloseDeviceNV = (PFNWGLDXCLOSEDEVICENVPROC)load("wglDXCloseDeviceNV");
|
||||
glad_wglDXRegisterObjectNV = (PFNWGLDXREGISTEROBJECTNVPROC)load("wglDXRegisterObjectNV");
|
||||
glad_wglDXUnregisterObjectNV = (PFNWGLDXUNREGISTEROBJECTNVPROC)load("wglDXUnregisterObjectNV");
|
||||
glad_wglDXObjectAccessNV = (PFNWGLDXOBJECTACCESSNVPROC)load("wglDXObjectAccessNV");
|
||||
glad_wglDXLockObjectsNV = (PFNWGLDXLOCKOBJECTSNVPROC)load("wglDXLockObjectsNV");
|
||||
glad_wglDXUnlockObjectsNV = (PFNWGLDXUNLOCKOBJECTSNVPROC)load("wglDXUnlockObjectsNV");
|
||||
}
|
||||
static void load_WGL_NV_copy_image(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_copy_image) return;
|
||||
glad_wglCopyImageSubDataNV = (PFNWGLCOPYIMAGESUBDATANVPROC)load("wglCopyImageSubDataNV");
|
||||
}
|
||||
static void load_WGL_NV_delay_before_swap(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_delay_before_swap) return;
|
||||
glad_wglDelayBeforeSwapNV = (PFNWGLDELAYBEFORESWAPNVPROC)load("wglDelayBeforeSwapNV");
|
||||
}
|
||||
static void load_WGL_NV_gpu_affinity(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_gpu_affinity) return;
|
||||
glad_wglEnumGpusNV = (PFNWGLENUMGPUSNVPROC)load("wglEnumGpusNV");
|
||||
glad_wglEnumGpuDevicesNV = (PFNWGLENUMGPUDEVICESNVPROC)load("wglEnumGpuDevicesNV");
|
||||
glad_wglCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)load("wglCreateAffinityDCNV");
|
||||
glad_wglEnumGpusFromAffinityDCNV = (PFNWGLENUMGPUSFROMAFFINITYDCNVPROC)load("wglEnumGpusFromAffinityDCNV");
|
||||
glad_wglDeleteDCNV = (PFNWGLDELETEDCNVPROC)load("wglDeleteDCNV");
|
||||
}
|
||||
static void load_WGL_NV_present_video(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_present_video) return;
|
||||
glad_wglEnumerateVideoDevicesNV = (PFNWGLENUMERATEVIDEODEVICESNVPROC)load("wglEnumerateVideoDevicesNV");
|
||||
glad_wglBindVideoDeviceNV = (PFNWGLBINDVIDEODEVICENVPROC)load("wglBindVideoDeviceNV");
|
||||
glad_wglQueryCurrentContextNV = (PFNWGLQUERYCURRENTCONTEXTNVPROC)load("wglQueryCurrentContextNV");
|
||||
}
|
||||
static void load_WGL_NV_swap_group(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_swap_group) return;
|
||||
glad_wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC)load("wglJoinSwapGroupNV");
|
||||
glad_wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC)load("wglBindSwapBarrierNV");
|
||||
glad_wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC)load("wglQuerySwapGroupNV");
|
||||
glad_wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)load("wglQueryMaxSwapGroupsNV");
|
||||
glad_wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC)load("wglQueryFrameCountNV");
|
||||
glad_wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC)load("wglResetFrameCountNV");
|
||||
}
|
||||
static void load_WGL_NV_vertex_array_range(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_vertex_array_range) return;
|
||||
glad_wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)load("wglAllocateMemoryNV");
|
||||
glad_wglFreeMemoryNV = (PFNWGLFREEMEMORYNVPROC)load("wglFreeMemoryNV");
|
||||
}
|
||||
static void load_WGL_NV_video_capture(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_video_capture) return;
|
||||
glad_wglBindVideoCaptureDeviceNV = (PFNWGLBINDVIDEOCAPTUREDEVICENVPROC)load("wglBindVideoCaptureDeviceNV");
|
||||
glad_wglEnumerateVideoCaptureDevicesNV = (PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC)load("wglEnumerateVideoCaptureDevicesNV");
|
||||
glad_wglLockVideoCaptureDeviceNV = (PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC)load("wglLockVideoCaptureDeviceNV");
|
||||
glad_wglQueryVideoCaptureDeviceNV = (PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC)load("wglQueryVideoCaptureDeviceNV");
|
||||
glad_wglReleaseVideoCaptureDeviceNV = (PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC)load("wglReleaseVideoCaptureDeviceNV");
|
||||
}
|
||||
static void load_WGL_NV_video_output(GLADloadproc load) {
|
||||
if(!GLAD_WGL_NV_video_output) return;
|
||||
glad_wglGetVideoDeviceNV = (PFNWGLGETVIDEODEVICENVPROC)load("wglGetVideoDeviceNV");
|
||||
glad_wglReleaseVideoDeviceNV = (PFNWGLRELEASEVIDEODEVICENVPROC)load("wglReleaseVideoDeviceNV");
|
||||
glad_wglBindVideoImageNV = (PFNWGLBINDVIDEOIMAGENVPROC)load("wglBindVideoImageNV");
|
||||
glad_wglReleaseVideoImageNV = (PFNWGLRELEASEVIDEOIMAGENVPROC)load("wglReleaseVideoImageNV");
|
||||
glad_wglSendPbufferToVideoNV = (PFNWGLSENDPBUFFERTOVIDEONVPROC)load("wglSendPbufferToVideoNV");
|
||||
glad_wglGetVideoInfoNV = (PFNWGLGETVIDEOINFONVPROC)load("wglGetVideoInfoNV");
|
||||
}
|
||||
static void load_WGL_OML_sync_control(GLADloadproc load) {
|
||||
if(!GLAD_WGL_OML_sync_control) return;
|
||||
glad_wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)load("wglGetSyncValuesOML");
|
||||
glad_wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)load("wglGetMscRateOML");
|
||||
glad_wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)load("wglSwapBuffersMscOML");
|
||||
glad_wglSwapLayerBuffersMscOML = (PFNWGLSWAPLAYERBUFFERSMSCOMLPROC)load("wglSwapLayerBuffersMscOML");
|
||||
glad_wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)load("wglWaitForMscOML");
|
||||
glad_wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)load("wglWaitForSbcOML");
|
||||
}
|
||||
static int find_extensionsWGL(void) {
|
||||
if (!get_exts()) return 0;
|
||||
GLAD_WGL_3DFX_multisample = has_ext("WGL_3DFX_multisample");
|
||||
GLAD_WGL_3DL_stereo_control = has_ext("WGL_3DL_stereo_control");
|
||||
GLAD_WGL_AMD_gpu_association = has_ext("WGL_AMD_gpu_association");
|
||||
GLAD_WGL_ARB_buffer_region = has_ext("WGL_ARB_buffer_region");
|
||||
GLAD_WGL_ARB_context_flush_control = has_ext("WGL_ARB_context_flush_control");
|
||||
GLAD_WGL_ARB_create_context = has_ext("WGL_ARB_create_context");
|
||||
GLAD_WGL_ARB_create_context_no_error = has_ext("WGL_ARB_create_context_no_error");
|
||||
GLAD_WGL_ARB_create_context_profile = has_ext("WGL_ARB_create_context_profile");
|
||||
GLAD_WGL_ARB_create_context_robustness = has_ext("WGL_ARB_create_context_robustness");
|
||||
GLAD_WGL_ARB_extensions_string = has_ext("WGL_ARB_extensions_string");
|
||||
GLAD_WGL_ARB_framebuffer_sRGB = has_ext("WGL_ARB_framebuffer_sRGB");
|
||||
GLAD_WGL_ARB_make_current_read = has_ext("WGL_ARB_make_current_read");
|
||||
GLAD_WGL_ARB_multisample = has_ext("WGL_ARB_multisample");
|
||||
GLAD_WGL_ARB_pbuffer = has_ext("WGL_ARB_pbuffer");
|
||||
GLAD_WGL_ARB_pixel_format = has_ext("WGL_ARB_pixel_format");
|
||||
GLAD_WGL_ARB_pixel_format_float = has_ext("WGL_ARB_pixel_format_float");
|
||||
GLAD_WGL_ARB_render_texture = has_ext("WGL_ARB_render_texture");
|
||||
GLAD_WGL_ARB_robustness_application_isolation = has_ext("WGL_ARB_robustness_application_isolation");
|
||||
GLAD_WGL_ARB_robustness_share_group_isolation = has_ext("WGL_ARB_robustness_share_group_isolation");
|
||||
GLAD_WGL_ATI_pixel_format_float = has_ext("WGL_ATI_pixel_format_float");
|
||||
GLAD_WGL_ATI_render_texture_rectangle = has_ext("WGL_ATI_render_texture_rectangle");
|
||||
GLAD_WGL_EXT_colorspace = has_ext("WGL_EXT_colorspace");
|
||||
GLAD_WGL_EXT_create_context_es2_profile = has_ext("WGL_EXT_create_context_es2_profile");
|
||||
GLAD_WGL_EXT_create_context_es_profile = has_ext("WGL_EXT_create_context_es_profile");
|
||||
GLAD_WGL_EXT_depth_float = has_ext("WGL_EXT_depth_float");
|
||||
GLAD_WGL_EXT_display_color_table = has_ext("WGL_EXT_display_color_table");
|
||||
GLAD_WGL_EXT_extensions_string = has_ext("WGL_EXT_extensions_string");
|
||||
GLAD_WGL_EXT_framebuffer_sRGB = has_ext("WGL_EXT_framebuffer_sRGB");
|
||||
GLAD_WGL_EXT_make_current_read = has_ext("WGL_EXT_make_current_read");
|
||||
GLAD_WGL_EXT_multisample = has_ext("WGL_EXT_multisample");
|
||||
GLAD_WGL_EXT_pbuffer = has_ext("WGL_EXT_pbuffer");
|
||||
GLAD_WGL_EXT_pixel_format = has_ext("WGL_EXT_pixel_format");
|
||||
GLAD_WGL_EXT_pixel_format_packed_float = has_ext("WGL_EXT_pixel_format_packed_float");
|
||||
GLAD_WGL_EXT_swap_control = has_ext("WGL_EXT_swap_control");
|
||||
GLAD_WGL_EXT_swap_control_tear = has_ext("WGL_EXT_swap_control_tear");
|
||||
GLAD_WGL_I3D_digital_video_control = has_ext("WGL_I3D_digital_video_control");
|
||||
GLAD_WGL_I3D_gamma = has_ext("WGL_I3D_gamma");
|
||||
GLAD_WGL_I3D_genlock = has_ext("WGL_I3D_genlock");
|
||||
GLAD_WGL_I3D_image_buffer = has_ext("WGL_I3D_image_buffer");
|
||||
GLAD_WGL_I3D_swap_frame_lock = has_ext("WGL_I3D_swap_frame_lock");
|
||||
GLAD_WGL_I3D_swap_frame_usage = has_ext("WGL_I3D_swap_frame_usage");
|
||||
GLAD_WGL_NV_DX_interop = has_ext("WGL_NV_DX_interop");
|
||||
GLAD_WGL_NV_DX_interop2 = has_ext("WGL_NV_DX_interop2");
|
||||
GLAD_WGL_NV_copy_image = has_ext("WGL_NV_copy_image");
|
||||
GLAD_WGL_NV_delay_before_swap = has_ext("WGL_NV_delay_before_swap");
|
||||
GLAD_WGL_NV_float_buffer = has_ext("WGL_NV_float_buffer");
|
||||
GLAD_WGL_NV_gpu_affinity = has_ext("WGL_NV_gpu_affinity");
|
||||
GLAD_WGL_NV_multigpu_context = has_ext("WGL_NV_multigpu_context");
|
||||
GLAD_WGL_NV_multisample_coverage = has_ext("WGL_NV_multisample_coverage");
|
||||
GLAD_WGL_NV_present_video = has_ext("WGL_NV_present_video");
|
||||
GLAD_WGL_NV_render_depth_texture = has_ext("WGL_NV_render_depth_texture");
|
||||
GLAD_WGL_NV_render_texture_rectangle = has_ext("WGL_NV_render_texture_rectangle");
|
||||
GLAD_WGL_NV_swap_group = has_ext("WGL_NV_swap_group");
|
||||
GLAD_WGL_NV_vertex_array_range = has_ext("WGL_NV_vertex_array_range");
|
||||
GLAD_WGL_NV_video_capture = has_ext("WGL_NV_video_capture");
|
||||
GLAD_WGL_NV_video_output = has_ext("WGL_NV_video_output");
|
||||
GLAD_WGL_OML_sync_control = has_ext("WGL_OML_sync_control");
|
||||
free_exts();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void find_coreWGL(HDC hdc) {
|
||||
GLADWGLhdc = hdc;
|
||||
}
|
||||
|
||||
int gladLoadWGLLoader(GLADloadproc load, HDC hdc) {
|
||||
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)load("wglGetExtensionsStringARB");
|
||||
wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)load("wglGetExtensionsStringEXT");
|
||||
if(wglGetExtensionsStringARB == NULL && wglGetExtensionsStringEXT == NULL) return 0;
|
||||
find_coreWGL(hdc);
|
||||
|
||||
if (!find_extensionsWGL()) return 0;
|
||||
load_WGL_3DL_stereo_control(load);
|
||||
load_WGL_AMD_gpu_association(load);
|
||||
load_WGL_ARB_buffer_region(load);
|
||||
load_WGL_ARB_create_context(load);
|
||||
load_WGL_ARB_extensions_string(load);
|
||||
load_WGL_ARB_make_current_read(load);
|
||||
load_WGL_ARB_pbuffer(load);
|
||||
load_WGL_ARB_pixel_format(load);
|
||||
load_WGL_ARB_render_texture(load);
|
||||
load_WGL_EXT_display_color_table(load);
|
||||
load_WGL_EXT_extensions_string(load);
|
||||
load_WGL_EXT_make_current_read(load);
|
||||
load_WGL_EXT_pbuffer(load);
|
||||
load_WGL_EXT_pixel_format(load);
|
||||
load_WGL_EXT_swap_control(load);
|
||||
load_WGL_I3D_digital_video_control(load);
|
||||
load_WGL_I3D_gamma(load);
|
||||
load_WGL_I3D_genlock(load);
|
||||
load_WGL_I3D_image_buffer(load);
|
||||
load_WGL_I3D_swap_frame_lock(load);
|
||||
load_WGL_I3D_swap_frame_usage(load);
|
||||
load_WGL_NV_DX_interop(load);
|
||||
load_WGL_NV_copy_image(load);
|
||||
load_WGL_NV_delay_before_swap(load);
|
||||
load_WGL_NV_gpu_affinity(load);
|
||||
load_WGL_NV_present_video(load);
|
||||
load_WGL_NV_swap_group(load);
|
||||
load_WGL_NV_vertex_array_range(load);
|
||||
load_WGL_NV_video_capture(load);
|
||||
load_WGL_NV_video_output(load);
|
||||
load_WGL_OML_sync_control(load);
|
||||
return 1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,311 @@
|
|||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
Loading…
Reference in New Issue