istereo

changeset 8:aa70df4bb0e5

added vbo test
author John Tsiombikas <nuclear@mutantstargoat.com>
date Wed, 07 Sep 2011 07:58:53 +0300
parents 557d86c8d7ed
children 22dc37e3ca05
files src/istereo.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/istereo.c	Wed Sep 07 07:43:22 2011 +0300
     1.2 +++ b/src/istereo.c	Wed Sep 07 07:58:53 2011 +0300
     1.3 @@ -24,6 +24,8 @@
     1.4  
     1.5  unsigned int prog;
     1.6  
     1.7 +unsigned int vbo, cbo;
     1.8 +
     1.9  int init(void)
    1.10  {
    1.11  	add_resource_path("sdr");
    1.12 @@ -33,6 +35,16 @@
    1.13  		return -1;
    1.14  	}
    1.15  
    1.16 +	glGenBuffers(1, &vbo);
    1.17 +	glBindBuffer(GL_ARRAY_BUFFER, vbo);
    1.18 +	glBufferData(GL_ARRAY_BUFFER, sizeof varr, varr, GL_STATIC_DRAW);
    1.19 +
    1.20 +	glGenBuffers(1, &cbo);
    1.21 +	glBindBuffer(GL_ARRAY_BUFFER, cbo);
    1.22 +	glBufferData(GL_ARRAY_BUFFER, sizeof carr, carr, GL_STATIC_DRAW);
    1.23 +
    1.24 +	glBindBuffer(GL_ARRAY_BUFFER, 0);
    1.25 +
    1.26  	return 0;
    1.27  }
    1.28  
    1.29 @@ -104,11 +116,16 @@
    1.30  	cloc = glGetAttribLocation(prog, "attr_color");
    1.31  	assert(vloc != -1 && cloc != -1);
    1.32  
    1.33 -	glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, varr);
    1.34 +	glBindBuffer(GL_ARRAY_BUFFER, vbo);
    1.35 +	glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, 0);
    1.36  	glEnableVertexAttribArray(vloc);
    1.37 -	glVertexAttribPointer(cloc, 3, GL_FLOAT, 0, 0, carr);
    1.38 +
    1.39 +	glBindBuffer(GL_ARRAY_BUFFER, cbo);
    1.40 +	glVertexAttribPointer(cloc, 3, GL_FLOAT, 0, 0, 0);
    1.41  	glEnableVertexAttribArray(cloc);
    1.42  
    1.43 +	glBindBuffer(GL_ARRAY_BUFFER, 0);
    1.44 +
    1.45  	glDrawArrays(GL_TRIANGLES, 0, 3);
    1.46  
    1.47  	glDisableVertexAttribArray(vloc);