// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/apps/mshview/mshview.cpp
// Function: GLUTKeyboard(unsigned char, int, int)
void GLUTKeyboard(unsigned char key, int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;

  // Process keyboard button event 
  switch (key) {
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
    if (key == '0') current_mesh = -1;
    else if (key - '1' < meshes.NEntries()) current_mesh = key - '1';
    else printf("Unable to select mesh %d\n", key - '1');
    break;

  case 'A':
  case 'a':
    show_axes = !show_axes;
    break;

  case 'B':
  case 'b':
    show_backfacing = !show_backfacing;
    break;

  case 'C': 
  case 'c':
    show_vertex_colors = !show_vertex_colors;
    break;
    
  case 'E':
    show_edge_names = !show_edge_names;
    break;

  case 'e':
    show_edges = !show_edges;
    break;

  case 'F':
    show_face_names = !show_face_names;
    break;

  case 'f':
    show_faces = !show_faces;
    break;

  case 'L':
    show_category_names = !show_category_names;
    break;

  case 'l':
    show_categories = !show_categories;
    break;

  case 'M':
    show_material_names = !show_material_names;
    break;

  case 'm':
    show_materials = !show_materials;
    break;

  case 'N':
    show_vertex_normals = !show_vertex_normals;
    break;

  case 'n':
    show_face_normals = !show_face_normals;
    break;

  case 'O':
  case 'o':
    show_world_origin = !show_world_origin;
    break;

  case 'S':
    show_segment_names = !show_segment_names;
    break;

  case 's':
    show_segments = !show_segments;
    break;

  case 'T':
  case 't':
    show_vertex_texcoords = !show_vertex_texcoords;
    break;

  case 'V':
    show_vertex_names = !show_vertex_names;
    break;

  case 'v':
    show_vertices = !show_vertices;
    break;

  case 'X':
  case 'x':
    show_boundaries = !show_boundaries;
    break;

  case ' ': {
    // Print camera
    const R3Camera& camera = viewer->Camera();
    RNFail("%g %g %g  %g %g %g  %g %g %g  %g %g  1\n",
           camera.Origin().X(), camera.Origin().Y(), camera.Origin().Z(),
           camera.Towards().X(), camera.Towards().Y(), camera.Towards().Z(),
           camera.Up().X(), camera.Up().Y(), camera.Up().Z(),
           camera.XFOV(), camera.YFOV());
    printf("%g %g %g  %g %g %g  %g %g %g  %g %g  1\n",
           camera.Origin().X(), camera.Origin().Y(), camera.Origin().Z(),
           camera.Towards().X(), camera.Towards().Y(), camera.Towards().Z(),
           camera.Up().X(), camera.Up().Y(), camera.Up().Z(),
           camera.XFOV(), camera.YFOV());
    break; }
      
  case 16:  // ctrl-P
    image_name = "mshview.png";
    break; 

  case 27: // ESCAPE
    GLUTStop();
    break;
  }

  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = y;

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %ebp
movl %esi, %ebx
movl 0x118c03(%rip), %r13d   # 0x13f9bc
leal -0x1b(%rdi), %eax
cmpl $0x5d, %eax
ja 0x26e8c
leaq 0xb52cc(%rip), %rcx     # 0xdc098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %dil, %esi
addl $-0x31, %esi
cmpl 0x11db12(%rip), %esi    # 0x1448f4
jge 0x26def
movl %esi, 0x118bc6(%rip)    # 0x13f9b0
jmp 0x27193
leaq 0xb541a(%rip), %rdi     # 0xdc210
xorl %eax, %eax
callq 0x21080
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e1ed(%rip)    # 0x144ff8
sete %al
movl %eax, 0x11e1e4(%rip)    # 0x144ff8
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e1be(%rip)    # 0x144fe0
sete %al
movl %eax, 0x11e1b5(%rip)    # 0x144fe0
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e227(%rip)    # 0x145060
sete %al
movl %eax, 0x11e21e(%rip)    # 0x145060
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e1d4(%rip)    # 0x145024
sete %al
movl %eax, 0x11e1cb(%rip)    # 0x145024
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e1b9(%rip)    # 0x145020
sete %al
movl %eax, 0x11e1b0(%rip)    # 0x145020
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e172(%rip)    # 0x144ff0
sete %al
movl %eax, 0x11e169(%rip)    # 0x144ff0
jmp 0x27193
cmpl $0x10, %edi
jne 0x27193
leaq 0xb53b6(%rip), %rax     # 0xdc252
movq %rax, 0x11e185(%rip)    # 0x145028
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e14f(%rip)    # 0x145000
sete %al
movl %eax, 0x11e146(%rip)    # 0x145000
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e124(%rip)    # 0x144fec
sete %al
movl %eax, 0x11e11b(%rip)    # 0x144fec
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e109(%rip)    # 0x144fe8
sete %al
movl %eax, 0x11e100(%rip)    # 0x144fe8
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e0ee(%rip)    # 0x144fe4
sete %al
movl %eax, 0x11e0e5(%rip)    # 0x144fe4
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x118aa7(%rip)    # 0x13f9b4
sete %al
movl %eax, 0x118a9e(%rip)    # 0x13f9b4
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e0f0(%rip)    # 0x145014
sete %al
movl %eax, 0x11e0e7(%rip)    # 0x145014
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e0d5(%rip)    # 0x145010
sete %al
movl %eax, 0x11e0cc(%rip)    # 0x145010
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e0ca(%rip)    # 0x14501c
sete %al
movl %eax, 0x11e0c1(%rip)    # 0x14501c
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11e093(%rip)    # 0x144ffc
sete %al
movl %eax, 0x11e08a(%rip)    # 0x144ffc
jmp 0x27193
movl $0xffffffff, 0x118a2f(%rip) # imm = 0xFFFFFFFF
jmp 0x27193
movq 0x11e04b(%rip), %r15    # 0x144fd8
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x10(%r15), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x50(%r15), %r14
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd 0x10(%r12), %xmm5
movsd 0x38(%r15), %xmm6
movsd 0x40(%r15), %xmm7
movsd 0x48(%r15), %xmm0
movsd 0x68(%r15), %xmm1
movsd 0x70(%r15), %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
leaq 0xb51ef(%rip), %rdi     # 0xdc22a
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movb $0x8, %al
callq 0x8ae2e
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x10(%r15), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x772dc
movsd 0x10(%r12), %xmm5
movsd 0x38(%r15), %xmm6
movsd 0x40(%r15), %xmm7
movsd 0x48(%r15), %xmm0
movsd 0x68(%r15), %xmm1
movsd 0x70(%r15), %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
leaq 0xb5120(%rip), %rdi     # 0xdc22a
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movb $0x8, %al
callq 0x21080
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11deba(%rip)    # 0x144ff4
sete %al
movl %eax, 0x11deb1(%rip)    # 0x144ff4
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11deba(%rip)    # 0x145008
sete %al
movl %eax, 0x11deb1(%rip)    # 0x145008
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11deaa(%rip)    # 0x14500c
sete %al
movl %eax, 0x11dea1(%rip)    # 0x14500c
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11de8e(%rip)    # 0x145004
sete %al
movl %eax, 0x11de85(%rip)    # 0x145004
jmp 0x27193
xorl %eax, %eax
cmpl $0x0, 0x11de8e(%rip)    # 0x145018
sete %al
movl %eax, 0x11de85(%rip)    # 0x145018
subl %ebp, %r13d
movl %ebx, 0x11de94(%rip)    # 0x145030
movl %r13d, 0x11de91(%rip)   # 0x145034
callq 0xd3c50
callq 0xced08
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x11de0b(%rip), %edi    # 0x144fd0
callq 0xd5048
xorl %edi, %edi
callq 0x21af0