libresman

diff examples/imgthumbs/src/thumbs.c @ 18:711698580eb0

fixed visual studio build directories fixed debug id problem with the thread pool
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 12 Feb 2014 06:53:30 +0200
parents 43a9fe4a80ee
children c6073bf9fd38
line diff
     1.1 --- a/examples/imgthumbs/src/thumbs.c	Tue Feb 11 18:48:24 2014 +0200
     1.2 +++ b/examples/imgthumbs/src/thumbs.c	Wed Feb 12 06:53:30 2014 +0200
     1.3 @@ -9,7 +9,7 @@
     1.4  #include "thumbs.h"
     1.5  #include "resman.h"
     1.6  
     1.7 -#define DBG_SYNC
     1.8 +#undef DBG_SYNC
     1.9  
    1.10  #ifndef GL_COMPRESSED_RGB
    1.11  #define GL_COMPRESSED_RGB	0x84ed
    1.12 @@ -45,8 +45,7 @@
    1.13  
    1.14  	while((dent = readdir(dir))) {
    1.15  #ifdef DBG_SYNC
    1.16 -		int xsz, ysz;
    1.17 -		unsigned char *pixels;
    1.18 +		struct img_pixmap img;
    1.19  #endif
    1.20  		struct thumbnail *node;
    1.21  
    1.22 @@ -71,7 +70,9 @@
    1.23  #ifndef DBG_SYNC
    1.24  		resman_lookup(texman, node->fname, node);
    1.25  #else
    1.26 -		if(!(pixels = img_load_pixels(node->fname, &xsz, &ysz, IMG_FMT_RGBA32))) {
    1.27 +		img_init(&img);
    1.28 +		if(img_load(&img, node->fname) == -1) {
    1.29 +			img_destroy(&img);
    1.30  			free(node->fname);
    1.31  			free(node);
    1.32  			continue;
    1.33 @@ -79,14 +80,14 @@
    1.34  
    1.35  		printf("loaded image: %s\n", node->fname);
    1.36  
    1.37 +		node->aspect = (float)img.width / (float)img.height;
    1.38 +
    1.39  		glGenTextures(1, &node->tex);
    1.40  		glBindTexture(GL_TEXTURE_2D, node->tex);
    1.41  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.42  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.43 -		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    1.44 -		img_free_pixels(pixels);
    1.45 -
    1.46 -		node->aspect = (float)xsz / (float)ysz;
    1.47 +		glTexImage2D(GL_TEXTURE_2D, 0, img_glintfmt(&img), img.width, img.height, 0, img_glfmt(&img), img_gltype(&img), img.pixels);
    1.48 +		img_destroy(&img);
    1.49  #endif
    1.50  
    1.51  		node->next = list->next;