3dphotoshoot

diff src/sdr.c @ 21:4ca4e3c5a754

port to C++ completed, shader programs now use the SdrProg class
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 11 Jun 2015 04:56:33 +0300
parents aef7f51f6397
children 2712c5da2e00
line diff
     1.1 --- a/src/sdr.c	Thu Jun 11 02:53:43 2015 +0300
     1.2 +++ b/src/sdr.c	Thu Jun 11 04:56:33 2015 +0300
     1.3 @@ -5,6 +5,7 @@
     1.4  #include <stdarg.h>
     1.5  #include <assert.h>
     1.6  #include "opengl.h"
     1.7 +#include "assman.h"
     1.8  
     1.9  #if defined(unix) || defined(__unix__)
    1.10  #include <unistd.h>
    1.11 @@ -136,35 +137,28 @@
    1.12  
    1.13  unsigned int load_shader(const char *fname, unsigned int sdr_type)
    1.14  {
    1.15 -#if defined(unix) || defined(__unix__)
    1.16 -	struct stat st;
    1.17 -#endif
    1.18  	unsigned int sdr;
    1.19  	size_t filesize;
    1.20 -	FILE *fp;
    1.21 +	ass_file *fp;
    1.22  	char *src;
    1.23  
    1.24 -	if(!(fp = fopen(fname, "rb"))) {
    1.25 +	if(!(fp = ass_fopen(fname, "rb"))) {
    1.26  		fprintf(stderr, "failed to open shader %s: %s\n", fname, strerror(errno));
    1.27  		return 0;
    1.28  	}
    1.29  
    1.30 -#if defined(unix) || defined(__unix__)
    1.31 -	fstat(fileno(fp), &st);
    1.32 -	filesize = st.st_size;
    1.33 -#else
    1.34 -	fseek(fp, 0, SEEK_END);
    1.35 -	filesize = ftell(fp);
    1.36 -	fseek(fp, 0, SEEK_SET);
    1.37 -#endif	/* unix */
    1.38 +	filesize = ass_fseek(fp, 0, SEEK_END);
    1.39 +	/*filesize = ass_ftell(fp);*/
    1.40 +	printf("  filesize: %ld\n", filesize);
    1.41 +	ass_fseek(fp, 0, SEEK_SET);
    1.42  
    1.43  	if(!(src = malloc(filesize + 1))) {
    1.44 -		fclose(fp);
    1.45 +		ass_fclose(fp);
    1.46  		return 0;
    1.47  	}
    1.48 -	fread(src, 1, filesize, fp);
    1.49 +	ass_fread(src, 1, filesize, fp);
    1.50  	src[filesize] = 0;
    1.51 -	fclose(fp);
    1.52 +	ass_fclose(fp);
    1.53  
    1.54  	fprintf(stderr, "compiling %s shader: %s... ", sdrtypestr(sdr_type), fname);
    1.55  	sdr = create_shader(src, sdr_type);