Android opengl debug callback, Android device properties, fix texture internal format
This commit is contained in:
@@ -26,6 +26,24 @@
|
||||
#include "app.h"
|
||||
#include "..\..\..\..\engine\asset.h"
|
||||
|
||||
typedef void (*GLDEBUGPROC)(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam);
|
||||
|
||||
typedef void (*fnDebugMessageCallback)(GLDEBUGPROC callback, const void* userParam);
|
||||
|
||||
#define GL_DEBUG_SEVERITY_HIGH 0x9146
|
||||
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
|
||||
#define GL_DEBUG_SEVERITY_LOW 0x9148
|
||||
#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
|
||||
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
|
||||
|
||||
/**
|
||||
* Our saved state data.
|
||||
*/
|
||||
@@ -116,8 +134,10 @@ static int engine_init_display(struct engine* engine) {
|
||||
surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
|
||||
|
||||
const EGLint attribs_test[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
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_NONE
|
||||
};
|
||||
|
||||
context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribs_test);
|
||||
@@ -138,11 +158,92 @@ static int engine_init_display(struct engine* engine) {
|
||||
engine->state.angle = 0;
|
||||
|
||||
// Check openGL on the system
|
||||
auto opengl_info = {GL_VENDOR, GL_RENDERER, GL_VERSION/*, GL_EXTENSIONS*/};
|
||||
auto opengl_info = { GL_VENDOR, GL_RENDERER, GL_VERSION/*, GL_EXTENSIONS*/ };
|
||||
for (auto name : opengl_info) {
|
||||
auto info = glGetString(name);
|
||||
LOG("OpenGL Info: %s", info);
|
||||
}
|
||||
|
||||
const char* ext = (const char*) glGetString(GL_EXTENSIONS);
|
||||
int ext_len = strlen(ext);
|
||||
std::map<std::string, bool> ext_map;
|
||||
static char ext_name[256];
|
||||
int ext_name_i = 0;
|
||||
for (int i = 0; i < ext_len; i++)
|
||||
{
|
||||
char c = ext[i];
|
||||
if (c == ' ')
|
||||
{
|
||||
ext_map.emplace(std::string(ext_name, ext_name_i), true);
|
||||
ext_name_i = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext_name[ext_name_i++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
if (ext_map.count("GL_KHR_debug"))
|
||||
{
|
||||
LOG("GL_KHR_debug supported");
|
||||
auto glDebugMessageCallback = (fnDebugMessageCallback)eglGetProcAddress("glDebugMessageCallbackKHR");
|
||||
if (glDebugMessageCallback)
|
||||
{
|
||||
LOG("glDebugMessageCallback proc found at %p", glDebugMessageCallback);
|
||||
glDebugMessageCallback([](GLenum source, GLenum type, GLuint id,
|
||||
GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
|
||||
{
|
||||
//if (severity == GL_DEBUG_SEVERITY_MEDIUM || severity == GL_DEBUG_SEVERITY_HIGH)
|
||||
{
|
||||
LOG("OPENGL: %.*s", length, message);
|
||||
}
|
||||
}, nullptr);
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("glDebugMessageCallback proc NOT FOUND");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ret = -1;
|
||||
FILE* file = popen("getprop", "r");
|
||||
std::map<std::string, std::string> os_props;
|
||||
if (file)
|
||||
{
|
||||
char output[100];
|
||||
while (fgets(output, sizeof(output), file) != nullptr)
|
||||
{
|
||||
int i = 0;
|
||||
int l = strlen(output);
|
||||
char buf[64];
|
||||
int j = 0;
|
||||
while (i < l && output[i] != '[') i++;
|
||||
i++;
|
||||
while (i < l && output[i] != ']') { buf[j++] = output[i]; i++; }
|
||||
std::string key(buf, j);
|
||||
j = 0;
|
||||
while (i < l && output[i] != '[') i++;
|
||||
i++;
|
||||
while (i < l && output[i] != ']') { buf[j++] = output[i]; i++; }
|
||||
os_props[key] = std::string(buf, j);
|
||||
//LOG("PROP: %s -> %s", key.c_str(), os_props[key].c_str());
|
||||
}
|
||||
pclose(file);
|
||||
}
|
||||
LOG("PROP Android Version: %s", os_props["ro.build.version.release"].c_str());
|
||||
LOG("PROP Android SDK: %s", os_props["ro.build.version.sdk"].c_str());
|
||||
LOG("PROP Country Code: %s", os_props["ro.csc.country_code"].c_str());
|
||||
LOG("PROP ABI: %s", os_props["ro.product.cpu.abilist"].c_str());
|
||||
LOG("PROP Brand: %s", os_props["ro.product.brand"].c_str());
|
||||
LOG("PROP Maker: %s", os_props["ro.product.manufacturer"].c_str());
|
||||
LOG("PROP Mode: %s", os_props["ro.product.model"].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
|
||||
// Initialize GL state.
|
||||
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
@@ -203,7 +304,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
||||
struct engine* engine = (struct engine*)app->userData;
|
||||
float x = AMotionEvent_getX(event, 0);
|
||||
float y = AMotionEvent_getY(event, 0);
|
||||
LOG("event source: %d", AInputEvent_getSource(event));
|
||||
//LOG("event source: %d", AInputEvent_getSource(event));
|
||||
MouseEvent e;
|
||||
int32_t eventType = AInputEvent_getType(event);
|
||||
switch (eventType) {
|
||||
@@ -225,7 +326,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
||||
App::I.mouse_move(x, y);
|
||||
return 1;
|
||||
default:
|
||||
LOG("motion action: %d", action);
|
||||
//LOG("motion action: %d", action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user