2006-05-25 19:18:29 +00:00
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
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.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
2006-09-28 01:11:16 +00:00
|
|
|
#include "renderTexture.h"
|
2006-05-25 19:18:29 +00:00
|
|
|
#include <memory.h>
|
|
|
|
#include "BMF_FontData.h"
|
|
|
|
|
2006-09-28 01:11:16 +00:00
|
|
|
renderTexture::renderTexture(int width,int height)
|
2006-05-25 19:18:29 +00:00
|
|
|
: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++)
|
|
|
|
{
|
2006-09-28 01:11:16 +00:00
|
|
|
setPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
|
2006-05-25 19:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-09-28 01:11:16 +00:00
|
|
|
void renderTexture::grapicalPrintf(char* str, BMF_FontData* fontData, int startx,int starty)
|
2006-05-25 19:18:29 +00:00
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
int rasterposx = startx;
|
|
|
|
int rasterposy = starty;
|
2006-09-23 14:51:54 +00:00
|
|
|
while ((c = (unsigned char) *str++)) {
|
2006-05-25 19:18:29 +00:00
|
|
|
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 ? 1.f : 0.f;
|
2006-09-27 20:43:51 +00:00
|
|
|
btVector4 rgba(colorf,colorf,colorf,1.f);
|
2006-09-28 01:11:16 +00:00
|
|
|
setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
|
2006-05-25 19:18:29 +00:00
|
|
|
bit >>=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rasterposx+= cd.advance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 01:11:16 +00:00
|
|
|
renderTexture::~renderTexture()
|
2006-05-25 19:18:29 +00:00
|
|
|
{
|
|
|
|
delete [] m_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|