Multimedia
  Home arrow Multimedia arrow Page 2 - Working with Colors in OpenGL for Game Programming with SDL
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

Working with Colors in OpenGL for Game Programming with SDL
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 21
    2007-12-05


    Table of Contents:
  • Working with Colors in OpenGL for Game Programming with SDL
  • RGB and Indexed Mode
  • Manipulating Color
  • Testing the Colors

  • 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


    Working with Colors in OpenGL for Game Programming with SDL - RGB and Indexed Mode
    ( Page 2 of 4 )


    1. RGB Mode:

    RGB Mode is also known as the RGBA mode when the Alpha component is used. RGB stands for red, green, and blue. The A in RGBA is the Alpha component. It defines transparency for red (R), blue (B), and green (G) components. In this mode, the hardware sets aside a certain number of bit-planes for each red, blue, and green component. The R, G, B values are stored as integer values rather than floating point numbers. The values of these components can vary from 0 to 255. The range can be more. The range of the acceptable value for a given component is based on the number of bits available for that component. Typically, on most systems the number of available bits is 8. Hence, the number 255 is used for specifying a particular intensity of a color component.

    Now, the number of bits available directly corresponds to the bit-planes of a component. In this case, since 8 bits are there, there are 28=256 bit-planes in a system supporting 8 bits for each of the red, blue and green components. The integer values of a component can be converted into their floating point by dividing the integer value of a component with the number of bit-planes available for that component. For example, in an 8-bit system there are 256 bit-planes available for the red color component. The value in each plane is from 0-255. Thus 0 in the bit-plane would correspond to 0/255=0.0 in floating point value of R. The values range from 0.0 to 1.0 for all the components. Pictorially, the RGBA would be represented as follows:

     


    2. Indexed Mode:

    Indexed Mode, or color index mode, derives its name from the fact that it uses a lookup table to mix the colors. It is metaphorically similar to a painter who uses a numbered palette to create different colors. To take the metaphor further, as a painter's palette has spaces to mix the colors and these spaces act as an index for new colors, in the same way a color map or lookup table indexes where the components can be mixed. This map is stored in the bit-planes. Then those bit-plane values reference the color map, and the screen is painted with the corresponding red, green, and blue values from the color map. Pictorially a color map would look like:

     


     

    OpenGL manages both of these very easily without letting the developer know the low-level system calls and device-dependent API mappings. The steps involved in invoking the OpenGL commands that perform these functions are the focus of the next section.



     
     
    >>> 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 3 Hosted by Hostway
    Stay green...Green IT