c++ - Android NDK GLES 2.0 Nothing Drawing -


i trying draw gles 2.0 through ndk, doing except creating surface in c++, nothing drawing on screen...and can't figure out why.

i have tried/verified many different things , still @ loss.

my last few guesses these:

my textures somehow compatible screen:

i load textures this:

glteximage2d(gl_texture_2d, 0, gl_rgba, w, h, 0, gl_rgba, gl_unsigned_byte, image->getpixels()); 

but default glsurfaceview format rgb_565

i tried no success:

mglview.getholder().setformat(pixelformat.rgba_8888); 

and this:

glteximage2d(gl_texture_2d, 0, gl_unsigned_short_5_6_5, w, h, 0, gl_rgba, gl_unsigned_byte, image->getpixels()); 

could texture format have problem? have no reference because android sdk abstracts away completely..

this shader using:

const char *vertexshader = "\     uniform mat4 umtxprojection; \     uniform mat4 umtxmodelview; \     attribute vec2 aposition; \     attribute vec2 atexcoord; \     varying vec2 vtexcoord; \     void main() \     { \         gl_position = umtxprojection * (umtxmodelview * vec4(aposition.x, aposition.y, 0.0, 1.0)); \         vtexcoord = atexcoord; \     }";  const char *fragmentshader = "\     precision mediump float; \     varying vec2 vtexcoord; \     uniform sampler2d stexture; \     void main() \     { \         gl_fragcolor = vec4(1.0, 0.0, 0.0, 1.0); \     }"; 

after further testing, , removing texture(filling triangle red) can see distorted red box flash 3 times each time app run, screen goes blank =/

and ortho matrix:

mat4 ortho2d(float left, float right, float bottom, t top, float znear, float zfar) {     float dx = right - left;     float dy = top - bottom;     float dz = zfar - znear;      // avoid division 0     float tx = (dx != 0) ? -(right + left) / dx : 0;     float ty = (dy != 0) ? -(top + bottom) / dy : 0;     float tz = (dz != 0) ? -(zfar + znear) / dz : 0;      return mat4(2.0f / dx, 0,           0,          tx,                 0,          2.0f / dy, 0,           ty,                 0,          0,          -2.0f / dz, tz,                 0,          0,          0,          1); } 

actually, i'm not sure going on exactly, changed fixed problem =/ tried going on code re-break it, couldn't..

but reference, can't guarantee broken, can sure, problem neither texture, nor shader. though default surface view set rgb_565, using following line creates texture fine in ndk, with working alpha.

glteximage2d(gl_texture_2d, 0, gl_rgba, w, h, 0, gl_rgba, gl_unsigned_byte, image->getpixels()); 

the projection matrix using fine, because copied directly opengl specs.

i noticed while working call glenable(texture_2d) causing error (invalid enum) because pertains fixed function pipeline of opengl, , using gles2.0... , copying of old code fixed function implementation gles1. can think of was causing gl crash somehow old code =/


Comments