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

  // Allocate pixels
  unsigned char *pixels = new unsigned char [ width * height * 4];

  // Fill pixels
  unsigned char *pixelsp = pixels;
  for (int iy = 0; iy < height; iy++) {
    for (int ix = 0; ix < width; ix++) {
      RNRgb color = TexelColor(ix, iy);
      *pixelsp++ = (color.R() < 1.0) ? color.R() * 255 : 255;
      *pixelsp++ = (color.G() < 1.0) ? color.G() * 255 : 255;
      *pixelsp++ = (color.B() < 1.0) ? color.B() * 255 : 255;
      *pixelsp++ = 255;
    }
  }

  // Define texture
  glBindTexture(GL_TEXTURE_2D, identifier);
  glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height,
    0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

  // Delete the pixels
  delete [] pixels;

  //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  // 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:
cmpl $0x0, 0x30(%rdi)
jle 0x1c911
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x4(%rsp), %rsi
movl $0x1, %edi
callq 0x11840
movl 0x2c(%rbx), %ebp
movl 0x28(%rbx), %eax
imull %ebp, %eax
shll $0x2, %eax
movslq %eax, %rdi
callq 0x11040
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
jle 0x1c9fb
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
movl $0xff, %r13d
movq 0x8(%rsp), %r14
cmpl $0x0, 0x28(%rbx)
jle 0x1c9f0
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x1b132
movsd 0xa150f(%rip), %xmm2    # 0xbde98
movsd 0xa0697(%rip), %xmm1    # 0xbd028
movsd 0x10(%rsp), %xmm0
ucomisd %xmm0, %xmm1
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
cmovbel %r13d, %eax
movsd 0x18(%rsp), %xmm0
ucomisd %xmm0, %xmm1
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %ecx
cmovbel %r13d, %ecx
movsd 0x20(%rsp), %xmm0
ucomisd %xmm0, %xmm1
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %edx
cmovbel %r13d, %edx
movb %al, (%r14)
movb %cl, 0x1(%r14)
movb %dl, 0x2(%r14)
movb $-0x1, 0x3(%r14)
addq $0x4, %r14
incl %r12d
cmpl 0x28(%rbx), %r12d
jl 0x1c971
incl %ebp
cmpl 0x2c(%rbx), %ebp
jl 0x1c964
movl 0x4(%rsp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x11760
movl $0xcf5, %edi            # imm = 0xCF5
movl $0x4, %esi
callq 0x112c0
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2802, %esi           # imm = 0x2802
movl $0x812f, %edx           # imm = 0x812F
callq 0x11820
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2803, %esi           # imm = 0x2803
movl $0x812f, %edx           # imm = 0x812F
callq 0x11820
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2600, %edx           # imm = 0x2600
callq 0x11820
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2600, %edx           # imm = 0x2600
callq 0x11820
movl $0x2300, %edi           # imm = 0x2300
movl $0x2200, %esi           # imm = 0x2200
movl $0x2100, %edx           # imm = 0x2100
callq 0x11660
movl 0x28(%rbx), %ecx
movl 0x2c(%rbx), %r8d
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1908, %edx           # imm = 0x1908
xorl %r9d, %r9d
movq 0x10(%rsp), %r14
pushq %r14
pushq $0x1401                 # imm = 0x1401
pushq $0x1908                 # imm = 0x1908
callq 0x11230
addq $0x20, %rsp
movq %r14, %rdi
callq 0x117b0
movl 0x4(%rsp), %eax
movl %eax, 0x30(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq