But glgetuniformlocation always returns the-1 uniform.

Source: Internet
Author: User

This is because the uniform is not used.

It is used not only to say that you have used it, but also to say that it has an effect on the output.

That is to say, only the shader function uses its value. The used state of the uniform is false.

For example, halotex

// Fp
Uniform sampler2d halotex;
Uniform vec4 halorect;
Void Main ( Void )
{


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

Float X = gl_fragcoord.x;
Float Y = gl_fragcoord.y;

If (X> halorect. X & x Y> halorect. Y & Y {

Float Width = halorect. Z-halorect. X;
Float Height = halorect. W-halorect. Y;

Float Coordx = (X-halorect. X)/width;
Float Coordy = (Y-halorect. Y)/height;

Vec4 texcolor = texture2d (halotex, vec2 (coordx, coordy ));

Gl_fragcolor.rgba = vec4 ( 0 , 0 , 1 , 0.5 );
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.