View Full Version : Drawing Line in color and Mapping Texture in the same scene

01-09-2011, 10:44 PM

I encounter some difficulties on drawing in color and mapping texture. If I only draw line in different color or map texture to the rectangle, it is ok. However, when I combine these two into one scene; that's drawing in color and mapping texture in the same scene, it fails.

I think the problem is in shader script. There is an attribute called "gl_FragColor" and I can set it to gl_FragColor = vec4(vColor.rgb * lightWeighting, vColor.a); to draw in color and set it to gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); to map texture.

However, when I draw in color and map texture in the same scene, I fails to set this gl_FragColor.

Can anyone help me to solve the problem? How to set the gl_FragColor correctly?

01-10-2011, 12:03 PM
You know you need two shaders - right? One for your lines and one for the polygons.

In some of my applications, I have nearly as many shaders as I do textures! My present WebGL game uses 24 frag shaders and six vert shaders.

01-10-2011, 06:25 PM
Yes, I duplicated the original sharder and shader-fs, shader-vs. Also, I have initialized two sharders. However, firefox show me the following message:
UniformMatrix4fv: location: this uniform location doesn't correspond to the current program
enable: invalid enum value 0xde1
Uniformli: location: null object passed as argument
UniformMatrix4fv: location: null object passed as argument

I still don't know how to solve it. Do you have any ideas to solve it?