Re: [AD] min/mag filters

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


It seems that in Direct3D, filtering is tied to the sampler unit and not the texture.
Something tells me OpenGL may be the same. Since in the OpenGL driver
and the Direct3D driver we always use sampler 0, if that is correct then we have
to set the sampler type before drawing each bitmap, which makes it slightly more
annoying to use (not bitmap holding for example). Just to make sure I'd like to
see the following program rewritten for OpenGL:

#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_direct3d.h>

int main(int argc, char **argv)
{
	al_init();
	al_init_image_addon();

	ALLEGRO_DISPLAY *display = al_create_display(640, 480);

	ALLEGRO_BITMAP *mario = al_load_bitmap("mario.png");
	ALLEGRO_BITMAP *checker = al_load_bitmap("checkerboard.png");

	LPDIRECT3DTEXTURE9 mario_tex = al_get_d3d_video_texture(mario);
	LPDIRECT3DTEXTURE9 checker_tex = al_get_d3d_video_texture(checker);
	LPDIRECT3DDEVICE9 device = al_get_d3d_device(display);

	device->SetTexture(0, mario_tex);                               // 1
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);  // 1

	device->SetTexture(0, checker_tex);                             // 2
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);   // 2

	al_draw_scaled_bitmap(mario, 0, 0, 12, 16, 10, 10, 12*10, 16*10, 0);
	al_draw_scaled_bitmap(checker, 0, 0, 8, 8, 200, 10, 8*10, 8*10, 0);

	al_flip_display();

	al_rest(5);
}

Which I will do now. The result of this is that  the last call to SetSamplerState takes
precedence, which in this case means that both sprites are drawn with point
filtering.

On 2010-08-14, at 5:59 PM, Trent Gamblin wrote:
> Sorry, I was only kind of skimming threads the past few days. If my
> reading of the D3D docs is correct, then texture filtering can be
> applied per-bitmap like in GL. I will test that now to make sure
> that is the case, and report back.





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/