How to turn off texture filtering

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
dirk1134
Posts: 1
Joined: Wed Feb 21, 2007 11:13 pm

How to turn off texture filtering

Post by dirk1134 »

I want to draw a small (16x16) texture. The following code draws the texture, but there is some kind of (apparently linear) filter applied to it. I manually turn off all the filtering options I could find in the material flags, but the texture is still smeared. I want to see the pixels of the original source texture, with sharp boundaries in between them.

I've tried everything I can think of; does anyone have any ideas? Thanks in advance

Code: Select all

#include <cstdlib>
#include <iostream>
#include <irrlicht.h>

using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")

int main(int argc, char *argv[])
{
   IrrlichtDevice *device =
		createDevice( video::EDT_SOFTWARE2, dimension2d<s32>(640, 480), 16,
			false, false, false, 0);
	device->setWindowCaption(L"Procedural Texture Viewer");
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

   ISceneNode* node = smgr->addCubeSceneNode(10, NULL, 1, vector3df(0, 0, 0));
   smgr->addCameraSceneNode(0, vector3df(0,0,-15), vector3df(0,0,0));

   driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
   ITexture *t2 = driver->getTexture("eh.bmp");

   node->setMaterialTexture(0, t2);
   node->setMaterialFlag(video::EMF_LIGHTING, false);
   node->setMaterialFlag(video::EMF_ANISOTROPIC_FILTER, false);
   node->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
   node->setMaterialFlag(video::EMF_TRILINEAR_FILTER, false);
   node->setMaterialFlag(video::EMF_GOURAUD_SHADING, false);

   while(device->run())
   {
	   driver->beginScene(true, true, SColor(255,100,101,140));
	   smgr->drawAll();
      guienv->drawAll();
      driver->endScene();
	}
   device->drop();
   system("PAUSE");
   return EXIT_SUCCESS;
}
[/code]
bandinopla
Posts: 28
Joined: Fri Nov 24, 2006 11:05 am

Post by bandinopla »

i have the same problem, did u find an anser?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe try a different driver, don't know if software2 uses a default filtering?
Post Reply