Home arrow Multimedia arrow Working with Colors in OpenGL for Game Programming with SDL

Working with Colors in OpenGL for Game Programming with SDL

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.

TABLE OF CONTENTS:
  1. Working with Colors in OpenGL for Game Programming with SDL
  2. RGB and Indexed Mode
  3. Manipulating Color
  4. Testing the Colors
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 21
December 05, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: