when i'm using opengl glsl to implement skybox, getting something wrong.

I’m currently using glsl to draw a skybox, but final result of my program is not my expect, the six sides of the skybox looks like all sides flipped vertically, then flipped vertically. If I make the six image (right.bmp, left.bmp, top.bmp, and so on) vertical and vertical manually in some image editor, the skybox works fine. To locate the problem within my program quickly, I just simplify my program to draw only one side, front side.

here is the relevant code :

vertics shader:

attribute  vec3 VertexPosition;
varying vec3 ReflectDir;

void main()
{
   ReflectDir = VertexPosition;

   gl_Position = gl_ModelViewProjectionMatrix * vec4(VertexPosition,1.0);
}

fragment shader:

 varying vec3 ReflectDir;
 uniform samplerCube CubeMapTex; 

 void main() {
    vec4 cubeMapColor = texture(CubeMapTex,ReflectDir );

    gl_FragColor=  cubeMapColor;
 }

Some code within my opengl program:

This used for binding my cube map into shader.

 glActiveTexture(GL_TEXTURE5);
    
    GLuint texID;
    glGenTextures(1, &texID);
    glBindTexture(GL_TEXTURE_CUBE_MAP, texID);
    
    GLuint targets[] = {
    	GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
    	GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
    	GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
    };
    
    const char* baseFileName[] = {
    "Right",
    "Left",
    "Top",
    "Bottom",
    "Front",
    "Back"
    
    
    };
    
    for( int i = 0; i < 6; i++ ) {
    	string texName = string(baseFileName[i])+".bmp";
    
    		IMAGE img;
    		img.Load((char*)texName.c_str());
    		img.ExpandPalette();
    
    		glTexImage2D(targets[i], 0, GL_RGBA, img.width, img.height, 0,
    			 img.format, GL_UNSIGNED_BYTE, img.data);
    
    }
    
    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);
    
    m_shader->compileandlink();
    m_shader->useprogram();
    m_shader->setUniform("CubeMapTex", 5);
    m_shader->unuseprogram();

And this 's my front side vertics, it’s clock-wise winding.

    float extend2 = extend*.5f;
	m_cube_v = new vertex_t[24];

	//front
	m_cube_v[0].pos[0] = -extend2;
	m_cube_v[0].pos[1] = -extend2;
	m_cube_v[0].pos[2] = extend2;

	m_cube_v[1].pos[0] = extend2;
	m_cube_v[1].pos[1] = -extend2;
	m_cube_v[1].pos[2] = extend2;

	m_cube_v[2].pos[0] =  extend2;
	m_cube_v[2].pos[1] =  extend2;
	m_cube_v[2].pos[2] = extend2;

	m_cube_v[3].pos[0] = -extend2;
	m_cube_v[3].pos[1] = extend2;
	m_cube_v[3].pos[2] = extend2;

What went wrong? thank you.

here is my program screenshot that was totally fliped over.

image link: i1345.photobucket.com/albums/p668/nimaccc/front_zps741fc377.jpg

here is my original material:

image link: i1345.photobucket.com/albums/p668/nimaccc/original_zps3dbccf2e.jpg

Hi,

Sorry – you probably checked this, but what is loading the image?
(BMP files are saved upside down :slight_smile: )

Dave Driesen