mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-18 10:02:23 -07:00
egl/glx work; eliminate unneeded path normalization paths; do not assume os current path when normalizing paths; gl synchronous debug strings
This commit is contained in:
+74
-50
@@ -1226,40 +1226,51 @@ str8_from_version(Arena *arena, U64 version)
|
||||
//~ rjf: String Path Helpers
|
||||
|
||||
internal String8
|
||||
str8_chop_last_slash(String8 string){
|
||||
if (string.size > 0){
|
||||
str8_chop_last_slash(String8 string)
|
||||
{
|
||||
if(string.size > 0)
|
||||
{
|
||||
U8 *ptr = string.str + string.size - 1;
|
||||
for (;ptr >= string.str; ptr -= 1){
|
||||
if (*ptr == '/' || *ptr == '\\'){
|
||||
for(;ptr >= string.str; ptr -= 1)
|
||||
{
|
||||
if(*ptr == '/' || *ptr == '\\')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ptr >= string.str){
|
||||
if(ptr >= string.str)
|
||||
{
|
||||
string.size = (U64)(ptr - string.str);
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
string.size = 0;
|
||||
}
|
||||
}
|
||||
return(string);
|
||||
return string;
|
||||
}
|
||||
|
||||
internal String8
|
||||
str8_skip_last_slash(String8 string){
|
||||
if (string.size > 0){
|
||||
str8_skip_last_slash(String8 string)
|
||||
{
|
||||
if(string.size > 0)
|
||||
{
|
||||
U8 *ptr = string.str + string.size - 1;
|
||||
for (;ptr >= string.str; ptr -= 1){
|
||||
if (*ptr == '/' || *ptr == '\\'){
|
||||
for(;ptr >= string.str; ptr -= 1)
|
||||
{
|
||||
if(*ptr == '/' || *ptr == '\\')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ptr >= string.str){
|
||||
if(ptr >= string.str)
|
||||
{
|
||||
ptr += 1;
|
||||
string.size = (U64)(string.str + string.size - ptr);
|
||||
string.str = ptr;
|
||||
}
|
||||
}
|
||||
return(string);
|
||||
return string;
|
||||
}
|
||||
|
||||
internal String8
|
||||
@@ -1267,80 +1278,94 @@ str8_chop_last_dot(String8 string)
|
||||
{
|
||||
String8 result = string;
|
||||
U64 p = string.size;
|
||||
for (;p > 0;){
|
||||
for(;p > 0;)
|
||||
{
|
||||
p -= 1;
|
||||
if (string.str[p] == '.'){
|
||||
if(string.str[p] == '.')
|
||||
{
|
||||
result = str8_prefix(string, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
str8_skip_last_dot(String8 string){
|
||||
str8_skip_last_dot(String8 string)
|
||||
{
|
||||
String8 result = string;
|
||||
U64 p = string.size;
|
||||
for (;p > 0;){
|
||||
for(;p > 0;)
|
||||
{
|
||||
p -= 1;
|
||||
if (string.str[p] == '.'){
|
||||
if(string.str[p] == '.')
|
||||
{
|
||||
result = str8_skip(string, p + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal PathStyle
|
||||
path_style_from_str8(String8 string){
|
||||
path_style_from_str8(String8 string)
|
||||
{
|
||||
PathStyle result = PathStyle_Relative;
|
||||
if (string.size >= 1 && string.str[0] == '/'){
|
||||
if(string.size >= 1 && string.str[0] == '/')
|
||||
{
|
||||
result = PathStyle_UnixAbsolute;
|
||||
}
|
||||
else if (string.size >= 2 &&
|
||||
char_is_alpha(string.str[0]) &&
|
||||
string.str[1] == ':'){
|
||||
if (string.size == 2 ||
|
||||
char_is_slash(string.str[2])){
|
||||
else if(string.size >= 2 &&
|
||||
char_is_alpha(string.str[0]) &&
|
||||
string.str[1] == ':')
|
||||
{
|
||||
if(string.size == 2 || char_is_slash(string.str[2]))
|
||||
{
|
||||
result = PathStyle_WindowsAbsolute;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8List
|
||||
str8_split_path(Arena *arena, String8 string){
|
||||
str8_split_path(Arena *arena, String8 string)
|
||||
{
|
||||
String8List result = str8_split(arena, string, (U8*)"/\\", 2, 0);
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style){
|
||||
str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
String8MetaNode *stack = 0;
|
||||
String8MetaNode *free_meta_node = 0;
|
||||
String8Node *first = path->first;
|
||||
|
||||
MemoryZeroStruct(path);
|
||||
for (String8Node *node = first, *next = 0;
|
||||
node != 0;
|
||||
node = next){
|
||||
for(String8Node *node = first, *next = 0;
|
||||
node != 0;
|
||||
node = next)
|
||||
{
|
||||
// save next now
|
||||
next = node->next;
|
||||
|
||||
// cases:
|
||||
if (node == first && style == PathStyle_WindowsAbsolute){
|
||||
if(node == first && style == PathStyle_WindowsAbsolute)
|
||||
{
|
||||
goto save_without_stack;
|
||||
}
|
||||
if (node->string.size == 1 && node->string.str[0] == '.'){
|
||||
if(node->string.size == 1 && node->string.str[0] == '.')
|
||||
{
|
||||
goto do_nothing;
|
||||
}
|
||||
if (node->string.size == 2 && node->string.str[0] == '.' && node->string.str[1] == '.'){
|
||||
if (stack != 0){
|
||||
if(node->string.size == 2 && node->string.str[0] == '.' && node->string.str[1] == '.')
|
||||
{
|
||||
if(stack != 0)
|
||||
{
|
||||
goto eliminate_stack_top;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
goto save_without_stack;
|
||||
}
|
||||
}
|
||||
@@ -1351,24 +1376,23 @@ str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style){
|
||||
save_with_stack:
|
||||
{
|
||||
str8_list_push_node(path, node);
|
||||
|
||||
String8MetaNode *stack_node = free_meta_node;
|
||||
if (stack_node != 0){
|
||||
if(stack_node != 0)
|
||||
{
|
||||
SLLStackPop(free_meta_node);
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
stack_node = push_array_no_zero(scratch.arena, String8MetaNode, 1);
|
||||
}
|
||||
SLLStackPush(stack, stack_node);
|
||||
stack_node->node = node;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
save_without_stack:
|
||||
{
|
||||
str8_list_push_node(path, node);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1376,13 +1400,13 @@ str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style){
|
||||
{
|
||||
path->node_count -= 1;
|
||||
path->total_size -= stack->node->string.size;
|
||||
|
||||
SLLStackPop(stack);
|
||||
|
||||
if (stack == 0){
|
||||
if(stack == 0)
|
||||
{
|
||||
path->last = path->first;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
path->last = stack->node;
|
||||
}
|
||||
continue;
|
||||
|
||||
+15
-1
@@ -96,7 +96,7 @@ typedef enum PathStyle
|
||||
#elif OS_LINUX
|
||||
PathStyle_SystemAbsolute = PathStyle_UnixAbsolute
|
||||
#else
|
||||
# error "absolute path style is undefined for this OS"
|
||||
# error Absolute path style is undefined for this OS.
|
||||
#endif
|
||||
}
|
||||
PathStyle;
|
||||
@@ -302,6 +302,20 @@ internal String8 str8_from_version(Arena *arena, U64 version);
|
||||
////////////////////////////////
|
||||
//~ rjf: String Path Helpers
|
||||
|
||||
global read_only struct
|
||||
{
|
||||
String8 string;
|
||||
PathStyle path_style;
|
||||
}
|
||||
g_path_style_map[] =
|
||||
{
|
||||
{ str8_lit_comp(""), PathStyle_Null },
|
||||
{ str8_lit_comp("relative"), PathStyle_Relative },
|
||||
{ str8_lit_comp("windows"), PathStyle_WindowsAbsolute },
|
||||
{ str8_lit_comp("unix"), PathStyle_UnixAbsolute },
|
||||
{ str8_lit_comp("system"), PathStyle_SystemAbsolute },
|
||||
};
|
||||
|
||||
internal String8 str8_chop_last_slash(String8 string);
|
||||
internal String8 str8_skip_last_slash(String8 string);
|
||||
internal String8 str8_chop_last_dot(String8 string);
|
||||
|
||||
@@ -3989,7 +3989,7 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
||||
FileProperties props = os_properties_from_file_path(candidate_path);
|
||||
if(props.modified != 0 && props.size != 0)
|
||||
{
|
||||
initial_debug_info_path = push_str8_copy(arena, candidate_path);
|
||||
initial_debug_info_path = push_str8_copy(arena, path_normalized_from_string(scratch.arena, candidate_path));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ os_file_iter_begin(Arena *arena, String8 path, OS_FileIterFlags flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
w32_iter->handle = FindFirstFileW((WCHAR*)path16.str, &w32_iter->find_data);
|
||||
w32_iter->handle = FindFirstFileExW((WCHAR*)path16.str, FindExInfoBasic, &w32_iter->find_data, FindExSearchNameMatch, 0, FIND_FIRST_EX_LARGE_FETCH);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return iter;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Prototypes (which seem to sometimes be missing)
|
||||
|
||||
int XLookupString(XKeyEvent *event_struct, char *buffer_return, int bytes_buffer, KeySym *keysym_return, XComposeStatus *status_in_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Helpers
|
||||
|
||||
@@ -41,6 +36,9 @@ os_gfx_init(void)
|
||||
os_lnx_gfx_state->wm_sync_request_atom = XInternAtom(os_lnx_gfx_state->display, "_NET_WM_SYNC_REQUEST", 0);
|
||||
os_lnx_gfx_state->wm_sync_request_counter_atom = XInternAtom(os_lnx_gfx_state->display, "_NET_WM_SYNC_REQUEST_COUNTER", 0);
|
||||
|
||||
//- rjf: open im
|
||||
os_lnx_gfx_state->xim = XOpenIM(os_lnx_gfx_state->display, 0, 0, 0);
|
||||
|
||||
//- rjf: fill out gfx info
|
||||
os_lnx_gfx_state->gfx_info.double_click_time = 0.5f;
|
||||
os_lnx_gfx_state->gfx_info.caret_blink_time = 0.5f;
|
||||
@@ -149,6 +147,13 @@ os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title)
|
||||
}
|
||||
XChangeProperty(os_lnx_gfx_state->display, w->window, os_lnx_gfx_state->wm_sync_request_counter_atom, XA_CARDINAL, 32, PropModeReplace, (U8 *)&w->counter_xid, 1);
|
||||
|
||||
//- rjf: create xic
|
||||
w->xic = XCreateIC(os_lnx_gfx_state->xim,
|
||||
XNInputStyle, XIMPreeditNothing|XIMStatusNothing,
|
||||
XNClientWindow, w->window,
|
||||
XNFocusWindow, w->window,
|
||||
NULL);
|
||||
|
||||
//- rjf: attach name
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String8 title_copy = push_str8_copy(scratch.arena, title);
|
||||
@@ -399,9 +404,10 @@ os_get_events(Arena *arena, B32 wait)
|
||||
if(evt.xkey.state & Mod1Mask) { modifiers |= OS_Modifier_Alt; }
|
||||
|
||||
// rjf: map keycode -> keysym & codepoint
|
||||
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xkey.window);
|
||||
KeySym keysym = 0;
|
||||
U8 text[256] = {0};
|
||||
U64 text_size = XLookupString(&evt.xkey, (char *)text, sizeof(text), &keysym, 0);
|
||||
U64 text_size = Xutf8LookupString(window->xic, &evt.xkey, (char *)text, sizeof(text), &keysym, 0);
|
||||
|
||||
// rjf: map keysym -> OS_Key
|
||||
B32 is_right_sided = 0;
|
||||
@@ -475,7 +481,6 @@ os_get_events(Arena *arena, B32 wait)
|
||||
}
|
||||
|
||||
// rjf: push text event
|
||||
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xkey.window);
|
||||
if(evt.type == KeyPress && text_size != 0)
|
||||
{
|
||||
for(U64 off = 0; off < text_size;)
|
||||
|
||||
@@ -23,6 +23,7 @@ struct OS_LNX_Window
|
||||
OS_LNX_Window *next;
|
||||
OS_LNX_Window *prev;
|
||||
Window window;
|
||||
XIC xic;
|
||||
XID counter_xid;
|
||||
U64 counter_value;
|
||||
};
|
||||
@@ -35,6 +36,7 @@ struct OS_LNX_GfxState
|
||||
{
|
||||
Arena *arena;
|
||||
Display *display;
|
||||
XIM xim;
|
||||
OS_LNX_Window *first_window;
|
||||
OS_LNX_Window *last_window;
|
||||
OS_LNX_Window *free_window;
|
||||
|
||||
@@ -95,6 +95,7 @@ os_w32_window_release(OS_W32_Window *window)
|
||||
{
|
||||
arena_release(window->paint_arena);
|
||||
}
|
||||
ReleaseDC(window->hwnd, window->hdc);
|
||||
DestroyWindow(window->hwnd);
|
||||
DLLRemove(os_w32_gfx_state->first_window, os_w32_gfx_state->last_window, window);
|
||||
SLLStackPush(os_w32_gfx_state->free_window, window);
|
||||
@@ -1056,6 +1057,7 @@ os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title)
|
||||
OS_W32_Window *window = os_w32_window_alloc();
|
||||
{
|
||||
window->hwnd = hwnd;
|
||||
window->hdc = GetDC(hwnd);
|
||||
if(w32_GetDpiForWindow_func != 0)
|
||||
{
|
||||
window->dpi = (F32)w32_GetDpiForWindow_func(hwnd);
|
||||
|
||||
@@ -38,6 +38,7 @@ struct OS_W32_Window
|
||||
OS_W32_Window *next;
|
||||
OS_W32_Window *prev;
|
||||
HWND hwnd;
|
||||
HDC hdc;
|
||||
WINDOWPLACEMENT last_window_placement;
|
||||
F32 dpi;
|
||||
B32 first_paint_done;
|
||||
|
||||
+45
-64
@@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Relative <-> Absolute Path
|
||||
|
||||
internal String8
|
||||
path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src)
|
||||
{
|
||||
@@ -8,7 +11,7 @@ path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src)
|
||||
|
||||
// rjf: gather path parts
|
||||
String8 dst_name = str8_skip_last_slash(dst);
|
||||
String8 src_folder = str8_chop_last_slash(src);
|
||||
String8 src_folder = src;
|
||||
String8 dst_folder = str8_chop_last_slash(dst);
|
||||
String8List src_folders = str8_split_path(scratch.arena, src_folder);
|
||||
String8List dst_folders = str8_split_path(scratch.arena, dst_folder);
|
||||
@@ -35,7 +38,7 @@ path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src)
|
||||
String8 dst_path = {0};
|
||||
if(num_backtracks >= src_folders.node_count)
|
||||
{
|
||||
dst_path = path_normalized_from_string(arena, dst);
|
||||
dst_path = dst;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,54 +93,43 @@ path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src)
|
||||
if(dst_style == PathStyle_Relative)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 dst_from_src_absolute = push_str8f(scratch.arena, "%S/%S", str8_chop_last_slash(src), dst);
|
||||
String8 dst_from_src_absolute_normalized = path_normalized_from_string(arena, dst_from_src_absolute);
|
||||
result = dst_from_src_absolute_normalized;
|
||||
String8 dst_from_src_absolute = push_str8f(scratch.arena, "%S/%S", src, dst);
|
||||
String8List dst_from_src_absolute_parts = str8_split_path(scratch.arena, dst_from_src_absolute);
|
||||
PathStyle dst_from_src_absolute_style = path_style_from_str8(src);
|
||||
str8_path_list_resolve_dots_in_place(&dst_from_src_absolute_parts, dst_from_src_absolute_style);
|
||||
result = str8_path_list_join_by_style(arena, &dst_from_src_absolute_parts, dst_from_src_absolute_style);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Path Normalization
|
||||
|
||||
internal String8List
|
||||
path_normalized_list_from_string(Arena *arena, String8 path_string, PathStyle *style_out)
|
||||
{
|
||||
// analyze path
|
||||
// rjf: analyze path
|
||||
PathStyle path_style = path_style_from_str8(path_string);
|
||||
String8List path = str8_split_path(arena, path_string);
|
||||
|
||||
// prepend current path to convert relative -> absolute
|
||||
PathStyle path_style_full = path_style;
|
||||
if(path.node_count != 0 && path_style == PathStyle_Relative)
|
||||
{
|
||||
String8 current_path_string = os_get_current_path(arena);
|
||||
|
||||
PathStyle current_path_style = path_style_from_str8(current_path_string);
|
||||
Assert(current_path_style != PathStyle_Relative);
|
||||
|
||||
String8List current_path = str8_split_path(arena, current_path_string);
|
||||
str8_list_concat_in_place(¤t_path, &path);
|
||||
path = current_path;
|
||||
path_style_full = current_path_style;
|
||||
}
|
||||
// rjf: resolve dots
|
||||
str8_path_list_resolve_dots_in_place(&path, path_style);
|
||||
|
||||
// resolve dots
|
||||
str8_path_list_resolve_dots_in_place(&path, path_style_full);
|
||||
|
||||
// return
|
||||
// rjf: return
|
||||
if(style_out != 0)
|
||||
{
|
||||
*style_out = path_style_full;
|
||||
*style_out = path_style;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
internal String8
|
||||
path_normalized_from_string(Arena *arena, String8 path_string){
|
||||
path_normalized_from_string(Arena *arena, String8 path_string)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
PathStyle style = PathStyle_Relative;
|
||||
String8List path = path_normalized_list_from_string(scratch.arena, path_string, &style);
|
||||
|
||||
String8 result = str8_path_list_join_by_style(arena, &path, style);
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
@@ -154,8 +146,31 @@ path_match_normalized(String8 left, String8 right)
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helpers
|
||||
|
||||
internal PathStyle
|
||||
path_style_from_string(String8 string)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_path_style_map); ++i)
|
||||
{
|
||||
if(str8_match(g_path_style_map[i].string, string, StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
return g_path_style_map[i].path_style;
|
||||
}
|
||||
}
|
||||
return PathStyle_Null;
|
||||
}
|
||||
|
||||
internal String8
|
||||
path_char_from_style(PathStyle style)
|
||||
string_from_path_style(PathStyle style)
|
||||
{
|
||||
Assert(style < ArrayCount(g_path_style_map));
|
||||
return g_path_style_map[style].string;
|
||||
}
|
||||
|
||||
internal String8
|
||||
path_separator_string_from_style(PathStyle style)
|
||||
{
|
||||
String8 result = str8_zero();
|
||||
switch (style)
|
||||
@@ -194,7 +209,7 @@ path_convert_slashes(Arena *arena, String8 path, PathStyle path_style)
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8List list = str8_split_path(scratch.arena, path);
|
||||
StringJoin join = {0};
|
||||
join.sep = path_char_from_style(path_style);
|
||||
join.sep = path_separator_string_from_style(path_style);
|
||||
String8 result = str8_list_join(arena, &list, &join);
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
@@ -207,37 +222,3 @@ path_replace_file_extension(Arena *arena, String8 file_name, String8 ext)
|
||||
String8 result = push_str8f(arena, "%S.%S", file_name_no_ext, ext);
|
||||
return result;
|
||||
}
|
||||
|
||||
global read_only struct
|
||||
{
|
||||
String8 string;
|
||||
PathStyle path_style;
|
||||
} g_path_style_map[] =
|
||||
{
|
||||
{ str8_lit_comp(""), PathStyle_Null },
|
||||
{ str8_lit_comp("relative"), PathStyle_Relative },
|
||||
{ str8_lit_comp("windows"), PathStyle_WindowsAbsolute },
|
||||
{ str8_lit_comp("unix"), PathStyle_UnixAbsolute },
|
||||
{ str8_lit_comp("system"), PathStyle_SystemAbsolute },
|
||||
};
|
||||
|
||||
internal PathStyle
|
||||
path_style_from_string(String8 string)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_path_style_map); ++i)
|
||||
{
|
||||
if(str8_match(g_path_style_map[i].string, string, StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
return g_path_style_map[i].path_style;
|
||||
}
|
||||
}
|
||||
return PathStyle_Null;
|
||||
}
|
||||
|
||||
internal String8
|
||||
path_string_from_style(PathStyle style)
|
||||
{
|
||||
Assert(style < ArrayCount(g_path_style_map));
|
||||
return g_path_style_map[style].string;
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -5,30 +5,26 @@
|
||||
#define PATH_H
|
||||
|
||||
////////////////////////////////
|
||||
// Relative <-> Absolute Path
|
||||
//~ rjf: Relative <-> Absolute Path
|
||||
|
||||
internal String8 path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src);
|
||||
internal String8 path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src);
|
||||
|
||||
////////////////////////////////
|
||||
// Normal Path Helpers
|
||||
//~ rjf: Path Normalization
|
||||
|
||||
internal String8List path_normalized_list_from_string(Arena *arena, String8 path, PathStyle *style_out);
|
||||
internal String8 path_normalized_from_string(Arena *arena, String8 path);
|
||||
internal B32 path_match_normalized(String8 left, String8 right);
|
||||
|
||||
////////////////////////////////
|
||||
// Misc Helpers
|
||||
//~ rjf: Basic Helpers
|
||||
|
||||
internal String8 path_char_from_style(PathStyle style);
|
||||
internal PathStyle path_style_from_string(String8 string);
|
||||
internal String8 string_from_path_style(PathStyle style);
|
||||
internal String8 path_separator_string_from_style(PathStyle style);
|
||||
internal StringMatchFlags path_match_flags_from_os(OperatingSystem os);
|
||||
internal String8 path_convert_slashes(Arena *arena, String8 path, PathStyle path_style);
|
||||
internal String8 path_replace_file_extension(Arena *arena, String8 file_name, String8 ext);
|
||||
|
||||
////////////////////////////////
|
||||
// Enum <-> String
|
||||
|
||||
internal PathStyle path_style_from_string(String8 string);
|
||||
internal String8 path_string_from_style(PathStyle style);
|
||||
|
||||
#endif //PATH_H
|
||||
|
||||
+19
-34
@@ -1489,8 +1489,7 @@ rd_mapped_from_file_path(Arena *arena, String8 file_path)
|
||||
String8 result = file_path;
|
||||
if(file_path.size != 0)
|
||||
{
|
||||
String8 file_path__normalized = path_normalized_from_string(scratch.arena, file_path);
|
||||
String8List file_path_parts = str8_split_path(scratch.arena, file_path__normalized);
|
||||
String8List file_path_parts = str8_split_path(scratch.arena, file_path);
|
||||
RD_CfgList maps = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("file_path_map"));
|
||||
String8 best_map_dst = {0};
|
||||
U64 best_map_match_length = max_U64;
|
||||
@@ -1498,8 +1497,7 @@ rd_mapped_from_file_path(Arena *arena, String8 file_path)
|
||||
for(RD_CfgNode *n = maps.first; n != 0; n = n->next)
|
||||
{
|
||||
String8 map_src = rd_cfg_child_from_string(n->v, str8_lit("source"))->first->string;
|
||||
String8 map_src__normalized = path_normalized_from_string(scratch.arena, map_src);
|
||||
String8List map_src_parts = str8_split_path(scratch.arena, map_src__normalized);
|
||||
String8List map_src_parts = str8_split_path(scratch.arena, map_src);
|
||||
B32 matches = 1;
|
||||
U64 match_length = 0;
|
||||
String8Node *file_path_part_n = file_path_parts.first;
|
||||
@@ -1523,8 +1521,7 @@ rd_mapped_from_file_path(Arena *arena, String8 file_path)
|
||||
}
|
||||
if(best_map_dst.size != 0)
|
||||
{
|
||||
String8 best_map_dst__normalized = path_normalized_from_string(scratch.arena, best_map_dst);
|
||||
String8List best_map_dst_parts = str8_split_path(scratch.arena, best_map_dst__normalized);
|
||||
String8List best_map_dst_parts = str8_split_path(scratch.arena, best_map_dst);
|
||||
for(String8Node *n = best_map_remaining_suffix_first; n != 0; n = n->next)
|
||||
{
|
||||
str8_list_push(scratch.arena, &best_map_dst_parts, n->string);
|
||||
@@ -1532,10 +1529,6 @@ rd_mapped_from_file_path(Arena *arena, String8 file_path)
|
||||
StringJoin join = {.sep = str8_lit("/")};
|
||||
result = str8_list_join(arena, &best_map_dst_parts, &join);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = path_normalized_from_string(arena, result);
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
@@ -9263,7 +9256,7 @@ rd_window_frame(void)
|
||||
for(String8Node *n = evt->paths.first; n != 0; n = n->next)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String8 path = path_normalized_from_string(scratch.arena, n->string);
|
||||
String8 path = n->string;
|
||||
if(str8_match(str8_skip_last_dot(path), str8_lit("exe"), StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
str8_list_push(ws->drop_completion_arena, &ws->drop_completion_paths, push_str8_copy(ws->drop_completion_arena, path));
|
||||
@@ -10897,14 +10890,13 @@ rd_init(CmdLine *cmdln)
|
||||
String8 user_path = cmd_line_string(cmdln, str8_lit("user"));
|
||||
String8 project_path = cmd_line_string(cmdln, str8_lit("project"));
|
||||
{
|
||||
String8 initial_path = push_str8f(scratch.arena, "%S/", os_get_process_info()->initial_path);
|
||||
if(user_path.size != 0)
|
||||
{
|
||||
user_path = path_absolute_dst_from_relative_dst_src(scratch.arena, user_path, initial_path);
|
||||
user_path = path_absolute_dst_from_relative_dst_src(scratch.arena, user_path, os_get_process_info()->initial_path);
|
||||
}
|
||||
if(project_path.size != 0)
|
||||
{
|
||||
project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_path, initial_path);
|
||||
project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_path, os_get_process_info()->initial_path);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -12857,7 +12849,7 @@ rd_frame(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
file_cfg_list = rd_cfg_tree_list_from_string(scratch.arena, file_path, file_data);
|
||||
file_cfg_list = rd_cfg_tree_list_from_string(scratch.arena, str8_chop_last_slash(file_path), file_data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12956,7 +12948,7 @@ rd_frame(void)
|
||||
{
|
||||
recent_project = rd_cfg_new(user, str8_lit("recent_project"));
|
||||
RD_Cfg *path_root = rd_cfg_new(recent_project, str8_lit("path"));
|
||||
rd_cfg_new(path_root, path_normalized_from_string(scratch.arena, file_path));
|
||||
rd_cfg_new(path_root, path_absolute_dst_from_relative_dst_src(scratch.arena, file_path, str8_chop_last_slash(rd_state->user_path)));
|
||||
}
|
||||
rd_cfg_unhook(user, recent_project);
|
||||
rd_cfg_insert_child(user, &rd_nil_cfg, recent_project);
|
||||
@@ -13102,7 +13094,7 @@ rd_frame(void)
|
||||
str8_list_pushf(scratch.arena, &strings, "// raddbg %s %S file\n\n", BUILD_VERSION_STRING_LITERAL, bucket_name);
|
||||
for(RD_Cfg *child = tree_root->first; child != &rd_nil_cfg; child = child->next)
|
||||
{
|
||||
str8_list_push(scratch.arena, &strings, rd_string_from_cfg_tree(scratch.arena, dst_path, child));
|
||||
str8_list_push(scratch.arena, &strings, rd_string_from_cfg_tree(scratch.arena, str8_chop_last_slash(dst_path), child));
|
||||
}
|
||||
String8 data = str8_list_join(scratch.arena, &strings, 0);
|
||||
B32 temp_write_good = os_write_data_to_file_path(temp_path, data);
|
||||
@@ -13496,10 +13488,8 @@ rd_frame(void)
|
||||
//- rjf: unpack
|
||||
String8 src_path = rd_regs()->string;
|
||||
String8 dst_path = rd_regs()->file_path;
|
||||
String8 src_path__normalized = path_normalized_from_string(scratch.arena, src_path);
|
||||
String8 dst_path__normalized = path_normalized_from_string(scratch.arena, dst_path);
|
||||
String8List src_path_parts = str8_split_path(scratch.arena, src_path__normalized);
|
||||
String8List dst_path_parts = str8_split_path(scratch.arena, dst_path__normalized);
|
||||
String8List src_path_parts = str8_split_path(scratch.arena, src_path);
|
||||
String8List dst_path_parts = str8_split_path(scratch.arena, dst_path);
|
||||
|
||||
//- rjf: reverse path parts
|
||||
String8List src_path_parts__reversed = {0};
|
||||
@@ -13918,7 +13908,7 @@ rd_frame(void)
|
||||
//- rjf: files
|
||||
case RD_CmdKind_Open:
|
||||
{
|
||||
String8 path = rd_regs()->file_path;
|
||||
String8 path = path_absolute_dst_from_relative_dst_src(scratch.arena, rd_regs()->file_path, os_get_current_path(scratch.arena));
|
||||
FileProperties props = os_properties_from_file_path(path);
|
||||
if(props.created != 0)
|
||||
{
|
||||
@@ -13940,10 +13930,9 @@ rd_frame(void)
|
||||
case RD_CmdKind_SwitchToPartnerFile:
|
||||
{
|
||||
String8 file_path = rd_regs()->file_path;
|
||||
String8 file_full_path = path_normalized_from_string(scratch.arena, file_path);
|
||||
String8 file_folder = str8_chop_last_slash(file_full_path);
|
||||
String8 file_name = str8_skip_last_slash(str8_chop_last_dot(file_full_path));
|
||||
String8 file_ext = str8_skip_last_dot(file_full_path);
|
||||
String8 file_folder = str8_chop_last_slash(file_path);
|
||||
String8 file_name = str8_skip_last_slash(str8_chop_last_dot(file_path));
|
||||
String8 file_ext = str8_skip_last_dot(file_path);
|
||||
String8 partner_ext_candidates[] =
|
||||
{
|
||||
str8_lit_comp("h"),
|
||||
@@ -13972,7 +13961,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_RecordFileInProject:
|
||||
if(rd_regs()->file_path.size != 0)
|
||||
{
|
||||
String8 path = path_normalized_from_string(scratch.arena, rd_regs()->file_path);
|
||||
String8 path = rd_regs()->file_path;
|
||||
RD_Cfg *project = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("project"));
|
||||
RD_CfgList recent_files = rd_cfg_child_list_from_string(scratch.arena, project, str8_lit("recent_file"));
|
||||
RD_Cfg *recent_file = &rd_nil_cfg;
|
||||
@@ -14001,7 +13990,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_ShowFileInExplorer:
|
||||
if(rd_regs()->file_path.size != 0)
|
||||
{
|
||||
String8 full_path = path_normalized_from_string(scratch.arena, rd_regs()->file_path);
|
||||
String8 full_path = rd_regs()->file_path;
|
||||
os_show_in_filesystem_ui(full_path);
|
||||
}break;
|
||||
|
||||
@@ -14976,11 +14965,7 @@ rd_frame(void)
|
||||
{
|
||||
current_path_string = path_normalized_from_string(scratch.arena, os_get_current_path(scratch.arena));
|
||||
}
|
||||
else
|
||||
{
|
||||
current_path_string = path_normalized_from_string(scratch.arena, current_path_string);
|
||||
}
|
||||
initial_input = path_normalized_from_string(scratch.arena, current_path_string);
|
||||
initial_input = current_path_string;
|
||||
initial_input = push_str8f(scratch.arena, "%S/", initial_input);
|
||||
}
|
||||
else if(cmd_kind_info->query.flags & RD_QueryFlag_KeepOldInput)
|
||||
@@ -15383,7 +15368,7 @@ rd_frame(void)
|
||||
String8List strings = {0};
|
||||
for(RD_CfgNode *n = colors.first; n != 0; n = n->next)
|
||||
{
|
||||
str8_list_push(scratch.arena, &strings, rd_string_from_cfg_tree(scratch.arena, dst_path, n->v));
|
||||
str8_list_push(scratch.arena, &strings, rd_string_from_cfg_tree(scratch.arena, str8_chop_last_slash(dst_path), n->v));
|
||||
}
|
||||
String8 data = str8_list_join(scratch.arena, &strings, 0);
|
||||
if(os_write_data_to_file_path(dst_path, data))
|
||||
|
||||
@@ -7,6 +7,7 @@ rd_cfg_tree_list_from_string__pre_0_9_16(Arena *arena, String8 file_path, String
|
||||
RD_CfgList result = {0};
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 folder_path = str8_skip_last_slash(file_path);
|
||||
MD_Node *src_root = md_parse_from_text(scratch.arena, file_path, data).root;
|
||||
{
|
||||
for MD_EachNode(tln, src_root->first)
|
||||
@@ -26,13 +27,13 @@ rd_cfg_tree_list_from_string__pre_0_9_16(Arena *arena, String8 file_path, String
|
||||
RD_Cfg *dst_root = rd_cfg_new(&rd_nil_cfg, str8_lit("target"));
|
||||
rd_cfg_list_push(arena, &result, dst_root);
|
||||
{
|
||||
if(executable.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("executable")), path_absolute_dst_from_relative_dst_src(scratch.arena, executable, file_path)); }
|
||||
if(executable.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("executable")), path_absolute_dst_from_relative_dst_src(scratch.arena, executable, folder_path)); }
|
||||
if(arguments.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("arguments")), raw_from_escaped_str8(scratch.arena, arguments)); }
|
||||
if(working_directory.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("working_directory")), path_absolute_dst_from_relative_dst_src(scratch.arena, working_directory, file_path)); }
|
||||
if(working_directory.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("working_directory")), path_absolute_dst_from_relative_dst_src(scratch.arena, working_directory, folder_path)); }
|
||||
if(entry_point.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("entry_point")), raw_from_escaped_str8(scratch.arena, entry_point)); }
|
||||
if(stdout_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stdout_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stdout_path, file_path)); }
|
||||
if(stderr_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stderr_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stderr_path, file_path)); }
|
||||
if(stdin_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stdin_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stdin_path, file_path)); }
|
||||
if(stdout_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stdout_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stdout_path, folder_path)); }
|
||||
if(stderr_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stderr_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stderr_path, folder_path)); }
|
||||
if(stdin_path.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("stdin_path")), path_absolute_dst_from_relative_dst_src(scratch.arena, stdin_path, folder_path)); }
|
||||
if(debug_subprocesses.size != 0) { rd_cfg_new(rd_cfg_new(dst_root, str8_lit("debug_subprocesses")), raw_from_escaped_str8(scratch.arena, debug_subprocesses)); }
|
||||
if(!str8_match(disabled_string, str8_lit("1"), 0))
|
||||
{
|
||||
@@ -47,7 +48,7 @@ rd_cfg_tree_list_from_string__pre_0_9_16(Arena *arena, String8 file_path, String
|
||||
{
|
||||
RD_Cfg *dst_root = rd_cfg_new(&rd_nil_cfg, tln->string);
|
||||
rd_cfg_list_push(arena, &result, dst_root);
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("path")), path_absolute_dst_from_relative_dst_src(scratch.arena, tln->first->string, file_path));
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("path")), path_absolute_dst_from_relative_dst_src(scratch.arena, tln->first->string, folder_path));
|
||||
}
|
||||
|
||||
//- rjf: file path maps
|
||||
@@ -57,8 +58,8 @@ rd_cfg_tree_list_from_string__pre_0_9_16(Arena *arena, String8 file_path, String
|
||||
String8 dest = md_child_from_string(tln, str8_lit("dest"), 0)->first->string;
|
||||
RD_Cfg *dst_root = rd_cfg_new(&rd_nil_cfg, tln->string);
|
||||
rd_cfg_list_push(arena, &result, dst_root);
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("source")), path_absolute_dst_from_relative_dst_src(scratch.arena, source, file_path));
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("dest")), path_absolute_dst_from_relative_dst_src(scratch.arena, dest, file_path));
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("source")), path_absolute_dst_from_relative_dst_src(scratch.arena, source, folder_path));
|
||||
rd_cfg_new(rd_cfg_new(dst_root, str8_lit("dest")), path_absolute_dst_from_relative_dst_src(scratch.arena, dest, folder_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,11 +468,11 @@ entry_point(CmdLine *cmd_line)
|
||||
// rjf: unpack full executable path
|
||||
if(args.first->string.size != 0)
|
||||
{
|
||||
String8 current_path = os_get_current_path(scratch.arena);
|
||||
String8 exe_name = args.first->string;
|
||||
PathStyle style = path_style_from_str8(exe_name);
|
||||
if(style == PathStyle_Relative)
|
||||
{
|
||||
String8 current_path = os_get_current_path(scratch.arena);
|
||||
exe_name = push_str8f(scratch.arena, "%S/%S", current_path, exe_name);
|
||||
exe_name = path_normalized_from_string(scratch.arena, exe_name);
|
||||
}
|
||||
|
||||
@@ -2461,7 +2461,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
||||
U64 cursor_vaddr = (1 <= rd_regs()->cursor.line && rd_regs()->cursor.line <= dasm_info.lines.count) ? (range.min+dasm_info.lines.v[rd_regs()->cursor.line-1].code_off) : 0;
|
||||
if(dasm_module != &ctrl_entity_nil)
|
||||
{
|
||||
ui_labelf("%S", path_normalized_from_string(scratch.arena, dasm_module->string));
|
||||
ui_labelf("%S", dasm_module->string);
|
||||
ui_spacer(ui_em(1.5f, 1));
|
||||
}
|
||||
ui_labelf("Address: 0x%I64x, Line: %I64d, Column: %I64d", cursor_vaddr, rd_regs()->cursor.line, rd_regs()->cursor.column);
|
||||
|
||||
@@ -642,14 +642,10 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
|
||||
String8 file_path = lines->file_name;
|
||||
String8 file_path_normalized = lower_from_str8(scratch.arena, str8_skip_chop_whitespace(file_path));
|
||||
{
|
||||
for(U64 idx = 0; idx < file_path_normalized.size; idx += 1)
|
||||
{
|
||||
if(file_path_normalized.str[idx] == '\\')
|
||||
{
|
||||
file_path_normalized.str[idx] = '/';
|
||||
}
|
||||
}
|
||||
file_path_normalized = path_normalized_from_string(scratch.arena, file_path_normalized);
|
||||
PathStyle file_path_normalized_style = path_style_from_str8(file_path_normalized);
|
||||
String8List file_path_normalized_parts = str8_split_path(scratch.arena, file_path_normalized);
|
||||
str8_path_list_resolve_dots_in_place(&file_path_normalized_parts, file_path_normalized_style);
|
||||
file_path_normalized = str8_path_list_join_by_style(scratch.arena, &file_path_normalized_parts, file_path_normalized_style);
|
||||
}
|
||||
|
||||
// rjf: normalized file path -> source file node
|
||||
|
||||
@@ -52,7 +52,9 @@ r_ogl_os_init(CmdLine *cmdln)
|
||||
os_abort(1);
|
||||
}
|
||||
|
||||
//- rjf: set up EGL config
|
||||
//- rjf: get all EGL configs
|
||||
EGLConfig configs[256] = {0};
|
||||
EGLint configs_count = 0;
|
||||
{
|
||||
EGLint options[] =
|
||||
{
|
||||
@@ -69,14 +71,39 @@ r_ogl_os_init(CmdLine *cmdln)
|
||||
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLint config_count = 0;
|
||||
if(!eglChooseConfig(r_ogl_lnx_state->display, options, &r_ogl_lnx_state->config, 1, &config_count) || config_count != 1)
|
||||
if(!eglChooseConfig(r_ogl_lnx_state->display, options, configs, ArrayCount(configs), &configs_count) || configs_count == 0)
|
||||
{
|
||||
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't choose EGL configuration."));
|
||||
os_abort(1);
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: actually choose the egl config
|
||||
{
|
||||
Window dummy_window = XCreateWindow(os_lnx_gfx_state->display, XDefaultRootWindow(os_lnx_gfx_state->display), 0, 0, 100, 100, 0, CopyFromParent, InputOutput, CopyFromParent, 0, 0);
|
||||
EGLint options[] =
|
||||
{
|
||||
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
||||
EGL_NONE,
|
||||
};
|
||||
for(U32 idx = 0; idx < configs_count; idx += 1)
|
||||
{
|
||||
EGLSurface *dummy_surface = eglCreateWindowSurface(r_ogl_lnx_state->display, configs[idx], dummy_window, options);
|
||||
if(dummy_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
r_ogl_lnx_state->config = configs[idx];
|
||||
eglDestroySurface(r_ogl_lnx_state->display, dummy_surface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(r_ogl_lnx_state->config == 0)
|
||||
{
|
||||
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't find a suitable EGL configuration."));
|
||||
os_abort(1);
|
||||
}
|
||||
XDestroyWindow(os_lnx_gfx_state->display, dummy_window);
|
||||
}
|
||||
|
||||
//- rjf: construct context
|
||||
{
|
||||
B32 debug_mode = cmd_line_has_flag(cmdln, str8_lit("opengl_debug"));
|
||||
@@ -118,8 +145,7 @@ r_ogl_os_window_equip(OS_Handle window)
|
||||
{
|
||||
EGLint options[] =
|
||||
{
|
||||
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_LINEAR,
|
||||
EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
|
||||
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
||||
EGL_NONE,
|
||||
};
|
||||
w->surface = eglCreateWindowSurface(r_ogl_lnx_state->display, r_ogl_lnx_state->config, window_os->window, options);
|
||||
|
||||
@@ -51,10 +51,6 @@ r_ogl_os_init(CmdLine *cmdln)
|
||||
GLXFBConfig framebuffer_config = framebuffer_configs[0];
|
||||
XFree(framebuffer_configs);
|
||||
|
||||
//- rjf: get visual info; create color map
|
||||
XVisualInfo *visual_info = glXGetVisualFromFBConfig(os_lnx_gfx_state->display, framebuffer_config);
|
||||
Colormap cmap = XCreateColormap(os_lnx_gfx_state->display, RootWindow(os_lnx_gfx_state->display, visual_info->screen), visual_info->visual, AllocNone);
|
||||
|
||||
//- rjf: construct set-window-attributes
|
||||
XSetWindowAttributes set_window_attributes = {0};
|
||||
set_window_attributes.background_pixmap = None;
|
||||
@@ -79,7 +75,7 @@ r_ogl_os_init(CmdLine *cmdln)
|
||||
r_ogl_lnx_ctx = glXCreateContextAttribsARB(os_lnx_gfx_state->display, framebuffer_config, 0, 1, context_options);
|
||||
}
|
||||
|
||||
glXMakeCurrent(os_lnx_gfx_state->display, RootWindow(os_lnx_gfx_state->display, visual_info->screen), r_ogl_lnx_ctx);
|
||||
glXMakeCurrent(os_lnx_gfx_state->display, 0, r_ogl_lnx_ctx);
|
||||
}
|
||||
|
||||
internal R_Handle
|
||||
|
||||
@@ -193,7 +193,7 @@ r_init(CmdLine *cmdln)
|
||||
#endif
|
||||
if(debug_mode)
|
||||
{
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
glDebugMessageCallback(r_ogl_debug_message_callback, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ typedef ptrdiff_t GLintptr;
|
||||
#define GL_TEXTURE31 0x84DF
|
||||
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: OS Backend Includes
|
||||
|
||||
@@ -98,8 +98,6 @@ r_ogl_os_init(CmdLine *cmdline)
|
||||
wglDeleteContext(bootstrap_ctx);
|
||||
wglMakeCurrent(dc, real_ctx);
|
||||
wglSwapIntervalEXT(1);
|
||||
ReleaseDC(bootstrap_hwnd, dc);
|
||||
DestroyWindow(bootstrap_hwnd);
|
||||
}
|
||||
|
||||
internal R_Handle
|
||||
@@ -108,7 +106,7 @@ r_ogl_os_window_equip(OS_Handle window)
|
||||
//- rjf: unpack window
|
||||
OS_W32_Window *w = os_w32_window_from_handle(window);
|
||||
HWND hwnd = w->hwnd;
|
||||
HDC hdc = GetDC(hwnd);
|
||||
HDC hdc = w->hdc;
|
||||
|
||||
//- rjf: select in ctx
|
||||
wglMakeCurrent(hdc, r_ogl_w32_hglrc);
|
||||
@@ -152,7 +150,6 @@ r_ogl_os_window_equip(OS_Handle window)
|
||||
SetPixelFormat(hdc, pixel_format, &pfd);
|
||||
|
||||
//- rjf: release hdc
|
||||
ReleaseDC(hwnd, hdc);
|
||||
R_Handle result = {0};
|
||||
return result;
|
||||
}
|
||||
@@ -169,9 +166,8 @@ r_ogl_os_select_window(OS_Handle os, R_Handle r)
|
||||
if(w != 0)
|
||||
{
|
||||
HWND hwnd = w->hwnd;
|
||||
HDC hdc = GetDC(hwnd);
|
||||
HDC hdc = w->hdc;
|
||||
wglMakeCurrent(hdc, r_ogl_w32_hglrc);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +177,7 @@ r_ogl_os_window_swap(OS_Handle os, R_Handle r)
|
||||
OS_W32_Window *w = os_w32_window_from_handle(os);
|
||||
if(w != 0)
|
||||
{
|
||||
HDC dc = GetDC(w->hwnd);
|
||||
HDC dc = w->hdc;
|
||||
SwapBuffers(dc);
|
||||
ReleaseDC(w->hwnd, dc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user