fix typo in texels flip
add support to create a cube in TinyRenderer (quick test)
This commit is contained in:
committed by
Erwin Coumans
parent
a3767193ce
commit
aa9a276a71
@@ -141,7 +141,7 @@ bool TGAImage::load_rle_data(std::ifstream &in) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TGAImage::write_tga_file(const char *filename, bool rle) {
|
||||
bool TGAImage::write_tga_file(const char *filename, bool rle) const {
|
||||
unsigned char developer_area_ref[4] = {0, 0, 0, 0};
|
||||
unsigned char extension_area_ref[4] = {0, 0, 0, 0};
|
||||
unsigned char footer[18] = {'T','R','U','E','V','I','S','I','O','N','-','X','F','I','L','E','.','\0'};
|
||||
@@ -202,7 +202,7 @@ bool TGAImage::write_tga_file(const char *filename, bool rle) {
|
||||
}
|
||||
|
||||
// TODO: it is not necessary to break a raw chunk for two equal pixels (for the matter of the resulting size)
|
||||
bool TGAImage::unload_rle_data(std::ofstream &out) {
|
||||
bool TGAImage::unload_rle_data(std::ofstream &out) const {
|
||||
const unsigned char max_chunk_length = 128;
|
||||
unsigned long npixels = width*height;
|
||||
unsigned long curpix = 0;
|
||||
@@ -244,9 +244,9 @@ bool TGAImage::unload_rle_data(std::ofstream &out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TGAColor TGAImage::get(int x, int y) {
|
||||
TGAColor TGAImage::get(int x, int y) const {
|
||||
if (!data || x<0 || y<0 || x>=width || y>=height) {
|
||||
return TGAColor();
|
||||
return TGAColor(128.f,128.f,128.f,255.f);
|
||||
}
|
||||
return TGAColor(data+(x+y*width)*bytespp, bytespp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user