// File: /workspace/github_cpp_makefile_star2_O2/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 0x2efb7
pushq %rbx
movq %rdi, %rbx
addq $0x80, %rdi
xorl %esi, %esi
callq 0x70a46
cvtsd2ss 0x380(%rbx), %xmm0
cvtsd2ss 0x388(%rbx), %xmm1
cvtsd2ss 0x390(%rbx), %xmm2
movss 0xeb287(%rip), %xmm3    # 0x11a040
callq 0x27ea0
movl $0x4100, %edi           # imm = 0x4100
callq 0x27210
leaq 0x178c61(%rip), %rdx    # 0x1a7a30
movl $0x4000, %edi           # imm = 0x4000
movl $0x1203, %esi           # imm = 0x1203
callq 0x28120
leaq 0x178c5b(%rip), %rdx    # 0x1a7a40
movl $0x4001, %edi           # imm = 0x4001
movl $0x1203, %esi           # imm = 0x1203
callq 0x28120
cmpl $0x0, 0x2f8(%rbx)
je 0x2ee09
movl $0xb44, %edi            # imm = 0xB44
callq 0x27220
jmp 0x2ee13
movl $0xb44, %edi            # imm = 0xB44
callq 0x27870
movl $0xb50, %edi            # imm = 0xB50
callq 0x27220
movss 0xeb21b(%rip), %xmm0    # 0x11a040
callq 0x270a0
movss 0xeb20e(%rip), %xmm0    # 0x11a040
callq 0x281c0
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 0x2ef59
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2f8(%rax)
movq 0x4f0(%rbx), %rdi
callq 0x27b20
andq $0x0, 0x4f0(%rbx)
xorpd %xmm0, %xmm0
ucomisd 0x4e8(%rbx), %xmm0
jbe 0x2ef71
movsd 0xeb451(%rip), %xmm0    # 0x11a3c0
jmp 0x2ef7d
leaq 0x4d8(%rbx), %rdi
callq 0xd0554
movsd %xmm0, 0x4e8(%rbx)
leaq 0x4d8(%rbx), %rdi
callq 0x2baa4
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x268(%rax)
callq 0x27470
testl %eax, %eax
je 0x2efb6
leaq 0xeb908(%rip), %rdi     # 0x11a8b5
movl %eax, %esi
xorl %eax, %eax
callq 0x27080
popq %rbx
xorl %eax, %eax
retq