iphone - OpenGL ES 2.0 texturing -
i'm trying render simple textured quad in opengl es 2.0 on iphone. geometry fine , expected quad if use solid color in shader:
gl_fragcolor = vec4 (1.0, 0.0, 0.0, 1.0);
and expected gradients if render texture coordinates directly:
gl_fragcolor = vec4 (texcoord.x, texcoord.y, 0.0, 1.0);
the image data loaded uiimage, scaled fit within 1024x1024, , loaded texture so:
glgentextures (1, &_texture); glbindtexture (gl_texture_2d, _texture); glteximage2d(gl_texture_2d, 0, gl_rgba, width, height, 0, gl_rgba, gl_unsigned_byte, data);
width, height, , contents of data correct, examined in debugger.
when change fragment shader use texture:
gl_fragcolor = texture2d (tex, texcoord);
... , bind texture , render so:
glactivetexture (gl_texture0); glbindtexture (gl_texture_2d, _texture); // unnecessary, defaults 0, completeness... gluint texloc = glgetuniformlocation(_program, "tex"); gluniform1i(texloc, 0); gldrawarrays(gl_triangle_strip, 0, 4);
... nothing. black quad. glgeterror() doesn't return error , glistexture(_texture) returns true.
what doing wrong here? i've been on , on every example find online, doing am, , debugger shows parameters various gl functions expect them be.
after glteximage2d, set min/mag filters gltexparameter, defaults use mipmaps texture incomplete code.
Comments
Post a Comment