I noticed the blurred image using the direct3d9/direct3d8 driver. There is no blur when using the opengl driver.
Please, compare results.
OpenGL
http://imageshack.us/photo/my-images/37/opengl.png/
D3D9
http://imageshack.us/photo/my-images/28/d3d9.png/
Original texture:
http://imageshack.us/photo/my-images/267/fractal.png/
My environment: Win 7 64-bit, VS2010, irrlicht 1.7.2
Please, explain me what's wrong.
For testing purposes I replaced "01.HelloWorld_vc9" with this code
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
const int WIN_X = 1024;
const int WIN_Y = 768;
const int MARGIN_X = 85;
const int MARGIN_Y = 0;
typedef enum {
BM_NORMAL,
BM_LIGHTEN,
BM_DARKEN,
BM_DISABLE,
BM_ALPHABLEND_ALPHATEST,
} EBlendingMode;
irr::f32 GetBlendFunc (EBlendingMode blend_mode)
{
switch (blend_mode)
{
case BM_NORMAL: return pack_texureBlendFunc (
irr::video::EBF_SRC_ALPHA,
irr::video::EBF_ONE_MINUS_SRC_ALPHA,
irr::video::EMFN_MODULATE_1X,
irr::video::EAS_TEXTURE | irr::video::EAS_VERTEX_COLOR);
case BM_LIGHTEN: return pack_texureBlendFunc (
irr::video::EBF_SRC_ALPHA,
irr::video::EBF_ONE,
irr::video::EMFN_MODULATE_1X,
irr::video::EAS_TEXTURE | irr::video::EAS_VERTEX_COLOR);
case BM_DARKEN: return pack_texureBlendFunc (
irr::video::EBF_ZERO,
irr::video::EBF_SRC_COLOR,
irr::video::EMFN_MODULATE_1X,
irr::video::EAS_TEXTURE | irr::video::EAS_VERTEX_COLOR);
}
return 0;
}
void SetRenderMatrices(IVideoDriver * driver)
{
core::matrix4 identity_matrix;
identity_matrix.makeIdentity();
driver->setTransform (video::ETS_WORLD, identity_matrix);
//------------ VIEW --------------
core::matrix4 view_matrix;
view_matrix.setTranslation (core::vector3df (-0.5f * WIN_X, -0.5f * WIN_Y, 0));
driver->setTransform (video::ETS_VIEW, view_matrix);
//------------ PROJECTION --------------
core::matrix4 proj_matrix;
proj_matrix.buildProjectionMatrixOrthoLH (WIN_X, -WIN_Y, -500, 500);
driver->setTransform (video::ETS_PROJECTION, proj_matrix);
}
void SetViewport(IVideoDriver * driver)
{
//Setup viewport a bit smaller than whole window size
driver->setViewPort(irr::core::recti (MARGIN_X, MARGIN_Y, WIN_X - MARGIN_X - 1, WIN_Y - MARGIN_Y - 1));
}
IrrlichtDevice * CreateIrrDevice()
{
SIrrlichtCreationParameters p;
p.AntiAlias = false;
p.Bits = 32;
p.Doublebuffer = true;
p.DeviceType = EIDT_BEST;
p.EventReceiver = NULL;
p.Fullscreen = true;
p.HighPrecisionFPU = false;
p.IgnoreInput = false;
p.Stencilbuffer = false;
p.Stereobuffer = false;
p.Vsync = true;
p.WindowId = 0;
p.WindowSize = core::dimension2d<int> (WIN_X, WIN_Y);
p.WithAlphaChannel = false;
p.ZBufferBits = 0;
p.DriverType = video::EDT_OPENGL;
return irr::createDeviceEx (p);
}
int main()
{
IrrlichtDevice *device = CreateIrrDevice();
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
irr::video::SMaterial material;
material.BackfaceCulling = false;
material.AntiAliasing = false;
material.Lighting = false;
material.ZBuffer = irr::video::ECFN_ALWAYS;
material.Wireframe = false;
material.MaterialType = irr::video::EMT_ONETEXTURE_BLEND;
material.MaterialTypeParam = GetBlendFunc (BM_NORMAL);
material.setFlag (irr::video::EMF_BILINEAR_FILTER, true);
material.setFlag (irr::video::EMF_TRILINEAR_FILTER, false);
material.setFlag (irr::video::EMF_ANISOTROPIC_FILTER, false);
material.setFlag (irr::video::EMF_TEXTURE_WRAP, false);
driver->setMaterial (material);
irr::video::S3DVertex2TCoords Vertices [4];
irr::video::SColor color(255, 255, 255, 255);
Vertices [0].Color = color;
Vertices [1].Color = color;
Vertices [2].Color = color;
Vertices [3].Color = color;
Vertices [0].Pos.set(0, 0, 0);
Vertices [1].Pos.set(1024, 0, 0);
Vertices [2].Pos.set(1024, 768, 0);
Vertices [3].Pos.set(0, 768, 0);
Vertices [0].TCoords.set(0, 0);
Vertices [1].TCoords.set(1, 0);
Vertices [2].TCoords.set(1, 1);
Vertices [3].TCoords.set(0, 1);
Vertices [0].Normal.set(0.0f, 0.0f, -1.0f);
Vertices [1].Normal.set(0.0f, 0.0f, -1.0f);
Vertices [2].Normal.set(0.0f, 0.0f, -1.0f);
Vertices [3].Normal.set(0.0f, 0.0f, -1.0f);
irr::u16 VertexIndices [6] = { 0, 1, 2, 0, 2, 3 };
irr::video::ITexture * tex = driver->getTexture("fractal.png");
while(device->run())
{
SetRenderMatrices(driver);
SetViewport(driver);
irr::core::matrix4 world = driver->getTransform(irr::video::ETS_WORLD);
irr::core::matrix4 view = driver->getTransform(irr::video::ETS_VIEW);
irr::core::matrix4 proj = driver->getTransform(irr::video::ETS_PROJECTION);
driver->beginScene(true, true, SColor(255, 100, 101, 140));
material.setTexture(0, tex);
driver->setMaterial(material);
driver->drawIndexedTriangleList (Vertices, 4, VertexIndices, 2);
driver->endScene();
}
device->drop();
return 0;
}