Course list http://www.c-jump.com/bcc/

Lab 7 -- Diffuse and specular light


  1. Part 1: Experimenting with lights
  2. Setting things up
  3. Part 1 project updates
  4. Things to do
  5. Part 2: Adding configuration window
  6. Visual Studio project updates
  7. Using the config window
  8. How to submit

Part 1: Experimenting with lights



Setting things up



Part 1 project updates


  1. The vertex shader now includes lightPosition input variable.

  2. The Light C++ class is added to the source code:

    
        Shader* myShader = new Shader( BCC_VERTEX_SHADER, BCC_FRAGMENT_SHADER );
        //...
        light = new Light( light_pos, light_ambient, light_diffuse, light_specular, myShader );
        myModel = new Model( myShader );
        //...
        myModel->set_material( material_ambient, material_diffuse, material_specular, shininess );
        myModel->set_light( light );
    
    

    Here, most of the parameters are arrays of 4 GLfloats.

  3. The shininess is in range 1 to 255.

  4. The render() function also calls

    
        light->set_shader_light_position();
    
    

    because the light position can move around.

  5. The Model::render() function combines all light components and uploads them to OpenGL.

  6. In the vertex shader the are three new out variables:

  7. In the fragment shader,

     


Things to do



Part 2: Adding configuration window



Visual Studio project updates


  1. The source file

    
        labs\c262_lab07_x2\fluid_project\CFluidWindow.cxx
    
    

    was added to the project.

  2. In Solution Explorer, after right-clicking the project and opening the project properties and switching configuration to 'All Configurations', the "Configuration Properties" -> "C/C++" -> "Preprocessor" -> Preprocessor definitions -> preprocessor symbol WIN32 was added.

  3. Changed "Configuration Properties" -> "C/C++" -> "General" -> SDL checks -> No.

  4. Added "Configuration Properties" -> "C/C++" -> "General" -> Additional Include Directories from blank to

    
        ..\..\external\include
    
    
  5. Added "Configuration Properties" -> "Linker" -> "General" -> Additional Library Directories from blank to

    
        ..\..\external\lib
    
    
  6. Applied changes and switched Configuration to 'Debug'

  7. Changed "Configuration Properties" -> "Linker" -> "Input" -> Additional Dependencies, Edit and added

    
    fltkd.lib
    fltkformsd.lib
    fltkgld.lib
    fltkimagesd.lib
    fltkjpegd.lib
    fltkpngd.lib
    fltkzlibd.lib
    
    
  8. Changed "Configuration Properties" -> "Linker" -> "Input" -> Ignore Specific Default Libraries

    
    libcd.lib
    
    
  9. Applied changes and switched Configuration to 'Release'

  10. Changed "Configuration Properties" -> "Linker" -> "Input" -> Additional Dependencies, Edit and added

    
    fltk.lib
    fltkforms.lib
    fltkgl.lib
    fltkimages.lib
    fltkjpeg.lib
    fltkpng.lib
    fltkzlib.lib
    
    
  11. Changed "Configuration Properties" -> "Linker" -> "Input" -> Ignore Specific Default Libraries

    
    libc.lib
    
    
  12. Also, verified that Debug configuration uses

  13. Saved all options and closed the project properties dialog window.

     


Using the config window



How to submit