OSX KeyCode translation table, fixed rendering bug
This commit is contained in:
parent
4ef76dacbe
commit
b680f90c24
|
@ -1,3 +1,3 @@
|
|||
SCRIPT_REL_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
$SCRIPT_REL_DIR/build_.sh debug osx arm64
|
||||
$SCRIPT_REL_DIR/build_.sh debug osx intel
|
||||
# $SCRIPT_REL_DIR/build_.sh debug wasm intel
|
Binary file not shown.
Binary file not shown.
|
@ -168,6 +168,15 @@ input_state_create(Allocator* a)
|
|||
Input_State* result = allocator_alloc_struct(a, Input_State);
|
||||
result->frame_hot = result->frames + 0;
|
||||
result->frame_cold = result->frames + 1;
|
||||
|
||||
// Clear the new hot input frame
|
||||
Key_Flags* hot_key_flags = result->frame_hot->key_flags;
|
||||
Key_Flags* cold_key_flags = result->frame_cold->key_flags;
|
||||
for (u32 i = 0; i < KeyCode_Count; i++)
|
||||
{
|
||||
hot_key_flags[i] = 0;
|
||||
cold_key_flags[i] = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void geometry_buffer_update(Geometry_Buffer* buffer, r32* verts, u32 verts_offse
|
|||
// Shaders
|
||||
void geometry_bind(Geometry_Buffer geo);
|
||||
void shader_bind(Shader shader);
|
||||
void geometry_drawi(Geometry_Buffer geo, u32 indices);
|
||||
void geometry_drawi(Geometry_Buffer geo, u32 indices, u32 offset);
|
||||
void geometry_draw(Geometry_Buffer geo);
|
||||
void vertex_attrib_pointer(Geometry_Buffer geo, Shader shader, u32 count, u32 attr_index, u32 stride, u32 offset);
|
||||
void set_uniform(Shader shader, u32 index, m44 u);
|
||||
|
@ -282,14 +282,14 @@ shader_bind(Shader shader)
|
|||
}
|
||||
|
||||
void
|
||||
geometry_drawi(Geometry_Buffer geo, u32 indices){
|
||||
glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, 0);
|
||||
geometry_drawi(Geometry_Buffer geo, u32 indices, u32 offset){
|
||||
glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, (void*)(offset * sizeof(u32)));
|
||||
os_gl_no_error();
|
||||
}
|
||||
|
||||
void
|
||||
geometry_draw(Geometry_Buffer geo){
|
||||
geometry_drawi(geo, geo.indices_len);
|
||||
geometry_drawi(geo, geo.indices_len, 0);
|
||||
}
|
||||
|
||||
void vertex_attrib_pointer(Geometry_Buffer geo, Shader shader, GLuint count, GLuint attr_index, GLuint stride, GLuint offset){
|
||||
|
|
|
@ -266,11 +266,17 @@ ed_sculpture_updated(App_State* state, r32 scale, r32 led_size)
|
|||
}
|
||||
ed->sculpture_geo = geometry_buffer_create(
|
||||
geo.buffer_vertex.values,
|
||||
geo.buffer_vertex.len,
|
||||
geo.buffer_vertex.len * geo.buffer_vertex.stride,
|
||||
geo.buffer_index.values,
|
||||
geo.buffer_index.len
|
||||
);
|
||||
|
||||
for (u32 i = 0; i < 6; i++)
|
||||
{
|
||||
u32 index = geo.buffer_index.values[1008 + i];
|
||||
r32* values = geo.buffer_vertex.values + (index * 5);
|
||||
printf("%d -> %f %f %f, %f %f\n", index, values[0], values[1], values[2], values[3], values[4]);
|
||||
}
|
||||
vertex_attrib_pointer(ed->sculpture_geo, ed->sculpture_shd, 3, ed->sculpture_shd.attrs[0], 5, 0);
|
||||
vertex_attrib_pointer(ed->sculpture_geo, ed->sculpture_shd, 2, ed->sculpture_shd.attrs[1], 5, 3);
|
||||
|
||||
|
|
|
@ -14,12 +14,32 @@ ed_sculpture_visualizer_init(App_State* state)
|
|||
}
|
||||
|
||||
r32 cam_theta = 0;
|
||||
u32 offset = 0;
|
||||
|
||||
internal void
|
||||
ed_sculpture_visualizer(App_State* state)
|
||||
{
|
||||
Editor* ed = state->editor;
|
||||
|
||||
Input_State* in = state->input_state;
|
||||
u32 delta = 1;
|
||||
if (input_key_is_down(in, KeyCode_LeftShift) || input_key_is_down(in, KeyCode_RightShift))
|
||||
{
|
||||
delta = 100;
|
||||
}
|
||||
if (input_key_went_down(in, KeyCode_UpArrow))
|
||||
{
|
||||
offset += delta;
|
||||
printf("%d\n", offset);
|
||||
}
|
||||
if (input_key_went_down(in, KeyCode_DownArrow))
|
||||
{
|
||||
offset -= delta;
|
||||
printf("%d\n", offset);
|
||||
}
|
||||
offset = clamp(0, offset, ed->sculpture_geo.indices_len);
|
||||
|
||||
|
||||
// Set the viewport to the current layout's region so that the sculpture
|
||||
// never overlaps any other ui elements
|
||||
UI_Layout l = *ed->ui.layout;
|
||||
|
@ -52,7 +72,7 @@ ed_sculpture_visualizer(App_State* state)
|
|||
u32 j = 2868;
|
||||
u32 k = ed->sculpture_geo.indices_len;
|
||||
u32 h = (i * 6) + 3;
|
||||
geometry_drawi(ed->sculpture_geo, k);
|
||||
geometry_drawi(ed->sculpture_geo, k, 0);
|
||||
|
||||
// reset the viewport for all other rendering
|
||||
v2 wds = HMM_MultiplyVec2(ed->window_dim, ed->content_scale);
|
||||
|
|
|
@ -29,7 +29,7 @@ ui_create(u32 widget_pool_cap, u32 verts_cap, Input_State* input, Allocator* a)
|
|||
|
||||
result.per_frame_buffer = geometry_buffer_create(
|
||||
result.geo.buffer_vertex.values,
|
||||
result.geo.buffer_vertex.cap,
|
||||
result.geo.buffer_vertex.cap * result.geo.buffer_vertex.stride,
|
||||
result.geo.buffer_index.values,
|
||||
result.geo.buffer_index.cap
|
||||
);
|
||||
|
@ -225,7 +225,7 @@ ui_draw(UI* ui)
|
|||
set_uniform(ui->shader, 0, ui->proj);
|
||||
texture_bind(ui->atlas_texture);
|
||||
geometry_bind(ui->per_frame_buffer);
|
||||
geometry_drawi(ui->per_frame_buffer, ui->geo.buffer_index.len);
|
||||
geometry_drawi(ui->per_frame_buffer, ui->geo.buffer_index.len, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
|
|
@ -9,7 +9,7 @@ lumenarium_init()
|
|||
permanent = bump_allocator_create_reserve(GB(2));
|
||||
global_scratch_ = bump_allocator_create_reserve(GB(4));
|
||||
|
||||
run_tests();
|
||||
//run_tests();
|
||||
scratch_get(scratch);
|
||||
App_Init_Desc desc = incenter_get_init_desc();
|
||||
// TODO(PS): make sure the values make sense in desc
|
||||
|
@ -24,10 +24,28 @@ lumenarium_init()
|
|||
|
||||
String exe_file_path = os_get_exe_path(scratch.a);
|
||||
u64 run_tree_start = string_find_substring(exe_file_path, lit_str("run_tree"), 0, StringMatch_FindLast);
|
||||
if (run_tree_start >= exe_file_path.cap)
|
||||
{
|
||||
u64 exe_path_start = string_find_substring(exe_file_path, lit_str("lumenarium"), 0, StringMatch_FindLast);
|
||||
if (exe_path_start < exe_file_path.cap)
|
||||
{
|
||||
String run_tree_path = string_get_prefix(exe_file_path, exe_path_start);
|
||||
String run_tree_path_nullterm = string_copy(run_tree_path, scratch.a);
|
||||
os_pwd_set(run_tree_path_nullterm);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unable to set working directory\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u64 run_tree_end = run_tree_start + lit_str("run_tree").len;
|
||||
String run_tree_path = string_get_prefix(exe_file_path, run_tree_end);
|
||||
String run_tree_path_nullterm = string_copy(run_tree_path, scratch.a);
|
||||
os_pwd_set(run_tree_path_nullterm);
|
||||
}
|
||||
|
||||
|
||||
en_init(state, desc);
|
||||
if (has_flag(state->flags, AppState_RunEditor)) ed_init(state);
|
||||
|
|
|
@ -288,6 +288,8 @@ geo_quad_buffer_builder_push_vt(Geo_Quad_Buffer_Builder* b, v3 p0, v3 p1, v3 p2,
|
|||
u32 i3 = geo_vertex_buffer_builder_push_vtc(&b->buffer_vertex, p3, t3, (v4){});
|
||||
|
||||
geo_index_buffer_builder_push_quad(&b->buffer_index, i0, i1, i2, i3);
|
||||
// u32 base = 2869;
|
||||
// geo_index_buffer_builder_push_quad(&b->buffer_index, base + 0, base + 1, base + 2, base + 3);
|
||||
}
|
||||
|
||||
internal void
|
||||
|
|
|
@ -75,6 +75,126 @@ glfw_error_callback(int error, const char* description)
|
|||
global u8* app_state_data = 0;
|
||||
|
||||
global Key_Code glfw_key_translation_table[] = {
|
||||
[GLFW_KEY_SPACE] = KeyCode_Space,
|
||||
[GLFW_KEY_APOSTROPHE] = KeyCode_SingleQuote,
|
||||
[GLFW_KEY_COMMA] = KeyCode_Comma,
|
||||
[GLFW_KEY_MINUS] = KeyCode_Minus,
|
||||
[GLFW_KEY_PERIOD] = KeyCode_Period,
|
||||
[GLFW_KEY_SLASH] = KeyCode_ForwardSlash,
|
||||
[GLFW_KEY_0] = KeyCode_0,
|
||||
[GLFW_KEY_1] = KeyCode_1,
|
||||
[GLFW_KEY_2] = KeyCode_2,
|
||||
[GLFW_KEY_3] = KeyCode_3,
|
||||
[GLFW_KEY_4] = KeyCode_4,
|
||||
[GLFW_KEY_5] = KeyCode_5,
|
||||
[GLFW_KEY_6] = KeyCode_6,
|
||||
[GLFW_KEY_7] = KeyCode_7,
|
||||
[GLFW_KEY_8] = KeyCode_8,
|
||||
[GLFW_KEY_9] = KeyCode_9,
|
||||
[GLFW_KEY_SEMICOLON] = KeyCode_SemiColon,
|
||||
[GLFW_KEY_EQUAL] = KeyCode_Equals,
|
||||
[GLFW_KEY_A] = KeyCode_A,
|
||||
[GLFW_KEY_B] = KeyCode_B,
|
||||
[GLFW_KEY_C] = KeyCode_C,
|
||||
[GLFW_KEY_D] = KeyCode_D,
|
||||
[GLFW_KEY_E] = KeyCode_E,
|
||||
[GLFW_KEY_F] = KeyCode_F,
|
||||
[GLFW_KEY_G] = KeyCode_G,
|
||||
[GLFW_KEY_H] = KeyCode_H,
|
||||
[GLFW_KEY_I] = KeyCode_I,
|
||||
[GLFW_KEY_J] = KeyCode_J,
|
||||
[GLFW_KEY_K] = KeyCode_K,
|
||||
[GLFW_KEY_L] = KeyCode_L,
|
||||
[GLFW_KEY_M] = KeyCode_M,
|
||||
[GLFW_KEY_N] = KeyCode_N,
|
||||
[GLFW_KEY_O] = KeyCode_O,
|
||||
[GLFW_KEY_P] = KeyCode_P,
|
||||
[GLFW_KEY_Q] = KeyCode_Q,
|
||||
[GLFW_KEY_R] = KeyCode_R,
|
||||
[GLFW_KEY_S] = KeyCode_S,
|
||||
[GLFW_KEY_T] = KeyCode_T,
|
||||
[GLFW_KEY_U] = KeyCode_U,
|
||||
[GLFW_KEY_V] = KeyCode_V,
|
||||
[GLFW_KEY_W] = KeyCode_W,
|
||||
[GLFW_KEY_X] = KeyCode_X,
|
||||
[GLFW_KEY_Y] = KeyCode_Y,
|
||||
[GLFW_KEY_Z] = KeyCode_Z,
|
||||
[GLFW_KEY_LEFT_BRACKET] = KeyCode_LeftBracket,
|
||||
[GLFW_KEY_BACKSLASH] = KeyCode_Backslash,
|
||||
[GLFW_KEY_RIGHT_BRACKET] = KeyCode_RightBrace,
|
||||
[GLFW_KEY_GRAVE_ACCENT] = KeyCode_Invalid,
|
||||
[GLFW_KEY_WORLD_1] = KeyCode_Invalid,
|
||||
[GLFW_KEY_WORLD_2] = KeyCode_Invalid,
|
||||
[GLFW_KEY_ESCAPE] = KeyCode_Esc,
|
||||
[GLFW_KEY_ENTER] = KeyCode_Enter,
|
||||
[GLFW_KEY_TAB] = KeyCode_Tab,
|
||||
[GLFW_KEY_BACKSPACE] = KeyCode_Backspace,
|
||||
[GLFW_KEY_INSERT] = KeyCode_Invalid,
|
||||
[GLFW_KEY_DELETE] = KeyCode_Delete,
|
||||
[GLFW_KEY_RIGHT] = KeyCode_RightArrow,
|
||||
[GLFW_KEY_LEFT] = KeyCode_LeftArrow,
|
||||
[GLFW_KEY_DOWN] = KeyCode_DownArrow,
|
||||
[GLFW_KEY_UP] = KeyCode_UpArrow,
|
||||
[GLFW_KEY_PAGE_UP] = KeyCode_PageUp,
|
||||
[GLFW_KEY_PAGE_DOWN] = KeyCode_PageDown,
|
||||
[GLFW_KEY_HOME] = KeyCode_Invalid,
|
||||
[GLFW_KEY_END] = KeyCode_Invalid,
|
||||
[GLFW_KEY_CAPS_LOCK] = KeyCode_CapsLock,
|
||||
[GLFW_KEY_SCROLL_LOCK] = KeyCode_Invalid,
|
||||
[GLFW_KEY_NUM_LOCK] = KeyCode_Invalid,
|
||||
[GLFW_KEY_PRINT_SCREEN] = KeyCode_Invalid,
|
||||
[GLFW_KEY_PAUSE] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F1] = KeyCode_F1,
|
||||
[GLFW_KEY_F2] = KeyCode_F2,
|
||||
[GLFW_KEY_F3] = KeyCode_F3,
|
||||
[GLFW_KEY_F4] = KeyCode_F4,
|
||||
[GLFW_KEY_F5] = KeyCode_F5,
|
||||
[GLFW_KEY_F6] = KeyCode_F6,
|
||||
[GLFW_KEY_F7] = KeyCode_F7,
|
||||
[GLFW_KEY_F8] = KeyCode_F8,
|
||||
[GLFW_KEY_F9] = KeyCode_F9,
|
||||
[GLFW_KEY_F10] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F11] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F12] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F13] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F14] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F15] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F16] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F17] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F18] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F19] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F20] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F21] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F22] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F23] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F24] = KeyCode_Invalid,
|
||||
[GLFW_KEY_F25] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_0] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_1] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_2] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_3] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_4] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_5] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_6] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_7] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_8] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_9] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_DECIMAL] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_DIVIDE] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_MULTIPLY] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_SUBTRACT] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_ADD] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_ENTER] = KeyCode_Invalid,
|
||||
[GLFW_KEY_KP_EQUAL] = KeyCode_Invalid,
|
||||
[GLFW_KEY_LEFT_SHIFT] = KeyCode_LeftShift,
|
||||
[GLFW_KEY_LEFT_CONTROL] = KeyCode_LeftCtrl,
|
||||
[GLFW_KEY_LEFT_ALT] = KeyCode_Alt,
|
||||
[GLFW_KEY_LEFT_SUPER] = KeyCode_Invalid,
|
||||
[GLFW_KEY_RIGHT_SHIFT] = KeyCode_RightShift,
|
||||
[GLFW_KEY_RIGHT_CONTROL] = KeyCode_RightCtrl,
|
||||
[GLFW_KEY_RIGHT_ALT] = KeyCode_Alt,
|
||||
[GLFW_KEY_RIGHT_SUPER] = KeyCode_Invalid,
|
||||
[GLFW_KEY_MENU] = KeyCode_Invalid,
|
||||
|
||||
};
|
||||
|
||||
|
@ -82,7 +202,7 @@ Key_Code
|
|||
osx_translate_key(int glfw_key)
|
||||
{
|
||||
// TODO: turn this into an actual key_code
|
||||
return (Key_Code)glfw_key;
|
||||
return glfw_key_translation_table[glfw_key];
|
||||
}
|
||||
|
||||
Key_Code
|
||||
|
@ -204,6 +324,8 @@ int main (int arg_count, char** args)
|
|||
r64 target_seconds_per_frame = 1.0 / 30.0f;
|
||||
Ticks ticks_start = os_get_ticks();
|
||||
while(!glfwWindowShouldClose(window) && running && has_flag(state->flags, AppState_IsRunning)) {
|
||||
lumenarium_frame_prepare(state);
|
||||
glfwPollEvents();
|
||||
|
||||
if (has_flag(state->flags, AppState_RunEditor))
|
||||
{
|
||||
|
@ -212,12 +334,10 @@ int main (int arg_count, char** args)
|
|||
state->editor->window_dim = (v2){ (r32)w, (r32)h };
|
||||
}
|
||||
|
||||
lumenarium_frame_prepare(state);
|
||||
lumenarium_frame(state);
|
||||
lumenarium_env_validate();
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
||||
Ticks ticks_end = os_get_ticks();
|
||||
r64 seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second());
|
||||
|
|
|
@ -54,7 +54,7 @@ incenter_init(App_State* state)
|
|||
}
|
||||
|
||||
r32 rad = 0.05f;
|
||||
ed_sculpture_updated(state, 10, rad);
|
||||
ed_sculpture_updated(state, 5, rad);
|
||||
scratch_release(scratch);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue