add remote logging system using curl, normalize log messages removing \n, fix fra shaders precision issue, enable core and forward comp. in WGL, disable multisampling,
This commit is contained in:
108
engine/app.cpp
108
engine/app.cpp
@@ -33,8 +33,8 @@ void App::initShaders()
|
||||
static const char* shader_f =
|
||||
SHADER_VERSION
|
||||
"uniform sampler2D tex;"
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"in mediump vec3 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
//" frag = texture(tex, uv.xy/uv.z);"
|
||||
" frag = texture(tex, uv.xy);"
|
||||
@@ -42,8 +42,8 @@ void App::initShaders()
|
||||
static const char* shader_uv_f =
|
||||
SHADER_VERSION
|
||||
"uniform sampler2D tex;"
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"in mediump vec3 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = vec4(uv.xy, 0.0, 1.0);"
|
||||
"}";
|
||||
@@ -64,8 +64,8 @@ void App::initShaders()
|
||||
static const char* shader_atlas_f =
|
||||
SHADER_VERSION
|
||||
"uniform sampler2D tex;"
|
||||
"in vec2 uv;"
|
||||
"out vec4 frag;"
|
||||
"in mediump vec2 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = texture(tex, uv);"
|
||||
"}";
|
||||
@@ -80,8 +80,8 @@ void App::initShaders()
|
||||
"}";
|
||||
static const char* shader_color_f =
|
||||
SHADER_VERSION
|
||||
"uniform vec4 col;"
|
||||
"out vec4 frag;"
|
||||
"uniform mediump vec4 col;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" frag = col;"
|
||||
"}";
|
||||
@@ -99,11 +99,11 @@ void App::initShaders()
|
||||
"}";
|
||||
static const char* shader_color_quad_f =
|
||||
SHADER_VERSION
|
||||
"uniform vec4 col;"
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"uniform mediump vec4 col;"
|
||||
"in mediump vec3 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" vec4 gradient_x = mix(col, vec4(1.0, 1.0, 1.0, 1.0), uv.x);"
|
||||
" mediump vec4 gradient_x = mix(col, vec4(1.0, 1.0, 1.0, 1.0), uv.x);"
|
||||
" frag = mix(gradient_x, vec4(0.0, 0.0, 0.0, 1.0), uv.y);"
|
||||
"}";
|
||||
|
||||
@@ -120,12 +120,12 @@ void App::initShaders()
|
||||
"}";
|
||||
static const char* shader_color_hue_f =
|
||||
SHADER_VERSION
|
||||
"uniform vec4 col;"
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"vec3 hsv2rgb(vec3 c) {"
|
||||
" vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
|
||||
" vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
|
||||
"uniform mediump vec4 col;"
|
||||
"in mediump vec3 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"mediump vec3 hsv2rgb(mediump vec3 c) {"
|
||||
" mediump vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
|
||||
" mediump vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
|
||||
" return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
|
||||
"}"
|
||||
"void main(){"
|
||||
@@ -145,12 +145,12 @@ void App::initShaders()
|
||||
"}";
|
||||
static const char* shader_font_f =
|
||||
SHADER_VERSION
|
||||
"uniform sampler2D tex;"
|
||||
"uniform vec4 col;"
|
||||
"in vec2 uv;"
|
||||
"out vec4 frag;"
|
||||
"uniform mediump sampler2D tex;"
|
||||
"uniform mediump vec4 col;"
|
||||
"in mediump vec2 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" float a = texture(tex, uv).r;"
|
||||
" mediump float a = texture(tex, uv).r;"
|
||||
" frag = vec4(col.rgb, a);"
|
||||
"}";
|
||||
|
||||
@@ -167,13 +167,13 @@ void App::initShaders()
|
||||
"}";
|
||||
static const char* shader_stroke_f =
|
||||
SHADER_VERSION
|
||||
"uniform sampler2D tex;"
|
||||
"uniform vec4 col;"
|
||||
"uniform float alpha;"
|
||||
"in vec3 uv;"
|
||||
"out vec4 frag;"
|
||||
"uniform mediump sampler2D tex;"
|
||||
"uniform mediump vec4 col;"
|
||||
"uniform mediump float alpha;"
|
||||
"in mediump vec3 uv;"
|
||||
"out mediump vec4 frag;"
|
||||
"void main(){"
|
||||
" float a = (1.0 - texture(tex, uv.xy).r) * alpha;"
|
||||
" mediump float a = (1.0 - texture(tex, uv.xy).r) * alpha;"
|
||||
" frag = vec4(col.rgb, a);"
|
||||
"}";
|
||||
|
||||
@@ -209,7 +209,7 @@ void App::initAssets()
|
||||
sampler.create(GL_NEAREST);
|
||||
LOG("initializing assets load uvs texture");
|
||||
if (!tex.load("data/uvs.jpg"))
|
||||
LOG("error loading image\n");
|
||||
LOG("error loading image");
|
||||
LOG("initializing assets completed");
|
||||
}
|
||||
|
||||
@@ -444,6 +444,8 @@ void App::initLayout()
|
||||
|
||||
void App::init()
|
||||
{
|
||||
LogRemote::I.start();
|
||||
|
||||
#ifdef _WIN32
|
||||
static CONSOLE_SCREEN_BUFFER_INFO info;
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
|
||||
@@ -457,15 +459,33 @@ void App::init()
|
||||
{ GL_DEBUG_SEVERITY_MEDIUM, FOREGROUND_GREEN | FOREGROUND_INTENSITY },
|
||||
{ GL_DEBUG_SEVERITY_HIGH, FOREGROUND_RED | FOREGROUND_INTENSITY },
|
||||
};
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors[severity]);
|
||||
LOG("%.*s\n", length, message);
|
||||
FlushConsoleInputBuffer(GetStdHandle(STD_OUTPUT_HANDLE));
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), info.wAttributes);
|
||||
if (severity == GL_DEBUG_SEVERITY_MEDIUM || severity == GL_DEBUG_SEVERITY_HIGH)
|
||||
{
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors[severity]);
|
||||
LOG("%.*s", length, message);
|
||||
FlushConsoleInputBuffer(GetStdHandle(STD_OUTPUT_HANDLE));
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), info.wAttributes);
|
||||
__debugbreak();
|
||||
}
|
||||
}, nullptr);
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
#endif
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
//int n;
|
||||
//glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
//for (int i = 0; i < n; i++)
|
||||
//{
|
||||
// const unsigned char* s = glGetStringi(GL_EXTENSIONS, i);
|
||||
// LOG("GL ext %03d: %s\n", i, s);
|
||||
//}
|
||||
LOG("GL version: %s", glGetString(GL_VERSION));
|
||||
LOG("GL vendor: %s", glGetString(GL_VENDOR));
|
||||
LOG("GL renderer: %s", glGetString(GL_RENDERER));
|
||||
LOG("Screen Resolution: %dx%d", (int)width, (int)height);
|
||||
|
||||
zoom = ceilf(width / 1000.f);
|
||||
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -475,20 +495,10 @@ void App::init()
|
||||
initAssets();
|
||||
initLayout();
|
||||
|
||||
//int n;
|
||||
//glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
//for (int i = 0; i < n; i++)
|
||||
//{
|
||||
// const unsigned char* s = glGetStringi(GL_EXTENSIONS, i);
|
||||
// LOG("GL ext %03d: %s\n", i, s);
|
||||
//}
|
||||
LOG("GL version: %s\n", glGetString(GL_VERSION));
|
||||
LOG("GL vendor: %s\n", glGetString(GL_VENDOR));
|
||||
LOG("GL renderer: %s\n", glGetString(GL_RENDERER));
|
||||
|
||||
GLfloat width_range[2];
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, width_range);
|
||||
LOG("GL line range: %f - %f\n", width_range[0], width_range[1]);
|
||||
LOG("GL line range: %f - %f", width_range[0], width_range[1]);
|
||||
LOG("Screen Size: %f %f", width, height);
|
||||
}
|
||||
|
||||
@@ -540,7 +550,7 @@ bool App::mouse_down(int button, float x, float y)
|
||||
e.m_type = button ? kEventType::MouseDownR : kEventType::MouseDownL;
|
||||
e.m_pos = { x / zoom, y / zoom };
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
LOG("mouse click button%d pos %f %f\n", button, x, y);
|
||||
LOG("mouse click button%d pos %f %f", button, x, y);
|
||||
|
||||
// if (popup)
|
||||
// {
|
||||
@@ -574,7 +584,7 @@ bool App::mouse_up(int button, float x, float y)
|
||||
e.m_pos = { x / zoom, y / zoom };
|
||||
auto ret = layout[main_id]->on_event(&e);
|
||||
layout[main_id]->update();
|
||||
LOG("mouse up button%d pos %f %f\n", button, x, y);
|
||||
LOG("mouse up button%d pos %f %f", button, x, y);
|
||||
return ret == kEventResult::Consumed;
|
||||
}
|
||||
bool App::key_down(int key)
|
||||
|
||||
Reference in New Issue
Block a user