mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-06 12:12:59 +02:00
Switch android to GLAD
This commit is contained in:
parent
acb95d1355
commit
55bfdc105b
13 changed files with 67 additions and 51 deletions
|
@ -97,6 +97,11 @@ def packages = [
|
|||
versionId: 'cA3tVJSmkvb1naA3l6D_Jv2Noh.4yc4m',
|
||||
checksum: '617a80d213a5ec69fbfa21a1f2f738cd',
|
||||
],
|
||||
glad: [
|
||||
file: 'glad_armv8-libcpp.zip',
|
||||
versionId: 'Q9szthzeye8fFyAA.cY26Lgn2B8kezEE',
|
||||
checksum: 'a8ee8584cf1ccd34766c7ddd9d5e5449',
|
||||
],
|
||||
glm: [
|
||||
file: 'glm-0.9.8.tgz',
|
||||
versionId: 'BlkJNwaYV2Gfy5XwMeU7K0uzPDRKFMt2',
|
||||
|
|
|
@ -6,29 +6,38 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
macro(TARGET_GLAD)
|
||||
|
||||
if (APPLE)
|
||||
set(GLAD_VER "41")
|
||||
if (ANDROID)
|
||||
set(INSTALL_DIR ${HIFI_ANDROID_PRECOMPILED}/glad)
|
||||
set(GLAD_INCLUDE_DIRS "${INSTALL_DIR}/include")
|
||||
set(GLAD_LIBRARY_DEBUG ${INSTALL_DIR}/lib/libglad_d.a)
|
||||
set(GLAD_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libglad.a)
|
||||
select_library_configurations(GLAD)
|
||||
find_library(EGL EGL)
|
||||
target_link_libraries(${TARGET_NAME} ${EGL})
|
||||
else()
|
||||
if (USE_GLES)
|
||||
set(GLAD_VER "32es")
|
||||
if (APPLE)
|
||||
set(GLAD_VER "41")
|
||||
else()
|
||||
set(GLAD_VER "45")
|
||||
add_dependency_external_projects(glad45)
|
||||
endif()
|
||||
if (WIN32)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
|
||||
# we don't need the include, because we get everything from GLAD
|
||||
#target_include_directories(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIR})
|
||||
if (USE_GLES)
|
||||
set(GLAD_VER "32es")
|
||||
else()
|
||||
set(GLAD_VER "45")
|
||||
add_dependency_external_projects(glad45)
|
||||
endif()
|
||||
if (WIN32)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
|
||||
# we don't need the include, because we get everything from GLAD
|
||||
#target_include_directories(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
set(GLAD "glad${GLAD_VER}")
|
||||
string(TOUPPER ${GLAD} GLAD_UPPER)
|
||||
add_dependency_external_projects(${GLAD})
|
||||
set(GLAD_INCLUDE_DIRS ${${GLAD_UPPER}_INCLUDE_DIRS})
|
||||
set(GLAD_LIBRARY ${${GLAD_UPPER}_LIBRARY})
|
||||
endif()
|
||||
set(GLAD "glad${GLAD_VER}")
|
||||
string(TOUPPER ${GLAD} GLAD_UPPER)
|
||||
add_dependency_external_projects(${GLAD})
|
||||
set(GLAD_INCLUDE_DIRS ${${GLAD_UPPER}_INCLUDE_DIRS})
|
||||
set(GLAD_LIBRARY ${${GLAD_UPPER}_LIBRARY})
|
||||
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLAD_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} ${GLAD_LIBRARY})
|
||||
endmacro()
|
||||
|
|
|
@ -6,13 +6,6 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
macro(TARGET_OPENGL)
|
||||
if (ANDROID)
|
||||
find_library(EGL EGL)
|
||||
find_library(OpenGLES3 GLESv3)
|
||||
list(APPEND IGNORE_COPY_LIBS ${OpenGLES3} ${OpenGLES2} ${EGL})
|
||||
target_link_libraries(${TARGET_NAME} ${OpenGLES3} ${EGL})
|
||||
else()
|
||||
target_glad()
|
||||
target_nsight()
|
||||
endif()
|
||||
target_glad()
|
||||
target_nsight()
|
||||
endmacro()
|
||||
|
|
|
@ -10,15 +10,12 @@
|
|||
|
||||
#include "ResourceImageItem.h"
|
||||
|
||||
#include <gl/Config.h>
|
||||
|
||||
#include <QOpenGLFramebufferObjectFormat>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QOpenGLContext>
|
||||
|
||||
#include <plugins/DisplayPlugin.h>
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <gl/Config.h>
|
||||
#endif
|
||||
|
||||
ResourceImageItem::ResourceImageItem() : QQuickFramebufferObject() {
|
||||
auto textureCache = DependencyManager::get<TextureCache>();
|
||||
connect(textureCache.data(), SIGNAL(spectatorCameraFramebufferReset()), this, SLOT(update()));
|
||||
|
@ -91,11 +88,9 @@ QOpenGLFramebufferObject* ResourceImageItemRenderer::createFramebufferObject(con
|
|||
}
|
||||
|
||||
void ResourceImageItemRenderer::render() {
|
||||
auto f = QOpenGLContext::currentContext()->extraFunctions();
|
||||
|
||||
if (_fenceSync) {
|
||||
f->glWaitSync(_fenceSync, 0, GL_TIMEOUT_IGNORED);
|
||||
f->glDeleteSync(_fenceSync);
|
||||
glWaitSync(_fenceSync, 0, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(_fenceSync);
|
||||
_fenceSync = 0;
|
||||
}
|
||||
if (_ready) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "Application.h"
|
||||
|
||||
#include <gl/Config.h>
|
||||
|
||||
#include <QQuickFramebufferObject>
|
||||
#include <QQuickWindow>
|
||||
#include <QTimer>
|
||||
|
|
|
@ -44,8 +44,18 @@ PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
|||
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
|
||||
static void* getGlProcessAddress(const char *namez) {
|
||||
auto result = eglGetProcAddress(namez);
|
||||
return (void*)result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void gl::initModuleGl() {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
|
@ -54,11 +64,12 @@ void gl::initModuleGl() {
|
|||
wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)getGlProcessAddress("wglGetSwapIntervalEXT");
|
||||
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)getGlProcessAddress("wglChoosePixelFormatARB");
|
||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)getGlProcessAddress("wglCreateContextAttribsARB");
|
||||
#endif
|
||||
|
||||
#if defined(USE_GLES)
|
||||
gladLoadGLES2Loader(getGlProcessAddress);
|
||||
#else
|
||||
gladLoadGLLoader(getGlProcessAddress);
|
||||
#endif
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,12 +32,7 @@
|
|||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#define GL_DEPTH_COMPONENT32_OES 0x81A7
|
||||
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
|
||||
#define GL_R16_EXT 0x822A
|
||||
#define GL_R16_SNORM_EXT 0x8F98
|
||||
#define GL_SLUMINANCE8_EXT 0x8C47
|
||||
#include <glad/glad.h>
|
||||
#else
|
||||
#include <glad/glad.h>
|
||||
#ifndef GL_SLUMINANCE8_EXT
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "Context.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
|
@ -48,7 +50,9 @@ void Context::moveToThread(QThread* thread) {
|
|||
#ifndef GL_CUSTOM_CONTEXT
|
||||
bool Context::makeCurrent() {
|
||||
updateSwapchainMemoryCounter();
|
||||
return _context->makeCurrent(_window);
|
||||
bool result = _context->makeCurrent(_window);
|
||||
gl::initModuleGl();
|
||||
return result;
|
||||
}
|
||||
|
||||
void Context::swapBuffers() {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <mutex>
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
@ -11,8 +13,6 @@
|
|||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QOpenGLDebugLogger>
|
||||
|
||||
#include <QtOpenGL/QGL>
|
||||
|
||||
size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format) {
|
||||
size_t pixelSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize() + format.alphaBufferSize();
|
||||
// We don't apply the length of the swap chain into this pixelSize since it is not vsible for the Process (on windows).
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "GLWindow.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "OffscreenGLCanvas.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QtCore/QProcessEnvironment>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QOffscreenSurface>
|
||||
|
|
|
@ -147,7 +147,6 @@ void GLBackend::do_clearFramebuffer(const Batch& batch, size_t paramOffset) {
|
|||
(void) CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
#pragma optimize( "", on )
|
||||
void GLBackend::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) {
|
||||
auto readFBO = getFramebufferID(srcFramebuffer);
|
||||
if (srcFramebuffer && readFBO) {
|
||||
|
|
|
@ -106,7 +106,7 @@ GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) {
|
|||
break;
|
||||
case gpu::NUINT8:
|
||||
if ((dstFormat.getSemantic() == gpu::SRGB || dstFormat.getSemantic() == gpu::SRGBA)) {
|
||||
result = GL_SLUMINANCE8_EXT;
|
||||
result = GL_SLUMINANCE8_NV;
|
||||
} else {
|
||||
result = GL_R8;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
|||
}
|
||||
case gpu::NUINT8: {
|
||||
if ((dstFormat.getSemantic() == gpu::SRGB || dstFormat.getSemantic() == gpu::SRGBA)) {
|
||||
texel.internalFormat = GL_SLUMINANCE8_EXT;
|
||||
texel.internalFormat = GL_SLUMINANCE8_NV;
|
||||
} else {
|
||||
texel.internalFormat = GL_R8;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue