nel-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nel] Interface change


From: Cyril 'Hulud' Corvazier
Subject: [Nel] Interface change
Date: Fri, 19 Mar 2004 12:06:45 +0100

Hi NeLers,

In order to release a "direct 3d" implementation of NeL, we had to do some
major modifications in the NeL 3d driver interface:

If you use the following classes, you are concerned by this modifications :

NL3D::CDriver
NL3D::CPrimitiveBlock
NL3D::CVertexBuffer
NL3D::CVertexBufferHard

1) The CPrimitiveBlock class doesn't exist anymore. It has been replaced by
the CIndexBuffer class. This is just a uint32 vector. Each uint32 number is
an index in the vertex buffer. WARNING : the method setTri/setLine (uint
triIndex, uint v0, uint v1...) has been replaced by a similar method
setTri/setLine (uint index, uint v0, uint v1...) BUT, "index" is the index
in the CIndexBuffer, and not a primitive index. So setTri (tri, 1, 2, 3)
should be now setTri (tri*3, 1, 2, 3) and setLine (line, 1, 2) should be now
setLine (line*2, 1, 2).

2) The CIndexBuffer / CVertexBuffer use now the same lock/unlock system. You
must lock before reading or writing a vertex buffer or an index buffer. You
must unlock the buffers before the rendering. You must unlock the buffers
before modifing the buffers capacity. You can modify the size of a locked
buffer if  it doesn't grow up the buffer capacity.

3) CIndexBuffer and CVertexBuffer can be directly created in RAM, VRAM or
AGP now. The class CVertexBufferHard doesn't
exist anymore.

4) The index buffer must be activated before the rendering, like vertex
buffer, with CDriver::activeIndexBuffer().

5) The render methods have been changed. You have now,
CDriver::renderRawPoints(), CDriver::renderRawLines(),
CDriver::renderRawTriangles(), CDriver::renderRawQuads() for non-indexed
primitives (primitive that don't need an index buffer).
CDriver::renderLines(), CDriver::renderTriangles() for indexed primitives
(primitive that need an index buffer).

6) There is no support for indexed quad primitives anymore.

7) A "render to texture" interface have been added to the driver interface.

8) All the classes serializations are backward compatibles, so you don't
need to reexport your data.

Before the modification you had :
---
CPrimitiveBlock pb;
pb.setNumTri (2)
pb.setTri (0, 0, 1, 2);
pb.setTri (1, 1, 2, 3);
CVertexBuffer vb;
vb.setNumVertices (4);
vb.setVertexCoord (0, 0.f, 0.f, 0.f);
vb.setVertexCoord (1, 1.f, 0.f, 0.f);
vb.setVertexCoord (2, 1.f, 1.f, 0.f);
vb.setVertexCoord (3, 0.f, 1.f, 0.f);
driver->activeVertexBuffer (vb);
driver->render (pb, material);

Now you should have :
---
CIndexBuffer ib;
ib.setNumIndexes (6);    // Set the buffer size before locking
CVertexBuffer vb;
vb.setNumVertices (4);    // Set the buffer size before locking
{
    CIndexBufferReadWrite iba;
    ib.lock (iba);
    iba.setTri (0, 0, 1, 2);
    iba.setTri (3, 1, 2, 3);    // Index is 3, not 1
    CVertexBufferReadWrite vba;
    vb.lock (vba);
    vba.setVertexCoord (0, 0.f, 0.f, 0.f);
    vba.setVertexCoord (1, 1.f, 0.f, 0.f);
    vba.setVertexCoord (2, 1.f, 1.f, 0.f);
    vba.setVertexCoord (3, 0.f, 1.f, 0.f);
}    // Unlock is done at the end of the block
driver->activeIndexBuffer (ib);                // Must activate the index
buffer now
driver->activeVertexBuffer (vb);
driver->renderTriangles (material, 0, 2);    // Buffers must be unlock
before the rendering

Hld.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]