This is the vertex shader. I think it's basic enough
uniform mat4 view_proj_matrix;
uniform vec4 view_position;
attribute vec4 vertex;
attribute vec3 normal;
varying vec3 vNormal;
varying vec3 vViewVec;
void main(void)
{
gl_Position = view_proj_matrix * vertex;
vNormal = normal;
vViewVec = view_position.xyz - vertex.xyz;
}
and the fragment shader:
uniform vec4 color;
varying vec3 vNormal;
varying vec3 vViewVec;
void main(void)
{
float v = 0.5 * (1.0 + dot(normalize(vViewVec), vNormal));
gl_FragColor = v * color;
}
On May 24, 9:43 pm, sebastian_bugiu
<[email protected]> wrote:
> Well the simple case works. I check after each call and compiling
> works.. creating the program works...everything return success. But
> when linking it just remains in the native call, never to return.
>
> I suspected that creating the shaders and program in one
> requestRender() and then linking in the next one could be the issue
> but it isn't.
>
> Anyway even if there is something wrong with my shader code it still
> should return immediately. This sounds like an Android bug to me....
>
> On May 24, 9:32 pm, RichardC <[email protected]> wrote:
>
>
>
>
>
>
>
> > Have your tried a simple test case? I would suggest a skeleton program
> > with just 1 fragment and 1 vertex shader and link them into a program.
>
> > Are you calling glGetError and logging or aborting after every OpenGL ES
> > API call?
>
> > On Thursday, May 24, 2012 6:37:17 PM UTC+1, sebastian_bugiu wrote:
>
> > > I have a LinkedQueue that stores the calls to anything from the GLES20
> > > class. After loading it up I send a requestRender() call to
> > > GLSurfaceView and in onDrawFrame() I process the queue and call the
> > > actual GLES20 method.
>
> > > Yet when I call GLES20.glLinkProgram() the function never returns. I
> > > don't have anything in the logcat, no exception, no killed thread
> > > nothing. It just remains there.
>
> > > Any ideas in which conditions glLinkProgram() doesn't return and what
> > > can I do to debug this situation?
>
> > > I use a queue in which I add the gl commands issued by the renderer
> > > and then I requestRender() to empty the queue by iterating through it
> > > and calling each method in the added order. Some gl commands are of
> > > get type and they can't be added to a queue so after issuing
> > > glCreateShader I immediately requestRender() and store the retrieved
> > > id that I then pass into the queue with the next commands like
> > > glAttachShader etc. So in one onDrawFrame() call I create the shaders
> > > and in the next I attach the source compile and link.
>
> > > What I do may seem awkward but it does create both a vertex and
> > > fragment shader and then compiles them both correctly. It also creates
> > > a program with no errors. But linking the shaders to program just goes
> > > into infinite loop or something
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en