D3DPT_POINTLIST And D3DPT_LINELIST don't work!

Started by
13 comments, last by Cipher3D 20 years, 8 months ago
You''re probably not getting points and lines because of:

1) You''ve still got blending enabled, which you may, but probably don''t want.

2) You''ve still got a texture with transparent pixels at 0,0, which is the UV you gave your lines and points. Lines and points will use textures if you tell them to, just like triangles do.

3) You never set any texturestagestates when trying to draw lines and points. The color of lines and points is based on the output of texturestages, just line triangles.

4) Your line is 1 primitive, not 2. It takes 2 points to make a line, just like it takes 3 vertices to make a triangle, but it''s still 1 primitive.

5) As said, you never set the FVF. The FVF is the same as when drawing quads in your case. It just defines your vertex structure, which you''ve made identical to your quads(x,y,z,rhw,diffuse,u,v). Just copy that code from your quad function.

6) That article is really bad. They don''t fully setup texture states, and just assume they''re default. If you render something else that changes states, then render a quad with their technique, the output is not fully defined. Also, locking and drawing each quad? And no warning that it''s just a beginner level tutorial, and that this isn''t what you should really do? Some of these articles need big, bold, flashing, warnings on them.
Advertisement
can you please clarify points 3 and 5? thx.
I eat heart attacks
The FVF is covered by an Anonymous Poster above. Your vertices are of type D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1.
In DX8: pDev->SetVertexShader(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)
In DX9: pDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

For the texturestagestates... hmmm. How much detail do post.

The color drawn to the backbuffer is based on a the flow through the texture stages. They can be programmed to read textures, use diffuse color, use a constant color, and to mix these in a variety of ways, such as multiplication, addition.

// Setup to mix diffuse and texture color and alpha for quadspDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);pDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);pDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

This says for stage 0:
modulate (multiply - colors are treated as 3 floats from 0 to 1) the texture by the diffuse color. Then it says modulate the texture alpha and diffuse alpha.

Then for stage 1, it says "I''m done".

Odds are for lines and points you don''t want textures, just the diffuse color so you''d do this instead:
// Setup texture stages for diffuse color only, and use diffuse alphapDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);pDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);


The number of stages you use will increase as you start doing multitexturing, and complex blending operations. The output of stage 0 and be used as the input to stage 1. The output from stage 1 can be the input to stage 2, and so on.

On modern cards you can also write to a temporary register. ie: Stage 0, calculate something and save it. Stage 1, calculate something entirely different. Stage 2, Modulate Stage 1 with Temp.

What each operation does is covered fairly well in the docs, and in the d3d9types.h file.
thx a lot ! My lines and pixels finally work, and now all i gotta do is optimize the hell outta it.
I eat heart attacks
quote:Original post by Cipher3D
My lines and pixels finally work, and now all i gotta do is optimize the hell outta it.


No. What you need to do is learn more about how Direct3D works. There are quite a few good books out there as well as many tutorial web sites.

You''re still very new to Direct3D and many things that may seem like optimizations can end up having no effect or a negative effect. I''ve seen many people at about this level go off to optimize their engine and most often they end up wasting their time because they don''t understand exactly what made things slow in the first place.

This isn''t a shot at you. We were all newbies once and we''re all still learning. I''m just trying to steer you towards a better path to get where you want to go.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement