# DX10... 3dMax Drawing..ZBuffer?

## Recommended Posts

[attachment=13364:?? ??.png]

Hi...

I use 3dMax, maxscript and DX10.

I guess Zbuffer problem...

But zbuffer setting value is default value( == ON ).

pDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );

cullmode = d3d10_cull_front;

Indexing is fullvertexmodel... like this...

for ( int i = 0; i < nFaceNum; i++ )
{
pstIndices[i].A = j++;
pstIndices[i].B = j++;
pstIndices[i].C = j++;
}


Is related to cullmode, zbuffer or Indexing method ?

I have no idea. Really... @.@

How to solve the problem ?

Edited by AquaMacker

##### Share on other sites

I found this problem...

I insert code pFont->DrawText()... -> This is PROBLEM !!!

Clear~~~~

ObjectDraw() -> Cull_Front
pFont-DrawText()

Present( 0, 0 );


Object draw with Cull_Front ... ONLY !!!

but font->draw() after object seems like to draw Cull_BACK !

I guess DrawText() function is Only Cull_BACK Draw...

Is DrawText() function Bug ?

Edited by AquaMacker

##### Share on other sites

DrawText sets some device state in order to do its job, and it's not resetting the state for you. You should explicitly set all the states upon drawing your objects.

##### Share on other sites

Thanks
I'll try.

hmm...
I decided to use DX10.1. Direct2D...

DrawText is hard to use...

Edited by AquaMacker

##### Share on other sites

Regardless of the API you end up using, my advice is still valid.

##### Share on other sites

end up using ?
pDevice->RSSetState( NULL ) ?

I don't understand what your saying...

Edited by AquaMacker

##### Share on other sites
Just before you draw your objects (at each frame), set all the states that affect the rendering of said objects. These include input assembler settings, rasterizer state, blend state, output merger state, shaders, views, textures, samplers, buffers, input layout (and some others). Rendering text usually sets some of these states, and in your case the font object isn't apparently resetting some of the states after drawing; this is why you need to do it.

For a small list of objects this may seem like overkill, but if you have many similar objects you can sort their rendering by the states they use (commonly known as "batching"). This potentially saves a lot of user->kernel transitions (driver calls) - those can eat your cpu cycles fast.

---

Note that if you use ID3DX10Font (this is not apparent in your code), you can use a sprite object that you previously allocated in order to store the font's render states. The sprite object uses a Begin/End pair; the Begin method lets you specify that upon calling End the device state is restored to pre-Begin state. So if you surround the font drawing with the Begin/End of its sprite, you can control whether or not it resets the state for you.

All that said, you can potentially save performance if you still do the state sets manually only when you actually do need to set them. You see, resetting takes the same time or more as setting. Edited by Nik02

##### Share on other sites
Thank you Sooooooooooooooooo much !!!

SO thank you ^^;;;

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Forum Statistics

• Total Topics
628275
• Total Posts
2981740

• 10
• 11
• 17
• 10
• 9