opengl es - Texture is all black -


as far can tell, first attempt draw texture on triangle being setup correctly, shows black.

i sending image opengl such:

   gluint gridtexture;     glgentextures(1, &gridtexture);     glbindtexture(gl_texture_2d, gridtexture);     gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear);     gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear);   glteximage2d(gl_texture_2d, 0, gl_rgba, size.x,                  size.y, 0, gl_rgba, gl_unsigned_byte, pixels); 

while i'm not sure how test "pixels" holds i'd expect, know size.x , size.y variables logging correctly png i'm using assume pixels working since both extracted in resource loader

my shaders simple:

attribute vec4 position; attribute vec4 sourcecolor; attribute vec2 texturecoordinate;  varying vec4 destinationcolor; varying vec2 texturecoordout;  uniform mat4 projection; uniform mat4 modelview;  void main(void) {     destinationcolor = sourcecolor;      gl_position=projection*modelview*position;     texturecoordout = texturecoordinate; } 

fragment:

varying lowp vec4 destinationcolor; varying mediump vec2 texturecoordout;  uniform sampler2d sampler;  void main(void) {     gl_fragcolor = texture2d(sampler, texturecoordout) * destinationcolor; //        gl_fragcolor = destinationcolor; //this works , see varied colors fine } 

i send texture coordinates client memory this:

glenablevertexattribarray(textcoordattribute));     glvertexattribpointer(textcoordattribute, 2, gl_float, gl_false, sizeof(vec2),&texs[0]); 

the triangle , vertices texture coordinates this; know coordinates aren't polished, want see on screen:

//omitting structures use hold vertex data, can @ least see vertices , coordinates associating them. triangle draws fine, , if disable texture2d() function in frag shader can see colors of vertices appears working except texture itself.      top.color=vec4(1,0,0,1);     top.position=vec3(0,300,0);     texs.push_back(vec2(0,1));      right.color=vec4(0,1,0,1);     right.position=vec3(300,0,0);     texs.push_back(vec2(1,0));      left.color=vec4(0,0,1,1);     left.position=vec3(-300,0,0);     texs.push_back(vec2(0,0));      verts.push_back(top);     verts.push_back(right);     verts.push_back(left); 

for measure tried binding texture again glbindtexture before drawing make "active" made no difference.

i think there simple step not doing somewhere can't find anywhere.

the issue resolved making texture dimensions power of 2 in length , width.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -