// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_glreset
void polymost_glreset (void)
{
	//Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory)
	if (gltexcacnum < 0)
	{
		gltexcacnum = 0;

			//Hack for polymost_dorotatesprite calls before 1st polymost_drawrooms()
		gcosang = gcosang2 = ((double)16384)/262144.0;
		gsinang = gsinang2 = ((double)    0)/262144.0;
	}
	else
	{
		PTReset();
		clearskins();
	}

	glox1 = -1;
	lastglpolygonmode = -1;
	lastglredbluemode = -1;

	if (glfunc.glUseProgram) {
		glfunc.glUseProgram(0);
#if (USE_OPENGL == USE_GL3)
		glfunc.glBindVertexArray(0);
#endif
		glfunc.glBindBuffer(GL_ARRAY_BUFFER, 0);
		glfunc.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	}

	if (elementindexbuffer) {
		glfunc.glDeleteBuffers(1, &elementindexbuffer);
		elementindexbuffersize = 0;
		elementindexbuffer = 0;
	}

#if (USE_OPENGL == USE_GL3)
	if (polymostglsl.vao) {
		glfunc.glDeleteVertexArrays(1, &polymostglsl.vao);
		polymostglsl.vao = 0;
	}
#endif
	if (polymostglsl.elementbuffer) {
		glfunc.glDeleteBuffers(1, &polymostglsl.elementbuffer);
		polymostglsl.elementbuffer = 0;
	}
	if (polymostglsl.program) {
		glfunc.glDeleteProgram(polymostglsl.program);
		polymostglsl.program = 0;
	}

#if (USE_OPENGL == USE_GL3)
	if (polymostauxglsl.vao) {
		glfunc.glDeleteVertexArrays(1, &polymostauxglsl.vao);
		polymostauxglsl.vao = 0;
	}
#endif
	if (polymostauxglsl.indexbuffer) {
		glfunc.glDeleteBuffers(1, &polymostauxglsl.indexbuffer);
		polymostauxglsl.indexbuffer = 0;
	}
	if (polymostauxglsl.elementbuffer) {
		glfunc.glDeleteBuffers(1, &polymostauxglsl.elementbuffer);
		polymostauxglsl.elementbuffer = 0;
	}
	if (polymostauxglsl.program) {
		glfunc.glDeleteProgram(polymostauxglsl.program);
		polymostauxglsl.program = 0;
	}

	if (texttexture) {
		glfunc.glDeleteTextures(1, &texttexture);
		texttexture = 0;
	}

	if (nulltexture) {
		glfunc.glDeleteTextures(1, &nulltexture);
		nulltexture = 0;
	}
}

// Assembly:
pushq %rbx
cmpb $0x0, 0x5aa839(%rip)    # 0x5fa9a4
je 0x50179
callq 0x673af
callq 0x5ff22
jmp 0x501a8
movb $0x1, 0x5aa824(%rip)    # 0x5fa9a4
movabsq $0x3fb0000000000000, %rax # imm = 0x3FB0000000000000
movq %rax, 0x5aa817(%rip)    # 0x5fa9a8
movq %rax, 0x5aa818(%rip)    # 0x5fa9b0
xorl %eax, %eax
movq %rax, 0x5aa817(%rip)    # 0x5fa9b8
movq %rax, 0x5aa818(%rip)    # 0x5fa9c0
movl $0xbf800000, 0x5aa816(%rip) # imm = 0xBF800000
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x5aa80f(%rip)    # 0x5fa9cc
movl %eax, 0x5aa80d(%rip)    # 0x5fa9d0
leaq 0x5aa576(%rip), %rbx    # 0x5fa740
movq 0x1f0(%rbx), %rax
testq %rax, %rax
je 0x501f4
xorl %edi, %edi
callq *%rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *0xf8(%rbx)
movl $0x8893, %edi           # imm = 0x8893
xorl %esi, %esi
callq *0xf8(%rbx)
cmpl $0x0, 0x5aa7d9(%rip)    # 0x5fa9d4
je 0x5021d
leaq 0x5aa7d0(%rip), %rsi    # 0x5fa9d4
movl $0x1, %edi
callq *0x110(%rbx)
xorl %eax, %eax
movl %eax, 0x5aa7c1(%rip)    # 0x5fa9d8
movl %eax, 0x5aa7b7(%rip)    # 0x5fa9d4
cmpl $0x0, 0x5aa7c0(%rip)    # 0x5fa9e4
je 0x50242
leaq 0x5aa7b7(%rip), %rsi    # 0x5fa9e4
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5aa7a2(%rip)    # 0x5fa9e4
movl 0x5aa798(%rip), %edi    # 0x5fa9e0
testl %edi, %edi
je 0x5025c
callq *0x168(%rbx)
movl $0x0, 0x5aa784(%rip)    # 0x5fa9e0
cmpl $0x0, 0x5aa7bd(%rip)    # 0x5faa20
je 0x50281
leaq 0x5aa7b4(%rip), %rsi    # 0x5faa20
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5aa79f(%rip)    # 0x5faa20
cmpl $0x0, 0x5aa794(%rip)    # 0x5faa1c
je 0x502a6
leaq 0x5aa78b(%rip), %rsi    # 0x5faa1c
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5aa776(%rip)    # 0x5faa1c
movl 0x5aa76c(%rip), %edi    # 0x5faa18
testl %edi, %edi
je 0x502c0
callq *0x168(%rbx)
movl $0x0, 0x5aa758(%rip)    # 0x5faa18
cmpl $0x0, 0x5aa77d(%rip)    # 0x5faa44
je 0x502e5
leaq 0x5aa774(%rip), %rsi    # 0x5faa44
movl $0x1, %edi
callq *0xc0(%rbx)
movl $0x0, 0x5aa75f(%rip)    # 0x5faa44
cmpl $0x0, 0x5aa75c(%rip)    # 0x5faa48
je 0x5030a
leaq 0x5aa753(%rip), %rsi    # 0x5faa48
movl $0x1, %edi
callq *0xc0(%rbx)
movl $0x0, 0x5aa73e(%rip)    # 0x5faa48
popq %rbx
retq