HW2 FAQ

GLSL Function Restrictions

The restrictions on OpenGL and GLM functions do not apply to the use of GLSL in GLSL shaders. There are currently no restrictions on using glsl functions in the fragment shader.

Initial Skeleton Code

Until you actually parse the input via readfile.cpp the program doesn't really know what to do. See the bottom of page 4 of the assignment, "(If you can't yet get the teapot to display with the HW 2 framework, you may want to use the HW 1 framework instead for now so you can actually see it)."

Perpsective fovy

The perspective fovy should be specified in degrees.

Passing Lights to Shader

There are two kinds of data being passed to shader program: uniforms and attributes. Attributes are things attached per vertex, whereas uniforms are more like a constant, so things like lights, modelview and projection transforms, or some switches you defined are uniforms.

When you declare a uniform in shader program, to access them from the CPU program you need first get a handle = glGetUniformLocation, and then when you want to set values(mostly during display, especially you have multiple objects whose model transforms are different), you use that handle to specify which variable in the shader program to work with using glUniform()

See this for documentation.

glUniform with arrays

Take a look at this.

On Row and Column Major

Kevin Zhang posted a great guide on row and column major matrices in OpenGL here.

Note that the same caveats on row and column major in openGL and GLM still apply however if you look in the code, you'll see that there are functions like "rightmultiply" and comments that are provided to help you. Think carefully about the way the matrices are multiplied but if you're not sure, just try it out. you can always switch from row to column major without too much work.

Near and Far plane values

The near and far plane values have been set for you to use in main.cpp as zNear=0.1 and zFar=99.0

Initializing shader values

Please initialize shader values, such as using:

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

If you are experiencing issues with shaders on either your local machine or on the feedback server

How to Debug

Debugging HW 2 can be a bit tricky. If you're having difficulties and don't know how to start debugging, our best advice to you is to proceed systematically . Here are some suggestions to get you started