//========================================================= // // Instead of a texured plane, // draw a hexagon based grid // //========================================================= static void draw_hex(void) { float size = HEX_SIZE; float height = HEX_HEIGHT; float x_1 = WORLD_X_MIN; float x_2 = WORLD_X_MAX; float y_1 = WORLD_Y_MIN; float y_2 = WORLD_Y_MAX; float offset=0.0f; bool s_flag = false; float i = 0.0f; glBegin(GL_TRIANGLES); for (i = y_1; i < y_2; i += height) { draw_hexplane(x_1-offset, x_2, i, size); if (s_flag == true) { offset=size; s_flag = false; } else { offset = 0.0f; s_flag = true; } // end of the if } // end of the for glEnd(); } // end of the function
void draw_hexcube(void) { a += da; if(a >= 720.) /* depends on slowest rotation factor */ a = 0.; /* draw hexplanes, without changing z-values */ glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); /* x-y plane */ glColor3f(0.2, 0.2, 0.6); glPushMatrix(); glTranslatef(cubeoffx, cubeoffy, cubeoffz); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); /* x-y plane, translated */ glPushMatrix(); glTranslatef(cubeoffx, cubeoffy, cubeoffz - 2*CUBESIDE); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); glColor3f(0.6, 0.2, 0.2); /* x-z plane, translate low */ glPushMatrix(); glRotatef(90, 1.0, 0.0, 0.0); glTranslatef(cubeoffx, cubeoffz - CUBESIDE, -cubeoffy + CUBESIDE); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); /* x-z plane, translate high */ glPushMatrix(); glRotatef(90, 1.0, 0.0, 0.0); glTranslatef(cubeoffx, cubeoffz - CUBESIDE, -cubeoffy - CUBESIDE); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); glColor3f(0.2, 0.6, 0.2); /* y-z plane, translate low */ glPushMatrix(); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(-cubeoffz + CUBESIDE, cubeoffy, cubeoffx + CUBESIDE); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); /* y-z plane, translate high */ glPushMatrix(); glRotatef (90, 0.0, 1.0, 0.0); glTranslatef(-cubeoffz + CUBESIDE, cubeoffy, cubeoffx - CUBESIDE); glScalef(CUBESCALE, CUBESCALE, CUBESCALE); draw_hexplane(); glPopMatrix(); glFlush(); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); }