Back to index

supertuxkart  0.5+dfsg1
RenderTexture.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef RENDER_TEXTURE_H
00017 #define RENDER_TEXTURE_H
00018 
00019 #include "LinearMath/btVector3.h"
00020 #include "BMF_FontData.h"
00021 
00025 class renderTexture
00026 {
00027        int m_height;
00028        int m_width;
00029        unsigned char*       m_buffer;
00030 
00031 public:
00032 
00033        renderTexture(int width,int height);
00034        ~renderTexture();
00035 
00036        inline void   setPixel(int x,int y,const btVector4& rgba)
00037        {
00038               unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
00039 
00040               pixel[0] = (unsigned char)(255*rgba.getX());
00041               pixel[1] = (unsigned char)(255*rgba.getY());
00042               pixel[2] = (unsigned char)(255*rgba.getZ());
00043               pixel[3] = (unsigned char)(255*rgba.getW());
00044        }
00045 
00046        inline btVector4 getPixel(int x,int y)
00047        {
00048               unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
00049               return btVector4(pixel[0]*1.f/255.f,
00050                      pixel[1]*1.f/255.f,
00051                      pixel[2]*1.f/255.f,
00052                      pixel[3]*1.f/255.f);
00053        }
00054 
00055        const unsigned char* getBuffer() const { return m_buffer;}
00056        int    getWidth() const { return m_width;}
00057        int    getHeight() const { return m_height;}
00058        void grapicalPrintf(char* str,     BMF_FontData* fontData, int startx = 0,int starty=0);
00059 
00060 };
00061 
00062 #endif //RENDER_TEXTURE_H
00063