# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CRGBA Class Reference

Class pixel RGBA. More...

#include <rgba.h>

List of all members.

Public Methods

 CRGBA ()
 Default constructor. do nothing. More...

 CRGBA (uint8 r, uint8 g, uint8 b, uint8 a=255)
 Constructor. More...

uint getPacked () const
 Return a packed pixel. More...

bool operator< (CRGBA c) const
 Comparison operator. More...

bool operator!= (CRGBA c) const
 Comparison operator. More...

bool operator== (CRGBA c) const
 Equality operator. More...

void serial (class NLMISC::IStream &f)
 Serialisation. More...

void blendFromui (CRGBA c0, CRGBA c1, uint coef)
 Blend two colors. More...

void modulateFromui (CRGBA c0, uint a)
 Modulate colors with a constant. More...

void modulateFromColor (CRGBA c0, CRGBA c1)
 Modulate colors with another color. More...

void set (uint8 r, uint8 g, uint8 b, uint8 a=255)
 Set colors. More...

uint16 get565 () const
 Get a 16 bits 565 pixel. More...

void set565 (uint16 col)
 Set the RGB fields with a 16 bits 565 pixel. More...

void avg2 (CRGBA a, CRGBA b)
 Compute in this the average of 2 RGBA. More...

void avg4 (CRGBA a, CRGBA b, CRGBA c, CRGBA d)
 Compute in this the average of 4 RGBA. More...

void add (CRGBA c0, CRGBA c1)
 Do the sum of 2 rgba, clamp, and store in this. More...

void sub (CRGBA c0, CRGBA c1)
 Compute c0 - c1, and store in this. More...

RGBOnly methods. Same f() as their homonym, but don't modify A component.
void blendFromuiRGBOnly (CRGBA c0, CRGBA c1, uint coef)
 see blendFromui(). More...

void modulateFromuiRGBOnly (CRGBA c0, uint a)
 see modulateFromui(). More...

void modulateFromColorRGBOnly (CRGBA c0, CRGBA c1)
 see modulateFromColor(). More...

void avg2RGBOnly (CRGBA a, CRGBA b)
 see avg2(). More...

void avg4RGBOnly (CRGBA a, CRGBA b, CRGBA c, CRGBA d)
 see avg4(). More...

void addRGBOnly (CRGBA c0, CRGBA c1)
 see add(). More...

void subRGBOnly (CRGBA c0, CRGBA c1)
 see sub(). More...

Color space conversions RGB only
bool convertToHLS (float &h, float &l, float &S) const
 Convert to HLS color space. More...

void buildFromHLS (float h, float l, float s)
 Build from HLS valued Each component ranges from 0 to 1.f. More...


Static Public Methods

Color group manipulation
void addColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1)
 Add a group of colors with saturation, using mmx instructions when present. More...

void modulateColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1)
 Modulate a group of colors with saturation, using mmx instructions when present. More...

void subtractColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1)
 Subtract a group of colors with saturation (src1 - src2), using mmx instructions when present. More...


Public Attributes

uint8 R
 Red componant. More...

uint8 G
 Green componant. More...

uint8 B
 Blue componant. More...

uint8 A
 Alpha componant. More...


Static Public Attributes

const CRGBA Black
 some colors. More...

const CRGBA Red
const CRGBA Green
const CRGBA Yellow
const CRGBA Blue
const CRGBA Magenta
const CRGBA Cyan
const CRGBA White


Detailed Description

Class pixel RGBA.

Author:
Cyril Corvazier , Nevrax France
Date:
2000

Definition at line 44 of file rgba.h.


Constructor & Destructor Documentation

NLMISC::CRGBA::CRGBA   [inline]
 

Default constructor. do nothing.

Definition at line 49 of file rgba.h.

Referenced by add, addColors, addRGBOnly, avg2, avg2RGBOnly, avg4, avg4RGBOnly, blendFromui, blendFromuiRGBOnly, modulateColors, modulateFromColor, modulateFromColorRGBOnly, modulateFromui, modulateFromuiRGBOnly, operator!=, operator<, operator==, sub, subRGBOnly, and subtractColors.

NLMISC::CRGBA::CRGBA uint8    r,
uint8    g,
uint8    b,
uint8    a = 255
[inline]
 

Constructor.

Parameters:
r  Red componant.
g  Green componant.
b  Blue componant.
a  Alpha componant.

Definition at line 58 of file rgba.h.

References A, B, G, R, and r.


Member Function Documentation

void NLMISC::CRGBA::add CRGBA    c0,
CRGBA    c1
[inline]
 

Do the sum of 2 rgba, clamp, and store in this.

Definition at line 190 of file rgba.h.

References A, B, CRGBA, G, min, R, and r.

Referenced by addColors, modulateColors, and subtractColors.

void NLMISC::CRGBA::addColors CRGBA *    dest,
const CRGBA *    src1,
const CRGBA *    src2,
uint    numColors,
uint    srcStride = sizeof(CRGBA),
uint    destStride = sizeof(CRGBA),
uint    dup = 1
[static]
 

Add a group of colors with saturation, using mmx instructions when present.

ams dest The destination color buffer, encoded as CRGBA's.
ams src1 The first source color buffer, encoded as CRGBA's.
ams src2 The second source color buffer, encoded as CRGBA's.
ams numColors The number of colors to compute
ams Stride between each source color.
ams Stride between each destination color.
ams Dup the number of time the result must be duplicated in the destination.

Definition at line 79 of file rgba.cpp.

References add, CRGBA, offset, and sub.

void NLMISC::CRGBA::addRGBOnly CRGBA    c0,
CRGBA    c1
[inline]
 

see add().

Definition at line 253 of file rgba.h.

References B, CRGBA, G, min, R, and r.

void NLMISC::CRGBA::avg2 CRGBA    a,
CRGBA    b
[inline]
 

Compute in this the average of 2 RGBA.

Definition at line 167 of file rgba.h.

References A, B, CRGBA, G, and R.

void NLMISC::CRGBA::avg2RGBOnly CRGBA    a,
CRGBA    b
[inline]
 

see avg2().

Definition at line 239 of file rgba.h.

References B, CRGBA, G, and R.

void NLMISC::CRGBA::avg4 CRGBA    a,
CRGBA    b,
CRGBA    c,
CRGBA    d
[inline]
 

Compute in this the average of 4 RGBA.

The average is "correct": +1 is added to the four color, to make a "round" like average.

Definition at line 179 of file rgba.h.

References A, B, CRGBA, G, and R.

void NLMISC::CRGBA::avg4RGBOnly CRGBA    a,
CRGBA    b,
CRGBA    c,
CRGBA    d
[inline]
 

see avg4().

Definition at line 246 of file rgba.h.

References B, CRGBA, G, and R.

void NLMISC::CRGBA::blendFromui CRGBA    c0,
CRGBA    c1,
uint    coef
[inline]
 

Blend two colors.

Parameters:
c0  Color 0.
c1  Color 1.
coef  Blend factor. 0~256. 0 return c0 and 256 return c1.

Definition at line 93 of file rgba.h.

References A, B, CRGBA, G, and R.

Referenced by NLMISC::CBitmap::decompressDXT1, NLMISC::CBitmap::decompressDXT3, NLMISC::CBitmap::decompressDXT5, and NL3D_expandLightmap.

void NLMISC::CRGBA::blendFromuiRGBOnly CRGBA    c0,
CRGBA    c1,
uint    coef
[inline]
 

see blendFromui().

Definition at line 216 of file rgba.h.

References B, CRGBA, G, and R.

void NLMISC::CRGBA::buildFromHLS float    h,
float    l,
float    s
 

Build from HLS valued Each component ranges from 0 to 1.f.

Definition at line 685 of file rgba.cpp.

References B, NLMISC::clamp, G, NLMISC::HLSValue, NLAISCRIPT::l, R, s, and v.

bool NLMISC::CRGBA::convertToHLS float &    h,
float &    l,
float &    S
const
 

Convert to HLS color space.

Lightness and satuation ranges from 0 to 1 There's no range for hue, (all hues colors range from 0 to 360, from 360 to 720 and so on)

Returns:
true if the color is achromatic

Definition at line 608 of file rgba.cpp.

References B, G, NLAISCRIPT::l, NLMISC::maxof, NLMISC::minof, R, r, and s.

uint16 NLMISC::CRGBA::get565   const [inline]
 

Get a 16 bits 565 pixel.

Definition at line 143 of file rgba.h.

References B, G, and R.

uint NLMISC::CRGBA::getPacked   const [inline]
 

Return a packed pixel.

Definition at line 64 of file rgba.h.

References A, B, G, and R.

Referenced by operator<.

void NLMISC::CRGBA::modulateColors CRGBA *    dest,
const CRGBA *    src1,
const CRGBA *    src2,
uint    numColors,
uint    srcStride = sizeof(CRGBA),
uint    destStride = sizeof(CRGBA),
uint    dup = 1
[static]
 

Modulate a group of colors with saturation, using mmx instructions when present.

ams dest The destination color buffer, encoded as CRGBA's.
ams src1 The first source color buffer, encoded as CRGBA's.
ams src2 The second source color buffer, encoded as CRGBA's.
ams numColors The number of colors to compute
ams Stride between each color. It is the same for sources and destination.

Definition at line 239 of file rgba.cpp.

References add, CRGBA, offset, and sub.

Referenced by NL3D::CPSConstraintMesh::computeColors.

void NLMISC::CRGBA::modulateFromColor CRGBA    c0,
CRGBA    c1
[inline]
 

Modulate colors with another color.

Parameters:
c0  Color 0.
c1  Color 1. c0*c1 returned into this.

Definition at line 122 of file rgba.h.

References A, B, CRGBA, G, and R.

Referenced by NL3D::CPSShockWave::draw, NL3D::CPSDot::draw, NL3D::CZoneLighter::lightWater, NL3D::CPSTailDot::setupGlobalColor, NL3D::CPSFanLight::setupMaterial, NL3D::CPSRibbon::setupTexturedGlobalColor, NL3D::CPSRibbon::setupUntexturedGlobalColor, and NL3D::CPSQuad::updateMatBeforeRendering.

void NLMISC::CRGBA::modulateFromColorRGBOnly CRGBA    c0,
CRGBA    c1
[inline]
 

see modulateFromColor().

Definition at line 232 of file rgba.h.

References B, CRGBA, G, and R.

void NLMISC::CRGBA::modulateFromui CRGBA    c0,
uint    a
[inline]
 

Modulate colors with a constant.

Parameters:
c0  Color 0.
a  E [0,256]. c0*a returned into this.

Definition at line 108 of file rgba.h.

References A, B, CRGBA, G, and R.

Referenced by NL3D::CVegetableLightEx::computeCurrentColors.

void NLMISC::CRGBA::modulateFromuiRGBOnly CRGBA    c0,
uint    a
[inline]
 

see modulateFromui().

Definition at line 225 of file rgba.h.

References B, CRGBA, G, and R.

Referenced by NL3D::CRenderTrav::changeLightSetup.

bool NLMISC::CRGBA::operator!= CRGBA    c const [inline]
 

Comparison operator.

Definition at line 73 of file rgba.h.

References CRGBA.

bool NLMISC::CRGBA::operator< CRGBA    c const [inline]
 

Comparison operator.

Definition at line 69 of file rgba.h.

References CRGBA, and getPacked.

bool NLMISC::CRGBA::operator== CRGBA    c const [inline]
 

Equality operator.

Definition at line 78 of file rgba.h.

References A, B, CRGBA, G, and R.

void NLMISC::CRGBA::serial class NLMISC::IStream   f
 

Serialisation.

Parameters:
f  Stream used for serialisation.

Definition at line 58 of file rgba.cpp.

References A, B, G, and R.

Referenced by NL3D::CPSValueBlendSampleFunc< NLMISC::CRGBA, n >::serial.

void NLMISC::CRGBA::set uint8    r,
uint8    g,
uint8    b,
uint8    a = 255
 

Set colors.

Parameters:
r  Red componant.
g  Green componant.
b  Blue componant.
a  Alpha componant.

Definition at line 66 of file rgba.cpp.

References A, B, G, R, and r.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial, NL3D::CVegetableManager::CVegetableManager, NLMISC::CBitmap::decompressDXT1, NL3D::CVisualCollisionEntity::getStaticLightSetup, NL3D::CIGSurfaceLight::getStaticLightSetup, NLMISC::CBitmap::makeDummy, and NL3D::CRenderTrav::resetLightSetup.

void NLMISC::CRGBA::set565 uint16    col [inline]
 

Set the RGB fields with a 16 bits 565 pixel.

Definition at line 151 of file rgba.h.

References B, G, and R.

Referenced by NL3D_expandLightmap.

void NLMISC::CRGBA::sub CRGBA    c0,
CRGBA    c1
[inline]
 

Compute c0 - c1, and store in this.

Definition at line 202 of file rgba.h.

References A, B, CRGBA, G, R, and r.

Referenced by addColors, modulateColors, and subtractColors.

void NLMISC::CRGBA::subRGBOnly CRGBA    c0,
CRGBA    c1
[inline]
 

see sub().

Definition at line 261 of file rgba.h.

References B, CRGBA, G, R, and r.

void NLMISC::CRGBA::subtractColors CRGBA *    dest,
const CRGBA *    src1,
const CRGBA *    src2,
uint    numColors,
uint    srcStride = sizeof(CRGBA),
uint    destStride = sizeof(CRGBA),
uint    dup = 1
[static]
 

Subtract a group of colors with saturation (src1 - src2), using mmx instructions when present.

ams dest The destination color buffer, encoded as CRGBA's.
ams src1 The first source color buffer, encoded as CRGBA's.
ams src2 The second source color buffer, encoded as CRGBA's.
ams numColors The number of colors to compute
ams Stride between each color. It is the same for sources and destination.

Definition at line 412 of file rgba.cpp.

References add, CRGBA, offset, and sub.


Member Data Documentation

uint8 NLMISC::CRGBA::A
 

Alpha componant.

Definition at line 329 of file rgba.h.

Referenced by add, avg2, avg4, blendFromui, NL3D::CRenderTrav::changeLightSetup, CRGBA, NLMISC::CBitmap::decompressDXT1, NL3D::CDriverGL::forceActivateTexEnvColor, getPacked, NL3D::CSurfaceLightGrid::getStaticLightSetup, NL3D::CCloud::light, modulateFromColor, modulateFromui, operator==, NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh, serial, set, NL3D::CDriverGL::setBlendConstantColor, NL3D::CTileFarBank::CTileFar::setPixels, sub, and NLMISC::CBitmap::uncompress.

uint8 NLMISC::CRGBA::B
 

Blue componant.

Definition at line 327 of file rgba.h.

Referenced by add, addRGBOnly, avg2, avg2RGBOnly, avg4, avg4RGBOnly, blendFromui, blendFromuiRGBOnly, buildFromHLS, NL3D::CPatchDLMPointLight::compile, convertToHLS, NLGEORGES::CFormElm::convertValue, CRGBA, NLMISC::CBitmap::decompressDXT1, NLMISC::CBitmap::decompressDXT3, NLMISC::CBitmap::decompressDXT5, NL3D::CDriverGL::forceActivateTexEnvColor, get565, getPacked, NL3D::CSurfaceLightGrid::getStaticLightSetup, modulateFromColor, modulateFromColorRGBOnly, modulateFromui, modulateFromuiRGBOnly, operator==, serial, set, set565, NL3D::CDriverGL::setBlendConstantColor, NLGEORGES::CFormElm::setValueByName, sub, subRGBOnly, and NLMISC::CBitmap::uncompress.

const CRGBA NLMISC::CRGBA::Black [static]
 

some colors.

Referenced by NL3D::CPSColorBlender::CPSColorBlender, NL3D::CPSColorBlenderExact::CPSColorBlenderExact, NL3D::CInstanceMaterialUser::getConstantColor, and NL3D::CRenderTrav::getStrongestLightColors.

const CRGBA NLMISC::CRGBA::Blue [static]
 

const CRGBA NLMISC::CRGBA::Cyan [static]
 

uint8 NLMISC::CRGBA::G
 

Green componant.

Definition at line 325 of file rgba.h.

Referenced by add, addRGBOnly, avg2, avg2RGBOnly, avg4, avg4RGBOnly, blendFromui, blendFromuiRGBOnly, buildFromHLS, NL3D::CPatchDLMPointLight::compile, convertToHLS, NLGEORGES::CFormElm::convertValue, CRGBA, NLMISC::CBitmap::decompressDXT1, NLMISC::CBitmap::decompressDXT3, NLMISC::CBitmap::decompressDXT5, NL3D::CDriverGL::forceActivateTexEnvColor, get565, getPacked, NL3D::CSurfaceLightGrid::getStaticLightSetup, modulateFromColor, modulateFromColorRGBOnly, modulateFromui, modulateFromuiRGBOnly, operator==, serial, set, set565, NL3D::CDriverGL::setBlendConstantColor, NLGEORGES::CFormElm::setValueByName, sub, subRGBOnly, and NLMISC::CBitmap::uncompress.

const CRGBA NLMISC::CRGBA::Green [static]
 

const CRGBA NLMISC::CRGBA::Magenta [static]
 

uint8 NLMISC::CRGBA::R
 

Red componant.

Definition at line 323 of file rgba.h.

Referenced by add, addRGBOnly, avg2, avg2RGBOnly, avg4, avg4RGBOnly, blendFromui, blendFromuiRGBOnly, buildFromHLS, NL3D::CPatchDLMPointLight::compile, convertToHLS, NLGEORGES::CFormElm::convertValue, CRGBA, NLMISC::CBitmap::decompressDXT1, NLMISC::CBitmap::decompressDXT3, NLMISC::CBitmap::decompressDXT5, NL3D::CDriverGL::forceActivateTexEnvColor, get565, getPacked, NL3D::CSurfaceLightGrid::getStaticLightSetup, modulateFromColor, modulateFromColorRGBOnly, modulateFromui, modulateFromuiRGBOnly, operator==, serial, set, set565, NL3D::CDriverGL::setBlendConstantColor, NLGEORGES::CFormElm::setValueByName, sub, subRGBOnly, and NLMISC::CBitmap::uncompress.

const CRGBA NLMISC::CRGBA::Red [static]
 

const CRGBA NLMISC::CRGBA::White [static]
 

Referenced by NL3D::CPSColorBlender::CPSColorBlender, NL3D::CPSColorBlenderExact::CPSColorBlenderExact, NL3D::CPSColorMemory::CPSColorMemory, NL3D::CPSFanLight::init, NL3D::CParticleSystem::setColorAttenuationScheme, NL3D::CDriverGL::setDisplay, NL3D::CPSFanLight::setupMaterial, and NL3D::CWaterRenderObs::setupMaterialNVertexShader.

const CRGBA NLMISC::CRGBA::Yellow [static]
 


The documentation for this class was generated from the following files: