#include #include #include #include "stim/math/vector.h" //#include #include #include //#include //#include #include "stim/gl/gl_spider.h" #include "stim/gl/gl_texture.h" #include "stim/gl/error.h" #include "stim/visualization/camera.h" #define VERTICAL 1 #define HORIZONTAL 1 stim::camera cam; stim::camera Parker; GLuint texID; GLuint texID2; // GLuint fboId; stim::vec D; // GLuint rboId; // GLuint pbo; float a = -1.0; float b = 1.0; GLsizei size[2] = {900,900}; GLfloat Normals[6][3] = {{ -1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}}; GLint faces[6][4] = {{0, 1, 2, 3}, {4, 5, 7, 6}, {1, 5, 7, 2}, {3, 2, 7, 6}, {0, 4, 6, 3}, {0, 1, 5, 4}}; GLfloat vertex[8][3] = {{0.0, 0.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {0.0, 1.0, 1.0}, {0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}}; GLint lines[24] = {0,1,1,2,2,3,0,3,4,5,5,7,7,6,6,4,3,6,2,7,1,5,0,4}; GLfloat vertexDrw[8][3] = {{a, a, b}, {b, a, b}, {b, b, b}, {a, b, b}, {a, a, a}, {b, a, a}, {a, b, a}, {b, b, a}}; static float mousePos[2] = {0,0}; static float prevmousePos[2] = {0,0}; unsigned long tick = 0; stim::vec p; stim::vec up; stim::vec d; static bool button1 = false; static bool button_shift = false; static float degtorad = 360/(2*M_PI); static GLfloat adjustTex = 1.0/426.0; static GLfloat adjustDrw = 2.0/426.0; static GLfloat oriTex[3] = {adjustTex*213+adjustTex/2 ,adjustTex*213+adjustTex/2 ,adjustTex*213+adjustTex/2}; static GLfloat oriDrw[3] = {adjustDrw/2 ,adjustDrw/2 ,adjustDrw/2}; static GLfloat org[2] = {adjustTex/2,adjustTex/2+425*adjustTex}; stim::gl_spider spidey; stim::vecp1; stim::vecp2; stim::vecp3; stim::vecp4; //init for a cube /*void GenerateFBO(unsigned int width, unsigned int height) { glGenFramebuffers(1, &fboId); glBindFramebuffer(GL_FRAMEBUFFER, fboId); int numChannels = 3; unsigned char* texels = new unsigned char[width * height * numChannels]; glGenTextures(1, &texID2); glBindTexture(GL_TEXTURE_2D, texID2); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texels); delete[] texels; glBindFramebuffer(GL_FRAMEBUFFER, 0); }*/ void glInit() { CHECK_OPENGL_ERROR glEnable(GL_TEXTURE_3D); glEnable(GL_DEPTH_TEST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glClearColor(0.0, 0.0, 0.0, 0.0); glColor4d(0.0, 0.0, 0.0, 1.0); glShadeModel(GL_FLAT); cam.setPosition(3.0,3.0,3.0); cam.setFocalDistance(6.0); cam.LookAt(0.0, 0.0, 0.0); p = cam.getPosition(); up = cam.getUp(); d = cam.getLookAt(); glViewport(0, 0, size[0], size[1]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); glMatrixMode(GL_MODELVIEW); spidey = stim::gl_spider(0.515372, 0.564174, 0.494553, 0.130563, -0.98295, -0.129467, 0.03, 0.03); spidey.attachSpider(texID); Parker.setPosition(spidey.getPosition()); Parker.LookAt(spidey.getDirection()); // GenerateFBO(400, 200); spidey.initCuda(); //glGenRenderbuffers(1, &rboId); //glBindRenderbuffer(GL_RENDERBUFFER, rboId); //GLuint rboId; //glGenRenderbuffers(1, &rboId); //glBindRenderbuffer(GL_RENDERBUFFER, rboId); //glGenBuffers(1, &pbo); //glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo); //glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, 426*426*sizeof(uchar4), NULL, GL_DYNAMIC_DRAW_ARB); CHECK_OPENGL_ERROR } void DrawCube() { glLineWidth(2.5); glColor3f(1.0,0.0,0.0); glBegin(GL_LINES); for (int i = 0; i < 24; i++) { glVertex3f(vertexDrw[lines[i]][0], vertexDrw[lines[i]][1], vertexDrw[lines[i]][2]); } glEnd(); } void DrawPlanes() { glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, texID); p1 = spidey.ver.p(1,1); p2 = spidey.ver.p(1,0); p3 = spidey.ver.p(0,0); p4 = spidey.ver.p(0,1); //glPushName(VERTICAL); glBegin(GL_QUADS); glTexCoord3f( p1[0], p1[1], p1[2] ); glVertex3f( p1[0], p1[1], p1[2] ); glTexCoord3f( p2[0], p2[1], p2[2] ); glVertex3f( p2[0], p2[1], p2[2] ); glTexCoord3f( p3[0], p3[1], p3[2] ); glVertex3f( p3[0], p3[1], p3[2] ); glTexCoord3f( p4[0], p4[1], p4[2] ); glVertex3f( p4[0], p4[1], p4[2] ); glEnd(); //glPopName(); p1 = spidey.hor.p(1,1); p2 = spidey.hor.p(1,0); p3 = spidey.hor.p(0,0); p4 = spidey.hor.p(0,1); //glPushName(HORIZONTAL); glBegin(GL_QUADS); glTexCoord3f( p1[0], p1[1], p1[2] ); glVertex3f( p1[0], p1[1], p1[2] ); glTexCoord3f( p2[0], p2[1], p2[2] ); glVertex3f( p2[0], p2[1], p2[2] ); glTexCoord3f( p3[0], p3[1], p3[2] ); glVertex3f( p3[0], p3[1], p3[2] ); glTexCoord3f( p4[0], p4[1], p4[2] ); glVertex3f( p4[0], p4[1], p4[2] ); glEnd(); //glPopName(); glBindTexture(GL_TEXTURE_3D, 0); glDisable(GL_TEXTURE_3D); } void DrawSpiders() { glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, texID); p1 = spidey.hor.p(1,1); p2 = spidey.hor.p(1,0); p3 = spidey.hor.p(0,0); p4 = spidey.hor.p(0,1); glBegin(GL_QUADS); glTexCoord3f( p1[0], p1[1], p1[2] ); glVertex2f(0.0,0.0); glTexCoord3f( p2[0], p2[1], p2[2] ); glVertex2f(1.0, 0.0); glTexCoord3f( p3[0], p3[1], p3[2] ); glVertex2f(1.0, 2.0); glTexCoord3f( p4[0], p4[1], p4[2] ); glVertex2f(0.0, 2.0); glEnd(); p1 = spidey.ver.p(1,1); p2 = spidey.ver.p(1,0); p3 = spidey.ver.p(0,0); p4 = spidey.ver.p(0,1); glBegin(GL_QUADS); glTexCoord3f( p1[0], p1[1], p1[2] ); glVertex2f(1.0, 0.0); glTexCoord3f( p2[0], p2[1], p2[2] ); glVertex2f(2.0, 0.0); glTexCoord3f( p3[0], p3[1], p3[2] ); glVertex2f(2.0, 2.0); glTexCoord3f( p4[0], p4[1], p4[2] ); glVertex2f(1.0, 2.0); glEnd(); glBindTexture(GL_TEXTURE_3D, 0); glDisable(GL_TEXTURE_3D); } //render cube void renderScene() { glViewport(0, 0, size[0], size[1]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); glMatrixMode(GL_MODELVIEW); glInitNames(); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); p = cam.getPosition(); up = cam.getUp(); d = cam.getLookAt(); gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], up[0], up[1], up[2]); DrawPlanes(); DrawCube(); //glEnable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D, texID); /*glBindFramebuffer(GL_FRAMEBUFFER, fboId); glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID2, 0 ); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID2, 0); glBindFramebuffer(GL_FRAMEBUFFER, fboId); GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; glDrawBuffers(1, DrawBuffers); if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "damn" << std::endl; glBindTexture(GL_TEXTURE_2D, texID2); glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT); //glLoadIdentity(); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); CHECK_OPENGL_ERROR glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0,0,400,200); gluOrtho2D(0.0, 2.0, 0.0, 2.0); DrawSpiders(); //glPopMatrix(); //DrawSpiders2(); //glFlush(); //glFinish(); CHECK_OPENGL_ERROR glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0);*/ glBindFramebuffer(GL_READ_FRAMEBUFFER, spidey.getFB()); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0,0,400,200, 0, 0, 400, 200, GL_COLOR_BUFFER_BIT, GL_NEAREST); CHECK_OPENGL_ERROR //glBindFramebuffer(GL_FRAMEBUFFER,0); //glBindTexture(GL_TEXTURE_3D, texID); //glGenerateMipmap(GL_TEXTURE_3D); //glBindTexture(GL_TEXTURE_3D, 0); //glViewport(0,0, 800,800); //GLint curbuf; //glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &curbuf); //std::cout << curbuf << std::endl; //glViewport(0,0,600,600); //glBindFramebuffer(GL_FRAMEBUFFER, fboId); //glDrawBuffer(GL_FRAMEBUFFER0); //glDrawBuffer(fboId); //glClearColor(1,1,1,1); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glLoadIdentity(); //std::cout << fboId << std::endl; //DrawSpiders(); //glBlitFramebuffer(0.0,0.0,1,1,0.0,0.0,1,1, GL_COLOR_BUFFER_BIT, GL_LINEAR); //gluOrtho2D(-5.0, -3.0, -5.0, -1.0); //glClearColor(1,1,1,1); //glBindTexture(GL_TEXTURE_3D, texID); //glPushMatrix(); //glGenerateMipmap(GL_TEXTURE_3D); //glBindTexture(GL_TEXTURE_3D, 0); //glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &curbuf); //std::cout << curbuf << std::endl; // glCopyImageSubData(fboId, GL_FRAMEBUFFER, 0, 0, 0, 0, GL_FRONT_AND_BACK, GL_NONE, 0, 0, 0, 0, 20, 20, 0); glutSwapBuffers(); } void MouseButton(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON) { button1 = (state == GLUT_DOWN) ? true : false; button_shift = glutGetModifiers(); prevmousePos[0] = (float)x; prevmousePos[1] = (float)y; } if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) { std::cout << spidey.getPosition() << std::endl << spidey.getDirection() << std::endl; std::cout << spidey.getCost() << std::endl; } } void MouseMotion(int x, int y) { if(button1 && !button_shift) { mousePos[0] = (prevmousePos[0] - (float) x)*0.0005; mousePos[1] = ((float)y - prevmousePos[1])*0.0005; prevmousePos[0] = (float)x; prevmousePos[1] = (float)y; cam.OrbitFocus(mousePos[0]*degtorad, mousePos[1]*degtorad); } if(button1 && button_shift) { mousePos[0] = (prevmousePos[0] - (float) x)*0.00001; mousePos[1] = ((float)y - prevmousePos[1])*0.00001; prevmousePos[0] = (float)x; prevmousePos[1] = (float)y; Parker.Pan(mousePos[0]*degtorad); Parker.Tilt(mousePos[1]*degtorad); spidey.setDirection(Parker.getDirection()); spidey.Update(); std::cout << Parker.getLookAt() << std::endl; } } void idleFunction() { tick += 10; glutPostRedisplay(); } void printCost() { } void processSpecialKeys(int key, int xx, int yy) { switch(key) { case GLUT_KEY_UP: oriTex[2] = oriTex[2]+adjustTex; if (oriTex[2] > org[1]){ oriTex[2] = org[1]; } else{ oriDrw[2] = oriDrw[2] + adjustDrw; } if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) { stim::vec temp = spidey.getPosition(); temp[1] += 0.001; spidey.setPosition(temp); spidey.Update(); } if (glutGetModifiers() == GLUT_ACTIVE_CTRL) { //stim::vec temp = Parker.getDirection(); //temp[1] += 0.001; Parker.Pan(0.01); spidey.setDirection(Parker.getDirection()); spidey.Update(); } break; case GLUT_KEY_DOWN: oriTex[2] = oriTex[2]-adjustTex; if (oriTex[2] < org[0]){ oriTex[2] = org[0]; } else{ oriDrw[2] = oriDrw[2] - adjustDrw; } if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) { stim::vec temp = spidey.getPosition(); temp[1] -= 0.001; spidey.setPosition(temp); spidey.Update(); } if (glutGetModifiers() == GLUT_ACTIVE_CTRL) { //stim::vec temp = Parker.getDirection(); //temp[1] -= 0.001; Parker.Pan(-0.01); spidey.setDirection(Parker.getDirection()); spidey.Update(); } break; case GLUT_KEY_LEFT: oriTex[1] = oriTex[1]+adjustTex; if (oriTex[1] > org[1]){ oriTex[1] = org[1]; } else{ oriDrw[1] = oriDrw[1] + adjustDrw; } if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) { stim::vec temp = spidey.getPosition(); temp[0] += 0.001; spidey.setPosition(temp); spidey.Update(); } if (glutGetModifiers() == GLUT_ACTIVE_CTRL) { //stim::vec temp = Parker.getDirection(); //temp[0] += 0.001; Parker.Tilt(0.01); spidey.setDirection(Parker.getDirection()); spidey.Update(); } break; case GLUT_KEY_RIGHT: oriTex[1] = oriTex[1]-adjustTex; if (oriTex[1] < org[0]){ oriTex[1] = org[0]; } else{ oriDrw[1] = oriDrw[1] - adjustDrw; } if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) { stim::vec temp = spidey.getPosition(); temp[0] -= 0.001; spidey.setPosition(temp); spidey.Update(); } if (glutGetModifiers() == GLUT_ACTIVE_CTRL) { //stim::vec temp = Parker.getDirection(); //temp[0] -= 0.001; Parker.Tilt(-0.01); spidey.setDirection(Parker.getDirection()); spidey.Update(); } break; } glutPostRedisplay(); } void processKeys(unsigned char key, int x, int y) { if (key == 27) exit(0); if (key == 32) { spidey.Step(); std::cout << "Took a step" << std::endl; } if (key == 43) { stim::vec temp = spidey.getMagnitude(); temp = temp + 0.001; spidey.setMagnitude(temp); spidey.Update(); } if (key == 45) { stim::vec temp = spidey.getMagnitude(); temp = temp - 0.001; spidey.setMagnitude(temp); spidey.Update(); } } void changeSize(int w, int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); //gluPerspective(90, 4.0/3.0, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); } int main(int argc, char **argv) { CHECK_OPENGL_ERROR glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(size[0], size[1]); glutCreateWindow("gl_texture"); //std::cout << " Initialization is complete in Glut" << std::endl; CHECK_OPENGL_ERROR glutKeyboardFunc(processKeys); CHECK_OPENGL_ERROR glutSpecialFunc(processSpecialKeys); CHECK_OPENGL_ERROR glutReshapeFunc(changeSize); CHECK_OPENGL_ERROR glutDisplayFunc(renderScene); CHECK_OPENGL_ERROR glutMouseFunc(MouseButton); CHECK_OPENGL_ERROR glutMotionFunc(MouseMotion); //std::cerr << " Keyboard and Reshape is complete in Glut" << std::endl; GLenum err = glewInit(); if (GLEW_OK != err) { std::cerr << "Failed" << std::endl; fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); } stim::gl_texture stack ("/home/pavel/Documents/Test_Data/"); //stack.setDimensions(1.0,1.0,1.0); //D = stack.getDimensions(); stack.createTexture(); texID = stack.getTexture(); //std::cout << ("I have started an instance of the class") << std::endl; glInit(); CHECK_OPENGL_ERROR glutIdleFunc(idleFunction); CHECK_OPENGL_ERROR glutMainLoop(); CHECK_OPENGL_ERROR return 0; } //old code /* for (int i = 0; i < 6; i++) { //first vertex glTexCoord3f(vertex[faces[i][0]][0], vertex[faces[i][0]][1], vertex[faces[i][0]][2]); glVertex3f(vertex[faces[i][0]][0], vertex[faces[i][0]][1], vertex[faces[i][0]][2]); //second vertex glTexCoord3f(vertex[faces[i][1]][0], vertex[faces[i][1]][1], vertex[faces[i][1]][2]); glVertex3f(vertex[faces[i][1]][0], vertex[faces[i][1]][1], vertex[faces[i][1]][2]); //third vertex glTexCoord3f(vertex[faces[i][2]][0], vertex[faces[i][2]][1], vertex[faces[i][2]][2]); glVertex3f(vertex[faces[i][2]][0], vertex[faces[i][2]][1], vertex[faces[i][2]][2]); //fourth vertex glTexCoord3f(vertex[faces[i][3]][0], vertex[faces[i][3]][1], vertex[faces[i][3]][2]); glVertex3f(vertex[faces[i][3]][0], vertex[faces[i][3]][1], vertex[faces[i][3]][2]); }*/ //init for a square. /*void glInitSquare(int w, int h) { glEnable(GL_TEXTURE_3D); glEnable(GL_DEPTH_TEST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glClearColor(0.0, 0.0, 0.0, 0.0); glColor4d(0.0, 0.0, 0.0, 1.0); //glPointSize(3.0); glShadeModel(GL_FLAT); glViewport(0, 0, (GLsizei) 900, (GLsizei) 900); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90, 4.0/3.0, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); } //render square void renderSceneSquare() { glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, texID); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(-0.5, -0.5, -pos); glBegin(GL_QUADS); glTexCoord3f(vertexTex[faces[1][0]][0], vertexTex[faces[1][0]][1], oriTex[2]); glVertex3f(vertexDrw[faces[1][0]][0], vertexDrw[faces[1][0]][1], vertexDrw[faces[1][0]][2]); //second vertex glTexCoord3f(vertexTex[faces[1][1]][0], vertexTex[faces[1][1]][1], oriTex[2]); glVertex3f(vertexDrw[faces[1][1]][0], vertexDrw[faces[1][1]][1], vertexDrw[faces[1][1]][2]); //third vertex glTexCoord3f(vertexTex[faces[1][2]][0], vertexTex[faces[1][2]][1], oriTex[2]); glVertex3f(vertexDrw[faces[1][2]][0], vertexDrw[faces[1][2]][1], vertexDrw[faces[1][2]][2]); //fourth vertex glTexCoord3f(vertexTex[faces[1][3]][0], vertexTex[faces[1][3]][1], oriTex[2]); glVertex3f(vertexDrw[faces[1][3]][0], vertexDrw[faces[1][3]][1], vertexDrw[faces[1][3]][2]); glEnd(); CHECK_OPENGL_ERROR glutSwapBuffers(); }*/ //GLint faces[6][4] = // {{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 vertex[8][3] = // {{0.0, 0.0, 1.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, // {0.0, 1.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, // {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}}; //GLfloat vertex[8][3] = // {{-1.0, -1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, // {-1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, // {1.0, 1.0, -1.0}, {1.0, 1.0, 1.0}}; /* void DrawPlanes() { glPushName(VERTICAL); glBegin(GL_QUADS); glTexCoord3f( vertexTex[0][0], vertexTex[0][1], oriTex[2] ); glVertex3f( vertexDrw[0][0], vertexDrw[0][1], oriDrw[2] ); glTexCoord3f( vertexTex[1][0], vertexTex[1][1], oriTex[2] ); glVertex3f( vertexDrw[1][0], vertexDrw[1][1], oriDrw[2] ); glTexCoord3f( vertexTex[2][0], vertexTex[2][1], oriTex[2] ); glVertex3f( vertexDrw[2][0], vertexDrw[2][1], oriDrw[2] ); glTexCoord3f( vertexTex[3][0], vertexTex[3][1], oriTex[2] ); glVertex3f( vertexDrw[3][0], vertexDrw[3][1], oriDrw[2] ); glEnd(); glPopName(); glPushName(HORIZONTAL); glBegin(GL_QUADS); glTexCoord3f( vertexTex[3][0], oriTex[1], vertexTex[3][2] ); glVertex3f( vertexDrw[3][0], oriDrw[1], vertexDrw[3][2] ); glTexCoord3f( vertexTex[2][0], oriTex[1], vertexTex[2][2] ); glVertex3f( vertexDrw[2][0], oriDrw[1], vertexDrw[2][2] ); glTexCoord3f( vertexTex[7][0], oriTex[1], vertexTex[7][2] ); glVertex3f( vertexDrw[7][0], oriDrw[1], vertexDrw[7][2] ); glTexCoord3f( vertexTex[6][0], oriTex[1], vertexTex[6][2] ); glVertex3f( vertexDrw[6][0], oriDrw[1], vertexDrw[6][2] ); glEnd(); glPopName(); } */ /* void renderScene() { glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, texID); CHECK_OPENGL_ERROR glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); //glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(-0.4, -0.4, 0.4); //gluLookAt(0,0, -viewDistance, 0, 0, -1, 0, 1, 0); //gluLookAt(0,0, 0, 0, 0, 0, 0, 0, 0); glRotatef(-90, 1.0, 0.0, 0.0); glRotatef((float)tick/100.0, 1.0, 1.0, 1.0); CHECK_OPENGL_ERROR //glVertex3f(0.0, 0.0, 0.0); //glVertex3f(0.0, 1.0, 0.0); //glVertex3f(1.0, 1.0, 0.0); //glVertex3f(1.0, 0.0, 0.0); glBegin(GL_QUADS); for (int i = 0; i < 6; i++) { //first vertex // std::cout << "setting vertex 1 of face " << i << " vertex located at " << "[" << vertex[faces[i][0]][0] << "," << vertex[faces[i][0]][1] << "," << vertex[faces[i][0]][2] << "]" << std::endl;// glTexCoord3f(vertex[faces[i][0]][0], vertex[faces[i][0]][1], vertex[faces[i][0]][2]); glVertex3f(vertex[faces[i][0]][0], vertex[faces[i][0]][1], vertex[faces[i][0]][2]); //second vertex glTexCoord3f(vertex[faces[i][1]][0], vertex[faces[i][1]][1], vertex[faces[i][1]][2]); glVertex3f(vertex[faces[i][1]][0], vertex[faces[i][1]][1], vertex[faces[i][1]][2]); //third vertex glTexCoord3f(vertex[faces[i][2]][0], vertex[faces[i][2]][1], vertex[faces[i][2]][2]); glVertex3f(vertex[faces[i][2]][0], vertex[faces[i][2]][1], vertex[faces[i][2]][2]); //fourth vertex glTexCoord3f(vertex[faces[i][3]][0], vertex[faces[i][3]][1], vertex[faces[i][3]][2]); glVertex3f(vertex[faces[i][3]][0], vertex[faces[i][3]][1], vertex[faces[i][3]][2]); } glEnd(); CHECK_OPENGL_ERROR glutSwapBuffers(); //glutPostRedisplay(); } */