What are shaders in OpenGL and what do we need them for? [closed]

The OpenGL wiki gives a good definition: A Shader is a user-defined program designed to run on some stage of a graphics processor. History lesson In the past, graphics cards were non-programmable pieces of silicon which performed a set of fixed algorithms: inputs: 3D coordinates of triangles, their colors, light sources output: a 2D image … Read more

Shader optimization: Is a ternary operator equivalent to branching?

Actually this depends on the shader language one uses. In HLSL and Cg a ternary operator will never lead to branching. Instead both possible results are always evaluated and the not used one is being discarded. To quote the HLSL documentation: Unlike short-circuit evaluation of &&, ||, and ?: in C, HLSL expressions never short-circuit … Read more

How do I get the current color of a fragment?

The fragment shader receives gl_Color and gl_SecondaryColor as vertex attributes. It also gets four varying variables: gl_FrontColor, gl_FrontSecondaryColor, gl_BackColor, and gl_BackSecondaryColor that it can write values to. If you want to pass the original colors straight through, you’d do something like: gl_FrontColor = gl_Color; gl_FrontSecondaryColor = gl_SecondaryColor; gl_BackColor = gl_Color; gl_BackSecondaryColor = gl_SecondaryColor; Fixed functionality … Read more

Learning modern OpenGL

So… currently we have OpenGL 4.2 out, which as I read somewhere requires dx11 hardware (what does it mean?) and set of ‘side’ libraries, to for example create window. DX11 hardware is… hardware that has “supports DirectX 11” written on the side of the box. I’m not sure what it is you’re asking here; are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)