void Texture::setup_texture_parameters(bool repeat) 
{
	GLint repeat_mode = repeat ? GL_REPEAT : GL_CLAMP ;

	glEnable(texture_target_);
	glBindTexture(texture_target_, texture_id());
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
	glTexParameterf(texture_target_, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ;
	glTexParameterf(texture_target_, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ;
	glTexParameterf(texture_target_, GL_TEXTURE_WRAP_S, static_cast<GLfloat>(repeat_mode)) ;
	glTexParameterf(texture_target_, GL_TEXTURE_WRAP_T, static_cast<GLfloat>(repeat_mode)) ;
	glTexParameterf(texture_target_, GL_TEXTURE_WRAP_R, static_cast<GLfloat>(repeat_mode)) ;
}
Example #2
0
static void		display_vertical_tex(t_context *c, t_ray *ray, t_line *line)
{
	const double	h = (double)c->x->height;
	t_point			px;
	t_point			tpx;
	t_texture		*tex;
	unsigned int	color;

	tex = &c->map.tex[texture_id(c, ray)];
	tpx.x = texture_get_x(c, ray, tex);
	px = line->start;
	while (px.y < line->end.y)
	{
		tpx.y = (int)(((double)(px.y * 2) - h + ray->h) *
			(((double)tex->height / 2.0) / ray->h));
		if (tpx.y >= 0)
		{
			color = texture_px(tex, tpx);
			if ((ray->side == 1) && (tex->id >= 2))
				color = (color >> 1) & 8355711;
			draw_px(c->x, &px, color);
		}
		px.y++;
	}
Texture::~Texture() {
	GLuint id = texture_id() ;
	glDeleteTextures(1, &id);    
	texture_id_ = 0 ;
}