// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Cylinder::Draw(gaps::RNFlags) const
void R3Cylinder::
Draw(const R3DrawFlags draw_flags) const
{
#if (RN_3D_GRFX == RN_OPENGL)
    // Create GLU quadric
    static GLUquadricObj *cylinder = 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(cylinder, (GLenum) GLU_SMOOTH);
	else if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) gluQuadricNormals(cylinder, (GLenum) GLU_FLAT);
	if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) gluQuadricTexture(cylinder, GL_TRUE);
	else gluQuadricTexture(cylinder, GL_FALSE);
	gluQuadricDrawStyle(cylinder, (GLenum) GLU_FILL);
	gluCylinder(cylinder, base.Radius(), top.Radius(), Height(), 16, 1);
	gluQuadricOrientation(cylinder, (GLenum) GLU_INSIDE);
	gluDisk(cylinder, 0.0, Radius(), 16, 1);
	gluQuadricOrientation(cylinder, (GLenum) GLU_OUTSIDE);
	glTranslated(0.0, 0.0, Height());
	gluDisk(cylinder, 0.0, Radius(), 16, 1);
    }

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

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

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rsi, 0x130(%rsp)
movq %rdi, 0x128(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpb $0x0, 0x501925(%rip)    # 0x579820
jne 0x77f32
leaq 0x50191c(%rip), %rdi    # 0x579820
callq 0xf8e0
cmpl $0x0, %eax
je 0x77f32
callq 0xf5c0
movq %rax, 0x48(%rsp)
jmp 0x77f1a
movq 0x48(%rsp), %rax
movq %rax, 0x5018f2(%rip)    # 0x579818
leaq 0x5018f3(%rip), %rdi    # 0x579820
callq 0xf310
leaq 0x98(%rsp), %rdi
leaq 0x100cef(%rip), %rsi    # 0x178c30
callq 0x51b60
movq 0x50(%rsp), %rdi
addq $0x8, %rdi
callq 0x39250
movq %rax, %rsi
leaq 0x80(%rsp), %rdi
callq 0x36d10
leaq 0x98(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x534b0
movq 0x50(%rsp), %rdi
addq $0x8, %rdi
callq 0x392b0
movq %rax, %rdx
leaq 0x98(%rsp), %rdi
leaq 0x501667(%rip), %rsi    # 0x579600
callq 0x53ec0
leaq 0x98(%rsp), %rdi
callq 0x75ad0
leaq 0x78(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x78(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x781c2
leaq 0x70(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x13d80
movq 0x70(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78033
movq 0x501816(%rip), %rdi    # 0x579818
movl $0x186a0, %esi          # imm = 0x186A0
callq 0xf1e0
jmp 0x7806c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0x5017f7(%rip), %rdi    # 0x579820
callq 0xf300
jmp 0x78295
leaq 0x68(%rsp), %rdi
movl $0x20, %esi
callq 0x13d80
movq 0x68(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x7806a
movq 0x5017b8(%rip), %rdi    # 0x579818
movl $0x186a1, %esi          # imm = 0x186A1
callq 0xf1e0
jmp 0x7806c
leaq 0x60(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x13d80
movq 0x60(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x780a5
movq 0x50177f(%rip), %rdi    # 0x579818
movl $0x1, %esi
callq 0xf900
jmp 0x780b3
movq 0x50176c(%rip), %rdi    # 0x579818
xorl %esi, %esi
callq 0xf900
movq 0x50175e(%rip), %rdi    # 0x579818
movl $0x186ac, %esi          # imm = 0x186AC
callq 0xf820
movq 0x50(%rsp), %rdi
movq 0x501748(%rip), %rax    # 0x579818
movq %rax, 0x20(%rsp)
addq $0x58, %rdi
callq 0x3c2e0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x30(%rsp)
addq $0xa0, %rdi
callq 0x3c2e0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x28(%rsp)
callq 0x39ff0
movq 0x20(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x30(%rsp), %xmm0
movl $0x10, %esi
movl $0x1, %edx
callq 0xf090
movq 0x5016e9(%rip), %rdi    # 0x579818
movl $0x186b5, %esi          # imm = 0x186B5
callq 0xf160
movq 0x50(%rsp), %rdi
movq 0x5016d3(%rip), %rax    # 0x579818
movq %rax, 0x38(%rsp)
callq 0x39fd0
movq 0x38(%rsp), %rdi
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
movl $0x10, %esi
movl $0x1, %edx
callq 0xf560
movq 0x5016a8(%rip), %rdi    # 0x579818
movl $0x186b4, %esi          # imm = 0x186B4
callq 0xf160
movq 0x50(%rsp), %rdi
callq 0x39ff0
movaps %xmm0, %xmm2
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xf530
movq 0x50(%rsp), %rdi
movq 0x50167a(%rip), %rax    # 0x579818
movq %rax, 0x40(%rsp)
callq 0x39fd0
movq 0x40(%rsp), %rdi
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
movl $0x10, %esi
movl $0x1, %edx
callq 0xf560
leaq 0x58(%rsp), %rdi
movl $0x1, %esi
callq 0x13d80
movq 0x58(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x13d50
cmpl $0x0, %eax
je 0x78280
movq 0x501625(%rip), %rdi    # 0x579818
movl $0x186a2, %esi          # imm = 0x186A2
callq 0xf1e0
movq 0x501614(%rip), %rdi    # 0x579818
xorl %esi, %esi
callq 0xf900
movq 0x501606(%rip), %rdi    # 0x579818
movl $0x186ad, %esi          # imm = 0x186AD
callq 0xf820
movq 0x50(%rsp), %rdi
movq 0x5015f0(%rip), %rax    # 0x579818
movq %rax, 0x8(%rsp)
addq $0x58, %rdi
callq 0x3c2e0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x18(%rsp)
addq $0xa0, %rdi
callq 0x3c2e0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x39ff0
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
movl $0x10, %esi
movl $0x1, %edx
callq 0xf090
leaq 0x98(%rsp), %rdi
callq 0x75b00
addq $0x138, %rsp            # imm = 0x138
retq
movq 0x120(%rsp), %rdi
callq 0xf890
nopw %cs:(%rax,%rax)