// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::UpdateOpenGL()
void RGBDImage::
UpdateOpenGL(void) 
{
  // Check identifier
  if (opengl_texture_id > 0) return;
  
  // Create identifier
  GLuint identifier;
  glGenTextures(1, &identifier);

  // Read color channels
  // ReadColorChannels();
  
  // Create temporary R2Image
  R2Image rgb_image(width, height, 3);
  for (int iy = 0; iy < height; iy++) {
    for (int ix = 0; ix < width; ix++) {
      rgb_image.SetPixelRGB(ix, iy, PixelColor(ix, iy));
    }
  }

  // Release color channels
  // ReleaseColorChannels();

  // Define texture
  glBindTexture(GL_TEXTURE_2D, identifier);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, rgb_image.Width(), rgb_image.Height(),
    GL_RGB, GL_UNSIGNED_BYTE, (const unsigned char *) rgb_image.Pixels());

  // Remember identifier
  opengl_texture_id = identifier;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x1c8(%rax)
jle 0x2f6ba
jmp 0x2f883
movl $0x1, %edi
leaq 0x7c(%rsp), %rsi
callq 0x129d0
movq 0x28(%rsp), %rax
movl 0x28(%rax), %esi
movl 0x2c(%rax), %edx
leaq 0x60(%rsp), %rdi
movl $0x3, %ecx
callq 0xd1c40
movl $0x0, 0x5c(%rsp)
movq 0x28(%rsp), %rcx
movl 0x5c(%rsp), %eax
cmpl 0x2c(%rcx), %eax
jge 0x2f78b
movl $0x0, 0x58(%rsp)
movq 0x28(%rsp), %rcx
movl 0x58(%rsp), %eax
cmpl 0x28(%rcx), %eax
jge 0x2f779
movq 0x28(%rsp), %rsi
movl 0x58(%rsp), %edx
movl %edx, 0x20(%rsp)
movl 0x5c(%rsp), %ecx
movl %ecx, 0x24(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x29420
jmp 0x2f734
movl 0x24(%rsp), %edx
movl 0x20(%rsp), %esi
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rcx
callq 0xd2490
jmp 0x2f74d
jmp 0x2f74f
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x2f705
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xd2160
jmp 0x2f88b
jmp 0x2f77b
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x2f6eb
movl 0x7c(%rsp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x128c0
jmp 0x2f79b
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2802, %esi           # imm = 0x2802
movl $0x2900, %edx           # imm = 0x2900
callq 0x129b0
jmp 0x2f7b1
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2803, %esi           # imm = 0x2803
movl $0x2900, %edx           # imm = 0x2900
callq 0x129b0
jmp 0x2f7c7
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2703, %edx           # imm = 0x2703
callq 0x129b0
jmp 0x2f7dd
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2601, %edx           # imm = 0x2601
callq 0x129b0
jmp 0x2f7f3
movl $0x2300, %edi           # imm = 0x2300
movl $0x2200, %esi           # imm = 0x2200
movl $0x2100, %edx           # imm = 0x2100
callq 0x127c0
jmp 0x2f809
leaq 0x60(%rsp), %rdi
callq 0x22940
movl %eax, 0x1c(%rsp)
jmp 0x2f819
leaq 0x60(%rsp), %rdi
callq 0x22950
movl %eax, 0x18(%rsp)
jmp 0x2f829
leaq 0x60(%rsp), %rdi
callq 0x30830
movq %rax, 0x10(%rsp)
jmp 0x2f83a
movl 0x18(%rsp), %ecx
movl 0x1c(%rsp), %edx
movq 0x10(%rsp), %rsi
movq %rsp, %rax
movq %rsi, (%rax)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x3, %esi
movl $0x1907, %r8d           # imm = 0x1907
movl $0x1401, %r9d           # imm = 0x1401
callq 0x123d0
jmp 0x2f86a
movq 0x28(%rsp), %rax
movl 0x7c(%rsp), %ecx
movl %ecx, 0x1c8(%rax)
leaq 0x60(%rsp), %rdi
callq 0xd2160
addq $0x88, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x12c20
nopw %cs:(%rax,%rax)