Texture flickers when Rendering on primitives

I'm currently writing an dx-mesh-editor to create my own meshes, I use Visual Basic 6 with  DX8.1 even if it's a little older and I have DX9.0c installed too. All fine so far.
I'm  using the D3DVERTEX-Type - drawn directly into world space (X,Y,Z) , also Normals and Textur-coordinates(tU+tV).
My Cursor is a simple XMesh with some material but no Texture.  So I have to call device.setTexture 0, Nothing  before I render  the cursor, which is the last Object in my scene.

when I apply a texture to any of the primitives which are rendered first in the scene the texture applied on the primitives flickers and moves and so do all other objects that have a Texture.

If there are just Meshes to draw it works like it's supposed to. Even if some of them have a texture and others don't.  All exactly the same renderstates & settings. 

It did help a little to set some TextureStageStates to LinearMipmap but it does not solve the problem .
If   I .SetTextureStageState 0, D3DTSS_TEXCOORDINDEX, to something like &H10000,&H20000 or &H30000 it works fine- but I dont want to have my Texture  look like that (It mirrors the Texture onto the primitives as if it was a Water-Surface reflecting the Sky)
 
What am I doing wrong

-scuse my bad and rusty english, it's been a while ago I used it-




Edit: Ok, I've found a Workaround :
it works if I create an array of 3dObjects, call them "TextureKeeper", for the first TextureKeeper(0) I have to load a simple Mesh with one Material and one Texture applied.
Then I  redim  the array of TextureKeepers for each new Material that gets indicated by the user, set
 TextureKeeper(theNewOne) = TextureKeeper(0),
transform them onto a place in worldspace OutOfSight and just before I render my primitive I call

for MaterialToUse =1 to nMaterials

if myMaterial(MaterialToUse).hasTexture
    '(setTransform OutOfSight somehow)
    device.setTexture 0, myD3DTexture(
MaterialToUse)
    TextureKeeper(
MaterialToUse).Mesh DrawSubset 0
else
      device.setTexture 0,Nothing
endif

setTransform back to world coordinates
then follows the DrawTriangle-List call for CurrentMaterial

next CurrentMaterial

It works but it limits me to one texture per Material.
Maybe anyone out there knows some better way



Answer this question

Texture flickers when Rendering on primitives

  • JimSeidel

    It's just to tell that I've found an easier way, I can use the same "Texture-Keeper" for all the textures I use and I dont need separate "Texturekeepers" for each texture, it works to draw the same mesh one with another texture just before drawing the primitive list.

  • Shaik Habeeb

    Reposting your workaround to close the thread:
    Edit: Ok, I've found a Workaround :
    it works if I create an array of 3dObjects, call them "TextureKeeper", for the first TextureKeeper(0) I have to load a simple Mesh with one Material and one Texture applied.
    Then I  redim  the array of TextureKeepers for each new Material that gets indicated by the user, set
     TextureKeeper(theNewOne) = TextureKeeper(0),
    transform them onto a place in worldspace OutOfSight and just before I render my primitive I call

    for MaterialToUse =1 to nMaterials

    if myMaterial(MaterialToUse).hasTexture
        '(setTransform OutOfSight somehow)
        device.setTexture 0, myD3DTexture(
    MaterialToUse )
        TextureKeeper(
    MaterialToUse ).Mesh DrawSubset 0
    else
          device.setTexture 0,Nothing
    endif

    setTransform back to world coordinates
    then follows the DrawTriangle-List call for CurrentMaterial

    next CurrentMaterial

    It works but it limits me to one texture per Material.
    Maybe anyone out there knows some better way



  • Texture flickers when Rendering on primitives