// File: /workspace/github_c_makefile_star2_O1/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, 0x5abfad(%rip)    # 0x5f99a4
je 0x4da05
callq 0x656ac
callq 0x5de60
jmp 0x4da34
movb $0x1, 0x5abf98(%rip)    # 0x5f99a4
movabsq $0x3fb0000000000000, %rax # imm = 0x3FB0000000000000
movq %rax, 0x5abf8b(%rip)    # 0x5f99a8
movq %rax, 0x5abf8c(%rip)    # 0x5f99b0
xorl %eax, %eax
movq %rax, 0x5abf8b(%rip)    # 0x5f99b8
movq %rax, 0x5abf8c(%rip)    # 0x5f99c0
movl $0xbf800000, 0x5abf8a(%rip) # imm = 0xBF800000
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x5abf83(%rip)    # 0x5f99cc
movl %eax, 0x5abf81(%rip)    # 0x5f99d0
leaq 0x5abcea(%rip), %rbx    # 0x5f9740
movq 0x1f0(%rbx), %rax
testq %rax, %rax
je 0x4da80
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, 0x5abf4d(%rip)    # 0x5f99d4
je 0x4daa9
leaq 0x5abf44(%rip), %rsi    # 0x5f99d4
movl $0x1, %edi
callq *0x110(%rbx)
xorl %eax, %eax
movl %eax, 0x5abf35(%rip)    # 0x5f99d8
movl %eax, 0x5abf2b(%rip)    # 0x5f99d4
cmpl $0x0, 0x5abf34(%rip)    # 0x5f99e4
je 0x4dace
leaq 0x5abf2b(%rip), %rsi    # 0x5f99e4
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5abf16(%rip)    # 0x5f99e4
movl 0x5abf0c(%rip), %edi    # 0x5f99e0
testl %edi, %edi
je 0x4dae8
callq *0x168(%rbx)
movl $0x0, 0x5abef8(%rip)    # 0x5f99e0
cmpl $0x0, 0x5abf31(%rip)    # 0x5f9a20
je 0x4db0d
leaq 0x5abf28(%rip), %rsi    # 0x5f9a20
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5abf13(%rip)    # 0x5f9a20
cmpl $0x0, 0x5abf08(%rip)    # 0x5f9a1c
je 0x4db32
leaq 0x5abeff(%rip), %rsi    # 0x5f9a1c
movl $0x1, %edi
callq *0x110(%rbx)
movl $0x0, 0x5abeea(%rip)    # 0x5f9a1c
movl 0x5abee0(%rip), %edi    # 0x5f9a18
testl %edi, %edi
je 0x4db4c
callq *0x168(%rbx)
movl $0x0, 0x5abecc(%rip)    # 0x5f9a18
cmpl $0x0, 0x5abef1(%rip)    # 0x5f9a44
je 0x4db71
leaq 0x5abee8(%rip), %rsi    # 0x5f9a44
movl $0x1, %edi
callq *0xc0(%rbx)
movl $0x0, 0x5abed3(%rip)    # 0x5f9a44
cmpl $0x0, 0x5abed0(%rip)    # 0x5f9a48
je 0x4db96
leaq 0x5abec7(%rip), %rsi    # 0x5f9a48
movl $0x1, %edi
callq *0xc0(%rbx)
movl $0x0, 0x5abeb2(%rip)    # 0x5f9a48
popq %rbx
retq