[BUG] Burning's cant handle EPT_LINE_STRIP

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
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

[BUG] Burning's cant handle EPT_LINE_STRIP

Post by gerdb »

i always get a runtime error when im calling

Code: Select all

 
            driver->drawVertexPrimitiveList(Buffer->getVertices(),
                                            Buffer->getVertexCount(),
                                            Buffer->getIndices(),
                                            primCount,
                                            video::EVT_STANDARD,
                                            primType,
                                            video::EIT_16BIT);
 
it stops at this line, the buffer has 366 vertices and indices, primCount is 365 for EPT_LINE_STRIP

this does not crash with OpenGL Driver.

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

Re: [BUG] Burning's cant handle EPT_LINE_STRIP

Post by hybrid »

Please post a reduced, but complete example. But many things are not properly supported by the software drivers.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: [BUG] Burning's cant handle EPT_LINE_STRIP

Post by gerdb »

hi, i rewrote Example 03 Custom SceneNode to reproduce this, just choose Burnings and it'll crash

Code: Select all

/** Example 003 Custom SceneNode */
 
#include <irrlicht.h>
#include "driverChoice.h"
 
#include <ctime>
 
using namespace irr;
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
scene::ICameraSceneNode* createCameraFPS( scene::ISceneManager* smgr );
 
const c8* const E_PRIMITIVE_TYPE_NAMES[] =
{
    "EPT_POINTS",
    "EPT_LINE_STRIP",
    "EPT_LINE_LOOP",
    "EPT_LINES",
    "EPT_TRIANGLE_STRIP",
    "EPT_TRIANGLE_FAN",
    "EPT_TRIANGLES",
    "EPT_QUAD_STRIP",
    "EPT_QUADS",
    "EPT_POLYGON",
    "EPT_POINT_SPRITES"
};
 
//! Test SceneNode
class CTestSceneNode : public scene::ISceneNode
{
    scene::SMeshBuffer Buffer;
    scene::E_PRIMITIVE_TYPE Type;
public:
 
    CTestSceneNode( u32 points, scene::E_PRIMITIVE_TYPE pType, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
        : scene::ISceneNode(parent, mgr, id), Type(pType)
    {
        srand( time(NULL) );
 
        Buffer.Material.Wireframe = false;
        Buffer.Material.Lighting = false;
        Buffer.Material.FogEnable = false;
        Buffer.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
        Buffer.Vertices.reallocate(points);
        Buffer.Vertices.set_used(0);
        for (u32 i=0; i<points; ++i)
        {
            f32 x = (f32)(1+rand()%points);
            f32 y = (f32)(1+rand()%points);
            f32 z = (f32)(1+rand()%points);
            video::SColor color( ((1+rand()%31)<<3)-1, rand()%255, rand()%255, rand()%255);
            Buffer.Vertices.push_back( video::S3DVertex(x,y,z,0,1,0,color,0,0) );
        }
        Buffer.recalculateBoundingBox();
 
        switch (Type)
        {
            case scene::EPT_POINTS:
            case scene::EPT_LINE_STRIP:
            case scene::EPT_LINE_LOOP:
            case scene::EPT_TRIANGLE_STRIP:
            case scene::EPT_TRIANGLE_FAN:
            case scene::EPT_QUAD_STRIP:
            case scene::EPT_QUADS:
            case scene::EPT_POLYGON:
            case scene::EPT_POINT_SPRITES:
//              Buffer.Indices.reallocate(points);
//              Buffer.Indices.set_used(0);
                for (u32 i=0; i<Buffer.Vertices.size(); ++i)
                {
                    Buffer.Indices.push_back(i);
                }
                break;
            case scene::EPT_LINES:
//              Buffer.Indices.reallocate(2*points);
//              Buffer.Indices.set_used(0);
                for (u32 i=0; i<Buffer.Vertices.size(); ++i)
                {
                    Buffer.Indices.push_back(rand()%(Buffer.Vertices.size()-1));
                    Buffer.Indices.push_back(rand()%(Buffer.Vertices.size()-1));
                }
                break;
            case scene::EPT_TRIANGLES:
//              Buffer.Indices.reallocate(3*points);
//              Buffer.Indices.set_used(0);
                for (u32 i=0; i<Buffer.Vertices.size(); ++i)
                {
                    Buffer.Indices.push_back(rand()%(Buffer.Vertices.size()-1));
                    Buffer.Indices.push_back(rand()%(Buffer.Vertices.size()-1));
                    Buffer.Indices.push_back(rand()%(Buffer.Vertices.size()-1));
                }
                break;
            default: break;
        }
    }
 
    virtual void render()
    {
        u32 primCount = 0;
        switch (Type)
        {
            case scene::EPT_POINTS: primCount = Buffer.Indices.size(); break;
            case scene::EPT_LINE_STRIP: primCount = Buffer.Indices.size()-1; break;
            case scene::EPT_LINE_LOOP: primCount = Buffer.Indices.size()-1; break;
            case scene::EPT_TRIANGLE_STRIP: primCount = Buffer.Indices.size()-2; break;
            case scene::EPT_TRIANGLE_FAN: primCount = Buffer.Indices.size()-2; break;
            case scene::EPT_QUAD_STRIP: primCount = (Buffer.Indices.size()-2)/4; break;
            case scene::EPT_QUADS: primCount = Buffer.Indices.size()/4; break;
            case scene::EPT_POLYGON: primCount = Buffer.Indices.size()-1; break;
            case scene::EPT_POINT_SPRITES: primCount = Buffer.Indices.size(); break;
            case scene::EPT_LINES: primCount = Buffer.Indices.size()/2; break;
            case scene::EPT_TRIANGLES: primCount = Buffer.Indices.size()/3; break;
            default: break;
        }
 
        video::IVideoDriver* driver = SceneManager->getVideoDriver();
        driver->setMaterial(Buffer.Material);
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
        driver->drawVertexPrimitiveList(Buffer.getVertices(),
                                        Buffer.getVertexCount(),
                                        Buffer.getIndices(),
                                        primCount,
                                        video::EVT_STANDARD,
                                        Type,
                                        video::EIT_16BIT);
 
 
        gui::IGUIEnvironment* guienv = SceneManager->getGUIEnvironment();
        gui::IGUIFont* font = guienv->getSkin()->getFont();
        if (font)
        {
            scene::ISceneCollisionManager* collision = SceneManager->getSceneCollisionManager();
            core::position2di p = collision->getScreenCoordinatesFrom3DPosition( AbsoluteTransformation.getTranslation() );
            font->draw( core::stringw(E_PRIMITIVE_TYPE_NAMES[Type]).c_str(), core::recti(p, core::dimension2du(200,200)), video::SColor(255,255,255,255), false,false,0);
        }
    }
 
    virtual const core::aabbox3d<f32>& getBoundingBox() const { return Buffer.getBoundingBox(); }
    virtual u32 getMaterialCount() const { return 1; }
    virtual video::SMaterial& getMaterial(u32 i) { return Buffer.Material; }
    virtual void OnRegisterSceneNode()
    {
        if (IsVisible)
            SceneManager->registerNodeForRendering(this);
 
        scene::ISceneNode::OnRegisterSceneNode();
    }
};
 
int main()
{
    // ask user for driver
    video::E_DRIVER_TYPE driverType=driverChoiceConsole();
    if (driverType==video::EDT_COUNT)
        return 1;
 
    // create device
 
    IrrlichtDevice *device = createDevice(driverType,
            core::dimension2d<u32>(1024, 768), 32, false);
 
    if (device == 0)
        return 1; // could not create selected driver.
 
    // create engine and camera
 
    device->setWindowCaption(L"Test SceneNodes | 2008-2012 by BenjaminHampe@gmx.de");
 
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
 
    createCameraFPS(smgr);
 
    const u32 vertexCount = 1000;
    for (u32 primType = (u32)scene::EPT_POINTS; primType < (u32)scene::EPT_POINT_SPRITES; ++primType)
    {
        scene::ISceneNode* node = new CTestSceneNode( vertexCount, (scene::E_PRIMITIVE_TYPE)primType, smgr->getRootSceneNode(), smgr, -1);
        if (node)
        {
            node->setPosition( core::vector3df(1.2f*primType*vertexCount, 0, 0) );
        }
    }
 
    u32 frames=0;
    while(device->run())
    {
        driver->beginScene(true, true, video::SColor(0,100,100,100));
 
        smgr->drawAll();
 
        driver->endScene();
        if (++frames==100)
        {
            core::stringw str = L"Irrlicht Engine [";
            str += driver->getName();
            str += L"] FPS: ";
            str += (s32)driver->getFPS();
 
            device->setWindowCaption(str.c_str());
            frames=0;
        }
    }
 
    device->drop();
 
    return 0;
}
 
 
scene::ICameraSceneNode* createCameraFPS( scene::ISceneManager* smgr )
{
    if (!smgr)
        return 0;
 
    video::IVideoDriver* driver = smgr->getVideoDriver();
 
    SKeyMap keyMapArray[6];
    keyMapArray[0].Action = EKA_MOVE_FORWARD;
    keyMapArray[0].KeyCode = KEY_KEY_W;
    keyMapArray[1].Action = EKA_MOVE_BACKWARD;
    keyMapArray[1].KeyCode = KEY_KEY_S;
    keyMapArray[2].Action = EKA_STRAFE_LEFT;
    keyMapArray[2].KeyCode = KEY_KEY_A;
    keyMapArray[3].Action = EKA_STRAFE_RIGHT;
    keyMapArray[3].KeyCode = KEY_KEY_D;
    keyMapArray[4].Action = EKA_CROUCH;
    keyMapArray[4].KeyCode = KEY_KEY_C;
    keyMapArray[5].Action = EKA_JUMP_UP;
    keyMapArray[5].KeyCode = KEY_SPACE;
    scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS( smgr->getRootSceneNode(), 100, 1.f, -1, &keyMapArray[0], 6, false, 1.0f, false, true);
//  scene::ICameraSceneNode* camera = smgr->addCameraSceneNode( smgr->getRootSceneNode() );
    if (camera)
    {
        core::matrix4 viewMatrix;
        viewMatrix.buildCameraLookAtMatrixLH( core::vector3df(0,0,0), core::vector3df(0,0,100), core::vector3df(0,100,0));
        camera->bindTargetAndRotation(true);
//      camera->setRotation( core::vector3df(0,0,0));
        camera->setProjectionMatrix( viewMatrix );
        camera->setNearValue(1.0f);
        camera->setFarValue(100000.0f);
        f32 aspect = (f32)driver->getScreenSize().Width / (f32)driver->getScreenSize().Height;
        camera->setAspectRatio( aspect );
        smgr->setActiveCamera( camera );
    }
 
    return camera;
}
 
Post Reply