[fixed]Problems with draw2DVertexPrimitiveList

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
hiker
Posts: 58
Joined: Thu May 31, 2007 5:12 am

[fixed]Problems with draw2DVertexPrimitiveList

Post by hiker »

Hi,

thanks for implementing the draw2DVertexPrimitiveList() function we needed in SuperTuxKart. And while it works in cases that we don't need a texture, I can't get it to do what I want if I need a texture:
Image
In the lower right corner will be a speedometer (not shown in the picture to make the problem more obvious), and the yellow line is from a texture which is used to indicate the speed. Unfortunately I can't get rid of the white triangle(s), which is where the texture has transparency. Here the code I am using:

Code: Select all

    video::S3DVertex vertices[4];

    vertices[0].TCoords = core::vector2df(1.0f, 1.0f);
    vertices[0].Pos = core::vector3df((float)meter_pos.LowerRightCorner.X,
                                      (float)meter_pos.LowerRightCorner.Y,
                                      0);
    ...
    // Setting of the remaining vertices skipped, the values appear to be all fine
    ...
    short int index[4];   // Note: count is either 3 or 4
    for(unsigned int i=0; i<count; i++)
    {
        index[i]=i;
        vertices[i].Color = video::SColor(255, 255, 255, 255);
    }
    video::SMaterial m;
    m.setTexture(0, m_speed_bar_icon->getTexture());
    irr_driver->getVideoDriver()->setMaterial(m);
    irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count,
        index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
I tried setting all kind of material types for m.MaterialType, but that made no difference. I can change the colour of the triangle by changing the vertex colour, but I couldn't find out how to make it go away.

I could get it to work by modifying the implementation of draw2DVertexPrimitiveList:

Code: Select all

setRenderStates2DMode(false, (Material.getTexture(0) != 0), false);
with

Code: Select all

setRenderStates2DMode(false, (Material.getTexture(0) != 0), true);
.

Is there a way to get the same effect (only show the texture with transparency, but not the actual triangle) without patching irrlicht?

Thanks!
Joerg

Edit: Should have mentioned it: that's with the OpenGL driver.
Last edited by hiker on Fri Oct 16, 2009 2:35 am, edited 1 time in total.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Why You can't draw "2d" similar to screen quad? so, similar to each 3d object in Irrlicht. Before render this quads You need only reset matrices or draw it with special vertex program.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
hiker
Posts: 58
Joined: Thu May 31, 2007 5:12 am

Post by hiker »

Nadro wrote:Why You can't draw "2d" similar to screen quad? so, similar to each 3d object in Irrlicht. Before render this quads You need only reset matrices or draw it with special vertex program.
Well, that's basically what draw2D...List() does. It just makes the whole programming simpler if the matrices are handled in irrlicht and not in the application - creating a simple hud on the screen in 3D feels 'wrong' (though it would work obviously). Otherwise you could argue that (nearly) all 2d drawing functions are unnecessary ;)

Also I am not sure how portable this would be to other devices (should have mentioned it: the above is with OpenGL, didn't try DirectX).

Cheers,
Joerg
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Seems that I've missed some things in the material setup. I'll investigate this and move to bug reports.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, I've added configurable transparency support in latest SVN/trunk. If it helps we could also backport this to 1.6.1, though most distributions seem to avoid the patch versions we release. So 1.7 might be better suited.
You can use the materials EMT_ONE_TEXTURE_BLEND (using the alpha source parameter there, also for both alpha modes at once), EMT_TRANSPARENT_VERTEX_ALPHA, or EMT_TRANSPARENT_ALPHA_CHANNEL for choosing the proper alpha mode.
Post Reply