forked from mikeseven/node-webgl
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- the binaries are pulled from Chrome 131 binary dirs - load the entry points via a loader, using code from ANGLE - use the WebGL compatibility mode extension in ANGLE - replace Linux and Mac gyp builds with binaries There's one WebGL regression due to a minor bug in ANGLE: it accepts two desktop GL enums in WebGL compatibility mode when it shouldn't. This contribution is funded by https://higharc.com/
- Loading branch information
Showing
72 changed files
with
30,904 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <string> | ||
#include <array> | ||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#else | ||
#include <dlfcn.h> | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
std::string Narrow(const std::wstring_view &utf16) | ||
{ | ||
if (utf16.empty()) | ||
{ | ||
return {}; | ||
} | ||
int requiredSize = WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.size()), | ||
nullptr, 0, nullptr, nullptr); | ||
std::string utf8(requiredSize, '\0'); | ||
WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.size()), &utf8[0], | ||
requiredSize, nullptr, nullptr); | ||
return utf8; | ||
} | ||
|
||
std::string GetPath(HMODULE module) | ||
{ | ||
std::array<wchar_t, MAX_PATH> executableFileBuf; | ||
DWORD executablePathLen = GetModuleFileNameW(module, executableFileBuf.data(), | ||
static_cast<DWORD>(executableFileBuf.size())); | ||
return Narrow(executablePathLen > 0 ? executableFileBuf.data() : L""); | ||
} | ||
|
||
std::string GetModulePath(void *moduleOrSymbol) | ||
{ | ||
HMODULE module = nullptr; | ||
if (GetModuleHandleExW( | ||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, | ||
reinterpret_cast<LPCWSTR>(moduleOrSymbol), &module)) | ||
{ | ||
return GetPath(module); | ||
} | ||
|
||
return ""; | ||
} | ||
#else | ||
std::string GetModulePath(void *moduleOrSymbol) | ||
{ | ||
Dl_info dlInfo; | ||
if (dladdr(moduleOrSymbol, &dlInfo) == 0) | ||
{ | ||
return ""; | ||
} | ||
|
||
return dlInfo.dli_fname; | ||
} | ||
#endif | ||
|
||
std::string StripFilenameFromPath(const std::string &path) | ||
{ | ||
size_t lastPathSepLoc = path.find_last_of("\\/"); | ||
return (lastPathSepLoc != std::string::npos) ? path.substr(0, lastPathSepLoc) : ""; | ||
} | ||
|
||
std::string GetModuleDirectory() | ||
{ | ||
static int placeholderSymbol = 0; | ||
std::string moduleName = GetModulePath(&placeholderSymbol); | ||
return StripFilenameFromPath(moduleName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#else | ||
#include <dlfcn.h> | ||
#endif | ||
|
||
inline std::string GetSharedLibraryExtension() { | ||
#ifdef _WIN32 | ||
return ".dll"; // Windows | ||
#elif __APPLE__ | ||
return ".dylib"; // OSX | ||
#elif __linux__ | ||
return ".so"; // Linux | ||
#else | ||
#error Unsupported platform | ||
#endif | ||
} | ||
|
||
std::string GetModuleDirectory(); | ||
|
||
class SharedLibrary { | ||
public: | ||
SharedLibrary() {} | ||
|
||
bool open(const std::string& libraryPath) { | ||
const std::string libraryPathWithExt = GetModuleDirectory() + "/" + libraryPath + GetSharedLibraryExtension(); | ||
#ifdef _WIN32 | ||
handle = LoadLibraryA(libraryPathWithExt.c_str()); | ||
#else | ||
handle = dlopen(libraryPathWithExt.c_str(), RTLD_LAZY); | ||
#endif | ||
return handle != nullptr; | ||
} | ||
|
||
~SharedLibrary() { | ||
if (handle) { | ||
#ifdef _WIN32 | ||
FreeLibrary(static_cast<HMODULE>(handle)); | ||
#else | ||
dlclose(handle); | ||
#endif | ||
} | ||
} | ||
|
||
template <typename Func> | ||
Func getFunction(const std::string& functionName) { | ||
#ifdef _WIN32 | ||
auto func = reinterpret_cast<Func>(GetProcAddress(static_cast<HMODULE>(handle), functionName.c_str())); | ||
#else | ||
auto func = reinterpret_cast<Func>(dlsym(handle, functionName.c_str())); | ||
#endif | ||
return func; | ||
} | ||
|
||
private: | ||
void* handle = nullptr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DisableFormat: true | ||
SortIncludes: false |
Oops, something went wrong.