libresman

diff examples/imgthumbs/src/thumbs.c @ 16:0a789208498d

fixed resman.def added debug mode in thumbs.c
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 11 Feb 2014 18:47:33 +0200
parents a42888d26839
children 43a9fe4a80ee
line diff
     1.1 --- a/examples/imgthumbs/src/thumbs.c	Sat Feb 08 07:41:39 2014 +0200
     1.2 +++ b/examples/imgthumbs/src/thumbs.c	Tue Feb 11 18:47:33 2014 +0200
     1.3 @@ -9,6 +9,8 @@
     1.4  #include "thumbs.h"
     1.5  #include "resman.h"
     1.6  
     1.7 +#define DBG_SYNC
     1.8 +
     1.9  #ifndef GL_COMPRESSED_RGB
    1.10  #define GL_COMPRESSED_RGB	0x84ed
    1.11  #endif
    1.12 @@ -27,12 +29,6 @@
    1.13  	/* allocate dummy head node */
    1.14  	struct thumbnail *list = calloc(1, sizeof *list);
    1.15  
    1.16 -	/*unsigned int intfmt = GL_COMPRESSED_RGB;
    1.17 -	if(!strstr((char*)glGetString(GL_EXTENSIONS), "GL_ARB_texture_compression")) {
    1.18 -		printf("warning, no texture compression available.\n");
    1.19 -		intfmt = GL_RGB;
    1.20 -	}*/
    1.21 -
    1.22  	if(!texman) {
    1.23  		texman = resman_create();
    1.24  		resman_set_load_func(texman, load_res_texture, 0);
    1.25 @@ -46,8 +42,10 @@
    1.26  	}
    1.27  
    1.28  	while((dent = readdir(dir))) {
    1.29 -		/*int xsz, ysz;
    1.30 -		unsigned char *pixels;*/
    1.31 +#ifdef DBG_SYNC
    1.32 +		int xsz, ysz;
    1.33 +		unsigned char *pixels;
    1.34 +#endif
    1.35  		struct thumbnail *node;
    1.36  
    1.37  		if(!(node = malloc(sizeof *node))) {
    1.38 @@ -66,11 +64,12 @@
    1.39  		}
    1.40  		strcat(node->fname, dent->d_name);
    1.41  
    1.42 -		node->aspect = 1.0;/*(float)xsz / (float)ysz;*/
    1.43 +		node->aspect = 1.0;
    1.44  
    1.45 +#ifndef DBG_SYNC
    1.46  		resman_lookup(texman, node->fname, node);
    1.47 -
    1.48 -		/*if(!(pixels = img_load_pixels(node->fname, &xsz, &ysz, IMG_FMT_RGBA32))) {
    1.49 +#else
    1.50 +		if(!(pixels = img_load_pixels(node->fname, &xsz, &ysz, IMG_FMT_RGBA32))) {
    1.51  			free(node->fname);
    1.52  			free(node);
    1.53  			continue;
    1.54 @@ -82,9 +81,11 @@
    1.55  		glBindTexture(GL_TEXTURE_2D, node->tex);
    1.56  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.57  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.58 -		glTexImage2D(GL_TEXTURE_2D, 0, intfmt, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    1.59 +		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    1.60  		img_free_pixels(pixels);
    1.61 -		*/
    1.62 +
    1.63 +		node->aspect = (float)xsz / (float)ysz;
    1.64 +#endif
    1.65  
    1.66  		node->next = list->next;
    1.67  		node->prev = list;