// File: /workspace/github_cpp_makefile_star2_O3/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 0x1eb04
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x2c(%rdi)
je 0x1eaf3
movl 0x1c8(%rbx), %esi
testl %esi, %esi
movsd %xmm0, 0x8(%rsp)
jg 0x1e7a2
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1d0(%rax)
movl 0x1c8(%rbx), %esi
testl %esi, %esi
jle 0x1eaf3
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11750
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11540
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movsd 0x9c860(%rip), %xmm0    # 0xbb028
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
callq 0x118f0
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1ea66
leaq 0x38(%rbx), %r14
leaq 0xe73ac(%rip), %rdx     # 0x105ba0
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x49ffa
leaq 0x9e7da(%rip), %rdx     # 0xbcfe8
leaq 0xb8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x9e748(%rip), %rdx     # 0xbcf70
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x9e746(%rip), %rdx     # 0xbcf88
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x4ca32
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4b947
movsd 0x8(%rsp), %xmm1
mulsd 0x9c794(%rip), %xmm1    # 0xbb020
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 0x4ca32
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 0x4ca32
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rbx), %xmm0
mulsd 0x9d764(%rip), %xmm0    # 0xbc050
addsd 0x150(%rbx), %xmm0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4ca32
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rbx), %xmm0
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x4cd7c
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4bf6a
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
mulsd 0x9d719(%rip), %xmm0    # 0xbc050
addsd 0x168(%rbx), %xmm0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4ca32
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4cd7c
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4bf6a
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 0x4c023
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c023
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 0x4b947
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c023
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 0x4b947
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4b947
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 0x4c023
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4b947
movq %r14, %rdi
callq 0x11170
jmp 0x1ead8
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 0x117c0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11180
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
callq 0x11750
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop