// File: /workspace/github_cpp_makefile_star2_O1/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 0x303f6
pushq %rbx
movq %rdi, %rbx
addq $0x80, %rdi
xorl %esi, %esi
callq 0x7b170
cvtsd2ss 0x380(%rbx), %xmm0
cvtsd2ss 0x388(%rbx), %xmm1
cvtsd2ss 0x390(%rbx), %xmm2
movss 0x10ae4d(%rip), %xmm3   # 0x13b040
callq 0x27e90
movl $0x4100, %edi           # imm = 0x4100
callq 0x271f0
leaq 0x18f807(%rip), %rdx    # 0x1bfa10
movl $0x4000, %edi           # imm = 0x4000
movl $0x1203, %esi           # imm = 0x1203
callq 0x28110
leaq 0x18f801(%rip), %rdx    # 0x1bfa20
movl $0x4001, %edi           # imm = 0x4001
movl $0x1203, %esi           # imm = 0x1203
callq 0x28110
cmpl $0x0, 0x2f8(%rbx)
je 0x30243
movl $0xb44, %edi            # imm = 0xB44
callq 0x27200
jmp 0x3024d
movl $0xb44, %edi            # imm = 0xB44
callq 0x27860
movl $0xb50, %edi            # imm = 0xB50
callq 0x27200
movss 0x10ade1(%rip), %xmm0   # 0x13b040
callq 0x270a0
movss 0x10add4(%rip), %xmm0   # 0x13b040
callq 0x281b0
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 0x30396
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x2f8(%rax)
movq 0x4f0(%rbx), %rdi
callq 0x27b30
movq $0x0, 0x4f0(%rbx)
xorpd %xmm0, %xmm0
ucomisd 0x4e8(%rbx), %xmm0
jbe 0x303ae
movsd 0x10b014(%rip), %xmm0   # 0x13b3c0
jmp 0x303ba
leaq 0x4d8(%rbx), %rdi
callq 0xe698e
movsd %xmm0, 0x4e8(%rbx)
leaq 0x4d8(%rbx), %rdi
xorl %esi, %esi
callq 0x28030
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x268(%rax)
callq 0x27460
testl %eax, %eax
je 0x303f5
leaq 0x10b4b9(%rip), %rdi    # 0x13b8a5
movl %eax, %esi
xorl %eax, %eax
callq 0x27080
popq %rbx
xorl %eax, %eax
retq
nop