iPhone OpenGL-ES: Adding a texture to one face of a cube -
building 3d environment, far have textured cubes , colored cubes. want add texture 1 of coloured cube faces
gldrawelements(gl_triangles, 6, gl_unsigned_byte, &colourcubevertexfaces[0]); glcolor4ub(colourcubefacecolors[colorindex], colourcubefacecolors[colorindex+1], colourcubefacecolors[colorindex+2], colourcubefacecolors[colorindex+3]);glcolor4ub(colourcubefacecolors[colorindex], colourcubefacecolors[colorindex+1], colourcubefacecolors[colorindex+2], colourcubefacecolors[colorindex+3]); gldrawelements(gl_triangles, 6, gl_unsigned_byte, &colourcubevertexfaces[6]); gldrawelements(gl_triangles, 6, gl_unsigned_byte, &colourcubevertexfaces[12]); gldrawelements(gl_triangles, 6, gl_unsigned_byte, &colourcubevertexfaces[18]); gldrawelements(gl_triangles, 6, gl_unsigned_byte, &colourcubevertexfaces[24]); i thought easy turning on (and off)
glenableclientstate(gl_texture_coord_array); then bind texture
glbindtexture(gl_texture_2d, ([[coordsarray objectatindex:4] floatvalue])); and plotting it
gltexcoordpointer(2, gl_float, 0, texturedcubecoord); but seems slow down alot , not show anything. other textured cubes fine.
you need glenable(gl_texture_2d)
Comments
Post a Comment