Indexed primitives anyone? 
Author Message
 Indexed primitives anyone?

Hi all,

im trying to use indexed primitives and i can't quite get to grips with it,
i'm sure its the order of my indexes but,, i cant quite get the right order,
can anyone give me a hint??

also, this code seems to crash vb6 fairly regularly,, methinks im leaking
memory,, but how!!!???

cheers,

nige.

    m_NumTileVertices = 9
    m_NumTileIndices = 12

    'Create vertex buffer for ground object
    Set m_GroundVB = g_dev.CreateVertexBuffer(m_NumTileVertices *
Len(m_grVerts(0)), _
                                              0, _
                                              D3DFVF_COLORVERTEX, _
                                              D3DPOOL_MANAGED)

'build the reference points
    ReDim m_grVerts(9)

        m_grVerts(0).v.x = 0
        m_grVerts(0).v.y = 0
        m_grVerts(0).v.z = 0

        m_grVerts(1).v.x = 3
        m_grVerts(1).v.y = 0
        m_grVerts(1).v.z = 0

        m_grVerts(2).v.x = 6
        m_grVerts(2).v.y = 0
        m_grVerts(2).v.z = 0

        m_grVerts(3).v.x = 0
        m_grVerts(3).v.y = 0
        m_grVerts(3).v.z = 3

        m_grVerts(4).v.x = 3
        m_grVerts(4).v.y = 0
        m_grVerts(4).v.z = 3

        m_grVerts(5).v.x = 6
        m_grVerts(5).v.y = 0
        m_grVerts(5).v.z = 3

        m_grVerts(6).v.x = 0
        m_grVerts(6).v.y = 0
        m_grVerts(6).v.z = 6

        m_grVerts(7).v.x = 3
        m_grVerts(7).v.y = 0
        m_grVerts(7).v.z = 6

        m_grVerts(8).v.x = 6
        m_grVerts(8).v.y = 0
        m_grVerts(8).v.z = 6

    D3DVertexBuffer8SetData m_GroundVB, _
                            0, _
                            (Len(m_grVerts(0)) * m_NumTileVertices), _
                            0, _
                            m_grVerts(0)

    ReDim Indices(m_NumTileIndices)

    'Create the index buffer
    Set m_GroundIB = g_dev.CreateIndexBuffer(m_NumTileIndices, _
                                             0, _
                                             D3DFMT_INDEX16, _
                                             D3DPOOL_MANAGED)

    'SQ1
    Indices(0) = 0
    Indices(1) = 3
    Indices(2) = 1

    Indices(3) = 4
    Indices(4) = 2
    Indices(5) = 5

    'SQ2
    Indices(6) = 3
    Indices(7) = 6
    Indices(8) = 4

    Indices(9) = 7
    Indices(10) = 5
    Indices(11) = 8

    D3DIndexBuffer8SetData m_GroundIB, _
                           0, _
                           (2 * m_NumTileIndices), _
                           D3DLOCK_READONLY, _
                           Indices(0)

'Rendering code....

        .SetTransform D3DTS_VIEW, g_viewMatrix
        .SetTexture 0, m_GroundTexture
        .SetVertexShader D3DFVF_COLORVERTEX
        .SetStreamSource 0, m_GroundVB, Len(v)
        .SetIndices m_GroundIB, 0

            .DrawIndexedPrimitive D3DPT_TRIANGLESTRIP, _
                                  0, _
                                  m_NumTileIndices, _
                                  0, _
                                  8



Wed, 29 Sep 2004 18:08:50 GMT  
 Indexed primitives anyone?
The way you are winding your triangle strip would require the D3DCULL_CW
render state to be set, rather than D3DCULL_CCW (the default).

See the recent thread regarding the complexities of rendering rows of
triangle strips.  Basically you are going to end up creating extra faces
with no area, playing with swap orders, etc.  Then you have to decide if you
will have enough vertices to describe your texture coordinates, etc. the way
you want.

NVIDIA has a strip library that you might want to dig through, the code
looks pretty cool.  However, it is written for C++ programmers.  The code
that stitches the strips together using degenerate triangles might be worth
looking at.

http://developer.nvidia.com/view.asp?IO=nvtristrip_library

Regarding your crashes, I noticed a few things looking at your code.  Mind
you that I did not spend a lot of time looking at it though!

CreateIndexBuffer has the number of indices specified, rather than the
length in bytes. i.e. Len(Indices(0)) * M_NumTileIndices

I'm not sure you need to lock your buffer as read only, it looks like you
want to write to the buffer.

What is the Len(v)?  Is this the same as Len(m_grVerts(0))?

hth

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Thu, 30 Sep 2004 01:15:52 GMT  
 Indexed primitives anyone?
You may want also to double check the declaration for g_verts to ensure it
matches the format.

For this kind of things, dbmon.exe and the debug runtime should provide
valuable information...



Quote:
> Hi all,

> im trying to use indexed primitives and i can't quite get to grips with
it,
> i'm sure its the order of my indexes but,, i cant quite get the right
order,
> can anyone give me a hint??

> also, this code seems to crash vb6 fairly regularly,, methinks im leaking
> memory,, but how!!!???

> cheers,

> nige.

>     m_NumTileVertices = 9
>     m_NumTileIndices = 12

>     'Create vertex buffer for ground object
>     Set m_GroundVB = g_dev.CreateVertexBuffer(m_NumTileVertices *
> Len(m_grVerts(0)), _
>                                               0, _
>                                               D3DFVF_COLORVERTEX, _
>                                               D3DPOOL_MANAGED)

> 'build the reference points
>     ReDim m_grVerts(9)

>         m_grVerts(0).v.x = 0
>         m_grVerts(0).v.y = 0
>         m_grVerts(0).v.z = 0

>         m_grVerts(1).v.x = 3
>         m_grVerts(1).v.y = 0
>         m_grVerts(1).v.z = 0

>         m_grVerts(2).v.x = 6
>         m_grVerts(2).v.y = 0
>         m_grVerts(2).v.z = 0

>         m_grVerts(3).v.x = 0
>         m_grVerts(3).v.y = 0
>         m_grVerts(3).v.z = 3

>         m_grVerts(4).v.x = 3
>         m_grVerts(4).v.y = 0
>         m_grVerts(4).v.z = 3

>         m_grVerts(5).v.x = 6
>         m_grVerts(5).v.y = 0
>         m_grVerts(5).v.z = 3

>         m_grVerts(6).v.x = 0
>         m_grVerts(6).v.y = 0
>         m_grVerts(6).v.z = 6

>         m_grVerts(7).v.x = 3
>         m_grVerts(7).v.y = 0
>         m_grVerts(7).v.z = 6

>         m_grVerts(8).v.x = 6
>         m_grVerts(8).v.y = 0
>         m_grVerts(8).v.z = 6

>     D3DVertexBuffer8SetData m_GroundVB, _
>                             0, _
>                             (Len(m_grVerts(0)) * m_NumTileVertices), _
>                             0, _
>                             m_grVerts(0)

>     ReDim Indices(m_NumTileIndices)

>     'Create the index buffer
>     Set m_GroundIB = g_dev.CreateIndexBuffer(m_NumTileIndices, _
>                                              0, _
>                                              D3DFMT_INDEX16, _
>                                              D3DPOOL_MANAGED)

>     'SQ1
>     Indices(0) = 0
>     Indices(1) = 3
>     Indices(2) = 1

>     Indices(3) = 4
>     Indices(4) = 2
>     Indices(5) = 5

>     'SQ2
>     Indices(6) = 3
>     Indices(7) = 6
>     Indices(8) = 4

>     Indices(9) = 7
>     Indices(10) = 5
>     Indices(11) = 8

>     D3DIndexBuffer8SetData m_GroundIB, _
>                            0, _
>                            (2 * m_NumTileIndices), _
>                            D3DLOCK_READONLY, _
>                            Indices(0)

> 'Rendering code....

>         .SetTransform D3DTS_VIEW, g_viewMatrix
>         .SetTexture 0, m_GroundTexture
>         .SetVertexShader D3DFVF_COLORVERTEX
>         .SetStreamSource 0, m_GroundVB, Len(v)
>         .SetIndices m_GroundIB, 0

>             .DrawIndexedPrimitive D3DPT_TRIANGLESTRIP, _
>                                   0, _
>                                   m_NumTileIndices, _
>                                   0, _
>                                   8



Fri, 01 Oct 2004 19:17:52 GMT  
 Indexed primitives anyone?
eric, firstly many thnx,

Quote:
> CreateIndexBuffer has the number of indices specified, rather than the
> length in bytes. i.e. Len(Indices(0)) * M_NumTileIndices

excellent, this seemed to cure my memory woes..

    Set m_GroundVB = g_dev.CreateVertexBuffer((m_NumTileVertices *
Len(m_grVerts(0))), _
                                              0, _
                                              D3DFVF_COLORVERTEX, _
                                              D3DPOOL_MANAGED)

    D3DVertexBuffer8SetData m_GroundVB, _
                            0, _
                            ((m_NumTileVertices + 1) * Len(m_grVerts(0))), _
                            0, _
                            m_grVerts(0)

    Set m_GroundIB = g_dev.CreateIndexBuffer(Len(m_Indices(0)) *
m_NumTileIndices, _
                                             0, _
                                             D3DFMT_INDEX16, _
                                             D3DPOOL_MANAGED)

    D3DIndexBuffer8SetData m_GroundIB, _
                           0, _
                           (Len(m_Indices(0)) * m_NumTileIndices), _
                           0, _
                           m_Indices(0)

Quote:
> I'm not sure you need to lock your buffer as read only, it looks like you
> want to write to the buffer.

pesky buffer locks...

Quote:
> What is the Len(v)?  Is this the same as Len(m_grVerts(0))?

er, oops,, little bit of legacy code creepin in... tis changed..

Quote:
> The way you are winding your triangle strip would require the D3DCULL_CW
> render state to be set, rather than D3DCULL_CCW (the default).

> See the recent thread regarding the complexities of rendering rows of
> triangle strips.  Basically you are going to end up creating extra faces
> with no area, playing with swap orders, etc.  Then you have to decide if
you
> will have enough vertices to describe your texture coordinates, etc. the
way
> you want.

I had read thru the previous thread,, but knowing myself pretty well i read
thru again to see what i had missed. One thing that confused me is the
orientation of the square,, why does zero start in top left rather than
bottom left.. to look at i would have though you would require negative
coords to make your grid work..?

   0         1         2
    +         +         +
    3         4          5
    +         +         +
    6         7          8
    +         +         +

for me it should look like this...

   6         7          8
    +         +         +
    3         4          5
    +         +         +
   0         1         2
    +         +         +

or am i being weird?

anyways, im afraid it didnt quite work out... and im not sure what im
missing,,, the theory is sound,, i mean what are we doing here but playing
join-the-dots?? so i have an array of dots and i have an array of coords (of
these dots) to make the lines,, i only have to make sure the dots are joined
in the correct order,, alas no... it does seem to render the top row ok,,
but the second row doesnt appear, instead the a line is drawn from 5 back to
0...

heres how i implemented your psud code thus based on the original grid..

zplane   0         1         2
            +         +         +
            3         4          5
            +         +         +
            6         7          8
            +         +         +
                xplane

    m_NumTileVertices = 9
    m_NumTileIndices = 24

    ReDim m_grVerts(9)

    'Row 1
    m_grVerts(0) = GetCustomVEC(0, 0, 6)
    m_grVerts(1) = GetCustomVEC(3, 0, 6)
    m_grVerts(2) = GetCustomVEC(6, 0, 6)
    'Row 2
    m_grVerts(3) = GetCustomVEC(0, 0, 3)
    m_grVerts(4) = GetCustomVEC(3, 0, 3)
    m_grVerts(5) = GetCustomVEC(6, 0, 3)
    'Row 3
    m_grVerts(6) = GetCustomVEC(0, 0, 0)
    m_grVerts(7) = GetCustomVEC(3, 0, 0)
    m_grVerts(8) = GetCustomVEC(6, 0, 0)

    'create indices
    m_Indices(0) = 3
    m_Indices(1) = 0
    m_Indices(2) = 4

    m_Indices(3) = 4
    m_Indices(4) = 0
    m_Indices(5) = 1

    m_Indices(6) = 4
    m_Indices(7) = 1
    m_Indices(8) = 5

    m_Indices(9) = 5
    m_Indices(10) = 1
    m_Indices(11) = 2

    m_Indices(12) = 6
    m_Indices(13) = 3
    m_Indices(14) = 7

    m_Indices(15) = 7
    m_Indices(16) = 3
    m_Indices(17) = 4

    m_Indices(18) = 7
    m_Indices(19) = 4
    m_Indices(20) = 8

    m_Indices(21) = 8
    m_Indices(22) = 4
    m_Indices(23) = 5

(and to render....)

        .DrawIndexedPrimitiveUP D3DPT_TRIANGLELIST, _
                                0, _
                                9, _
                                8, _
                                m_Indices(0), _
                                D3DFMT_INDEX16, _
                                m_grVerts(0), _
                                Len(m_grVerts(0))

Quote:
> NVIDIA has a strip library that you might want to dig through, the code
> looks pretty cool.  However, it is written for C++ programmers.  The code
> that stitches the strips together using degenerate triangles might be
worth
> looking at.

there seems to be plenty there, i downloaded the source ,, but i'm afraid it
reminded my of why i program in vb... ;-) i will persevere however...

apologies for the large post,, again,, many thnx...

nige.



Sat, 02 Oct 2004 01:08:29 GMT  
 Indexed primitives anyone?
Hi Nige,

Comments inline...


Quote:
> ...
> I had read thru the previous thread,, but knowing myself pretty well i
read
> thru again to see what i had missed. One thing that confused me is the
> orientation of the square,, why does zero start in top left rather than
> bottom left.. to look at i would have though you would require negative
> coords to make your grid work..?

>    0         1         2
>     +         +         +
>     3         4          5
>     +         +         +
>     6         7          8
>     +         +         +

> for me it should look like this...

>    6         7          8
>     +         +         +
>     3         4          5
>     +         +         +
>    0         1         2
>     +         +         +

> or am i being weird?

I don't think it really matters where you start. You could start at the
bottom-right corner if you like. It's all just positional information. The
important thing is that your winding is consistent (i.e. always draw your
tris clockwise or counterclockwise) to take advantage of backface culling. I
try to start at the top-left because that's how the screen and my bitmaps
are laid out. I'm not sure what you mean by having negative coordinates to
get it to work (or why this would be a bad thing), but my grid is centered
on the origin so half my coordinates are always gonna be negative.

- Show quoted text -

Quote:
> ...

> heres how i implemented your psud code thus based on the original grid..

> zplane   0         1         2
>             +         +         +
>             3         4          5
>             +         +         +
>             6         7          8
>             +         +         +
>                 xplane

>     m_NumTileVertices = 9
>     m_NumTileIndices = 24

>     ReDim m_grVerts(9)

>     'Row 1
>     m_grVerts(0) = GetCustomVEC(0, 0, 6)
>     m_grVerts(1) = GetCustomVEC(3, 0, 6)
>     m_grVerts(2) = GetCustomVEC(6, 0, 6)
>     'Row 2
>     m_grVerts(3) = GetCustomVEC(0, 0, 3)
>     m_grVerts(4) = GetCustomVEC(3, 0, 3)
>     m_grVerts(5) = GetCustomVEC(6, 0, 3)
>     'Row 3
>     m_grVerts(6) = GetCustomVEC(0, 0, 0)
>     m_grVerts(7) = GetCustomVEC(3, 0, 0)
>     m_grVerts(8) = GetCustomVEC(6, 0, 0)

>     'create indices
>     m_Indices(0) = 3
>     m_Indices(1) = 0
>     m_Indices(2) = 4

>     m_Indices(3) = 4
>     m_Indices(4) = 0
>     m_Indices(5) = 1

>     ...

> (and to render....)

>         .DrawIndexedPrimitiveUP D3DPT_TRIANGLELIST, _
>                                 0, _
>                                 9, _
>                                 8, _
>                                 m_Indices(0), _
>                                 D3DFMT_INDEX16, _
>                                 m_grVerts(0), _
>                                 Len(m_grVerts(0))

Why are you using DrawIndexedPrimitiveUP? You went through the trouble of
setting up a VB and IB, then you never use them. Try this line:

    .DrawIndexedPrimitive D3DPT_TRIANGLELIST,
                                        0, _
                                        24, _
                                        0, _
                                        8

Also, be sure to SetStreamSource to your vertex buffer and SetIndices to
your index buffer before the call to DrawIndexedPrimitive.

Hope that helps,

Tim



Sat, 02 Oct 2004 01:59:36 GMT  
 Indexed primitives anyone?
Hi patrice,,

Quote:
> You may want also to double check the declaration for g_verts to ensure it
> matches the format.

Private Type CUSTOMVERTEX
    v As D3DVECTOR
    'color As Long
    'tu As Single
    'tv As Single
End Type

Private m_grVerts() As CUSTOMVERTEX

look good? the commented out bits are for color and texture when the code is
implemented properly

Quote:
> For this kind of things, dbmon.exe and the debug runtime should provide
> valuable information...

running with debug gives me automation errors when the following executes..

        .DrawIndexedPrimitiveUP D3DPT_TRIANGLELIST, _
                                0, _
                                9, _
                                8, _
                                m_Indices(0), _
                                D3DFMT_INDEX16, _
                                m_grVerts(0), _
                                Len(m_grVerts(0))

never used dbmon,, so i gave it a try,, doesnt seem to output my debug
commands in the dos window tho... i have seen something similar using an
api.. how do u use this?

Im pretty sure you emailed me recently re: quaternions and im also pretty
sure i did not reply,, i apologise for that profusely..!!

I promise,, i have a good excuse..

thnx,

nige.



Sat, 02 Oct 2004 02:17:52 GMT  
 Indexed primitives anyone?
Tim,

Quote:
> I don't think it really matters where you start. You could start at the
> bottom-right corner if you like. It's all just positional information. The
> important thing is that your winding is consistent (i.e. always draw your
> tris clockwise or counterclockwise) to take advantage of backface culling.
I
> try to start at the top-left because that's how the screen and my bitmaps
> are laid out. I'm not sure what you mean by having negative coordinates to
> get it to work (or why this would be a bad thing), but my grid is centered
> on the origin so half my coordinates are always gonna be negative.

cool, that pretty much confirms what i thought,, my confusion lie in that
the coords given started in the top left corner of the grid and wound right
and down, which to me means decrementing the z coord rather than
incrementing, which seemed to be part of the code shown..

Quote:
> Why are you using DrawIndexedPrimitiveUP? You went through the trouble of
> setting up a VB and IB, then you never use them. Try this line:

>     .DrawIndexedPrimitive D3DPT_TRIANGLELIST,
>                                         0, _
>                                         24, _
>                                         0, _
>                                         8

ok, no other reason than trying to get eric's example working from the
previous thread,,, i had used the same call as u give b4. And still,, with
this done the triangles will not render properly..

Quote:

> Also, be sure to SetStreamSource to your vertex buffer and SetIndices to
> your index buffer before the call to DrawIndexedPrimitive.

yep... dun

the only other things i can think of...

my cull setting is ccw,, which seems ok..

in fact thats it,, i know this all works as i have a function ('borrowed'
from the dxsdk pointsprites example) that draws a grid to a max size using
trianglelists correctly,, its now a question of understanding why this
doesnt work...

cheers,

nige.



Sat, 02 Oct 2004 02:25:38 GMT  
 Indexed primitives anyone?

Quote:
> Private Type CUSTOMVERTEX
>     v As D3DVECTOR
>     'color As Long
>     'tu As Single
>     'tv As Single
> End Type

> Private m_grVerts() As CUSTOMVERTEX

> look good? the commented out bits are for color and texture when the code
is
> implemented properly

Looks good, so long as your vertex shader is set only to D3DFVF_XYZ - your
vertex shader must always match what is defined for your primitive type.

Quote:
> > For this kind of things, dbmon.exe and the debug runtime should provide
> > valuable information...

Keep in mind that it won't tell you when a triangle is back face culled
(hidden) due to a problem with the winding order.

Quote:
> never used dbmon,, so i gave it a try,, doesnt seem to output my debug
> commands in the dos window tho... i have seen something similar using an
> api.. how do u use this?

Did you turn up the debug levels in the DX control panel?  Also, DBMON only
shows debug output on W2K (and XP with DX8.1).

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Sat, 02 Oct 2004 04:33:08 GMT  
 Indexed primitives anyone?

Quote:
> cool, that pretty much confirms what i thought,, my confusion lie in that
> the coords given started in the top left corner of the grid and wound
right
> and down, which to me means decrementing the z coord rather than
> incrementing, which seemed to be part of the code shown..

I initially misunderstood their post and was demonstrating triangle lists.
A lot of code in that thread was for strips.  I don't know if this is part
of the confusion.  As far as the coordinates, they can be centered however
you want.  Whatever makes sense to you would be the best.

But I still suggest using triangle lists instead of strips.

Quote:
> And still,, with
> this done the triangles will not render properly..

Properly, as in not showing up?  Try testing your code with no back face
culling to check your winding order.

Quote:
> in fact thats it,, i know this all works as i have a function ('borrowed'
> from the dxsdk pointsprites example) that draws a grid to a max size using
> trianglelists correctly,, its now a question of understanding why this
> doesnt work...

You will have to compare what they did with what you are not doing.

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Sat, 02 Oct 2004 04:39:25 GMT  
 Indexed primitives anyone?

Quote:
> I initially misunderstood their post and was demonstrating triangle lists.
> A lot of code in that thread was for strips.  I don't know if this is part
> of the confusion.  As far as the coordinates, they can be centered however
> you want.  Whatever makes sense to you would be the best.

> But I still suggest using triangle lists instead of strips.

the sdk suggests strips as optimal? (for now ill get either one working :-)

Quote:
> Properly, as in not showing up?  Try testing your code with no back face
> culling to check your winding order.

i've set culling to;

.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE)

but with the same results,, the bottom row isnt rendered.

Quote:
> You will have to compare what they did with what you are not doing.

hehe, yep, i am, honest... ok,, i have a book on the way wich hopefully will
anser my questions.. however u guys seem to have a lot of the answers about
winding orders and memory allocation which are barely mentioned in the sdk
docs,, d u have a reference u can share? Or recommend a book?

thnx,

nige.



Sat, 02 Oct 2004 17:19:15 GMT  
 Indexed primitives anyone?

Quote:
> Looks good, so long as your vertex shader is set only to D3DFVF_XYZ - your
> vertex shader must always match what is defined for your primitive type.

the call seems to be doing the job required.

Quote:
> Keep in mind that it won't tell you when a triangle is back face culled
> (hidden) due to a problem with the winding order.

k.

Quote:
> Did you turn up the debug levels in the DX control panel?  Also, DBMON
only
> shows debug output on W2K (and XP with DX8.1).

aha, that would be the problem then... win98.

thnx anyway,, will have to stick to my debug class...

nige.



Sat, 02 Oct 2004 17:27:52 GMT  
 Indexed primitives anyone?
Okay, I plugged your data into my program and the only thing I can figure
out is that your primitive count is wrong. If you're doint a triangle strip
and using the spiral method, you're going to have two extra triangles for
each row except the last one. I use the following formula for figuring out
the primitive count:

    P = 2mn + 2(n-1)

Where m is the number of columns across and n is the number of rows down for
your grid. If you have a 2x2 grid, then the primitive count is 10. Calling
DIP with 10 for the primitive count parameter properly renders your data.

Hope that helps,

Tim


Quote:
> Tim,

> > I don't think it really matters where you start. You could start at the
> > bottom-right corner if you like. It's all just positional information.
The
> > important thing is that your winding is consistent (i.e. always draw
your
> > tris clockwise or counterclockwise) to take advantage of backface
culling.
> I
> > try to start at the top-left because that's how the screen and my
bitmaps
> > are laid out. I'm not sure what you mean by having negative coordinates
to
> > get it to work (or why this would be a bad thing), but my grid is
centered
> > on the origin so half my coordinates are always gonna be negative.

> cool, that pretty much confirms what i thought,, my confusion lie in that
> the coords given started in the top left corner of the grid and wound
right
> and down, which to me means decrementing the z coord rather than
> incrementing, which seemed to be part of the code shown..

> > Why are you using DrawIndexedPrimitiveUP? You went through the trouble
of
> > setting up a VB and IB, then you never use them. Try this line:

> >     .DrawIndexedPrimitive D3DPT_TRIANGLELIST,
> >                                         0, _
> >                                         24, _
> >                                         0, _
> >                                         8

> ok, no other reason than trying to get eric's example working from the
> previous thread,,, i had used the same call as u give b4. And still,, with
> this done the triangles will not render properly..

> > Also, be sure to SetStreamSource to your vertex buffer and SetIndices to
> > your index buffer before the call to DrawIndexedPrimitive.

> yep... dun

> the only other things i can think of...

> my cull setting is ccw,, which seems ok..

> in fact thats it,, i know this all works as i have a function ('borrowed'
> from the dxsdk pointsprites example) that draws a grid to a max size using
> trianglelists correctly,, its now a question of understanding why this
> doesnt work...

> cheers,

> nige.



Sun, 03 Oct 2004 00:15:36 GMT  
 Indexed primitives anyone?

Quote:
> the sdk suggests strips as optimal?

If strips were optimal for everything, we would not need any other primitive
types.  Those are "general guidelines".  Your app requirements will
determine which method is best.

Quote:
> hehe, yep, i am, honest... ok,, i have a book on the way wich hopefully
will
> anser my questions.. however u guys seem to have a lot of the answers
about
> winding orders and memory allocation which are barely mentioned in the sdk
> docs,, d u have a reference u can share? Or recommend a book?

I have a large bookshelf full of books, however they all mostly deal with DX
& C++, no DX & VB books.  I suggest Real-Time Rendering by Tomas Moller and
Eric Haines, any of the Watt books like 3D Computer Graphics, 3D Games, etc.
or Computer Graphics Principles and Practice by Foley, van Dam, Feiner and
Hughes.

The SDK docs are not meant to teach you everything about 3D, they are just
there to document the available functions, etc.

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Sun, 03 Oct 2004 00:21:46 GMT  
 Indexed primitives anyone?

Quote:
> aha, that would be the problem then... win98.

It's called Debug View, get it for your 98 box...

http://www.sysinternals.com

There was a *very* recent post on this before.

--
Eric DeBrosse
http://www.blown.com/dx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.



Sun, 03 Oct 2004 00:25:10 GMT  
 Indexed primitives anyone?

Quote:
> It's called Debug View, get it for your 98 box...

it's easy when u know how... many thnx,,

nige. ;-)



Sun, 03 Oct 2004 05:19:12 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Too many indexes - Wierd hidden indexes preventing index add

2. Primitive types

3. Question about "Primitives"

4. any asm code for line primitives?

5. STL2VB ( Data structures and primitives ) MFC CList and CMap as well

6. Line drawing graphics primitive

7. Primitive Connection Manager

8. Primitive Connection Manager

9. a very primitive question...

10. Using Mesh verses primitives

11. Retrieving 2D screen coordinates of a D3D primitive

12. Native primitives?

 

 
Powered by phpBB® Forum Software