blob: 16ab252f16ac18003c5412092f8c1213fa43b67b [file] [log] [blame]
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../dl_loader.h"
#include "../log.h"
namespace gapic {
#define FRAMEWORK_ROOT "/System/Library/Frameworks/OpenGL.framework/"
#define CORE_GRAPHICS "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics"
void* GetGfxProcAddress(const char *name, bool bypassLocal) {
if (bypassLocal) {
static DlLoader opengl(FRAMEWORK_ROOT "OpenGL");
if (void* proc = opengl.lookup(name)) {
GAPID_INFO("GetGfxProcAddress(%s, true) -> 0x%x (from OpenGL dlsym)", name, proc);
return proc;
}
static DlLoader libgl(FRAMEWORK_ROOT "Libraries/libGL.dylib");
if (void* proc = libgl.lookup(name)) {
GAPID_INFO("GetGfxProcAddress(%s, true) -> 0x%x (from libGL dlsym)", name, proc);
return proc;
}
static DlLoader libglu(FRAMEWORK_ROOT "Libraries/libGLU.dylib");
if (void* proc = libglu.lookup(name)) {
GAPID_INFO("GetGfxProcAddress(%s, true) -> 0x%x (from libGLU dlsym)", name, proc);
return proc;
}
static DlLoader coregraphics(CORE_GRAPHICS);
if (void* proc = coregraphics.lookup(name)) {
GAPID_INFO("GetGfxProcAddress(%s, true) -> 0x%x (from CoreGraphics dlsym)", name, proc);
return proc;
}
} else {
static DlLoader local(nullptr);
if (void* proc = local.lookup(name)) {
GAPID_INFO("GetGfxProcAddress(%s, false) -> 0x%x (from local dlsym)", name, proc);
return proc;
}
GAPID_INFO("GetGfxProcAddress(%s, false) -> not found", name);
}
return nullptr;
}
} // namespace gapic