Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Attributes
renderTexture Class Reference

renderTexture provides a software-render context (setpixel/printf) More...

#include <RenderTexture.h>

List of all members.

Public Member Functions

 renderTexture (int width, int height)
 ~renderTexture ()
void setPixel (int x, int y, const btVector4 &rgba)
btVector4 getPixel (int x, int y)
const unsigned char * getBuffer () const
int getWidth () const
int getHeight () const
void grapicalPrintf (char *str, BMF_FontData *fontData, int startx=0, int starty=0)

Private Attributes

int m_height
int m_width
unsigned char * m_buffer

Detailed Description

renderTexture provides a software-render context (setpixel/printf)

Definition at line 25 of file RenderTexture.h.


Constructor & Destructor Documentation

renderTexture::renderTexture ( int  width,
int  height 
)

Definition at line 20 of file RenderTexture.cpp.

:m_height(height),m_width(width)
{
       m_buffer = new unsigned char[m_width*m_height*4];
       
       //clear screen
       memset(m_buffer,0,m_width*m_height*4);

       //clear screen version 2
       for (int x=0;x<m_width;x++)
       {
              for (int y=0;y<m_height;y++)
              {
                     setPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
              }

       }

}

Here is the call graph for this function:

Definition at line 67 of file RenderTexture.cpp.

{
       delete [] m_buffer;
}

Member Function Documentation

const unsigned char* renderTexture::getBuffer ( ) const [inline]

Definition at line 55 of file RenderTexture.h.

{ return m_buffer;}
int renderTexture::getHeight ( ) const [inline]

Definition at line 57 of file RenderTexture.h.

{ return m_height;}
btVector4 renderTexture::getPixel ( int  x,
int  y 
) [inline]

Definition at line 46 of file RenderTexture.h.

       {
              unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
              return btVector4(pixel[0]*1.f/255.f,
                     pixel[1]*1.f/255.f,
                     pixel[2]*1.f/255.f,
                     pixel[3]*1.f/255.f);
       }
int renderTexture::getWidth ( ) const [inline]

Definition at line 56 of file RenderTexture.h.

{ return m_width;}
void renderTexture::grapicalPrintf ( char *  str,
BMF_FontData fontData,
int  startx = 0,
int  starty = 0 
)

Definition at line 40 of file RenderTexture.cpp.

{
       unsigned char c;
       int rasterposx = startx;
       int rasterposy = starty;
       while ((c = (unsigned char) *str++)) {
              BMF_CharData & cd = fontData->chars[c];
              
              if (cd.data_offset!=-1) {
                     unsigned char* bitmap = &fontData->bitmap_data[cd.data_offset];
                     for (int y=0;y<cd.height;y++)
                     {
                            int bit = 128;
                            for (int x=0;x<cd.width;x++)
                            {
                                   char packedColor = bitmap[y];
                                   float colorf = packedColor & bit ? 0.f : 1.f;
                                   btVector4 rgba(colorf,colorf,colorf,1.f);
                                   setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
                                   bit >>=1;
                            }
                     }
              }
              rasterposx+= cd.advance;
       }
}

Here is the call graph for this function:

void renderTexture::setPixel ( int  x,
int  y,
const btVector4 rgba 
) [inline]

Definition at line 36 of file RenderTexture.h.

       {
              unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];

              pixel[0] = (unsigned char)(255*rgba.getX());
              pixel[1] = (unsigned char)(255*rgba.getY());
              pixel[2] = (unsigned char)(255*rgba.getZ());
              pixel[3] = (unsigned char)(255*rgba.getW());
       }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

unsigned char* renderTexture::m_buffer [private]

Definition at line 29 of file RenderTexture.h.

int renderTexture::m_height [private]

Definition at line 27 of file RenderTexture.h.

int renderTexture::m_width [private]

Definition at line 28 of file RenderTexture.h.


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