gTextureCycle Class Reference

Inheritance diagram for gTextureCycle:

Inheritance graph
[legend]
Collaboration diagram for gTextureCycle:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 gTextureCycle (rSurface const &surface, const gRealColor &color, bool repx=0, bool repy=0, bool wheel=false)
virtual void ProcessImage (SDL_Surface *im)
 process the surface before uploading it to GL
virtual void OnSelect (bool enforce)
 Selects the texture for rendering.

Private Attributes

gRealColor color_
bool wheel


Detailed Description

Definition at line 222 of file gCycle.cpp.


Constructor & Destructor Documentation

gTextureCycle::gTextureCycle ( rSurface const &  surface,
const gRealColor color,
bool  repx = 0,
bool  repy = 0,
bool  wheel = false 
)

Definition at line 234 of file gCycle.cpp.

References rITexture::Select().

00235         :rSurfaceTexture(rTextureGroups::TEX_OBJ,surface,repx,repy),
00236         color_(color),wheel(w)
00237 {
00238     Select();
00239 }

Here is the call graph for this function:


Member Function Documentation

void gTextureCycle::ProcessImage ( SDL_Surface *  surface  )  [virtual]

process the surface before uploading it to GL

Parameters:
surface the surface to process

Reimplemented from rISurfaceTexture.

Definition at line 241 of file gCycle.cpp.

References gRealColor::b, color_, gRealColor::g, G, gRealColor::r, and tVERIFY.

00242 {
00243 #ifndef DEDICATED
00244     // blend transparent texture parts with cycle color
00245     tVERIFY(im->format->BytesPerPixel == 4);
00246     GLubyte R=int(color_.r*255);
00247     GLubyte G=int(color_.g*255);
00248     GLubyte B=int(color_.b*255);
00249 
00250     GLubyte *pixels =reinterpret_cast<GLubyte *>(im->pixels);
00251 
00252     for(int i=im->w*im->h-1;i>=0;i--){
00253         GLubyte alpha=pixels[4*i+3];
00254         pixels[4*i  ] = (alpha * pixels[4*i  ] + (255-alpha)*R) >> 8;
00255         pixels[4*i+1] = (alpha * pixels[4*i+1] + (255-alpha)*G) >> 8;
00256         pixels[4*i+2] = (alpha * pixels[4*i+2] + (255-alpha)*B) >> 8;
00257         pixels[4*i+3] = 255;
00258     }
00259 #endif
00260 }

void gTextureCycle::OnSelect ( bool  enforce  )  [virtual]

Selects the texture for rendering.

Parameters:
enforce enforce when set to true, the texture should be loaded even if the configuration says it should not

Reimplemented from rISurfaceTexture.

Definition at line 262 of file gCycle.cpp.

References gRealColor::b, color_, gRealColor::g, G, rISurfaceTexture::OnSelect(), gRealColor::r, REAL, rTextureGroups::TEX_OBJ, rTextureGroups::TextureMode, and wheel.

00262                                         {
00263 #ifndef DEDICATED
00264     rISurfaceTexture::OnSelect(enforce);
00265 
00266     if(rTextureGroups::TextureMode[rTextureGroups::TEX_OBJ]<0){
00267         REAL R=color_.r,G=color_.g,B=color_.b;
00268         if(wheel){
00269             R*=.7;
00270             G*=.7;
00271             B*=.7;
00272         }
00273         glColor3f(R,G,B);
00274         GLfloat color[4]={R,G,B,1};
00275 
00276         glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,color);
00277         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color);
00278     }
00279 #endif
00280 }

Here is the call graph for this function:


Member Data Documentation

gRealColor gTextureCycle::color_ [private]

Definition at line 224 of file gCycle.cpp.

Referenced by OnSelect(), and ProcessImage().

bool gTextureCycle::wheel [private]

Definition at line 225 of file gCycle.cpp.

Referenced by OnSelect().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:45:52 2008 for Armagetron Advanced by  doxygen 1.5.4