finished switching over linux logging
This commit is contained in:
parent
9491068bfe
commit
b8107e74df
|
@ -105,7 +105,7 @@ open_all_files_with_extension_internal(Application_Links *app, String dir, char
|
|||
for (uint32_t i = 0; i < list.count; ++i){
|
||||
File_Info *info = list.infos + i;
|
||||
if (info->folder){
|
||||
if (recursive){
|
||||
if (recursive && info->filename[0] != '.'){
|
||||
dir.size = dir_size;
|
||||
append(&dir, info->filename);
|
||||
append(&dir, "/");
|
||||
|
|
|
@ -399,7 +399,7 @@ Sys_CLI_Call_Sig(system_cli_call){
|
|||
if (chdir(path) == -1){
|
||||
perror("system_cli_call: chdir");
|
||||
exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
char* argv[] = { "sh", "-c", script_name, NULL };
|
||||
|
||||
|
@ -852,7 +852,7 @@ LinuxLoadAppCode(String* base_dir){
|
|||
get_funcs = (App_Get_Functions*)
|
||||
dlsym(linuxvars.app_code, "app_get_functions");
|
||||
} else {
|
||||
fprintf(stderr, "dlopen failed: %s\n", dlerror());
|
||||
LOGF("dlopen failed: %s\n", dlerror());
|
||||
}
|
||||
|
||||
if (get_funcs){
|
||||
|
@ -979,7 +979,7 @@ GLsizei length,
|
|||
const GLchar* message,
|
||||
const void* userParam
|
||||
){
|
||||
fprintf(stderr, "GL DEBUG: %s\n", message);
|
||||
LOGF("GL DEBUG: %s\n", message);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1008,7 +1008,7 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
|
||||
if (!glXCreateContextAttribsARB)
|
||||
{
|
||||
fprintf(stderr, "glXCreateContextAttribsARB() not found, using old-style GLX context\n" );
|
||||
LOG("glXCreateContextAttribsARB() not found, using old-style GLX context\n" );
|
||||
ctx = glXCreateNewContext( XDisplay, bestFbc, GLX_RGBA_TYPE, 0, True );
|
||||
}
|
||||
else
|
||||
|
@ -1024,13 +1024,13 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
None
|
||||
};
|
||||
|
||||
fprintf(stderr, "Creating GL 4.3 context...\n");
|
||||
LOG("Creating GL 4.3 context...\n");
|
||||
ctx = glXCreateContextAttribsARB(XDisplay, bestFbc, 0, True, context_attribs);
|
||||
|
||||
XSync( XDisplay, False );
|
||||
if (!ctxErrorOccurred && ctx)
|
||||
{
|
||||
fprintf(stderr, "Created GL 4.3 context.\n" );
|
||||
LOG("Created GL 4.3 context.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1039,14 +1039,14 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
context_attribs[1] = 3;
|
||||
context_attribs[3] = 2;
|
||||
|
||||
fprintf(stderr, "GL 4.3 unavailable, creating GL 3.2 context...\n" );
|
||||
LOG("GL 4.3 unavailable, creating GL 3.2 context...\n" );
|
||||
ctx = glXCreateContextAttribsARB( XDisplay, bestFbc, 0, True, context_attribs );
|
||||
|
||||
XSync(XDisplay, False);
|
||||
|
||||
if (!ctxErrorOccurred && ctx)
|
||||
{
|
||||
fprintf(stderr, "Created GL 3.2 context.\n" );
|
||||
LOG("Created GL 3.2 context.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1055,7 +1055,7 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
|
||||
ctxErrorOccurred = false;
|
||||
|
||||
fprintf(stderr, "Failed to create GL 3.2 context, using old-style GLX context\n");
|
||||
LOG("Failed to create GL 3.2 context, using old-style GLX context\n");
|
||||
ctx = glXCreateContextAttribsARB(XDisplay, bestFbc, 0, True, context_attribs);
|
||||
|
||||
IsLegacy = true;
|
||||
|
@ -1066,25 +1066,23 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
XSync(XDisplay, False);
|
||||
XSetErrorHandler(oldHandler);
|
||||
|
||||
if (ctxErrorOccurred || !ctx)
|
||||
{
|
||||
fprintf(stderr, "Failed to create an OpenGL context\n");
|
||||
if (ctxErrorOccurred || !ctx){
|
||||
LOG("Failed to create an OpenGL context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
b32 Direct;
|
||||
if (!glXIsDirect(XDisplay, ctx))
|
||||
{
|
||||
fprintf(stderr, "Indirect GLX rendering context obtained\n");
|
||||
Direct = 0;
|
||||
LOG("Indirect GLX rendering context obtained\n");
|
||||
Direct = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Direct GLX rendering context obtained\n");
|
||||
Direct = 1;
|
||||
else{
|
||||
LOG("Direct GLX rendering context obtained\n");
|
||||
Direct = true;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Making context current\n");
|
||||
LOG("Making context current\n");
|
||||
glXMakeCurrent( XDisplay, XWindow, ctx );
|
||||
|
||||
char *Vendor = (char *)glGetString(GL_VENDOR);
|
||||
|
@ -1094,14 +1092,12 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
//TODO(inso): glGetStringi is required in core profile if the GL version is >= 3.0
|
||||
char *Extensions = (char *)glGetString(GL_EXTENSIONS);
|
||||
|
||||
fprintf(stderr, "GL_VENDOR: %s\n", Vendor);
|
||||
fprintf(stderr, "GL_RENDERER: %s\n", Renderer);
|
||||
fprintf(stderr, "GL_VERSION: %s\n", Version);
|
||||
// fprintf(stderr, "GL_EXTENSIONS: %s\n", Extensions);
|
||||
LOGF("GL_VENDOR: %s\n", Vendor);
|
||||
LOGF("GL_RENDERER: %s\n", Renderer);
|
||||
LOGF("GL_VERSION: %s\n", Version);
|
||||
|
||||
//NOTE(inso): enable vsync if available. this should probably be optional
|
||||
if (Direct && strstr(glxExts, "GLX_EXT_swap_control ")){
|
||||
|
||||
GLXLOAD(glXSwapIntervalEXT);
|
||||
|
||||
if (glXSwapIntervalEXT){
|
||||
|
@ -1111,10 +1107,11 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
glXQueryDrawable(XDisplay, XWindow, GLX_SWAP_INTERVAL_EXT, &swap_val);
|
||||
|
||||
linuxvars.vsync = swap_val == 1;
|
||||
fprintf(stderr, "VSync enabled? %s.\n", linuxvars.vsync ? "Yes" : "No");
|
||||
LOGF("VSync enabled? %s.\n", linuxvars.vsync ? "Yes" : "No");
|
||||
}
|
||||
|
||||
} else if(Direct && strstr(glxExts, "GLX_MESA_swap_control ")){
|
||||
}
|
||||
else if (Direct && strstr(glxExts, "GLX_MESA_swap_control ")){
|
||||
|
||||
GLXLOAD(glXSwapIntervalMESA);
|
||||
GLXLOAD(glXGetSwapIntervalMESA);
|
||||
|
@ -1124,15 +1121,16 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
|
||||
if (glXGetSwapIntervalMESA){
|
||||
linuxvars.vsync = glXGetSwapIntervalMESA();
|
||||
fprintf(stderr, "VSync enabled? %s (MESA)\n", linuxvars.vsync ? "Yes" : "No");
|
||||
LOGF("VSync enabled? %s (MESA)\n", linuxvars.vsync ? "Yes" : "No");
|
||||
} else {
|
||||
// NOTE(inso): assume it worked?
|
||||
linuxvars.vsync = 1;
|
||||
fputs("VSync enabled? possibly (MESA)\n", stderr);
|
||||
LOG("VSync enabled? possibly (MESA)\n");
|
||||
}
|
||||
}
|
||||
|
||||
} else if(Direct && strstr(glxExts, "GLX_SGI_swap_control ")){
|
||||
}
|
||||
else if (Direct && strstr(glxExts, "GLX_SGI_swap_control ")){
|
||||
|
||||
GLXLOAD(glXSwapIntervalSGI);
|
||||
|
||||
|
@ -1141,11 +1139,12 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
|
||||
//NOTE(inso): The SGI one doesn't seem to have a way to confirm we got it...
|
||||
linuxvars.vsync = 1;
|
||||
fputs("VSync enabled? hopefully (SGI)\n", stderr);
|
||||
LOG("VSync enabled? hopefully (SGI)\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
fputs("VSync enabled? nope, no suitable extension\n", stderr);
|
||||
}
|
||||
else{
|
||||
LOG("VSync enabled? nope, no suitable extension\n");
|
||||
}
|
||||
|
||||
#if FRED_INTERNAL
|
||||
|
@ -1154,7 +1153,7 @@ InitializeOpenGLContext(Display *XDisplay, Window XWindow, GLXFBConfig &bestFbc,
|
|||
GLXLOAD(glDebugMessageCallback);
|
||||
|
||||
if (glDebugMessageCallback){
|
||||
fputs("Enabling GL Debug Callback\n", stderr);
|
||||
LOG("Enabling GL Debug Callback\n");
|
||||
glDebugMessageCallback(&LinuxGLDebugCallback, 0);
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
}
|
||||
|
@ -1178,10 +1177,10 @@ GLXCanUseFBConfig(Display *XDisplay)
|
|||
int GLXMajor, GLXMinor;
|
||||
|
||||
char *XVendor = ServerVendor(XDisplay);
|
||||
fprintf(stderr, "XWindows vendor: %s\n", XVendor);
|
||||
LOGF("XWindows vendor: %s\n", XVendor);
|
||||
if (glXQueryVersion(XDisplay, &GLXMajor, &GLXMinor))
|
||||
{
|
||||
fprintf(stderr, "GLX version %d.%d\n", GLXMajor, GLXMinor);
|
||||
LOGF("GLX version %d.%d\n", GLXMajor, GLXMinor);
|
||||
if (((GLXMajor == 1 ) && (GLXMinor >= 3)) || (GLXMajor > 1))
|
||||
{
|
||||
Result = true;
|
||||
|
@ -1236,7 +1235,7 @@ ChooseGLXConfig(Display *XDisplay, int XScreenIndex)
|
|||
|
||||
int id = 0;
|
||||
glXGetFBConfigAttrib(XDisplay, Result.BestConfig, GLX_FBCONFIG_ID, &id);
|
||||
fprintf(stderr, "Using FBConfig: %d (0x%x)\n", id, id);
|
||||
LOGF("Using FBConfig: %d (0x%x)\n", id, id);
|
||||
|
||||
XFree(VI);
|
||||
}
|
||||
|
@ -1268,12 +1267,12 @@ LinuxInputInit(Display *dpy, Window XWindow){
|
|||
setlocale(LC_ALL, "");
|
||||
XSetLocaleModifiers("");
|
||||
b32 locale_supported = XSupportsLocale();
|
||||
fprintf(stderr, "Supported locale?: %s.\n", locale_supported ? "Yes" : "No");
|
||||
LOGF("Supported locale?: %s.\n", locale_supported ? "Yes" : "No");
|
||||
if (!locale_supported){
|
||||
fprintf(stderr, "Reverting to 'C' ... ");
|
||||
LOG("Reverting to 'C' ... ");
|
||||
setlocale(LC_ALL, "C");
|
||||
locale_supported = XSupportsLocale();
|
||||
fprintf(stderr, "C is supported? %s.\n", locale_supported ? "Yes" : "No");
|
||||
LOGF("C is supported? %s.\n", locale_supported ? "Yes" : "No");
|
||||
}
|
||||
|
||||
result.input_method = XOpenIM(dpy, 0, 0, 0);
|
||||
|
@ -1307,13 +1306,13 @@ LinuxInputInit(Display *dpy, Window XWindow){
|
|||
}
|
||||
else{
|
||||
result = null_init_input_result;
|
||||
fputs("Could not get minimum required input style.\n", stderr);
|
||||
LOG("Could not get minimum required input style.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
result = null_init_input_result;
|
||||
fprintf(stderr, "Could not open X Input Method.\n");
|
||||
LOG("Could not open X Input Method.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1543,7 +1542,7 @@ LinuxX11ConnectionWatch(Display* dpy, XPointer cdata, int fd, Bool opening, XPoi
|
|||
internal void
|
||||
LinuxFatalErrorMsg(const char* msg)
|
||||
{
|
||||
fprintf(stderr, "Fatal Error: %s\n", msg);
|
||||
LOGF("Fatal Error: %s\n", msg);
|
||||
|
||||
Display *dpy = XOpenDisplay(0);
|
||||
if (!dpy){
|
||||
|
@ -1748,8 +1747,8 @@ LinuxGetXSettingsDPI(Display* dpy, int screen)
|
|||
Atom XSET_SET = XInternAtom(dpy, "_XSETTINGS_SETTINGS", True);
|
||||
|
||||
if (XSET_SEL == None || XSET_SET == None){
|
||||
fputs("XSETTINGS unavailable.\n", stderr);
|
||||
return dpi;
|
||||
LOG("XSETTINGS unavailable.\n");
|
||||
return(dpi);
|
||||
}
|
||||
|
||||
Window xset_win = XGetSelectionOwner(dpy, XSET_SEL);
|
||||
|
@ -1765,12 +1764,12 @@ LinuxGetXSettingsDPI(Display* dpy, int screen)
|
|||
unsigned long pad, num;
|
||||
|
||||
if (XGetWindowProperty(dpy, xset_win, XSET_SET, 0, 1024, False, XSET_SET, &type, &fmt, &num, &pad, &prop) != Success){
|
||||
fputs("XSETTINGS: GetWindowProperty failed.\n", stderr);
|
||||
LOG("XSETTINGS: GetWindowProperty failed.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fmt != 8){
|
||||
fputs("XSETTINGS: Wrong format.\n", stderr);
|
||||
LOG("XSETTINGS: Wrong format.\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -1779,16 +1778,13 @@ LinuxGetXSettingsDPI(Display* dpy, int screen)
|
|||
p = (char*)(xs + 1);
|
||||
|
||||
if (xs->byte_order != 0){
|
||||
fputs("FIXME: XSETTINGS not host byte order?\n", stderr);
|
||||
LOG("FIXME: XSETTINGS not host byte order?\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (int i = 0; i < xs->num_settings; ++i){
|
||||
struct XSettingHeader* h = (struct XSettingHeader*)p;
|
||||
|
||||
// const char* strs[] = { "Int", "String", "Color" };
|
||||
// printf("%s:\t\"%.*s\"\n", strs[h->type], h->name_len, h->name);
|
||||
|
||||
p += sizeof(struct XSettingHeader);
|
||||
p += h->name_len;
|
||||
p += ((4 - (h->name_len & 3)) & 3);
|
||||
|
@ -1815,7 +1811,7 @@ LinuxGetXSettingsDPI(Display* dpy, int screen)
|
|||
} break;
|
||||
|
||||
default: {
|
||||
fputs("XSETTINGS: Got invalid type...\n", stderr);
|
||||
LOG("XSETTINGS: Got invalid type...\n");
|
||||
goto out;
|
||||
} break;
|
||||
}
|
||||
|
@ -2020,7 +2016,7 @@ LinuxHandleX11Events(void)
|
|||
//TODO(inso): handle properly
|
||||
Xutf8ResetIC(linuxvars.input_context);
|
||||
XSetICFocus(linuxvars.input_context);
|
||||
fputs("FIXME: XBufferOverflow from LookupString.\n", stderr);
|
||||
LOG("FIXME: XBufferOverflow from LookupString.\n");
|
||||
}
|
||||
|
||||
u32 key = utf8_to_u32_unchecked(buff);
|
||||
|
@ -2343,8 +2339,7 @@ main(int argc, char **argv){
|
|||
output_size = linuxvars.app.read_command_line(&linuxvars.system, &memory_vars, current_directory, &linuxvars.settings, &files, &file_count, clparams);
|
||||
|
||||
if (output_size > 0){
|
||||
// TODO(allen): crt free version
|
||||
fprintf(stdout, "%.*s", output_size, (char*)memory_vars.target_memory);
|
||||
LOGF("%.*s", output_size, (char*)memory_vars.target_memory);
|
||||
}
|
||||
if (output_size != 0){
|
||||
LinuxFatalErrorMsg("Error reading command-line arguments.");
|
||||
|
@ -2399,7 +2394,7 @@ main(int argc, char **argv){
|
|||
exit(1);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "Successfully loaded custom_4coder.so\n");
|
||||
LOG("Successfully loaded custom_4coder.so\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2472,8 +2467,8 @@ main(int argc, char **argv){
|
|||
linuxvars.XDisplay = XOpenDisplay(0);
|
||||
if (!linuxvars.XDisplay){
|
||||
// NOTE(inso): probably not worth trying the popup in this case...
|
||||
fprintf(stderr, "Can't open display!\n");
|
||||
return 1;
|
||||
LOG("Can't open display!\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
#define LOAD_ATOM(x) linuxvars.atom_##x = XInternAtom(linuxvars.XDisplay, #x, False);
|
||||
|
@ -2508,10 +2503,10 @@ main(int argc, char **argv){
|
|||
linuxvars.dpi_x = dw_mm ? dw / (dw_mm / 25.4) : 96;
|
||||
linuxvars.dpi_y = dh_mm ? dh / (dh_mm / 25.4) : 96;
|
||||
|
||||
fprintf(stderr, "%dx%d - %dmmx%dmm DPI: %dx%d\n", dw, dh, dw_mm, dh_mm, linuxvars.dpi_x, linuxvars.dpi_y);
|
||||
LOGF("%dx%d - %dmmx%dmm DPI: %dx%d\n", dw, dh, dw_mm, dh_mm, linuxvars.dpi_x, linuxvars.dpi_y);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "DPI from XSETTINGS: %d\n", linuxvars.dpi_x);
|
||||
LOGF("DPI from XSETTINGS: %d\n", linuxvars.dpi_x);
|
||||
}
|
||||
|
||||
int window_width, window_height;
|
||||
|
@ -2527,7 +2522,7 @@ main(int argc, char **argv){
|
|||
XFixesSelectSelectionInput(linuxvars.XDisplay, linuxvars.XWindow, linuxvars.atom_CLIPBOARD, XFixesSetSelectionOwnerNotifyMask);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "Your X server doesn't support XFIXES, mention this fact if you report any clipboard-related issues.\n");
|
||||
LOG("Your X server doesn't support XFIXES, mention this fact if you report any clipboard-related issues.\n");
|
||||
}
|
||||
|
||||
Init_Input_Result input_result = LinuxInputInit(linuxvars.XDisplay, linuxvars.XWindow);
|
||||
|
@ -2624,7 +2619,7 @@ main(int argc, char **argv){
|
|||
|
||||
if (num_events == -1){
|
||||
if (errno != EINTR){
|
||||
fprintf(stderr, "epoll_wait\n");
|
||||
LOG("epoll_wait\n");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -2737,7 +2732,9 @@ main(int argc, char **argv){
|
|||
}
|
||||
|
||||
if (linuxvars.XDisplay){
|
||||
if(linuxvars.XWindow) XDestroyWindow(linuxvars.XDisplay, linuxvars.XWindow);
|
||||
if (linuxvars.XWindow){
|
||||
XDestroyWindow(linuxvars.XDisplay, linuxvars.XWindow);
|
||||
}
|
||||
XCloseDisplay(linuxvars.XDisplay);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue