Hey,
I'm having some troubles getting shaders to compile using the OpenGL ES emulator
"precision mediump float;\n" "attribute vec3 inPosition;\n" "attribute vec2 inTexCoords;\n" "varying vec4 Position;\n" "varying vec2 TexCoords;\n" "uniform mat4 modelMatrix;\n" "uniform mat4 viewMatrix;\n" "uniform mat4 projMatrix;\n" "void main()\n" "{\n" " mat4 MVP = projMatrix * viewMatrix * modelMatrix;\n" " Position = MVP * vec4(inPosition, 1.0);\n" " TexCoords = inTexCoords;\n" " gl_Position = Position;\n" "}\n");
This basic shader compiles if I run it on my actual Android device using GLES, however when using the emulator glGetShaderiv reports that the compilation failed but glGetShaderInfoLog returns an empty log.
Is there anything I can do to try and find out why this is failing? I've attached a table of the values I've extracted from glGetString() for reference.
Thanks!
What host OS and graphics card / driver version are you using? Do any of the emulator examples work?
Cheers,
Pete
One unrelated other obersvation:
uniform mat4 modelMatrix; uniform mat4 viewMatrix; uniform mat4 projMatrix; <snip> mat4 MVP = projMatrix * viewMatrix * modelMatrix;
Please don't write vertex shaders like this - it makes the performance gods cry. You're forcing every vertex to repeat the computation of the same two matrix multiplications, which is a huge waste of energy and performance. Pre-multiply the MVP matrix in software on the CPU and upload that as the uniform - it is far more efficient.
HTH,
A fair point and duly noted, just trying to get things running first but that'll be the first thing to go .
I'm running Windows 7, Geforce GTX 780, Driver 347.25.
I could attach a DxDiag if that helps?
I tried simpler shaders and saw the same result.
Thanks
Also, regarding the samples, they all seem to be in Java. Just to clarify (as I didn't state before) I'm using C++, Windows and the EGL library's to emulate running EGL but on Windows.
I'm currently not set up to run the Java samples but can be if that will help.
Seems like I got this working now, looked like an error with the params I was passing to glShaderSource(), they worked on Windows + EGL on device but not with the emu wrapping, now using:
const char *strings[1] = { NULL };
strings[0] = &src[0];
glShaderSource(m_shader, 1, strings, NULL);
Instead of passing the source code string through.
Hi maddius,
The samples are intended for Linux and are therefore C/C++, although I suspect they build for X11 or fbdev so you might need to modify these to do whatever the cube example shipped in the Windows emulator package does to get a window up. Probably you downloaded the Android GLES SDK which contains a mix of Java and native examples AFAIK.
As for glShaderSource, it expects the string(s) to be passed as const GLchar * const *string, so a pointer to the first element of an array of const pointers to const strings. Passing the string directly shouldn't work in any case, so not sure how you had that working in other environments. It should have been sufficient to pass &src as the string param.
Thanks,
Chris