work-in-progress tinyrenderer -> shared memory API synthetic camera image

This commit is contained in:
erwin coumans
2016-05-17 23:57:19 -07:00
parent 876c9e57fe
commit 606f78da43
17 changed files with 319 additions and 122 deletions

View File

@@ -49,6 +49,28 @@ Model::Model():verts_(), faces_(), norms_(), uv_(), diffusemap_(), normalmap_(),
{
}
void Model::setDiffuseTextureFromData(unsigned char* textureImage,int textureWidth,int textureHeight)
{
diffusemap_ = TGAImage(textureWidth, textureHeight, TGAImage::RGB);
for (int i=0;i<textureWidth;i++)
{
for (int j=0;j<textureHeight;j++)
{
TGAColor color;
color.bgra[0] = textureImage[(i+j*textureWidth)*3+0];
color.bgra[1] = textureImage[(i+j*textureWidth)*3+1];
color.bgra[2] = textureImage[(i+j*textureWidth)*3+2];
color.bgra[3] = 255;
color.bytespp = 3;
diffusemap_.set(i,j,color);
}
}
diffusemap_.flip_vertically();
}
void Model::loadDiffuseTexture(const char* relativeFileName)
{
diffusemap_.read_tga_file(relativeFileName);