PyOpenGL Cube Mapping Textures

i've tried texture_2D to push textures on my cube. thats no problem.

but when i use TEXTURE_CUBE_MAP the textures aren't visible. Just a black cube.

Can anybody help me?

#### INIT FUNCTION
textureIDs = glGenTextures(1)                                                                                                                                                                                                       

glBindTexture(GL_TEXTURE_CUBE_MAP, textureIDs)                                                                                                                                                                                      
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)                                                                                                                                                           
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR)                                                                                                                                                              
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR)   

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, imgRaw.size[0], imgRaw.size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, img)                                                                                                           


..... (for the other five also)


####DISPLAY FUNCTION
glEnable(GL_TEXTURE_GEN_S)                                                                                                                                                                                                          
glEnable(GL_TEXTURE_GEN_T)                                                                                                                                                                                                          
glEnable(GL_TEXTURE_GEN_R)                                                                                                                                                                                                          
glEnable(GL_TEXTURE_CUBE_MAP)                                                                                                                                                                                                       

glEnableClientState(GL_VERTEX_ARRAY)              


myVBO.bind()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

glUseProgram(program) #shader frag and vert                                                                                                                                                                                                               
varLocation = glGetUniformLocation(program, "mvpMatrix")                                                                                                                                                                            
glUniformMatrix4fv(varLocation , 1, GL_TRUE, mvpMat.tolist())                                                                                                                                                                       


glVertexPointer(3, GL_FLOAT, 32, myVBO)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
glBindTexture(GL_TEXTURE_CUBE_MAP, textureIDs)                                                                                                                                                                                     
glDrawArrays(GL_QUADS, 0 ,len(data))                                                                                                                                                                                                
myVBO.unbind()                            

A cube map is not a literal "put texture on a cube." It is a kind of texture, separate from 2D, 3D, etc texture types.

A 2D texture is a 2D image that you use a position in 2D space to access. A 3D texture is a 3D image that you use a position in 3D space to access. A cube map is a set of 6 2D images that you use a 3D direction to access. Imagine yourself sitting in the center of a cube. In every direction is a location on that cube. That's what color you get from accessing a cube map with a given direction.

链接地址: http://www.djcxy.com/p/81850.html

上一篇: 基于弧球四元数旋转矩阵旋转我的立方体稍微偏离

下一篇: PyOpenGL多维数据集映射纹理