#include #ifdef WIN32 #include #else #include #endif #include #include #include #include #ifdef __amigaos4__ #include #include struct Window *_infoWin; #endif /* Minimum stack space */ static USED const char *stack = "$STACK:65535"; GLboolean fogging = GL_TRUE; GLenum fog_mode = GL_LINEAR; GLfloat fog_start = 4.0f; GLfloat fog_end = 10.0f; GLfloat fog_density = 0.04f; GLfloat width,height; GLboolean simple_ground = GL_FALSE; GLfloat angularSpeed = 0.1f; GLboolean rotating = GL_TRUE; GLint faces[6][4] = { /* Vertex indices for the 6 faces of a cube. */ {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4}, {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} }; GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */ void myReshape(int,int); void drawBox(void) { int i; glPushMatrix(); glScalef(0.2, 3.0, 0.2); for (i = 0; i < 6; i++) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, v); //glColor3fv(&colors[i][0]); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, faces[i]); } glPopMatrix(); } #if 1 void ShowParams(void) { char buffer[256], *c; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0, width, height, 0); glDisable(GL_FOG); glRasterPos2f(10, 10); #ifdef MGL_HAS_NO_SPE_NEWLIB sprintf(buffer, "MODE: %s s: %d e: %d d: %d c:%s", fog_mode == GL_LINEAR ? "GL_LINEAR" : fog_mode == GL_EXP ? "GL_EXP" : fog_mode == GL_EXP2 ? "GL_EXP2" : "Unknown", (int)fog_start, (int)fog_end, (int)fog_density, simple_ground == GL_TRUE ? "N" : "Y" ); #else sprintf(buffer, "MODE: %s s: %f e: %f d: %f c:%s", fog_mode == GL_LINEAR ? "GL_LINEAR" : fog_mode == GL_EXP ? "GL_EXP" : fog_mode == GL_EXP2 ? "GL_EXP2" : "Unknown", fog_start, fog_end, fog_density, simple_ground == GL_TRUE ? "N" : "Y" ); #endif for (c=buffer; *c; c++) { glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *c); } glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); if (fogging) { glEnable(GL_FOG); } } #endif #define GROUND_W 30 #define GROUND_H 30 #define GROUND_STEP 3.0f typedef struct { GLfloat x,y,z; GLfloat r,g,b; } Vertex; Vertex vertexArray[GROUND_W*GROUND_H]; #define Vi(x,y) (y*GROUND_W+x) #define V(x,y) vertexArray[Vi(x,y)] GLuint indexArrays[(GROUND_H-1)][GROUND_W*2]; void myinit(void) { GLfloat fogcolor[] = {0.1f, 0.1f, 0.1f, 1.0f}; glEnable(GL_DEPTH_TEST); //glShadeModel(GL_FLAT); glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]); glColor3f(1.0f, 1.0f, 1.0f); glFogi(GL_FOG_MODE, fog_mode); glFogf(GL_FOG_START, fog_start); glFogf(GL_FOG_END, fog_end); glFogf(GL_FOG_DENSITY, fog_density); glFogfv(GL_FOG_COLOR, fogcolor); if (fogging) { glEnable(GL_FOG); } int index = 0; // Initialize the vertex array for the ground for (int x=0; x 1) { fogging = GL_FALSE; } myinit(); // glutFullScreen(); glutReshapeFunc (myReshape); glutDisplayFunc(display); glutKeyboardFunc(key); glutIdleFunc(idle); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }