Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ANGLE binaries. #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,20 @@
'sources': [
'src/native/bindings.cc',
'src/native/webgl.cc',
'src/native/procs.cc'
'src/native/SharedLibrary.cc',
'src/native/angle-loader/egl_loader.cc',
'src/native/angle-loader/gles_loader.cc'
],
'include_dirs': [
"<!(node -e \"require('nan')\")",
'<(module_root_dir)/deps/include',
"angle/include"
"src/native/angle-includes"
],
'library_dirs': [
'<(module_root_dir)/deps/<(platform)'
],
'conditions': [
['OS=="mac"', {
'dependencies':
[
'angle/src/angle.gyp:libEGL',
'angle/src/angle.gyp:libGLESv2'
],
'libraries': [
'-framework QuartzCore',
'-framework Quartz'
Expand All @@ -45,22 +42,28 @@
'CLANG_CXX_LANGUAGE_STANDARD':'c++17',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
},
"copies": [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(module_root_dir)/deps/darwin/dylib/libEGL.dylib',
'<(module_root_dir)/deps/darwin/dylib/libGLESv2.dylib',
]
}
]
}],
['OS=="linux"', {
'dependencies':
[
'angle/src/angle.gyp:libEGL',
'angle/src/angle.gyp:libGLESv2'
]
"copies": [
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(module_root_dir)/deps/linux/so/libEGL.so',
'<(module_root_dir)/deps/linux/so/libGLESv2.so',
]
}
]
}],
['OS=="win"', {
'library_dirs': [
'<(module_root_dir)/deps/windows/lib/<(target_arch)',
],
'libraries': [
'libEGL.lib',
'libGLESv2.lib'
],
'defines' : [
'WIN32_LEAN_AND_MEAN',
'VC_EXTRALEAN'
Expand Down Expand Up @@ -102,11 +105,11 @@
},
"copies": [
{
'destination': '$(SolutionDir)$(ConfigurationName)',
'destination': '<(PRODUCT_DIR)',
'files': [
'<(module_root_dir)/deps/windows/dll/<(target_arch)/libEGL.dll',
'<(module_root_dir)/deps/windows/dll/<(target_arch)/libGLESv2.dll',
'<(module_root_dir)/deps/windows/dll/<(target_arch)/d3dcompiler_47.dll'
'<(module_root_dir)/deps/windows/dll/libEGL.dll',
'<(module_root_dir)/deps/windows/dll/libGLESv2.dll',
'<(module_root_dir)/deps/windows/dll/d3dcompiler_47.dll'
]
}
]
Expand Down
Binary file added deps/darwin/dylib/libEGL.dylib
Binary file not shown.
Binary file added deps/darwin/dylib/libGLESv2.dylib
Binary file not shown.
Binary file added deps/linux/so/libEGL.so
Binary file not shown.
Binary file added deps/linux/so/libGLESv2.so
Binary file not shown.
Binary file added deps/windows/dll/d3dcompiler_47.dll
Binary file not shown.
Binary file added deps/windows/dll/libEGL.dll
Binary file not shown.
Binary file added deps/windows/dll/libGLESv2.dll
Binary file not shown.
Binary file removed deps/windows/dll/x64/d3dcompiler_47.dll
Binary file not shown.
Binary file removed deps/windows/dll/x64/libEGL.dll
Binary file not shown.
Binary file removed deps/windows/dll/x64/libGLESv2.dll
Binary file not shown.
Binary file removed deps/windows/lib/x64/libEGL.lib
Binary file not shown.
Binary file removed deps/windows/lib/x64/libGLESv2.lib
Binary file not shown.
6 changes: 3 additions & 3 deletions src/javascript/webgl-rendering-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -1213,15 +1213,15 @@ class WebGLRenderingContext extends NativeWebGLRenderingContext {
exts.push('OES_texture_float_linear')
}

if (supportedExts.indexOf('EXT_draw_buffers') >= 0) {
if (supportedExts.indexOf('GL_EXT_draw_buffers') >= 0) {
exts.push('WEBGL_draw_buffers')
}

if (supportedExts.indexOf('EXT_blend_minmax') >= 0) {
if (supportedExts.indexOf('GL_EXT_blend_minmax') >= 0) {
exts.push('EXT_blend_minmax')
}

if (supportedExts.indexOf('EXT_texture_filter_anisotropic') >= 0) {
if (supportedExts.indexOf('GL_EXT_texture_filter_anisotropic') >= 0) {
exts.push('EXT_texture_filter_anisotropic')
}

Expand Down
69 changes: 69 additions & 0 deletions src/native/SharedLibrary.cc
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);
}
63 changes: 63 additions & 0 deletions src/native/SharedLibrary.h
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;
};
2 changes: 2 additions & 0 deletions src/native/angle-includes/EGL/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: false
Loading
Loading