#include "teksturowane.hpp"

void skrzynka(GLfloat k) {
	glColor3d(0.8, 0.7, 0.3);


	glEnable(GL_TEXTURE_2D); // Włącz teksturowanie

	glBindTexture(GL_TEXTURE_2D, texture[0]);
	glBegin(GL_QUADS);
		glNormal3d(0, 0, 1);
		glTexCoord2d(1.0, 1.0); glVertex3d( k,  k, k);
		glTexCoord2d(0.0, 1.0); glVertex3d(-k,  k, k);
		glTexCoord2d(0.0, 0.0); glVertex3d(-k, -k, k);
		glTexCoord2d(1.0, 0.0); glVertex3d( k, -k, k);
	glEnd();
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	glBegin(GL_QUADS);
		glNormal3d(1, 0, 0);
		glTexCoord2d(1.0, 1.0); glVertex3d(k,  k,  k);
		glTexCoord2d(0.0, 1.0); glVertex3d(k, -k,  k);
		glTexCoord2d(0.0, 0.0); glVertex3d(k, -k, -k);
		glTexCoord2d(1.0, 0.0); glVertex3d(k,  k, -k);
	glEnd();

	glDisable(GL_TEXTURE_2D); // Wyłącz teksturowanie


	glBegin(GL_QUADS);
		glNormal3d(0, 0, -1);
		glVertex3d( k,  k, -k);
		glVertex3d( k, -k, -k);
		glVertex3d(-k, -k, -k);
		glVertex3d(-k,  k, -k);

		glNormal3d(-1, 0, 0);
		glVertex3d(-k,  k, -k);
		glVertex3d(-k, -k, -k);
		glVertex3d(-k, -k,  k);
		glVertex3d(-k,  k,  k);

		glNormal3d(0, 1, 0);
		glVertex3d( k, k,  k);
		glVertex3d( k, k, -k);
		glVertex3d(-k, k, -k);
		glVertex3d(-k, k,  k);

		glNormal3d(0, -1, 0);
		glVertex3d( k, -k,  k);
		glVertex3d(-k, -k,  k);
		glVertex3d(-k, -k, -k);
		glVertex3d( k, -k, -k);
	glEnd();
}

void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen) {
	// glColor3d(0.729, 0.91, 0.51); // jasnozielony, dla grass02.bmp

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture[1]); // Wybieramy teksturę

	// Ustawienie powtarzania tekstury
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku S
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); // Powtarzanie w kierunku T

	glBegin(GL_QUADS);
	// Powtarzające się współrzędne tekstury (np. *5, aby powtórzyła się 5 razy)
	glTexCoord2d(5.0, 5.0); glVertex3d(xc - xlen, yc, zc - zlen); // Lewy dolny
	glTexCoord2d(5.0, 0.0); glVertex3d(xc + xlen, yc, zc - zlen); // Prawy dolny
	glTexCoord2d(0.0, 0.0); glVertex3d(xc + xlen, yc, zc + zlen); // Prawy górny
	glTexCoord2d(0.0, 5.0); glVertex3d(xc - xlen, yc, zc + zlen); // Lewy górny
	glEnd();

	glDisable(GL_TEXTURE_2D);
}


void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {

	glEnable(GL_TEXTURE_2D);

	// ściany stodoły z bruku (brickwall)
	glColor3d(0.612f, 0.573f, 0.478f); // ciemny szary popadający w brąz (https://rgbcolorpicker.com/0-1)
	glBindTexture(GL_TEXTURE_2D, texture[3]);
	glBegin(GL_QUADS);

		glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2,           yc, zc - krawedz/2);
		glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
		glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc - krawedz/2);
		glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2,           yc, zc - krawedz/2);

		glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2,           yc, zc - krawedz/2);
		glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc - krawedz/2);
		glTexCoord2d(0.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
		glTexCoord2d(0.0, 1.0); glVertex3d(xc - krawedz/2,           yc, zc + krawedz/2);

		glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2,           yc, zc + krawedz/2);
		glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + krawedz, zc + krawedz/2);
		glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + krawedz, zc + krawedz/2);
		glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2,           yc, zc + krawedz/2);

	glEnd();

	// przód i tył dachu
	glColor3d(0.612f, 0.573f, 0.478f);
	glBindTexture(GL_TEXTURE_2D, texture[3]);
	glBegin(GL_TRIANGLES);

		glTexCoord2f(1.0, 1.0); glVertex3f(xc - krawedz/2,       yc + krawedz, zc - krawedz/2);
		glTexCoord2f(1.0, 0.0); glVertex3f(xc - krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2f(0.0, 0.0); glVertex3f(xc - krawedz/2,       yc + krawedz, zc + krawedz/2);

		glTexCoord2f(1.0, 1.0); glVertex3f(xc + krawedz/2,       yc + krawedz, zc - krawedz/2);
		glTexCoord2f(1.0, 0.0); glVertex3f(xc + krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2f(0.0, 0.0); glVertex3f(xc + krawedz/2,       yc + krawedz, zc + krawedz/2);

	glEnd();


	// dach stodoły (barnroof)
	glColor3d(0.639, 0.553, 0.322); // wyblakły brązowy
	glBindTexture(GL_TEXTURE_2D, texture[2]);
	glBegin(GL_QUADS);

		glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2,       yc + krawedz, zc + krawedz/2);
		glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2,       yc + krawedz, zc + krawedz/2);

		glTexCoord2d(1.0, 1.0); glVertex3d(xc - krawedz/2,       yc + krawedz, zc - krawedz/2);
		glTexCoord2d(1.0, 0.0); glVertex3d(xc - krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2d(0.0, 0.0); glVertex3d(xc + krawedz/2, yc + 1.5 * krawedz,             zc);
		glTexCoord2d(0.0, 1.0); glVertex3d(xc + krawedz/2,       yc + krawedz, zc - krawedz/2);

	glEnd();

	glDisable(GL_TEXTURE_2D);

}

void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x) {

	GLfloat grubosc = 1.0f;

	// timestampedCout("main.cpp (plot): otrzymano xc=" << xc << " yc=" << yc << " zc=" << zc << " length=" << length << " mod_x=" << mod_x);

	GLfloat gruboscX = grubosc +  mod_x * length;
	GLfloat gruboscZ = grubosc + !mod_x * length;

	// timestampedCout("main.cpp (plot): gruboscX=" << gruboscX << " gruboscY=" << gruboscY << " gruboscZ=" << gruboscZ);

	//   d-----------c   Y
	//  /           /|   ^
	// a-----------b |    \
	// | h         | g     C->X
	// |           |/      |
	// e-----------f       v
	//                     Z (płaszczyzna XZ, Y to trzeci wymiar)
	
	GLfloat a1_x = xc - gruboscX / 2,  a1_y = yc   + 1 + gruboscY,   a1_z = zc + gruboscZ / 2; // 3
	GLfloat b1_x = xc + gruboscX / 2,  b1_y = yc   + 1 + gruboscY,   b1_z = zc + gruboscZ / 2;
	GLfloat c1_x = xc + gruboscX / 2,  c1_y = yc   + 1 + gruboscY,   c1_z = zc - gruboscZ / 2;
	GLfloat d1_x = xc - gruboscX / 2,  d1_y = yc   + 1 + gruboscY,   d1_z = zc - gruboscZ / 2;
	GLfloat e1_x = xc - gruboscX / 2,  e1_y = yc   + 1           ,   e1_z = zc + gruboscZ / 2; // 1
	GLfloat f1_x = xc + gruboscX / 2,  f1_y = yc   + 1           ,   f1_z = zc + gruboscZ / 2;
	GLfloat g1_x = xc + gruboscX / 2,  g1_y = yc   + 1           ,   g1_z = zc - gruboscZ / 2;
	GLfloat h1_x = xc - gruboscX / 2,  h1_y = yc   + 1           ,   h1_z = zc - gruboscZ / 2;

	GLfloat a2_x = a1_x,               a2_y = a1_y - 1 - gruboscY,  a2_z = a1_z; //zc - 1; // -4
	GLfloat b2_x = b1_x,               b2_y = b1_y - 1 - gruboscY,  b2_z = b1_z; //zc - 1;
	GLfloat c2_x = c1_x,               c2_y = c1_y - 1 - gruboscY,  c2_z = c1_z; //zc - 1;
	GLfloat d2_x = d1_x,               d2_y = d1_y - 1 - gruboscY,  d2_z = d1_z; //zc - 1;
	GLfloat e2_x = e1_x,               e2_y = e1_y - 1 - gruboscY,  e2_z = e1_z; //zc - 2;
	GLfloat f2_x = f1_x,               f2_y = f1_y - 1 - gruboscY,  f2_z = f1_z; //zc - 2;
	GLfloat g2_x = g1_x,               g2_y = g1_y - 1 - gruboscY,  g2_z = g1_z; //zc - 2;
	GLfloat h2_x = h1_x,               h2_y = h1_y - 1 - gruboscY,  h2_z = h1_z; //zc - 2;

	glColor3d(0.71, 0.522, 0.067);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture[0]);
	glBegin(GL_QUADS);

		// Góra (1_x, 1_y, 1_z):
		// ABCD
		glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);

		// EFGH
		glTexCoord2d(1.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);

		// BCGF
		glTexCoord2d(1.0, 1.0); glVertex3d(b1_x, b1_y, b1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(f1_x, f1_y, f1_z);

		// ADHE
		glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);

		// ABFE
		glTexCoord2d(1.0, 1.0); glVertex3d(a1_x, a1_y, a1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b1_x, b1_y, b1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(f1_x, f1_y, f1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(e1_x, e1_y, e1_z);

		// DCGH
		glTexCoord2d(1.0, 1.0); glVertex3d(d1_x, d1_y, d1_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(c1_x, c1_y, c1_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g1_x, g1_y, g1_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(h1_x, h1_y, h1_z);

		// Dół (2_x, 2_y, 2_z):
		// ABCD
		glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);

		// EFGH
		glTexCoord2d(1.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);

		// BCGF
		glTexCoord2d(1.0, 1.0); glVertex3d(b2_x, b2_y, b2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(f2_x, f2_y, f2_z);

		// ADHE
		glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);

		// ABFE
		glTexCoord2d(1.0, 1.0); glVertex3d(a2_x, a2_y, a2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(b2_x, b2_y, b2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(f2_x, f2_y, f2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(e2_x, e2_y, e2_z);

		// DCGH
		glTexCoord2d(1.0, 1.0); glVertex3d(d2_x, d2_y, d2_z);
		glTexCoord2d(1.0, 0.0); glVertex3d(c2_x, c2_y, c2_z);
		glTexCoord2d(0.0, 0.0); glVertex3d(g2_x, g2_y, g2_z);
		glTexCoord2d(0.0, 1.0); glVertex3d(h2_x, h2_y, h2_z);

		// Pachołki

		//   d-----------c   Y
		//  /           /|   ^
		// a-----------b |    \
		// | h         | g     C->X
		// |           |/      |
		// e-----------f       v
		//                     Z (płaszczyzna XZ, Y to trzeci wymiar)


		GLfloat p_a_x, p_a_y, p_a_z;
		GLfloat p_b_x, p_b_y, p_b_z;
		GLfloat p_c_x, p_c_y, p_c_z;
		GLfloat p_d_x, p_d_y, p_d_z;
		GLfloat p_e_x, p_e_y, p_e_z;
		GLfloat p_f_x, p_f_y, p_f_z;
		GLfloat p_g_x, p_g_y, p_g_z;
		GLfloat p_h_x, p_h_y, p_h_z;

		if (!mod_x) {

			p_a_x = xc + gruboscX / 2,  p_a_y = yc + 1.5f * gruboscY,  p_a_z = zc; // +3 dla y
			p_b_x = xc - gruboscX / 2,  p_b_y = yc + 1.5f * gruboscY,  p_b_z = zc; // +3 dla y
			p_c_x = xc + gruboscX / 2,  p_c_y = yc + 1.5f * gruboscY,  p_c_z = zc; // +3 dla y
			p_d_x = xc - gruboscX / 2,  p_d_y = yc + 1.5f * gruboscY,  p_d_z = zc; // +3 dla y
			p_e_x = xc + gruboscX / 2,  p_e_y = yc - 6              ,  p_e_z = zc;
			p_f_x = xc - gruboscX / 2,  p_f_y = yc - 6              ,  p_f_z = zc;
			p_g_x = xc + gruboscX / 2,  p_g_y = yc - 6              ,  p_g_z = zc;
			p_h_x = xc - gruboscX / 2,  p_h_y = yc - 6              ,  p_h_z = zc;

		} else {

			p_a_x = xc,                 p_a_y = yc + 1.5f * gruboscY,  p_a_z = zc - gruboscZ / 2; // +3 dla y
			p_b_x = xc,                 p_b_y = yc + 1.5f * gruboscY,  p_b_z = zc - gruboscZ / 2; // +3 dla y
			p_c_x = xc,                 p_c_y = yc + 1.5f * gruboscY,  p_c_z = zc + gruboscZ / 2; // +3 dla y
			p_d_x = xc,                 p_d_y = yc + 1.5f * gruboscY,  p_d_z = zc + gruboscZ / 2; // +3 dla y
			p_e_x = xc,                 p_e_y = yc - 6              ,  p_e_z = zc - gruboscZ / 2;
			p_f_x = xc,                 p_f_y = yc - 6              ,  p_f_z = zc - gruboscZ / 2;
			p_g_x = xc,                 p_g_y = yc - 6              ,  p_g_z = zc + gruboscZ / 2;
			p_h_x = xc,                 p_h_y = yc - 6              ,  p_h_z = zc + gruboscZ / 2;

		}

		for (int i = 0; i < 2; i++) {

			//   d-----------c   Y
			//  /           /|   ^
			// a-----------b |    \
			// | h         | g     C->X
			// |           |/      |
			// e-----------f       v
			//                     Z (płaszczyzna XZ, Y to trzeci wymiar)

			// timestampedCout("main.cpp (plot): p_a_x=" << p_a_x << " p_b_x=" << p_b_x << " p_c_x=" << p_c_x << " p_d_x=" << p_d_x);

			// ABCD
			glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);

			// EFGH
			glTexCoord2d(1.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);

			// BCGF
			glTexCoord2d(1.0, 1.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);

			// ADHE
			glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);

			// ABFE
			glTexCoord2d(1.0, 1.0); glVertex3d(p_a_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_a_y, p_a_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_b_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_b_y, p_b_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_f_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_f_y, p_f_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_e_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_e_y, p_e_z + (2*i-1) * (gruboscZ/2 - 5) * !mod_x);

			// DCGH
			glTexCoord2d(1.0, 1.0); glVertex3d(p_d_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_d_y, p_d_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(1.0, 0.0); glVertex3d(p_c_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_c_y, p_c_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 0.0); glVertex3d(p_g_x + (2*i-1) * (gruboscX/2 - 5) * mod_x, p_g_y, p_g_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);
			glTexCoord2d(0.0, 1.0); glVertex3d(p_h_x + (2*i-1) * (gruboscX/2 - 8) * mod_x, p_h_y, p_h_z + (2*i-1) * (gruboscZ/2 - 8) * !mod_x);

		}


	glEnd();

	glDisable(GL_TEXTURE_2D);

}