bloboland

diff src/texture.cc @ 4:9021a906c5d3

lots of stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 18 Dec 2012 06:13:09 +0200
parents a39c301cdcce
children 2f4406cc341e
line diff
     1.1 --- a/src/texture.cc	Sun Dec 16 14:24:16 2012 +0200
     1.2 +++ b/src/texture.cc	Tue Dec 18 06:13:09 2012 +0200
     1.3 @@ -38,11 +38,53 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 +void Texture::set_filtering(unsigned int min_filter, unsigned int mag_filter)
     1.8 +{
     1.9 +	if(mag_filter == 0) {
    1.10 +		mag_filter = min_filter;
    1.11 +	}
    1.12 +
    1.13 +	glBindTexture(type, tex);
    1.14 +	glTexParameteri(type, GL_TEXTURE_MIN_FILTER, min_filter);
    1.15 +	glTexParameteri(type, GL_TEXTURE_MAG_FILTER, mag_filter);
    1.16 +}
    1.17 +
    1.18 +void Texture::set_wrapping(unsigned int wrap)
    1.19 +{
    1.20 +	glBindTexture(type, tex);
    1.21 +	glTexParameteri(type, GL_TEXTURE_WRAP_S, wrap);
    1.22 +	glTexParameteri(type, GL_TEXTURE_WRAP_T, wrap);
    1.23 +	glTexParameteri(type, GL_TEXTURE_WRAP_R, wrap);
    1.24 +}
    1.25 +
    1.26  int Texture::get_size(int idx) const
    1.27  {
    1.28  	return idx >= 0 && idx < 3 ? size[idx] : 0;
    1.29  }
    1.30  
    1.31 +Texture1D::Texture1D()
    1.32 +{
    1.33 +	type = GL_TEXTURE_1D;
    1.34 +
    1.35 +	glBindTexture(type, tex);
    1.36 +	glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.37 +	glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.38 +}
    1.39 +
    1.40 +void Texture1D::create(int sz, float *data)
    1.41 +{
    1.42 +	glBindTexture(type, tex);
    1.43 +	glTexImage1D(type, 0, GL_RGBA, sz, 0, GL_RGBA, GL_FLOAT, data);
    1.44 +
    1.45 +	size[0] = sz;
    1.46 +}
    1.47 +
    1.48 +void Texture1D::update(float *data)
    1.49 +{
    1.50 +	glBindTexture(type, tex);
    1.51 +	glTexSubImage1D(type, 0, 0, size[0], GL_RGBA, GL_FLOAT, data);
    1.52 +}
    1.53 +
    1.54  Texture2D::Texture2D()
    1.55  {
    1.56  	type = GL_TEXTURE_2D;