Multimedia
  Home arrow Multimedia arrow 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 / 20
    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
    ( Page 1 of 4 )

    Colors magically bring a scene to life. No matter how interesting the plot is, how engrossing the special effects are, if the color combinations are not accurate or the colors are tepid, the liveliness of the game suffers. In short, it is the combination of and correct usage of colors that decide what the scene and eventually the whole game will be like.

    The next two discussions (starting with the current article) will be dedicated to the details and the usage of colors in OpenGL. The first section of this discussion will focus on modes available for color. The second section will explain how to use these modes from within OpenGL. The third section will focus on testing the concepts that were introduced in first two sections. So here we go.

    About Colors

    Any shade of any color can be decomposed into the three primary colors: red, blue and green. Every color rendering device (including computer monitors) works on this basis. If we consider a monitor with a color screen, the hardware causes each pixel on the screen to emit varied amounts of red, blue and green light. The emission of these can be controlled either by specifically controlling the primary color packs or by working with an index specifying the entry in a table that defines a particular set of red, green and blue values. So on the basis of specifying the colors, there are two modes of colors, which are:

    1. RGB Mode

    2. Indexed Mode


    Both of these modes are based on the concept of bit-planes in frame-buffer. Though both these concepts will be discussed in the second and third part of this series, I will go into an overview of bit-planes to refresh your memory.

    In either of the above, the data of colors are saved at each pixel. The amount of data saved at each pixel is decided by the bit-plane. A bit-plane contains one bit of data for each pixel. If there are 8 color bitplanes, there are eight color bits per pixel, and hence 28 =256 different values or colors that can be stored at that pixel.

    One generalization about bitplanes is that they are divided evenly in terms of storage of red, blue and green components of color. For example, if the bitplane is 24 bit, then each component would get 8 bits. But this generalization is not always true. With this in mind, let's have a look at the modes.



     
     
    >>> 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 1 hosted by Hostway
    Stay green...Green IT