// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Sphere::Draw(gaps::RNFlags) const
void R3Sphere::
Draw(const R3DrawFlags draw_flags) const
{
    // Draw sphere - sphdraw uses n3f only ???
#if (RN_3D_GRFX == RN_OPENGL)
    // Create GLU quadric
    static GLUquadricObj *sphere = gluNewQuadric(); // ???

    // Push matrix 
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	if (draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_SMOOTH);
	else if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_FLAT);
	if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) gluQuadricTexture(sphere, GL_TRUE);
	else gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_FILL);
	gluSphere(sphere, radius, 16, 8);
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	gluQuadricNormals(sphere, (GLenum) GLU_NONE);
	gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_SILHOUETTE);
	gluSphere(sphere, radius, 16, 8);
    }

    // Pop matrix
    matrix.Pop();
#else
    RNAbort("Not Implemented");
#endif
}

// Assembly:
subq $0xf8, %rsp
movq %rsi, 0xf0(%rsp)
movq %rdi, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpb $0x0, 0x501225(%rip)    # 0x579840
jne 0x78652
leaq 0x50121c(%rip), %rdi    # 0x579840
callq 0xf8e0
cmpl $0x0, %eax
je 0x78652
callq 0xf5c0
movq %rax, 0x8(%rsp)
jmp 0x7863a
movq 0x8(%rsp), %rax
movq %rax, 0x5011f2(%rip)    # 0x579838
leaq 0x5011f3(%rip), %rdi    # 0x579840
callq 0xf310
leaq 0x58(%rsp), %rdi
leaq 0x1005d2(%rip), %rsi    # 0x178c30
callq 0x51b60
movq 0x10(%rsp), %rsi
addq $0x8, %rsi
leaq 0x40(%rsp), %rdi
callq 0x36d10
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x534b0
leaq 0x58(%rsp), %rdi
callq 0x75ad0
leaq 0x38(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x38(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x787c8
leaq 0x30(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x13d80
movq 0x30(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78717
movq 0x501152(%rip), %rdi    # 0x579838
movl $0x186a0, %esi          # imm = 0x186A0
callq 0xf1e0
jmp 0x78750
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x501133(%rip), %rdi    # 0x579840
callq 0xf300
jmp 0x78850
leaq 0x28(%rsp), %rdi
movl $0x20, %esi
callq 0x13d80
movq 0x28(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x7874e
movq 0x5010f4(%rip), %rdi    # 0x579838
movl $0x186a1, %esi          # imm = 0x186A1
callq 0xf1e0
jmp 0x78750
leaq 0x20(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq 0x20(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78789
movq 0x5010bb(%rip), %rdi    # 0x579838
movl $0x1, %esi
callq 0xf900
jmp 0x78797
movq 0x5010a8(%rip), %rdi    # 0x579838
xorl %esi, %esi
callq 0xf900
movq 0x50109a(%rip), %rdi    # 0x579838
movl $0x186ac, %esi          # imm = 0x186AC
callq 0xf820
movq 0x10(%rsp), %rax
movq 0x501084(%rip), %rdi    # 0x579838
movsd 0x20(%rax), %xmm0
movl $0x10, %esi
movl $0x8, %edx
callq 0xf240
leaq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x13d80
movq 0x18(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x7883e
movq 0x501043(%rip), %rdi    # 0x579838
movl $0x186a2, %esi          # imm = 0x186A2
callq 0xf1e0
movq 0x501032(%rip), %rdi    # 0x579838
xorl %esi, %esi
callq 0xf900
movq 0x501024(%rip), %rdi    # 0x579838
movl $0x186ad, %esi          # imm = 0x186AD
callq 0xf820
movq 0x10(%rsp), %rax
movq 0x50100e(%rip), %rdi    # 0x579838
movsd 0x20(%rax), %xmm0
movl $0x10, %esi
movl $0x8, %edx
callq 0xf240
leaq 0x58(%rsp), %rdi
callq 0x75b00
addq $0xf8, %rsp
retq
movq 0xe0(%rsp), %rdi
callq 0xf890
nopl (%rax)