Page 1 of 2

PNG

Posted: Wed Nov 19, 2003 9:13 pm
by Guest
Hey

I noticed on the feature list and the planned features that the PNG format isn't included, is it supported? I've heard of a licence needs to be purchased for JPEG ( PNG is SO much better at compression and quality anyway :) )

Also, any plans to support the .MAX model format? I know that you can't store animations in .3DS and I don't really want to buy Milkshape as well as 3DSM. Any other format I can use ( or is planned ) apart from ms3de and the Q2 format?

Posted: Thu Nov 20, 2003 12:01 am
by saigumi
From what I remember, PNG was suggested and Niko acknowledge working on it in the Feature Request thread in the Open Discussion forum. I really like PNG.

Anim8or support is in the works and is free. I've seen some talk about Max. But not many people can afford the $795.00 for it, so I can't see many people using it... more people can afford the $25 for milkShape or the $0 pricetag of Anim8or

Posted: Thu Nov 20, 2003 1:59 am
by wornaki
Yes, the png situation is about to be settled. Hope it happens the same with .an8 file support. Just waiting...

Posted: Thu Nov 20, 2003 3:01 pm
by Isometric God
There is a free library on http://www.libpng.org/ including source code and tutorials. Why re-invent the wheel ?
And why does niko have to do all this ? Anybody could write a wrapper class for PNG files ( independent from using libpng or not )
Just my 2 cents ...

Posted: Sat Dec 13, 2003 8:19 pm
by rt
has there been any more thought about getting a png loader into the engine? it is such a great format 8)

i coded a CImageLoaderPNG class and it works ok with 24-bpp, but in 32-bpp the alpha doesn't show up right :( .. and also it required libpng.dll which i don't think niko wants.

this is what it looks like when a 32-bpp (with alpha) .png is loaded and then displayed with useAlphaChannelOfTexture=false
Image

and this is what is looks with the same image but useAlphaChannelOfTexture = true
Image

the problem is that the center part of the scope (the white part from the first image) is actually transparent (0x00FFFFFF). it's almost like the alpha is backwards? and the color of the numbers is changed too ..
can anyone help out?

[edit]: i set ETCF_OPTIMIZED_FOR_QUALITY = true and now the .png image is displayed perfectly! ... but only with the directx driver :? when i switch to opengl it suddenly becomes 1-bit alpha instead of 8 bit. this is also a problem for 32-bit .tga files.. they only display correctly in directx mode.

Posted: Sun Dec 14, 2003 7:38 am
by niko
Hm, ok.. I'll try to find out the problem until release :)

png loader source code (0.4.2)

Posted: Tue Dec 16, 2003 1:07 am
by rt
---->here<---- is the source for the CImageLoaderPng class (why png?).
there are at least 2 things you won't like about it:
1 - it requires you to hack CReadFile() so that it can get access the "FILE* File" variable.
2 - it requires libpng.dll (included) to be distributed with your exe (this of course could be solved by adding all the png source code to the project but who's got time for that!)

10 easy steps to adding the CImageLoaderPng class to irrlicht:
1 - unzip files to your irrlicht source code folder and in vc++ add CImageLoaderPng.h and .cpp to 'video impl' -> 'null'
2 - open CVideoNull.cpp and add 'createImageLoaderPNG()' in two places .. see if you can figure out where ;)
3 - hack CReadFile.h so that "FILE* File" is public (terrible.. simply terrible!)
4 - build irrlicht!
5 - copy libpng.dll to the same folder as your exe
6 - there is no step 6
7 - create a 64x64 .png image either with alpha (32bpp) or without (24bpp)
8 - add this line before loading any textures

Code: Select all

driver->setTextureCreationFlag(irr::video::ETCF_OPTIMIZED_FOR_QUALITY,true);
9 - load a texture like so

Code: Select all

irr::video::ITexture* my_png_image = driver->getTexture("cool_image.png");
10 - render it like so

Code: Select all

device->getVideoDriver()->draw2DImage(my_png_image,irr::core::position2d<irr::s32>(0,0),irr::core::rect<irr::s32>(0,0,63,63),NULL,irr::video::SColor(255,255,255,255),true);
good luck 8) i hope it works for you but i make no guarantee that it will or that there is not a huge memory leak which will blow up your system. i'm open to any suggestions or improvments so if you think you can improve the code please do.

[edit]: oh yeah, the 32bpp alpha only works properly when directx is the video driver at the moment. but before it will work you need to goto CVideoDirectX8::setRenderStates2DMode and look for the "if (alphaChannel)" block, now change SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE) to SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA)

here is a very ugly screen shot of the png alpha greatness in action:
Image

opened up opengl

Posted: Thu Dec 18, 2003 1:07 am
by rt
after some poking around i found out how to make 32-bit .png's and .tga's show up properly in opengl mode.
open up CVideoOpenGL.cpp and locate CVideoOpenGL::setRenderStates2DMode().

change this

Code: Select all

		if (alphaChannel)
		{
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
			glDisable(GL_BLEND);
			glEnable(GL_ALPHA_TEST);
			glAlphaFunc(GL_GREATER, 0);
		}
to this

Code: Select all

		if (alphaChannel)
		{
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
			glDisable(GL_ALPHA_TEST);
		}
now the alpha transparency shows up perfect :D ... but of course the .png file is 10 times smaller than the .tga!

the P is not for Popular

Posted: Fri Dec 26, 2003 9:09 pm
by rt
i guess no one likes png format in this forum :lol:

Posted: Fri Dec 26, 2003 9:16 pm
by keless
i do. yay!

currently, however, I am writing an IrrLicht Tetris without textures..

Posted: Tue Mar 09, 2004 6:24 pm
by saigumi
RT,

This would be a perfect TPIM. Mind if I put it into storage?

http://irrlicht.sourceforge.net/phpBB2/ ... =9076#9076

Posted: Wed Mar 10, 2004 1:24 am
by rt
saigumi wrote:RT,

This would be a perfect TPIM. Mind if I put it into storage?

http://irrlicht.sourceforge.net/phpBB2/ ... =9076#9076
sure, however my code bends the rules you set out... i.e. "TPIMs should be clean". as stated, the code requires a slight hack to CReadFile().. but if you (or someone else) can find a workaround i'd be happy to have it added to TPIM :D

Posted: Sun Apr 11, 2004 11:06 am
by Guest
Why do you need libpng.dll? You could just link with libpng.a / png.lib just like currently with libjpeg and libz :!:

Posted: Mon Apr 12, 2004 3:29 pm
by Guest
rt wrote: .. and also it required libpng.dll which i don't think niko wants.
Why does it need libpng.dll? You can of course link it statically, can't you!?
I like PNG the only correct format for games.. jpeg not good for textures, tga and others bad compression. That's why PNG-loader should be included in the Engine! I'v been using libjpeg, libz and libpng in my engine and just noticed that I need libz.dll, but libjpeg and libpng are statically there.. so as well as you have linjpeg in your engine, you could also have libpng there. (Except if there are licensing restrictions). :)

Re: Glazer & the Buccaneers

Posted: Sun Aug 01, 2004 12:35 pm
by blayde
duko wrote:Topics containing links to people's sites are unneeded and contribute nothing as a whole, much like topics containing content like this one. You could have PMed a moderator and asked this same question and received the same Black Jack response. Please do so in the future.
i'd have to disagree. i found them to be useful, helpful and informative.