Panda3D

store_pixel.h

00001 // Filename: store_pixel.h
00002 // Created by:  drose (12May08)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 /* Definition of a function to store a pixel in the framebuffer, using
00016    user-specified color blending. */
00017 
00018 /* This file generates lots of "template" variations, using #define
00019    and #include, similar to the way ztriangle.h works. */
00020 
00021 static void 
00022 FNAME(store_pixel) (ZBuffer *zb, PIXEL &result, int r, int g, int b, int a) {
00023   unsigned int fr = PIXEL_R(result);
00024   unsigned int fg = PIXEL_G(result);
00025   unsigned int fb = PIXEL_B(result);
00026   unsigned int fa = PIXEL_A(result);
00027 
00028   r = STORE_PIXEL_0(fr, ((unsigned int)r * OP_A(fr, r) >> 16) + ((unsigned int)fr * OP_B(fr, r) >> 16));
00029   g = STORE_PIXEL_1(fg, ((unsigned int)g * OP_A(fg, g) >> 16) + ((unsigned int)fg * OP_B(fg, g) >> 16));
00030   b = STORE_PIXEL_2(fg, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16));
00031   a = STORE_PIXEL_3(fg, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16));
00032   result = RGBA_TO_PIXEL(r, g, b, a);
00033 }
00034 
00035 
00036 #undef FNAME  
00037 #undef OP_A
00038 #undef OP_B
00039 #undef STORE_PIXEL_0
00040 #undef STORE_PIXEL_1
00041 #undef STORE_PIXEL_2
00042 #undef STORE_PIXEL_3
 All Classes Functions Variables Enumerations