Coloured Quad Problem

Started by
12 comments, last by FMDGames 18 years, 1 month ago
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 :)
Advertisement
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.
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 :|
For RHW coords, Z has to be from 0 to 1.
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.
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
------------------------------------------------------------Neo, the Matrix should be 16-byte aligned for better performance!
Sorry, thats what i meant, not good with descriptions sometimes. I relatively new to this sort of stuff :)
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
------------------------------------------------------------Neo, the Matrix should be 16-byte aligned for better performance!
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 :)
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
------------------------------------------------------------Neo, the Matrix should be 16-byte aligned for better performance!

This topic is closed to new replies.

Advertisement