**1. How do “Variables and Variable types” look in OpenGL?**

We have scalars *(eg: floats, int)*, floating point vectors* (eg: vec2-vec4)*, integer vectors, *(eg: ivec2-ivec4)*, boolean vectors *(eg: bvec2-bevec4)* and matirces *(mat2-mat4)*

**2. How do Vectors and matrix construction and selection work?**

*eg1: *

vec3 myVec3 = vec3(0.0,1.0,2.0);

vec3 temp = myVec3.zyx; // temp = {2.0, 1.0, 0.0};

eg2:

float m2_2 = myMat4[2].z;

**3. How do youdefine Constants?**

const mat4 indentity = mat4(1.0);

**4. How do you define Structures?**

struct fogDtruct {

vec4 color;

float start;

float end;

} fogVar;

fogVar = fogStruct(vec4(0.0, 1.0, 0.0, 0.0), 0.5, 2.0);

**5. How do you define Arrays?**

float floatArray[5];

vec vecArray[2];

**6. Tell something about the Operators in OpenGL ES?**

it is as normal as other languages. But, multiplication can perform matrix multiplications and vector multiplications.

**7. Tell something about the Control flow?**

Nothing special about them. Similar as other languages .

**8. Tell something about the Functions?**

like verilog language, this also has in, out and inout. in is default.

eg: vec4 myFunc (inout float myFloat, out vec4 myVec4, mat4 myMat4); //declaration

//definition you know.

And, OpenG provides some great built in functions like dot, pow out of the box.

**9. Tell something about Attributes and Uniforms?**

Uniforms normally store constant transformation matrices, light parameters and colors. But, they are called variable because they are not know at compile time.

eg uniform mat4 viewProjMatrix;

uniform vec3 lightPosition;

Attributes are only available in the vertex shader and are used to specify the per vertex input to the vertex shader.

attribute vec4 a_position;

**10. Tell something about the Varyings?**

varyings are the output of vertex shaders and input of fragment shaders. SO, you will find a matching varying in fragment shader.

**11. Tell something about the Preprocessor and directives?**

#equivalent to as other languages

**12. Uniforms and Varying packing.**

This is about how the OpenGL utilizes the hardware store by packing them together and saving efficiently. Not to be worried about programmers, I guess.

**13. What can you tell about precision qualifiers?**

Precision qualifiers enable the shader author to specify the precision with which computations for a shader variable are performed.

eg: varying lowp vec4 color;

**14. What is invariance?**

Due to optimisation by compiler (eg: using different precision qualifiers depending on the source), the same code on the same inputs might result in slightly different results. This might affect where the same object is being drawn on top of itself using alpha blending. ( called muti pass shader effects ). If we apply invariant keyword to varyings, this can be avoided.

eg: invariant gl_Position;

invariant varying texCoord;

#pragma STDGL invariant (all)