I’ve been attempting to cube map (this time using opengl).
I generate the textures as:
glGenTextures(7, texture_name); //generate the texture names
GLubyte texture[texture_size][texture_size][4]; //generic array for textures
//top
makeFillTexture(texture, top_rgba);
bindTextures(pos_y_face, texture);
//bottom
makeFillTexture(texture, bottom_rgba);
bindTextures(neg_y_face, texture);
//left
makeStripeTexture(texture, left_rgba, left_alt_rgba);
bindTextures(neg_x_face, texture);
//right
makeStripeTexture(texture, right_rgba, right_alt_rgba);
bindTextures(pos_x_face, texture);
//front
makeCheckerTexture(texture, front_rgba, front_alt_rgba);
bindTextures(pos_z_face, texture);
//back
makeFillTexture(texture, back_rgba);
bindTextures(neg_z_face, texture);
glEnable(GL_TEXTURE_2D);
GLubyte texture2[6][texture_size][texture_size][4];
//environment mapping
glBindTexture(GL_TEXTURE_CUBE_MAP, texture_name[6]);
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);
//top
makeFillTexture(texture2[0], top_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[0]);
//bottom
makeFillTexture(texture2[1], bottom_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[1]);
//left
makeStripeTexture(texture2[2], left_rgba, left_alt_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[2]);
//right
makeStripeTexture(texture2[3], right_rgba, right_alt_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[3]);
//front
makeCheckerTexture(texture2[4], front_rgba, front_alt_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[4]);
//back
makeFillTexture(texture2[5], back_rgba);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, texture_size, texture_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture2[5]);
And apply it using:
if (sphere_quad_strip == NULL)
makeSphere();
glBindTexture(GL_TEXTURE_CUBE_MAP, texture_name[6]);
glEnable(GL_TEXTURE_CUBE_MAP);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glBegin(GL_QUAD_STRIP);
for (int i = 0; i < sphere_quad_strip_size; i++)
glVertex3d(sphere_quad_strip[i][0], sphere_quad_strip[i][1], sphere_quad_strip[i][2]);
glEnd();
drawPole(sphere_top_tri_strip);
drawPole(sphere_bottom_tri_strip);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_CUBE_MAP);
To summarize: I create the textures, bind them to the faces, assign it to a texture name, and then use automatic texture coord generation to texture my sphere.
However, the resulting texture uses only one side of the texture map.
I probably assigned the textures incorrectly.
Thank you for any help.