Sign in to follow this  
FMDGames

Coloured Quad Problem

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->SetRenderState(D3DRS_LIGHTING, false);
Gfx.pD3DDevice9->SetMaterial(Mtrls);
Gfx.pD3DDevice9->SetStreamSource(0, Quad,0, sizeof(TLVERTEX));
Gfx.pD3DDevice9->SetFVF(D3DFVF_TLVERTEX);
Gfx.pD3DDevice9->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

Thanks for any hints :)

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
kovacsp    306
Quote:
Original post by FMDGames
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 :|


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

kp

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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!

Thanks for your time!

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

Share this post


Link to post
Share on other sites
kovacsp    306
Quote:
Original post by FMDGames
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!

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 this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this