/* The main drawing function. */ void DrawGLScene(void) { const_move(delta.get_ticks()); delta.start(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glTranslatef(-(gridsize/2) +1, 0, -30); //glRotatef(zrot, 0.0f, 0.0f, 1.0f); // choose the texture to use glBindTexture(GL_TEXTURE_2D, texture[0]); //glLoadIdentity(); for(float _xtrans_l =0; _xtrans_l < gridsize; _xtrans_l+=2) { for(float _ztrans_l =0; _ztrans_l < gridsize; _ztrans_l+=2) { //glPushMatrix(); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3ub(144, 213, 225); glLineWidth(1); glPushMatrix(); // rotate triangle on y axis /**glRotatef(xrot, 0.0f, 1.0f, 0.0f);*/ //glRotatef(0, 0.0f, 0.0f, 0.0f); glTranslatef(_xtrans_l, _ytrans, _ztrans_l); if(_xtrans_l != gridsize) { glBegin(GL_LINES); glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, -1.0f); glEnd(); glBegin(GL_LINES); glVertex3f(-1.0f, 0.0f, 1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glEnd(); } // { // glBegin(GL_LINES); // glVertex3f(0.0f, 0.0f, 0.0f); // glVertex3f(2.0f, 0.0f, 0.0f); // glEnd(); // } if(_ztrans_l != gridsize) { glBegin(GL_LINES); glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(-1.0f, 0.0f, 1.0f); glEnd(); glBegin(GL_LINES); glVertex3f(1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glEnd(); } // { // glBegin(GL_LINES); // glVertex3f(0.0f, 0.0f, 0.0f); // glVertex3f(0.0f, 0.0f, 2.0f); // glEnd(); // } glPopMatrix(); } } glPushMatrix(); glTranslatef(_xtrans, _ytrans, _ztrans); if(dir_array[0]) { //up glRotatef(90, 0, 1, 0); } else if(dir_array[1]) { //right glRotatef(0, 0, 1, 0); } else if(dir_array[2]) { //down glRotatef(-90, 0, 1, 0); } else if(dir_array[3]) { //left glRotatef(180, 0, 1, 0); } //draw cube for player palceholder glBegin(GL_QUADS); //bottom colour glColor3ub(144, 213, 225); //bottom glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glVertex3f(-1.0f, 0.0f, 1.0f); //left colour glColor3ub(144, 213, 225); //left glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(-1.0f, 0.0f, 1.0f); glVertex3f(-1.0f, 2.0f, 1.0f); glVertex3f(-1.0f, 2.0f, -1.0f); //top colour glColor3ub(144, 213, 225); //top glVertex3f(-1.0f, 2.0f, -1.0f); glVertex3f(-1.0f, 2.0f, 1.0f); glVertex3f(1.0f, 2.0f, 1.0f); glVertex3f(1.0f, 2.0f, -1.0f); //right colour glColor3ub(144, 213, 225); //right bottom glVertex3f(1.0f, 0.0f, -1.0f); glVertex3f(2.0f, 1.0f, -1.0f); glVertex3f(2.0f, 1.0f, 1.0f); glVertex3f(1.0f, 0.0f, 1.0f); //right colour glColor3ub(144, 213, 225); // right top glVertex3f(1.0f, 2.0f, -1.0f); glVertex3f(2.0f, 1.0f, -1.0f); glVertex3f(2.0f, 1.0f, 1.0f); glVertex3f(1.0f, 2.0f, 1.0f); //front colour glColor3ub(144, 213, 225); //front glVertex3f(-1.0f, 0.0f, 1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glVertex3f(1.0f, 2.0f, 1.0f); glVertex3f(-1.0f, 2.0f, 0.0f); //back colour glColor3ub(144, 213, 225); //back glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(-1.0f, 2.0f, -1.0f); glVertex3f(1.0f, 2.0f, -1.0f); glVertex3f(1.0f, 0.0f, -1.0f); glEnd(); glPopMatrix(); //push mid points of top and bottom of cube into vector // top // int vertexarray[12] = {}; // trail_vector.push_back(); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); //count = 0; float _xtrans_int = _xtrans; if( _xtrans_int > 2) { count ++; _xtrans_int = 0; } std::cout << _xtrans_int << std::endl; for(int i = 0; i < count; i++) { glPushMatrix(); drawtrail(count); glPopMatrix(); } // since this is double buffered, swap the buffers to display what just got drawn. glutSwapBuffers(); }