// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::DrawImage(int, double) const
void RGBDImage::
DrawImage(int color_scheme, RNLength depth) const
{
  // Check image
  if ((width == 0) || (height == 0)) return;

  // Update/select opengl texture
  if (opengl_texture_id <= 0) ((RGBDImage *) this)->UpdateOpenGL();
  if (opengl_texture_id <= 0) return;
  glBindTexture(GL_TEXTURE_2D, opengl_texture_id);
  glEnable(GL_TEXTURE_2D);

  // Set color
  glDisable(GL_LIGHTING);
  RNLoadRgb(1.0, 1.0, 1.0);

  // Check depth
  if (depth > 0) {
    // Draw textured polygon on view plane
    R3Point viewpoint = WorldViewpoint();
    R3Vector towards = WorldTowards();
    R3Vector right = WorldRight();
    R3Vector up = WorldUp();
    R3Point c = viewpoint + depth * towards;
    R3Vector dx = (depth * 0.5*width / intrinsics[0][0]) * right;
    R3Vector dy = (depth * 0.5*height / intrinsics[1][1]) * up;
    c -= dx*(intrinsics[0][2] - 0.5*width)/width;
    c -= dy*(intrinsics[1][2] - 0.5*height)/height;
    RNGrfxBegin(RN_GRFX_QUADS);
    R3LoadTextureCoords(0, 0);
    R3LoadPoint(c - dx - dy);
    R3LoadTextureCoords(1, 0);
    R3LoadPoint(c + dx - dy);
    R3LoadTextureCoords(1, 1);
    R3LoadPoint(c + dx + dy);
    R3LoadTextureCoords(0, 1);
    R3LoadPoint(c - dx + dy);
    RNGrfxEnd();
  }
  else {
    // Draw textured polygon on screen plane (in pixels)
    RNGrfxBegin(RN_GRFX_QUADS);
    R3LoadTextureCoords(0, 0);
    R3LoadPoint(0, 0, 0);
    R3LoadTextureCoords(1, 0);
    R3LoadPoint(width-1, 0, 0);
    R3LoadTextureCoords(1, 1);
    R3LoadPoint(width-1, height-1, 0);
    R3LoadTextureCoords(0, 1);
    R3LoadPoint(0, height-1, 0);
    RNGrfxEnd();
  }
  
  // Unselect opengl texture
  glDisable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, 0);
}

// Assembly:
cmpl $0x0, 0x28(%rdi)
je 0x1edaf
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x2c(%rdi)
je 0x1ed9e
cmpl $0x0, 0x1c8(%rbx)
movsd %xmm0, 0x8(%rsp)
jg 0x1ea3f
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1d0(%rax)
movl 0x1c8(%rbx), %esi
testl %esi, %esi
jle 0x1ed9e
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11760
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11540
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movsd 0x9e5b5(%rip), %xmm0    # 0xbd028
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
callq 0x11900
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1ed11
leaq 0x38(%rbx), %r14
leaq 0xe9111(%rip), %rdx     # 0x107bb0
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4a83e
leaq 0xa052f(%rip), %rdx     # 0xbefe8
leaq 0xb8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0xa049d(%rip), %rdx     # 0xbef70
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0xa049b(%rip), %rdx     # 0xbef88
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x4d2ae
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4c191
movsd 0x8(%rsp), %xmm1
mulsd 0x9e4e9(%rip), %xmm1    # 0xbd020
movsd %xmm1, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rbx), %xmm0
mulsd %xmm1, %xmm0
divsd 0x140(%rbx), %xmm0
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d2ae
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
mulsd 0x8(%rsp), %xmm0
divsd 0x160(%rbx), %xmm0
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x4d2ae
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rbx), %xmm0
mulsd 0x9f4b9(%rip), %xmm0    # 0xbe050
addsd 0x150(%rbx), %xmm0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d2ae
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rbx), %xmm0
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x4d620
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4c7b4
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
mulsd 0x9f46e(%rip), %xmm0    # 0xbe050
addsd 0x168(%rbx), %xmm0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4d2ae
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4d620
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4c7b4
movl $0x7, %edi
callq 0x11150
xorl %edi, %edi
xorl %esi, %esi
callq 0x11440
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4c86d
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c86d
movq %r14, %rdi
callq 0x11170
movl $0x1, %edi
xorl %esi, %esi
callq 0x11440
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4c191
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c86d
movq %r14, %rdi
callq 0x11170
movl $0x1, %edi
movl $0x1, %esi
callq 0x11440
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4c191
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c191
movq %r14, %rdi
callq 0x11170
xorl %edi, %edi
movl $0x1, %esi
callq 0x11440
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4c86d
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c191
movq %r14, %rdi
callq 0x11170
jmp 0x1ed83
movl $0x7, %edi
callq 0x11150
xorl %edi, %edi
xorl %esi, %esi
callq 0x11440
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x11470
movl $0x1, %edi
xorl %esi, %esi
callq 0x11440
movl 0x28(%rbx), %edi
decl %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x11470
movl $0x1, %edi
movl $0x1, %esi
callq 0x11440
movl 0x28(%rbx), %edi
movl 0x2c(%rbx), %esi
decl %edi
decl %esi
xorl %edx, %edx
callq 0x11470
xorl %edi, %edi
movl $0x1, %esi
callq 0x11440
movl 0x2c(%rbx), %esi
decl %esi
xorl %edi, %edi
xorl %edx, %edx
callq 0x11470
callq 0x117d0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11180
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
callq 0x11760
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq