Trouble with "Varying" in GLSL ES

I’m using OpenGL ES 2.0, with GLSL ES 1.0.0.
Currently I’m rendering a square to screen to the screen, and now attempting to apply a texture.

I’m having trouble using “varying” in vertex and fragment shaders, receiving the error message:

- Failed to compile vertex shader - 
0(3) : error C5060: out can't be used with non-varying tex_varying

in vec4 texture_coord ;
in vec4 position ;
out vec2 tex_varying ;
uniform mat4 translate ;
void main ( ) 
  gl_Position = translate * position ;
  tex_varying = texture_coord . xy ;

I’ve read through the documentation and can’t figure out what I’m doing wrong.

Here’s the code.


attribute vec4 position; 
attribute vec4 texture_coord; 
varying vec2 tex_varying; 
uniform mat4 translate; 

void main()
  gl_Position = translate * position; 
  tex_varying = texture_coord.xy;


varying vec2 tex_varying; 
uniform sampler2D texture; 

void main()
  gl_FragColor = texture2D(texture, tex_varying);

Any ideas?
Thanks in advance.

Replace out vec2 with varying vec2.

Oops. The error message containing out is not consistent with your source ode. Do you post process your source code somehow? Which ES implementation this is? Is it some ES wrapper on desktop?

Here’s a string output of the version I’m using:

OpenGL ES 2.0.0

OpenGL ES GLSL ES 1.0.0 Desktop; Shading Language Vendor(NVIDIA Corporation) Version(3.30 NVIDIA via Cg compiler) Renderer(GeForce 9600 GT/PCI/SSE2)

And as for post-processing, I’m unsure.

The error message source looks like the original source has been post processed, and there is some mistake in this.

This looks like a possible bug in the desktop wrapper you are using. Could you try some other ES on desktop wrapper?

You can also check with debugger what you pass in glShaderSource? If you pass in vertex shader with “out” then that part is wrong.

Thanks, I’ve contacted the developers of the platform who use this version to see if there’s a problem on their end. But I don’t think there’s a way I can change this.

I know that this code works with the version of ES 2.0 when developing for iOS. Currently I’m porting to a different platform which seems to use an older version.

There are no “versions of ES 2.0”. There’s one version: ES 2.0.

What you are encountering is a driver bug brought on by NVIDIA’s apparent refusal to compile actual GLSL.

In general, OpenGL ES does not work on the desktop, just as desktop GL does not work on mobile platforms. NVIDIA does have this ES profile extension, but as you can see, it has some issues.

Thank you very much. I’ll see if I can work around this then.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.