Hello,

I would like to know if you see huge errors in my code.

It’s incomprehensible for me…

1- If I call a function in my vertex shader some views are not drawn. If I copy/paste the code of the function in the main then all works well.

2- If I use a varying float variable in a fragment shader I have no more dashed lines. If I comment the line then all works well…

First problem :

- If I call a function in my vertex shader I have problems : some views are not drawn and on an old ATI X1300/X1550 the depth buffer is invalid (http://www.opengl.org/discussion_boards/showthread.php/181183-Problem-with-glReadPixels-on-a-part-of-a-view-on-ATI-cards?p=1248827&viewfull=1#post1248827)
- If I copy/paste the code of the function in the main() then all works well.

Here is the code : the green code works, the red code does not work.

[i]#version 110

varying vec3 N;

varying vec4 v;

varying vec2 glTexCoord;

uniform int TexGenMode = 0;

uniform int bIsTexture = 0;

// the function

void glTexGen( const in int textureUnit,

const in int genMode,

const vec4 ecPosition,

out vec2 _glTexCoord)

{

if (genMode == 0)

{

_glTexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);

return;

}

if (genMode == 1) // 1 == GL_EYE_LINEAR

{

_glTexCoord.s = dot(gl_Vertex, gl_ObjectPlaneS[textureUnit]);

_glTexCoord.t = dot(gl_Vertex, gl_ObjectPlaneT[textureUnit]);

return;

}

if (genMode == 2) // 2 == GL_OBJECT_LINEAR

{

_glTexCoord.s = dot(ecPosition, gl_EyePlaneS[textureUnit]);

_glTexCoord.t = dot(ecPosition, gl_EyePlaneT[textureUnit]);

return;

}

}

void main(void)

{

gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

```
v = gl_ModelViewMatrix * gl_Vertex;
N = normalize(gl_NormalMatrix * gl_Normal);
```

#if 0

if (bIsTexture != 0)

{

if (TexGenMode == 0) // ne pas toucher

{

glTexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);

}

if (TexGenMode == 1) // 1 == GL_EYE_LINEAR

{

glTexCoord.s = dot(gl_Vertex, gl_ObjectPlaneS[0]);

glTexCoord.t = dot(gl_Vertex, gl_ObjectPlaneT[0]);

}

if (TexGenMode == 2) // 2 == GL_OBJECT_LINEAR

{

glTexCoord.s = dot(v, gl_EyePlaneS[0]);

glTexCoord.t = dot(v, gl_EyePlaneT[0]);

}

}

#else

if (bIsTexture != 0)

glTexGen(0, TexGenMode, v, glTexCoord);

#endif

```
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
```

}[/i]

Second problem :

On an ATI X1300/X1550, with the basic shaders below, glLineStipple has no effect if I uncomment the red line !

I do not use this variable !

In my full shader I need a variable to compute lighting : so I have light but I have no more dashed lines…

Vertex shader :

[i]#version 110

varying vec3 N;

varying float vx;

void main(void)

{

gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

vx = 1.0;

N = normalize(gl_NormalMatrix * gl_Normal);

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

}[/i]

Fragment shader :

#version 110

varying vec3 N;

varying float vx;

void main (void)

{

vec3 L = normalize(gl_LightSource[0].position.xyz);

float vvx = vx; // If I comment this useless line the card draws again dashed lines

vec3 R = normalize(-reflect(L,N));

gl_FragColor = vec4(1,0,0,1);

return;

}

For the first problem it seems a bug in my code somewhere because the problem is on several ATI cards.

For the second problem maybe it is a bug in the old driver (last driver : 2/2010). Or something in my code that generates the problem in the shaders.

gdebugger and AMD GPU ShaderAnalyser see no error.

So if you have an idea…

As nvidia understand my code I started to detest ati cards…

Edit : the same code without color but in

```
tags :
[b]First problem[/b]
```

#version 110

varying vec3 N;

varying vec4 v;

varying vec2 glTexCoord;

uniform int TexGenMode = 0;

uniform int bIsTexture = 0;

// the function

void glTexGen( const in int textureUnit,

const in int genMode,

const vec4 ecPosition,

out vec2 _glTexCoord)

{

if (genMode == 0)

{

_glTexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);

return;

}

if (genMode == 1) // 1 == GL_EYE_LINEAR

{

_glTexCoord.s = dot(gl_Vertex, gl_ObjectPlaneS[textureUnit]);

_glTexCoord.t = dot(gl_Vertex, gl_ObjectPlaneT[textureUnit]);

return;

}

if (genMode == 2) // 2 == GL_OBJECT_LINEAR

{

_glTexCoord.s = dot(ecPosition, gl_EyePlaneS[textureUnit]);

_glTexCoord.t = dot(ecPosition, gl_EyePlaneT[textureUnit]);

return;

}

}

void main(void)

{

gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

```
v = gl_ModelViewMatrix * gl_Vertex;
N = normalize(gl_NormalMatrix * gl_Normal);
```

#if 0

if (bIsTexture != 0)

{

if (TexGenMode == 0) // ne pas toucher

{

glTexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);

}

if (TexGenMode == 1) // 1 == GL_EYE_LINEAR

{

glTexCoord.s = dot(gl_Vertex, gl_ObjectPlaneS[0]);

glTexCoord.t = dot(gl_Vertex, gl_ObjectPlaneT[0]);

}

if (TexGenMode == 2) // 2 == GL_OBJECT_LINEAR

{

glTexCoord.s = dot(v, gl_EyePlaneS[0]);

glTexCoord.t = dot(v, gl_EyePlaneT[0]);

}

}

#else

if (bIsTexture != 0)

glTexGen(0, TexGenMode, v, glTexCoord);

#endif

```
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
```

}

```
Second Problem :
```

Vertex shader :

#version 110

varying vec3 N;

varying float vx;

void main(void)

{

gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

vx = 1.0;

N = normalize(gl_NormalMatrix * gl_Normal);

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

}

Fragment shader :

#version 110

varying vec3 N;

varying float vx;

void main (void)

{

vec3 L = normalize(gl_LightSource[0].position.xyz);

float vvx = vx; // If I comment this useless line the card draws again dashed lines

vec3 R = normalize(-reflect(L,N));

gl_FragColor = vec4(1,0,0,1);

return;

}