dungeon_crawler
changeset 75:b05ab29cd17d
color grading done
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 22 Oct 2012 03:55:00 +0300 |
parents | 5981917093ff |
children | f379c00eb07f |
files | prototype/src/colgrade.cc prototype/src/main.cc |
diffstat | 2 files changed, 37 insertions(+), 2 deletions(-) [+] |
line diff
1.1 --- a/prototype/src/colgrade.cc Sun Oct 21 15:56:47 2012 +0300 1.2 +++ b/prototype/src/colgrade.cc Mon Oct 22 03:55:00 2012 +0300 1.3 @@ -117,7 +117,28 @@ 1.4 1.5 bool GradePalette::load_shot(const char *fname) 1.6 { 1.7 - return false; // TODO 1.8 + int xsz, ysz; 1.9 + unsigned char *img = (unsigned char*)img_load_pixels(fname, &xsz, &ysz, IMG_FMT_RGB24); 1.10 + if(!img) { 1.11 + fprintf(stderr, "failed to open image: %s\n", fname); 1.12 + return false; 1.13 + } 1.14 + 1.15 + int nslices = size; 1.16 + int slice_sz = size * size * 3; 1.17 + unsigned char *pal = img + xsz * (ysz - nslices) * 3; 1.18 + 1.19 + for(int i=0; i<nslices; i++) { 1.20 + memcpy(palette + i * slice_sz, pal, slice_sz); 1.21 + pal += xsz * 3; 1.22 + } 1.23 + img_free_pixels(img); 1.24 + 1.25 + glBindTexture(GL_TEXTURE_3D, tex); 1.26 + glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, size, size, size, 0, GL_RGB, 1.27 + GL_UNSIGNED_BYTE, palette); 1.28 + 1.29 + return true; 1.30 } 1.31 1.32 unsigned int GradePalette::get_texture() const
2.1 --- a/prototype/src/main.cc Sun Oct 21 15:56:47 2012 +0300 2.2 +++ b/prototype/src/main.cc Mon Oct 22 03:55:00 2012 +0300 2.3 @@ -405,8 +405,22 @@ 2.4 } 2.5 break; 2.6 2.7 + case 'G': 2.8 + save_grade_shot = true; 2.9 + break; 2.10 + 2.11 case 'g': 2.12 - save_grade_shot = true; 2.13 + { 2.14 + static bool do_grade; 2.15 + do_grade = !do_grade; 2.16 + 2.17 + GradePalette *gpal = rend->get_grade_palette(); 2.18 + if(do_grade) { 2.19 + gpal->load_shot("gradeshot-proc.ppm"); 2.20 + } else { 2.21 + gpal->create(); 2.22 + } 2.23 + } 2.24 break; 2.25 2.26 default: