// File: /workspace/github_c_makefile_star2_O2/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, 0x5ad085(%rip)    # 0x5f39a4
je 0x4692d
callq 0x5c85b
callq 0x5595d
jmp 0x4695c
movb $0x1, 0x5ad070(%rip)    # 0x5f39a4
movabsq $0x3fb0000000000000, %rax # imm = 0x3FB0000000000000
movq %rax, 0x5ad063(%rip)    # 0x5f39a8
andq $0x0, 0x5ad06b(%rip)    # 0x5f39b8
movq %rax, 0x5ad05c(%rip)    # 0x5f39b0
andq $0x0, 0x5ad064(%rip)    # 0x5f39c0
orl $-0x1, 0x5ad069(%rip)   # 0x5f39cc
orl $-0x1, 0x5ad066(%rip)   # 0x5f39d0
movl $0xbf800000, 0x5ad054(%rip) # imm = 0xBF800000
leaq 0x5acdc5(%rip), %rbx    # 0x5f3740
movq 0x1f0(%rbx), %rax
testq %rax, %rax
je 0x469a5
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, 0x5ad028(%rip)    # 0x5f39d4
je 0x469cc
leaq 0x5ad01f(%rip), %rsi    # 0x5f39d4
pushq $0x1
popq %rdi
callq *0x110(%rbx)
andl $0x0, 0x5ad013(%rip)    # 0x5f39d8
andl $0x0, 0x5ad008(%rip)    # 0x5f39d4
cmpl $0x0, 0x5ad011(%rip)    # 0x5f39e4
je 0x469ec
leaq 0x5ad008(%rip), %rsi    # 0x5f39e4
pushq $0x1
popq %rdi
callq *0x110(%rbx)
andl $0x0, 0x5acff8(%rip)    # 0x5f39e4
movl 0x5acfee(%rip), %edi    # 0x5f39e0
testl %edi, %edi
je 0x46a03
callq *0x168(%rbx)
andl $0x0, 0x5acfdd(%rip)    # 0x5f39e0
cmpl $0x0, 0x5ad016(%rip)    # 0x5f3a20
je 0x46a23
leaq 0x5ad00d(%rip), %rsi    # 0x5f3a20
pushq $0x1
popq %rdi
callq *0x110(%rbx)
andl $0x0, 0x5acffd(%rip)    # 0x5f3a20
cmpl $0x0, 0x5acff2(%rip)    # 0x5f3a1c
je 0x46a43
leaq 0x5acfe9(%rip), %rsi    # 0x5f3a1c
pushq $0x1
popq %rdi
callq *0x110(%rbx)
andl $0x0, 0x5acfd9(%rip)    # 0x5f3a1c
movl 0x5acfcf(%rip), %edi    # 0x5f3a18
testl %edi, %edi
je 0x46a5a
callq *0x168(%rbx)
andl $0x0, 0x5acfbe(%rip)    # 0x5f3a18
cmpl $0x0, 0x5acfe3(%rip)    # 0x5f3a44
je 0x46a7a
leaq 0x5acfda(%rip), %rsi    # 0x5f3a44
pushq $0x1
popq %rdi
callq *0xc0(%rbx)
andl $0x0, 0x5acfca(%rip)    # 0x5f3a44
cmpl $0x0, 0x5acfc7(%rip)    # 0x5f3a48
je 0x46a9a
leaq 0x5acfbe(%rip), %rsi    # 0x5f3a48
pushq $0x1
popq %rdi
callq *0xc0(%rbx)
andl $0x0, 0x5acfae(%rip)    # 0x5f3a48
popq %rbx
retq