restore screen density check on android, separate EGL attributes from Quest
This commit is contained in:
@@ -111,6 +111,7 @@ add_library(
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(native-lib PRIVATE
|
target_include_directories(native-lib PRIVATE
|
||||||
|
src/main/cpp
|
||||||
../src/cpp
|
../src/cpp
|
||||||
../../src
|
../../src
|
||||||
../../libs/glm
|
../../libs/glm
|
||||||
|
|||||||
@@ -327,6 +327,9 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
* Below, we select an EGLConfig with at least 8 bits per color
|
* Below, we select an EGLConfig with at least 8 bits per color
|
||||||
* component compatible with on-screen windows
|
* component compatible with on-screen windows
|
||||||
*/
|
*/
|
||||||
|
#ifdef __QUEST__
|
||||||
|
EGLint egl_depth = 0;
|
||||||
|
EGLint egl_alpha = 8;
|
||||||
const EGLint attribs[] = {
|
const EGLint attribs[] = {
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
|
||||||
@@ -339,18 +342,32 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
EGL_SAMPLES, 0,
|
EGL_SAMPLES, 0,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
EGLint w, h, dummy, format;
|
#else
|
||||||
|
EGLint egl_depth = 24;
|
||||||
|
EGLint egl_alpha = 0;
|
||||||
|
const EGLint attribs[] = {
|
||||||
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_GREEN_SIZE, 8,
|
||||||
|
EGL_RED_SIZE, 8,
|
||||||
|
EGL_DEPTH_SIZE, 24,
|
||||||
|
EGL_STENCIL_SIZE, 0,
|
||||||
|
EGL_SAMPLES, 0,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
EGLint w, h, format;
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
EGLConfig config;
|
EGLConfig config = nullptr;
|
||||||
EGLSurface surface;
|
EGLSurface surface = nullptr;
|
||||||
EGLContext context;
|
EGLContext context = nullptr;
|
||||||
|
|
||||||
EGLDisplay display = g_display;
|
EGLDisplay display = g_display;
|
||||||
if (g_display == EGL_NO_DISPLAY)
|
if (g_display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
LOG("DYSPLAY CREATE");
|
LOG("DYSPLAY CREATE");
|
||||||
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
eglInitialize(display, 0, 0);
|
eglInitialize(display, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else LOG("DISPLAY RESUME");
|
else LOG("DISPLAY RESUME");
|
||||||
|
|
||||||
@@ -371,7 +388,7 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
eglGetConfigAttrib(display, cfg, EGL_BLUE_SIZE, &b) &&
|
eglGetConfigAttrib(display, cfg, EGL_BLUE_SIZE, &b) &&
|
||||||
eglGetConfigAttrib(display, cfg, EGL_ALPHA_SIZE, &a) &&
|
eglGetConfigAttrib(display, cfg, EGL_ALPHA_SIZE, &a) &&
|
||||||
eglGetConfigAttrib(display, cfg, EGL_DEPTH_SIZE, &d) &&
|
eglGetConfigAttrib(display, cfg, EGL_DEPTH_SIZE, &d) &&
|
||||||
r == 8 && g == 8 && b == 8 && a == 8 && d == 0 ) {
|
r == 8 && g == 8 && b == 8 && a == egl_alpha && d == egl_depth ) {
|
||||||
|
|
||||||
config = supportedConfigs[i];
|
config = supportedConfigs[i];
|
||||||
break;
|
break;
|
||||||
@@ -386,10 +403,16 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
* As soon as we picked a EGLConfig, we can safely reconfigure the
|
* As soon as we picked a EGLConfig, we can safely reconfigure the
|
||||||
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
|
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
|
||||||
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
|
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
|
||||||
surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
|
surface = eglCreateWindowSurface(display, config, engine->app->window, nullptr);
|
||||||
|
|
||||||
|
#ifdef __QUEST__
|
||||||
|
const int gles_version = 3;
|
||||||
|
#else
|
||||||
|
const int gles_version = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
const EGLint attribs_test[] = {
|
const EGLint attribs_test[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
EGL_CONTEXT_CLIENT_VERSION, gles_version,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||||
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
@@ -409,7 +432,7 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
{
|
{
|
||||||
LOG("EGL: debug and forward context failed");
|
LOG("EGL: debug and forward context failed");
|
||||||
const EGLint attribs_test[] = {
|
const EGLint attribs_test[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
EGL_CONTEXT_CLIENT_VERSION, gles_version,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
@@ -418,7 +441,7 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
{
|
{
|
||||||
LOG("EGL: only forward context failed");
|
LOG("EGL: only forward context failed");
|
||||||
const EGLint attribs_test[] = {
|
const EGLint attribs_test[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
EGL_CONTEXT_CLIENT_VERSION, gles_version,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
|
||||||
//EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
//EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
@@ -428,7 +451,7 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
{
|
{
|
||||||
LOG("EGL: only debug context failed");
|
LOG("EGL: only debug context failed");
|
||||||
const EGLint attribs_test[] = {
|
const EGLint attribs_test[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
EGL_CONTEXT_CLIENT_VERSION, gles_version,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribs_test);
|
context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribs_test);
|
||||||
@@ -471,9 +494,9 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
engine->height = h;
|
engine->height = h;
|
||||||
engine->state.angle = 0;
|
engine->state.angle = 0;
|
||||||
|
|
||||||
//float density = get_display_density(engine->app);
|
float density = get_display_density(engine->app);
|
||||||
//LOG("density %f", density);
|
LOG("density %f", density);
|
||||||
//App::I.zoom = density / 1.5;
|
App::I.zoom = density;// / 1.5;
|
||||||
|
|
||||||
g_display = display;
|
g_display = display;
|
||||||
g_context = context;
|
g_context = context;
|
||||||
@@ -543,7 +566,6 @@ static int engine_init_display(struct engine* engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ret = -1;
|
|
||||||
FILE* file = popen("getprop", "r");
|
FILE* file = popen("getprop", "r");
|
||||||
std::map<std::string, std::string> os_props;
|
std::map<std::string, std::string> os_props;
|
||||||
if (file)
|
if (file)
|
||||||
|
|||||||
Reference in New Issue
Block a user