// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::Redraw()
int R3SurfelViewer::
Redraw(void)
{
  // Check scene
  if (!scene) return 0;

  // Set viewing transformation
  viewer.Camera().Load();

  // Clear window 
  glClearColor(background_color[0], background_color[1], background_color[2], 1.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // Set lights
  static GLfloat light0_position[] = { 3.0, 4.0, 5.0, 0.0 };
  glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
  static GLfloat light1_position[] = { -3.0, -2.0, -3.0, 0.0 };
  glLightfv(GL_LIGHT1, GL_POSITION, light1_position);

  // Set opengl modes
  if (backfacing_visibility) glDisable(GL_CULL_FACE);
  else glEnable(GL_CULL_FACE);
  glDisable(GL_LIGHTING);
  glPointSize(1);
  glLineWidth(1);

  // Draw everything (without culling to viewing extent)
  DrawSelectedPoint();
  DrawScanViewpoints();
  DrawImageViewpoints();
  DrawImagePlane();
  DrawImageInset();
  DrawAxes();

  // Set viewing extent
  DrawViewingExtent();
  EnableViewingExtent();
  UpdateViewingFrustum();

  // Draw everything else (with culling to viewing extent)
  DrawSurfels(surfel_color_scheme);
  DrawNormals();
  DrawObjectPrincipalAxes();
  DrawObjectOrientedBBoxes();
  DrawObjectRelationships();
  DrawObjectBBoxes();
  DrawNodeBBoxes();
  DrawBlockBBoxes();
  DrawImagePoints();
  DrawCenterPoint();

  // Reset viewing modes
  DisableViewingExtent();

  // Capture image
  if (screenshot_name) {
    CaptureImage(screenshot_name);
    free(screenshot_name);
    screenshot_name = NULL;
  }

  // Update the frame time
  if (frame_time < 0) frame_time = 0.05;
  else frame_time = frame_timer.Elapsed();
  frame_timer.Read();

  // Adapt working set
  AdaptWorkingSet();

  // Check if there are any GL errors
  GLenum status = glGetError();
  if (status != GL_NO_ERROR) {
    printf("Error in OpenGL: %d\n", (int) status);
  }

  // Return whether need redraw
  return 0;
}

// Assembly:
cmpq $0x0, 0x8(%rdi)
je 0x3029a
pushq %rbx
movq %rdi, %rbx
addq $0x80, %rdi
xorl %esi, %esi
callq 0x7a9a0
cvtsd2ss 0x380(%rbx), %xmm0
cvtsd2ss 0x388(%rbx), %xmm1
cvtsd2ss 0x390(%rbx), %xmm2
movss 0x107fa9(%rip), %xmm3   # 0x138040
callq 0x27e80
movl $0x4100, %edi           # imm = 0x4100
callq 0x271f0
leaq 0x18c963(%rip), %rdx    # 0x1bca10
movl $0x4000, %edi           # imm = 0x4000
movl $0x1203, %esi           # imm = 0x1203
callq 0x28100
leaq 0x18c95d(%rip), %rdx    # 0x1bca20
movl $0x4001, %edi           # imm = 0x4001
movl $0x1203, %esi           # imm = 0x1203
callq 0x28100
cmpl $0x0, 0x2f8(%rbx)
je 0x300e7
movl $0xb44, %edi            # imm = 0xB44
callq 0x27200
jmp 0x300f1
movl $0xb44, %edi            # imm = 0xB44
callq 0x27860
movl $0xb50, %edi            # imm = 0xB50
callq 0x27200
movss 0x107f3d(%rip), %xmm0   # 0x138040
callq 0x270a0
movss 0x107f30(%rip), %xmm0   # 0x138040
callq 0x281a0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2c0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2c8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2d0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2e0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2d8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2f0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x240(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x230(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x248(%rax)
movl 0x360(%rbx), %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x270(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x280(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x288(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x290(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x298(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2a0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2a8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2b0(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2e8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2b8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x238(%rax)
movq 0x4f0(%rbx), %rsi
testq %rsi, %rsi
je 0x3023a
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2f8(%rax)
movq 0x4f0(%rbx), %rdi
callq 0x27b20
movq $0x0, 0x4f0(%rbx)
xorpd %xmm0, %xmm0
ucomisd 0x4e8(%rbx), %xmm0
jbe 0x30252
movsd 0x108170(%rip), %xmm0   # 0x1383c0
jmp 0x3025e
leaq 0x4d8(%rbx), %rdi
callq 0xe514a
movsd %xmm0, 0x4e8(%rbx)
leaq 0x4d8(%rbx), %rdi
xorl %esi, %esi
callq 0x28020
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x268(%rax)
callq 0x27460
testl %eax, %eax
je 0x30299
leaq 0x108675(%rip), %rdi    # 0x138905
movl %eax, %esi
xorl %eax, %eax
callq 0x27080
popq %rbx
xorl %eax, %eax
retq
nop