void testApp::generateVBOs() { // If the meshes have already been generated once, we need to clear their data vboMeshOriginal.clear(); vboMeshMirrored.clear(); // Shorthand to make the equations more readable // r is the radius of a circle that is inscribed by the display window // a is the current angle heading we will use to sample the image // da is half the span of the triangle float r = minWindowDimension/2.0; float a = ofDegToRad(imageSectionHeading); float da = ofDegToRad(triangleAngularWidth/2); // Define the vertices of the triangular face ofVec3f triangleBottom(0, 0, 0); ofVec3f triangleLeft(r*cos(a+da), -r*sin(a+da), 0); // Flip because of drawing ofVec3f triangleRight(r*cos(a-da), -r*sin(a-da), 0); // Flip because of drawing float cx = imageSectionCenter.x; float cy = imageSectionCenter.y; r = minImageDimension/2.0; // Define the triangular section of the image that we want to draw on the face ofVec2f textureBottom(cx, cy); ofVec2f textureLeft(cx+r*cos(a+da), cy-r*sin(a+da)); ofVec2f textureRight(cx+r*cos(a-da), cy-r*sin(a-da)); // Add the vertices to the VBO mesh to form a triangle addFace(vboMeshOriginal, triangleBottom, triangleLeft, triangleRight); addFace(vboMeshMirrored, triangleBottom, triangleLeft, triangleRight); // Add the texture coordinates to the mesh addTexture(vboMeshOriginal, textureBottom, textureLeft, textureRight); addTexture(vboMeshMirrored, textureBottom, textureRight, textureLeft); }
bool CubemapTexture::Load(const char * path) { string textureLeft(VPLOGL_TEXTURE_PATH); textureLeft.append("Left.ppm"); string textureRight(VPLOGL_TEXTURE_PATH); textureRight.append("Right.ppm"); string textureUp(VPLOGL_TEXTURE_PATH); textureUp.append("Up.ppm"); string textureDown(VPLOGL_TEXTURE_PATH); textureDown.append("Down.ppm"); string textureFront(VPLOGL_TEXTURE_PATH); textureFront.append("Front.ppm"); string textureBehind(VPLOGL_TEXTURE_PATH); textureBehind.append("Behind.ppm"); _texture1->LoadPPM(textureRight.c_str()); _texture2->LoadPPM(textureLeft.c_str()); _texture3->LoadPPM(textureUp.c_str()); _texture4->LoadPPM(textureDown.c_str()); _texture5->LoadPPM(textureBehind.c_str()); _texture6->LoadPPM(textureFront.c_str()); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); return true; }