istereo

diff src/istereo.c @ 4:14bbdfcb9030

resource path find code
author John Tsiombikas <nuclear@mutantstargoat.com>
date Wed, 07 Sep 2011 06:25:05 +0300
parents 2c5620f0670c
children 76ad575d72d0
line diff
     1.1 --- a/src/istereo.c	Wed Sep 07 05:33:19 2011 +0300
     1.2 +++ b/src/istereo.c	Wed Sep 07 06:25:05 2011 +0300
     1.3 @@ -5,16 +5,17 @@
     1.4  #include "istereo.h"
     1.5  #include "sanegl.h"
     1.6  #include "sdr.h"
     1.7 -#include "objcsucks.h"
     1.8 +#include "respath.h"
     1.9 +
    1.10 +static unsigned int get_shader_program(const char *vfile, const char *pfile);
    1.11  
    1.12  unsigned int prog;
    1.13  
    1.14  int init(void)
    1.15  {
    1.16 -	char *path = ocs_get_path(OCS_PATH_RESOURCES);
    1.17 -	chdir(path);
    1.18 +	add_resource_path("sdr");
    1.19  
    1.20 -	if(!(prog = create_program_load("test.v.glsl", "test.p.glsl"))) {
    1.21 +	if(!(prog = get_shader_program("test.v.glsl", "test.p.glsl"))) {
    1.22  		fprintf(stderr, "failed to load shader program\n");
    1.23  		return -1;
    1.24  	}
    1.25 @@ -59,3 +60,20 @@
    1.26  	gl_load_identity();
    1.27  	glu_perspective(45.0, (float)x / (float)y, 1.0, 1000.0);
    1.28  }
    1.29 +
    1.30 +static unsigned int get_shader_program(const char *vfile, const char *pfile)
    1.31 +{
    1.32 +	unsigned int prog, vs, ps;
    1.33 +
    1.34 +	if(!(vs = get_vertex_shader(find_resource(vfile, 0, 0)))) {
    1.35 +		return -1;
    1.36 +	}
    1.37 +	if(!(ps = get_pixel_shader(find_resource(pfile, 0, 0)))) {
    1.38 +		return -1;
    1.39 +	}
    1.40 +
    1.41 +	if(!(prog = create_program_link(vs, ps))) {
    1.42 +		return -1;
    1.43 +	}
    1.44 +	return prog;
    1.45 +}