// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Cone::Draw(gaps::RNFlags) const
void R3Cone::
Draw(const R3DrawFlags draw_flags) const
{
#if (RN_3D_GRFX == RN_OPENGL)
    // Create GLU quadric
    // Should create GLU quadric for each draw style ???
    static GLUquadricObj *cone = gluNewQuadric(); 

    // Push matrix
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(axis.Start().Vector());
    matrix.Rotate(R3posz_vector, axis.Vector());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	if (draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG]) gluQuadricNormals(cone, (GLenum) GLU_SMOOTH);
	else if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) gluQuadricNormals(cone, (GLenum) GLU_FLAT);
	if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) gluQuadricTexture(cone, GL_TRUE);
	else gluQuadricTexture(cone, GL_FALSE);
	gluQuadricDrawStyle(cone, (GLenum) GLU_FILL);
	gluCylinder(cone, Radius(), 0.0, Height(), 16, 1);
	gluQuadricOrientation(cone, (GLenum) GLU_INSIDE);
	gluDisk(cone, 0.0, Radius(), 16, 1);
	gluQuadricOrientation(cone, (GLenum) GLU_OUTSIDE);
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	gluQuadricNormals(cone, (GLenum) GLU_NONE);
	gluQuadricTexture(cone, GL_FALSE);
	gluQuadricDrawStyle(cone, (GLenum) GLU_SILHOUETTE);
	gluCylinder(cone, Radius(), 0.0, Height(), 16, 1);
    }

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

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rsi, 0x110(%rsp)
movq %rdi, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpb $0x0, 0x501555(%rip)    # 0x579830
jne 0x78312
leaq 0x50154c(%rip), %rdi    # 0x579830
callq 0xf8e0
cmpl $0x0, %eax
je 0x78312
callq 0xf5c0
movq %rax, 0x28(%rsp)
jmp 0x782fa
movq 0x28(%rsp), %rax
movq %rax, 0x501522(%rip)    # 0x579828
leaq 0x501523(%rip), %rdi    # 0x579830
callq 0xf310
leaq 0x78(%rsp), %rdi
leaq 0x100912(%rip), %rsi    # 0x178c30
callq 0x51b60
movq 0x30(%rsp), %rdi
addq $0x8, %rdi
callq 0x39250
movq %rax, %rsi
leaq 0x60(%rsp), %rdi
callq 0x36d10
leaq 0x78(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x534b0
movq 0x30(%rsp), %rdi
addq $0x8, %rdi
callq 0x392b0
movq %rax, %rdx
leaq 0x78(%rsp), %rdi
leaq 0x501296(%rip), %rsi    # 0x579600
callq 0x53ec0
leaq 0x78(%rsp), %rdi
callq 0x75ad0
leaq 0x58(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x58(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x7852a
leaq 0x50(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x13d80
movq 0x50(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78401
movq 0x501458(%rip), %rdi    # 0x579828
movl $0x186a0, %esi          # imm = 0x186A0
callq 0xf1e0
jmp 0x7843a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x501439(%rip), %rdi    # 0x579830
callq 0xf300
jmp 0x785d6
leaq 0x48(%rsp), %rdi
movl $0x20, %esi
callq 0x13d80
movq 0x48(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78438
movq 0x5013fa(%rip), %rdi    # 0x579828
movl $0x186a1, %esi          # imm = 0x186A1
callq 0xf1e0
jmp 0x7843a
leaq 0x40(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq 0x40(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78473
movq 0x5013c1(%rip), %rdi    # 0x579828
movl $0x1, %esi
callq 0xf900
jmp 0x78481
movq 0x5013ae(%rip), %rdi    # 0x579828
xorl %esi, %esi
callq 0xf900
movq 0x5013a0(%rip), %rdi    # 0x579828
movl $0x186ac, %esi          # imm = 0x186AC
callq 0xf820
movq 0x30(%rsp), %rdi
movq 0x50138a(%rip), %rax    # 0x579828
movq %rax, 0x10(%rsp)
callq 0x78cd0
movq 0x30(%rsp), %rdi
movsd %xmm0, 0x18(%rsp)
callq 0x78cf0
movq 0x10(%rsp), %rdi
movaps %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
xorps %xmm1, %xmm1
movl $0x10, %esi
movl $0x1, %edx
callq 0xf090
movq 0x501349(%rip), %rdi    # 0x579828
movl $0x186b5, %esi          # imm = 0x186B5
callq 0xf160
movq 0x30(%rsp), %rdi
movq 0x501333(%rip), %rax    # 0x579828
movq %rax, 0x20(%rsp)
callq 0x78cd0
movq 0x20(%rsp), %rdi
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
movl $0x10, %esi
movl $0x1, %edx
callq 0xf560
movq 0x501308(%rip), %rdi    # 0x579828
movl $0x186b4, %esi          # imm = 0x186B4
callq 0xf160
leaq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x13d80
movq 0x38(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x785c4
movq 0x5012d1(%rip), %rdi    # 0x579828
movl $0x186a2, %esi          # imm = 0x186A2
callq 0xf1e0
movq 0x5012c0(%rip), %rdi    # 0x579828
xorl %esi, %esi
callq 0xf900
movq 0x5012b2(%rip), %rdi    # 0x579828
movl $0x186ad, %esi          # imm = 0x186AD
callq 0xf820
movq 0x30(%rsp), %rdi
movq 0x50129c(%rip), %rax    # 0x579828
movq %rax, (%rsp)
callq 0x78cd0
movq 0x30(%rsp), %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x78cf0
movq (%rsp), %rdi
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
movl $0x10, %esi
movl $0x1, %edx
callq 0xf090
leaq 0x78(%rsp), %rdi
callq 0x75b00
addq $0x118, %rsp            # imm = 0x118
retq
movq 0x100(%rsp), %rdi
callq 0xf890
nopw %cs:(%rax,%rax)