A patch to draw 2d vertices with materials enabled

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
vroad
Posts: 18
Joined: Sun Jan 03, 2010 1:30 pm

A patch to draw 2d vertices with materials enabled

Post by vroad »

I've made a patch to draw 2d images with materials enabled. It seems working in my test code, but there may be some cases that drawing doesn't work correctly.
This test code uses setMaterial to do alpha blending with EMT_ONETEXTURE_BLEND.
https://gist.github.com/vroad/d1a2e2cfe57ed7c9f5d7
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

Re: A patch to draw 2d vertices with materials enabled

Post by chronologicaldot »

I sort of understand what you're saying, but do you have an example picture?
I noticed the code is only for DX9 and OpenGL. (*sigh* I'm alone working on Burnings...)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: A patch to draw 2d vertices with materials enabled

Post by hybrid »

Well, although 2d materials take a different approach than 3d drawings, there's already quite a lot possible. Alpha blending, for example. And due to 2dmaterial we can also use filtering etc. But once we change material override support for 3d rendering, 2d should also get this.
Your patch seems to change far too much for this purpose IMHO.
vroad
Posts: 18
Joined: Sun Jan 03, 2010 1:30 pm

Re: A patch to draw 2d vertices with materials enabled

Post by vroad »

Image
This is the screen shot...
Currently OverrideMaterial2D only allows programmers to change basic render states only such as filtering mode. It doesn't allow you to use different material like EMT_ONETEXTURE_BLEND, or EMT_TRANSPARENT_ADD_COLOR. You can do it with 3d drawing mode by setting matricies by yourself and drawing a quad, but I think there must be more easier way to do that.

Also, current api design have a little problem. IVideoDriver::getMaterial2D() returns a reference to 2d material so that probrammers can modify its value. In tutorial 06, some properties of 2d material are modified directly, but if other properties of 2d material is modifed by previous drawing, you need to restore them. Restoring can be done by assigning a value to the reference. Then why Irrlicht doesn't reuse existing method setMaterial, or create new method like setMaterial2D? And Irrlicht must provide a function to restore its default value.

Code: Select all

 
driver->getMaterial2D() = createMaterial2D() // ...?
 

Code: Select all

 
driver->setMaterial2D(createMaterial2D()) // This one is better
 
Currently I have implemented this in opengl and d3d9 drivers. I should know internal structure of software drivers to implement this function in them.
Post Reply