// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_loadshaders
static void polymost_loadshaders(void)
{
	extern const char default_polymost_fs_glsl[];
	extern const char default_polymost_vs_glsl[];

	extern const char default_polymostaux_fs_glsl[];
	extern const char default_polymostaux_vs_glsl[];

	GLuint shader[2] = {0,0};

	// General texture rendering shader.
	if (polymostglsl.program) {
		glfunc.glDeleteProgram(polymostglsl.program);
		polymostglsl.program = 0;
	}

	shader[0] = polymost_load_shader(GL_VERTEX_SHADER, default_polymost_vs_glsl, "polymost_vs.glsl");
	shader[1] = polymost_load_shader(GL_FRAGMENT_SHADER, default_polymost_fs_glsl, "polymost_fs.glsl");
	if (shader[0] && shader[1]) {
		polymostglsl.program = glbuild_link_program(2, shader);
	}
	if (shader[0]) glfunc.glDeleteShader(shader[0]);
	if (shader[1]) glfunc.glDeleteShader(shader[1]);

	if (polymostglsl.program) {
		polymostglsl.attrib_vertex       = polymost_get_attrib(polymostglsl.program, "a_vertex");
		polymostglsl.attrib_texcoord     = polymost_get_attrib(polymostglsl.program, "a_texcoord");
		polymostglsl.uniform_modelview   = polymost_get_uniform(polymostglsl.program, "u_modelview");
		polymostglsl.uniform_projection  = polymost_get_uniform(polymostglsl.program, "u_projection");
		polymostglsl.uniform_texture     = polymost_get_uniform(polymostglsl.program, "u_texture");
		polymostglsl.uniform_glowtexture = polymost_get_uniform(polymostglsl.program, "u_glowtexture");
		polymostglsl.uniform_alphacut    = polymost_get_uniform(polymostglsl.program, "u_alphacut");
		polymostglsl.uniform_colour      = polymost_get_uniform(polymostglsl.program, "u_colour");
		polymostglsl.uniform_fogcolour   = polymost_get_uniform(polymostglsl.program, "u_fogcolour");
		polymostglsl.uniform_fogdensity  = polymost_get_uniform(polymostglsl.program, "u_fogdensity");
		polymostglsl.uniform_gamma       = polymost_get_uniform(polymostglsl.program, "u_gamma");

#if (USE_OPENGL == USE_GL3)
		glfunc.glGenVertexArrays(1, &polymostglsl.vao);
        glfunc.glBindVertexArray(polymostglsl.vao);
        glfunc.glEnableVertexAttribArray(polymostglsl.attrib_vertex);
        glfunc.glEnableVertexAttribArray(polymostglsl.attrib_texcoord);
#endif

		glfunc.glUseProgram(polymostglsl.program);
		glfunc.glUniform1i(polymostglsl.uniform_texture, 0);		//GL_TEXTURE0
		glfunc.glUniform1i(polymostglsl.uniform_glowtexture, 1);	//GL_TEXTURE1

		// Generate a buffer object for vertex/colour elements.
		glfunc.glGenBuffers(1, &polymostglsl.elementbuffer);
	}

	// A fully transparent texture for the case when a glow texture is not needed.
	if (!nulltexture) {
		const char pix[4] = {0,0,0,0};
		glfunc.glGenTextures(1, &nulltexture);
		glfunc.glBindTexture(GL_TEXTURE_2D, nulltexture);
		glfunc.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,1,1,0,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)&pix);
		glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
		glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
	}

	// Engine auxiliary shader.
	if (polymostauxglsl.program) {
		glfunc.glDeleteProgram(polymostauxglsl.program);
		polymostauxglsl.program = 0;
	}

	shader[0] = polymost_load_shader(GL_VERTEX_SHADER, default_polymostaux_vs_glsl, "polymostaux_vs.glsl");
	shader[1] = polymost_load_shader(GL_FRAGMENT_SHADER, default_polymostaux_fs_glsl, "polymostaux_fs.glsl");
	if (shader[0] && shader[1]) {
		polymostauxglsl.program = glbuild_link_program(2, shader);
	}
	if (shader[0]) glfunc.glDeleteShader(shader[0]);
	if (shader[1]) glfunc.glDeleteShader(shader[1]);

	if (polymostauxglsl.program) {
		polymostauxglsl.attrib_vertex    = polymost_get_attrib(polymostauxglsl.program, "a_vertex");
		polymostauxglsl.attrib_texcoord  = polymost_get_attrib(polymostauxglsl.program, "a_texcoord");
		polymostauxglsl.uniform_projection = polymost_get_uniform(polymostauxglsl.program, "u_projection");
		polymostauxglsl.uniform_texture  = polymost_get_uniform(polymostauxglsl.program, "u_texture");
		polymostauxglsl.uniform_colour   = polymost_get_uniform(polymostauxglsl.program, "u_colour");
		polymostauxglsl.uniform_bgcolour = polymost_get_uniform(polymostauxglsl.program, "u_bgcolour");
		polymostauxglsl.uniform_mode     = polymost_get_uniform(polymostauxglsl.program, "u_mode");
		polymostauxglsl.uniform_gamma    = polymost_get_uniform(polymostauxglsl.program, "u_gamma");

#if (USE_OPENGL == USE_GL3)
		glfunc.glGenVertexArrays(1, &polymostauxglsl.vao);
        glfunc.glBindVertexArray(polymostauxglsl.vao);
        glfunc.glEnableVertexAttribArray(polymostauxglsl.attrib_vertex);
        glfunc.glEnableVertexAttribArray(polymostauxglsl.attrib_texcoord);
#endif

		glfunc.glUseProgram(polymostauxglsl.program);
		glfunc.glUniform1i(polymostauxglsl.uniform_texture, 0);	//GL_TEXTURE0

		// Generate a buffer object for vertex/colour elements and pre-allocate its memory.
		glfunc.glGenBuffers(1, &polymostauxglsl.elementbuffer);

		// Generate a buffer object for ad-hoc indexes.
		glfunc.glGenBuffers(1, &polymostauxglsl.indexbuffer);
	}

	// Generate a buffer object for element indexes and populate it with an
	// initial set of ascending indices, the way drawpoly() will generate points.
	glfunc.glGenBuffers(1, &elementindexbuffer);
	checkindexbuffer(MINVBOINDEXES);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl 0x5ace8b(%rip), %edi    # 0x5f39e0
testl %edi, %edi
je 0x46b6d
leaq 0x5acbe0(%rip), %rax    # 0x5f3740
callq *0x168(%rax)
andl $0x0, 0x5ace73(%rip)    # 0x5f39e0
leaq 0x29c2c(%rip), %rsi     # 0x707a0
leaq 0x29242(%rip), %rdx     # 0x6fdbd
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x547b4
movl %eax, %ebx
movl %eax, 0x4(%rsp)
leaq 0x2972e(%rip), %rsi     # 0x702c0
leaq 0x29235(%rip), %rdx     # 0x6fdce
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x547b4
movl %eax, 0x8(%rsp)
testl %ebx, %ebx
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x46bcf
pushq $0x2
popq %rdi
leaq 0x4(%rsp), %rbx
movq %rbx, %rsi
callq 0x45e09
movl %eax, 0x5ace13(%rip)    # 0x5f39e0
movl (%rbx), %ebx
testl %ebx, %ebx
je 0x46be2
leaq 0x5acb66(%rip), %rax    # 0x5f3740
movl %ebx, %edi
callq *0x170(%rax)
movl 0x8(%rsp), %edi
testl %edi, %edi
je 0x46bf7
leaq 0x5acb4f(%rip), %rax    # 0x5f3740
callq *0x170(%rax)
movl 0x5acde3(%rip), %edi    # 0x5f39e0
testl %edi, %edi
je 0x46d4c
leaq 0x27e97(%rip), %rsi     # 0x6eaa3
callq 0x54869
movl %eax, 0x5acdd1(%rip)    # 0x5f39e8
movl 0x5acdc3(%rip), %edi    # 0x5f39e0
leaq 0x27e88(%rip), %rsi     # 0x6eaac
callq 0x54869
movl %eax, 0x5acdbd(%rip)    # 0x5f39ec
movl 0x5acdab(%rip), %edi    # 0x5f39e0
leaq 0x291a3(%rip), %rsi     # 0x6fddf
callq 0x5489c
movl %eax, 0x5acda9(%rip)    # 0x5f39f0
movl 0x5acd93(%rip), %edi    # 0x5f39e0
leaq 0x29197(%rip), %rsi     # 0x6fdeb
callq 0x5489c
movl %eax, 0x5acd95(%rip)    # 0x5f39f4
movl 0x5acd7b(%rip), %edi    # 0x5f39e0
leaq 0x2918c(%rip), %rsi     # 0x6fdf8
callq 0x5489c
movl %eax, 0x5acd81(%rip)    # 0x5f39f8
movl 0x5acd63(%rip), %edi    # 0x5f39e0
leaq 0x2917e(%rip), %rsi     # 0x6fe02
callq 0x5489c
movl %eax, 0x5acd6d(%rip)    # 0x5f39fc
movl 0x5acd4b(%rip), %edi    # 0x5f39e0
leaq 0x29174(%rip), %rsi     # 0x6fe10
callq 0x5489c
movl %eax, 0x5acd59(%rip)    # 0x5f3a00
movl 0x5acd33(%rip), %edi    # 0x5f39e0
leaq 0x29167(%rip), %rsi     # 0x6fe1b
callq 0x5489c
movl %eax, 0x5acd45(%rip)    # 0x5f3a04
movl 0x5acd1b(%rip), %edi    # 0x5f39e0
leaq 0x29158(%rip), %rsi     # 0x6fe24
callq 0x5489c
movl %eax, 0x5acd31(%rip)    # 0x5f3a08
movl 0x5acd03(%rip), %edi    # 0x5f39e0
leaq 0x2914c(%rip), %rsi     # 0x6fe30
callq 0x5489c
movl %eax, 0x5acd1d(%rip)    # 0x5f3a0c
movl 0x5acceb(%rip), %edi    # 0x5f39e0
leaq 0x27dbb(%rip), %rsi     # 0x6eab7
callq 0x5489c
movl %eax, 0x5acd09(%rip)    # 0x5f3a10
leaq 0x5aca32(%rip), %r14    # 0x5f3740
movl 0x5acccc(%rip), %edi    # 0x5f39e0
callq *0x1f0(%r14)
movl 0x5accd7(%rip), %edi    # 0x5f39f8
xorl %esi, %esi
callq *0x1c0(%r14)
movl 0x5acccc(%rip), %edi    # 0x5f39fc
pushq $0x1
popq %rbx
movl %ebx, %esi
callq *0x1c0(%r14)
leaq 0x5acca1(%rip), %rsi    # 0x5f39e4
movl %ebx, %edi
callq *0x118(%r14)
cmpl $0x0, 0x5accf5(%rip)    # 0x5f3a48
jne 0x46de9
leaq 0xc(%rsp), %r15
andl $0x0, (%r15)
leaq 0x5ac9d7(%rip), %r14    # 0x5f3740
leaq 0x5accd8(%rip), %rsi    # 0x5f3a48
pushq $0x1
popq %rbx
movl %ebx, %edi
callq *0xb8(%r14)
movl 0x5accc6(%rip), %esi    # 0x5f3a48
movl $0xde1, %edi            # imm = 0xDE1
callq *0xc8(%r14)
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1908, %edx           # imm = 0x1908
movl %ebx, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %r15
pushq $0x1401                 # imm = 0x1401
pushq $0x1908                 # imm = 0x1908
callq *0xd0(%r14)
addq $0x20, %rsp
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2600, %edx           # imm = 0x2600
callq *0xe8(%r14)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2600, %edx           # imm = 0x2600
callq *0xe8(%r14)
movl 0x5acc29(%rip), %edi    # 0x5f3a18
testl %edi, %edi
je 0x46e07
leaq 0x5ac946(%rip), %rax    # 0x5f3740
callq *0x168(%rax)
andl $0x0, 0x5acc11(%rip)    # 0x5f3a18
leaq 0x29f62(%rip), %rsi     # 0x70d70
leaq 0x29028(%rip), %rdx     # 0x6fe3d
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x547b4
movl %eax, 0x4(%rsp)
leaq 0x29b56(%rip), %rsi     # 0x70980
leaq 0x29020(%rip), %rdx     # 0x6fe51
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x547b4
movl %eax, 0x8(%rsp)
movl 0x4(%rsp), %edi
testl %edi, %edi
setne %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x46e6b
pushq $0x2
popq %rdi
leaq 0x4(%rsp), %rbx
movq %rbx, %rsi
callq 0x45e09
movl %eax, 0x5acbaf(%rip)    # 0x5f3a18
movl (%rbx), %edi
testl %edi, %edi
je 0x46e7c
leaq 0x5ac8ca(%rip), %rax    # 0x5f3740
callq *0x170(%rax)
movl 0x8(%rsp), %edi
testl %edi, %edi
je 0x46e91
leaq 0x5ac8b5(%rip), %rax    # 0x5f3740
callq *0x170(%rax)
movl 0x5acb81(%rip), %edi    # 0x5f3a18
testl %edi, %edi
je 0x46f9f
leaq 0x27bfd(%rip), %rsi     # 0x6eaa3
callq 0x54869
movl %eax, 0x5acb73(%rip)    # 0x5f3a24
movl 0x5acb61(%rip), %edi    # 0x5f3a18
leaq 0x27bee(%rip), %rsi     # 0x6eaac
callq 0x54869
movl %eax, 0x5acb5f(%rip)    # 0x5f3a28
movl 0x5acb49(%rip), %edi    # 0x5f3a18
leaq 0x28f15(%rip), %rsi     # 0x6fdeb
callq 0x5489c
movl %eax, 0x5acb4b(%rip)    # 0x5f3a2c
movl 0x5acb31(%rip), %edi    # 0x5f3a18
leaq 0x28f0a(%rip), %rsi     # 0x6fdf8
callq 0x5489c
movl %eax, 0x5acb37(%rip)    # 0x5f3a30
movl 0x5acb19(%rip), %edi    # 0x5f3a18
leaq 0x28f15(%rip), %rsi     # 0x6fe1b
callq 0x5489c
movl %eax, 0x5acb23(%rip)    # 0x5f3a34
movl 0x5acb01(%rip), %edi    # 0x5f3a18
leaq 0x28f47(%rip), %rsi     # 0x6fe65
callq 0x5489c
movl %eax, 0x5acb0f(%rip)    # 0x5f3a38
movl 0x5acae9(%rip), %edi    # 0x5f3a18
leaq 0x28f3a(%rip), %rsi     # 0x6fe70
callq 0x5489c
movl %eax, 0x5acafb(%rip)    # 0x5f3a3c
movl 0x5acad1(%rip), %edi    # 0x5f3a18
leaq 0x27b69(%rip), %rsi     # 0x6eab7
callq 0x5489c
movl %eax, 0x5acae7(%rip)    # 0x5f3a40
leaq 0x5ac7e0(%rip), %r14    # 0x5f3740
movl 0x5acab2(%rip), %edi    # 0x5f3a18
callq *0x1f0(%r14)
movl 0x5acabd(%rip), %edi    # 0x5f3a30
xorl %esi, %esi
callq *0x1c0(%r14)
leaq 0x5aca99(%rip), %rsi    # 0x5f3a1c
pushq $0x1
popq %rbx
movl %ebx, %edi
callq *0x118(%r14)
leaq 0x5aca8a(%rip), %rsi    # 0x5f3a20
movl %ebx, %edi
callq *0x118(%r14)
leaq 0x5ac79a(%rip), %rax    # 0x5f3740
leaq 0x5aca27(%rip), %rsi    # 0x5f39d4
pushq $0x1
popq %rdi
callq *0x118(%rax)
pushq $0x10
popq %rdi
callq 0x474b1
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq