// File: /workspace/github_cpp_makefile_star2_O2/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 0x108adb(%rip), %r13d   # 0x12e9dc
leal -0x1b(%rdi), %eax
cmpl $0x5d, %eax
ja 0x25fd4
leaq 0x9f184(%rip), %rcx     # 0xc5098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %dil, %esi
addl $-0x31, %esi
cmpl 0x10d9ea(%rip), %esi    # 0x133914
jge 0x25f37
movl %esi, 0x108a9e(%rip)    # 0x12e9d0
jmp 0x262d8
leaq 0x9f2d2(%rip), %rdi     # 0xc5210
xorl %eax, %eax
callq 0x21080
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e0c5(%rip)    # 0x134018
sete %al
movl %eax, 0x10e0bc(%rip)    # 0x134018
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e096(%rip)    # 0x134000
sete %al
movl %eax, 0x10e08d(%rip)    # 0x134000
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e0ff(%rip)    # 0x134080
sete %al
movl %eax, 0x10e0f6(%rip)    # 0x134080
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e0ac(%rip)    # 0x134044
sete %al
movl %eax, 0x10e0a3(%rip)    # 0x134044
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e091(%rip)    # 0x134040
sete %al
movl %eax, 0x10e088(%rip)    # 0x134040
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e04a(%rip)    # 0x134010
sete %al
movl %eax, 0x10e041(%rip)    # 0x134010
jmp 0x262d8
cmpl $0x10, %edi
jne 0x262d8
leaq 0x9f26e(%rip), %rax     # 0xc5252
movq %rax, 0x10e05d(%rip)    # 0x134048
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10e027(%rip)    # 0x134020
sete %al
movl %eax, 0x10e01e(%rip)    # 0x134020
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dffc(%rip)    # 0x13400c
sete %al
movl %eax, 0x10dff3(%rip)    # 0x13400c
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dfe1(%rip)    # 0x134008
sete %al
movl %eax, 0x10dfd8(%rip)    # 0x134008
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dfc6(%rip)    # 0x134004
sete %al
movl %eax, 0x10dfbd(%rip)    # 0x134004
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10897f(%rip)    # 0x12e9d4
sete %al
movl %eax, 0x108976(%rip)    # 0x12e9d4
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dfc8(%rip)    # 0x134034
sete %al
movl %eax, 0x10dfbf(%rip)    # 0x134034
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dfad(%rip)    # 0x134030
sete %al
movl %eax, 0x10dfa4(%rip)    # 0x134030
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dfa2(%rip)    # 0x13403c
sete %al
movl %eax, 0x10df99(%rip)    # 0x13403c
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10df6b(%rip)    # 0x13401c
sete %al
movl %eax, 0x10df62(%rip)    # 0x13401c
jmp 0x262d8
orl $-0x1, 0x10890a(%rip)   # 0x12e9d0
jmp 0x262d8
movq 0x10df26(%rip), %r15    # 0x133ff8
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 0x6c26e
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x6c26e
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x6c26e
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 0x9f0aa(%rip), %rdi     # 0xc522a
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movb $0x8, %al
callq 0x7e112
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 0x6c26e
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x6c26e
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x6c26e
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 0x9efdb(%rip), %rdi     # 0xc522a
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 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dd95(%rip)    # 0x134014
sete %al
movl %eax, 0x10dd8c(%rip)    # 0x134014
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dd95(%rip)    # 0x134028
sete %al
movl %eax, 0x10dd8c(%rip)    # 0x134028
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dd85(%rip)    # 0x13402c
sete %al
movl %eax, 0x10dd7c(%rip)    # 0x13402c
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dd69(%rip)    # 0x134024
sete %al
movl %eax, 0x10dd60(%rip)    # 0x134024
jmp 0x262d8
xorl %eax, %eax
cmpl $0x0, 0x10dd69(%rip)    # 0x134038
sete %al
movl %eax, 0x10dd60(%rip)    # 0x134038
subl %ebp, %r13d
movl %ebx, 0x10dd6f(%rip)    # 0x134050
movl %r13d, 0x10dd6c(%rip)   # 0x134054
callq 0xbcafe
callq 0xb8060
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2508c