This commit is contained in:
Bluepr1nt
2016-04-25 13:31:41 +02:00
parent 46e5f4ec57
commit e03c33d622
+63 -8
View File
@@ -69,6 +69,31 @@ void drawCube(int index)
glEnd(); glEnd();
} }
void drawTree(int xlocation, int ylocation, int zlocation, int height)
{
for (int z = zlocation; z <= zlocation+height; z += 2)
{
glPushMatrix();
glTranslatef((float)xlocation, (float)z, (float)ylocation);
drawCube(20);
glPopMatrix();
}
for (int x = xlocation-(height/2); x <= xlocation+ (height / 2); x += 2)
{
for (int y = ylocation- (height / 2); y <= ylocation+ (height / 2); y += 2)
{
for (int z = zlocation + height -(height/3); z <= zlocation + height+(height / 3); z += 2)
{
glPushMatrix();
glTranslatef((float)x, (float)z, (float)y);
drawCube(53);
glPopMatrix();
}
}
}
}
void display() void display()
{ {
@@ -77,7 +102,7 @@ void display()
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(60.0f, (float)width/height, 0.1, 30); gluPerspective(60.0f, (float)width/height, 0.1, 200);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
@@ -89,12 +114,11 @@ void display()
glColor3f(1.0f, 1.0f, 1.0f); glColor3f(1.0f, 1.0f, 1.0f);
glBindTexture(GL_TEXTURE_2D, grassTexture); glBindTexture(GL_TEXTURE_2D, grassTexture);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(-15, -1, -15); glTexCoord2f(0, 0); glVertex3f(-30, -1, -30);
glTexCoord2f(0, 8); glVertex3f( 15, -1, -15); glTexCoord2f(0, 8); glVertex3f( 30, -1, -30);
glTexCoord2f(8, 8); glVertex3f( 15, -1, 15); glTexCoord2f(8, 8); glVertex3f( 30, -1, 30);
glTexCoord2f(8, 0); glVertex3f(-15, -1, 15); glTexCoord2f(8, 0); glVertex3f(-30, -1, 30);
glEnd(); glEnd();
glBindTexture(GL_TEXTURE_2D, blocksTexture); glBindTexture(GL_TEXTURE_2D, blocksTexture);
for (int x = -10; x <= 10; x += 5) for (int x = -10; x <= 10; x += 5)
@@ -103,11 +127,42 @@ void display()
{ {
glPushMatrix(); glPushMatrix();
glTranslatef((float)x, 0.0f, (float)y); glTranslatef((float)x, 0.0f, (float)y);
drawCube(39); drawCube(21);
glPopMatrix(); glPopMatrix();
} }
} }
for (int x = 12; x <= 22; x += 2)
{
for (int y = 12; y <= 22; y += 2)
{
for (int z = 1; z <= 22; z += 2)
{
glPushMatrix();
glTranslatef((float)x, (float)z, (float)y);
drawCube(1);
glPopMatrix();
}
}
}
for (int x = 12; x <= 22; x += 2)
{
glPushMatrix();
glTranslatef((float)x, 0.0f, 0.0f);
drawCube(6);
glPopMatrix();
}
drawTree(0, 0, 0,10);
drawTree(-12, -12, 0, 5);
drawTree(15, 15, 22, 10);
drawTree(12, -12, 0, 6);
//drawTree(-12, 12, 0, 50);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glutSwapBuffers(); glutSwapBuffers();
} }
@@ -183,7 +238,7 @@ int main(int argc, char* argv[])
//Cursor //Cursor
glutWarpPointer(width / 2, height / 2); glutWarpPointer(width / 2, height / 2);
glutSetCursor(GLUT_CURSOR_NONE); //glutSetCursor(GLUT_CURSOR_NONE);
//Load Textures :: grass //Load Textures :: grass
int width1, height1, bpp1; int width1, height1, bpp1;