Multimedia
  Home arrow Multimedia arrow Basic Lighting in OpenGL and SDL Game Programming
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MULTIMEDIA

Basic Lighting in OpenGL and SDL Game Programming
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2008-12-09


    Table of Contents:
  • Basic Lighting in OpenGL and SDL Game Programming
  • Implementing Lighting, Step by Step
  • Lighting Model
  • Lighting in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Basic Lighting in OpenGL and SDL Game Programming
    ( Page 1 of 4 )

    Lighting is one of the components of a game that can provide an immersive reality to the player -- or be so distracting that playing becomes difficult. To ease working with lighting, OpenGL provides simplified API. The focus of this discussion will be on the basics of using lighting API provided by OpenGL. This article is the latest part in a multi-part series on game programming with OpenGL and SDL.

    The first section will be about the whys and wherefores of lighting. The second and third sections will focus on using the basic lighting API in a game. The last section will delve into an application that will make use of the concepts and API introduced in the first two sections. That is the outline for this discussion.

    Lighting in OpenGL: The Whys and Wherefores

    Similar to all other aspects of a game, lighting has a close relationship with the mechanics of illumination in real world. Hence, the first step in understanding how lighting works in OpenGL, and in any given game, is to know how lighting works in real life. One has to know the types of lighting or illumination one encounters in day-to-day life.

    The lighting encountered in the real world can be broadly categorized into ambient light, diffuse light, and specular light. The categorization is based upon the direction of the source of light. Here are the details:

    Ambient Light

    When the direction of light cannot be determined, giving an illusion that the light is coming from all directions, such a light or illumination is known as ambient light or ambient illumination. The reason for the illusion is the scattering of the light by the environment. Examples of ambient light are sunlight, the overhead lighting of a room, and so forth.

    The backlighting of a room also has a large component of ambient light. The reason for this is that the light is bounced off many surfaces before it reaches one’s eyes, thus seemingly coming from all directions. One of the main aspects of ambient light is that when it comes in contact with any surface, it is scattered in all directions equally.

    Diffuse Light

    When the light comes from a particular direction, it provides diffuse illumination. Since it comes from one direction, if it hits a surface squarely, it is brighter; if it just touches the surface, the illumination will be less. However, once the light hits the surface, it is scattered equally in all directions. Due to this, a diffuse light appears bright from whichever angle it is seen.

    Specular Light

    When a light comes from a particular direction, strikes a surface and bounces off in a preferred direction, such a light or illumination is known as specular light or specular illumination. In other words, light reflecting off the surface of smooth material is specular. The shininess of an object can be related to the specularity. One thing to keep in mind about specular light is that its angle of incidence is the same as that of its angle of reflection.

    Now that the types of lighting have been discussed, let us move onto the steps required to implement basic lighting in OpenGL.



     
     
    >>> More Multimedia Articles          >>> More By A.P.Rajshekhar
     

       

    MULTIMEDIA ARTICLES

    - Basic Lighting in OpenGL and SDL Game Progra...
    - Working with Colors in OpenGL for Game Progr...
    - Animation in OpenGL for Game Programming usi...
    - Game Programming with SDL: Getting Started w...
    - Using OpenGL with SDL for Game Programming
    - Learning Sound for Game Programming using SDL
    - Game Programming using SDL: Raw Graphics and...
    - Game Programming using SDL: Getting Started
    - Network Radio With Icecast
    - Learning To SMILe





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT