## Recommended Posts

FMDGames    134
I'm trying to display a quad which is white, and i have a background which is black (or textured if skybox is drawn). I can see everything else in game. The problem is i cannot see my quad. I know my vertex layout should work since i tested it manually on a seperate project before i touched this. Im using FVF: D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 and my triangles:
//locked the buffer etc
top = 0.0f;
left = 0.0f;
width = 400.0f;
height = 100.0f;

TLVERTEX V[6] =
{
{left, top, 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},	//Vertex 1 - Red	(250, 100)
{(left+width), 0.0f, 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},	//Vertex 2 - Green	(400, 350)
{(left+width), (top+height), 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},	//Vertex 3 - Blue	(100, 350)
{(left+width), (top+height), 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},
{left, (top+height), 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},
{left, top, 1.5f, 1.0f, D3DCOLOR_XRGB(128, 128, 128),},
};


Ive disabled lighting and can't think what else to do. I've tried commenting out camera control lines but no avail. If you need any more details let me know.
//Rendering code for quad
Gfx.pD3DDevice9-&gt;SetRenderState(D3DRS_LIGHTING, false);
Gfx.pD3DDevice9-&gt;SetMaterial(Mtrls);
Gfx.pD3DDevice9-&gt;SetFVF(D3DFVF_TLVERTEX);
Gfx.pD3DDevice9-&gt;DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);


Thanks for any hints :)

##### Share on other sites
greenwire    145
you could try disabling the z-buffer before drawing the quad.
or maybe reverse the winding order of the verts, coz it might be facing away from camera.

##### Share on other sites
FMDGames    134
i've tried disabling the zbuffer, and occusion culling is disabled also, so i dont understand why it is not visible. I dont think the order is a problem, at least it wasnt in my test application :|

##### Share on other sites
For RHW coords, Z has to be from 0 to 1.

##### Share on other sites
FMDGames    134
Nope, that didn't seem to make any difference either. I tried it with 1.5f as a test but it was originally set to 1.0f and i replaced them to 1.0f again.

##### Share on other sites
kovacsp    306
Quote:
 Original post by FMDGamesi've tried disabling the zbuffer, and occusion culling is disabled also, so i dont understand why it is not visible. I dont think the order is a problem, at least it wasnt in my test application :|

I think greenwire didn't mean occlusion culling, but simple culling! (set D3DRS_CULLMODE to D3DCULL_NONE)

kp

##### Share on other sites
FMDGames    134
Sorry, thats what i meant, not good with descriptions sometimes. I relatively new to this sort of stuff :)

##### Share on other sites
kovacsp    306
Hi,

you should try these then:
cullmode: none
zenable, zwriteenable: false
lighting: false
alphablendenable: false

also, have a good look at the transformations you use! (world, view, proj) make sure your quad is really on the screen!

I use the following transforms when doing a billboard with RHW:
int width, height;p_rView->GetSizeInPixels(width, height);D3DXMatrixOrthoLH(&matOrtho, (float)width, (float)height, 0.0f, 1.0f);D3DXMatrixIdentity(&matIdentity);guard.SetTransform(D3DTS_PROJECTION, &matOrtho);guard.SetTransform(D3DTS_WORLD, &matIdentity);guard.SetTransform(D3DTS_VIEW, &matIdentity);

kp

##### Share on other sites
FMDGames    134
I didnt have any success with that. I do think its something to do with the transformations, since im setting them for my space objects. I tried the code which you used but that didn't seem to work either. I did note that the projection transformation code was only in the initialization and not in the render loop, so it caused the whole screen to go dull?

So im still very confused at the moment :)

##### Share on other sites
kovacsp    306
you should have a look at some tutorials in this topic then. maybe you can use some parts of the sources, or get the idea you're missing:
2D in 3D, and 2D in Direct3D using Textured Quads

kp

##### Share on other sites
greenwire    145
XYZRHW are pre-transformed, so setting the transform should have no effect.
when i've had the problem you're having it's usually the winding order.
(swapping your first two verts temporarily would confirm this isnt the case)

but you could post the code where you make and fill your vertexbuffer, maybe something is wrong there.

##### Share on other sites
FMDGames    134
I think i found the problem, it was to do with the winding order, but more importantly it was the D3DRS_CULLMODE was being set during the skybox rendering therefore the D3DRS_CULLMODE set during init took no effect!

PS - if i have any other problems ill post here :)

##### Share on other sites
kovacsp    306
Quote:
 Original post by FMDGamesI think i found the problem, it was to do with the winding order, but more importantly it was the D3DRS_CULLMODE was being set during the skybox rendering therefore the D3DRS_CULLMODE set during init took no effect!

conclusion: everyone should have a state guard thingy, which sets the changed render states back in its destructor, at the end of the block/function. [smile]

kp

##### Share on other sites
FMDGames    134
almost came running back crying :P

tried to create another box and it wouldnt render it, then i noticed i was re-enabling culling in the for loop, but only disabling it once before the for loop. So the first object was drawn, but objects after were culled. :P soo many bugs to find :)

## Create an account

Register a new account