Alpha square

Started by
1 comment, last by mvtapia 17 years, 10 months ago
I have a very silly problem, I took the "Programming a Multiplayer FPS in DirectX" And I'm changing somethings. The Engine does everything ok. the problem is that I want to draw a square in front of the screen and have a little blend and color. I can get the square to work but it comes out gray. Now this is a newby question and I don't think there should be a problem cracking this. Here is some code:


#ifndef CUSTOMFVF
#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
#endif

//-----------------------------------------------------------------------------
// Custom Vertex Structure
//-----------------------------------------------------------------------------
struct CUSTOMVERTEX
{
    FLOAT x, y, z, rhw;		// from the D3DFVF_XYZRHW flag.
    D3DCOLOR diffuse;		// The color of the vertex.
};

	LPDIRECT3DVERTEXBUFFER9 t_buffer;
	VOID* pVoid;    // the void* we were talking about
	CUSTOMVERTEX m_filter[4];

	g_engine->GetDevice()->CreateVertexBuffer(4*sizeof(CUSTOMVERTEX),
                          0 /*D3DUSAGE_WRITEONLY | D3DUSAGE_DONOTCLIP*/,
                          CUSTOMFVF,
                          D3DPOOL_MANAGED,
                          &t_buffer,
                          NULL);

		// Vertices.
		m_filter[0].x = 10.0f;
		m_filter[0].y = 10.0f;
		m_filter[0].z = 0.0f;
		m_filter[0].rhw = 1.0f;
		m_filter[0].diffuse = 0xffff0000;//D3DCOLOR_ARGB( a, r, 0, 0);
	
		m_filter[1].x = 100;//(float)g_engine->GetDisplayMode()->Width;
		m_filter[1].y = 10.0f;
		m_filter[1].z = 0.0f;
		m_filter[1].rhw = 1.0f;
		m_filter[1].diffuse = D3DCOLOR_ARGB( a, 0, g, 0);
	
		m_filter[2].x = 10.0f;
		m_filter[2].y = 100;//(float)g_engine->GetDisplayMode()->Height;
		m_filter[2].z = 0.0f;
		m_filter[2].rhw = 1.0f;
		m_filter[2].diffuse = D3DCOLOR_ARGB( a, 0, 0, b);

		m_filter[3].x = 100;//(float)g_engine->GetDisplayMode()->Width;
		m_filter[3].y = 100;//(float)g_engine->GetDisplayMode()->Height;
		m_filter[3].z = 0.0f;
		m_filter[3].rhw = 1.0f;
		m_filter[3].diffuse = D3DCOLOR_ARGB( a, 0, 0, b);

		t_buffer->Lock(0, sizeof(m_filter), (void**)&pVoid, 0);    // locks t_buffer, the buffer we made earlier

		memcpy(pVoid, m_filter, sizeof(m_filter));    // copy vertices to the vertex buffer
		
		t_buffer->Unlock();    // unlock t_buffer

		g_engine->GetDevice()->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);

		g_engine->GetDevice()->SetStreamSource(0, t_buffer, 0, sizeof(CUSTOMVERTEX));

		g_engine->GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

Now this is shameful, but please help me out.
Marco Tapia
Advertisement
Your Vertex Processing looks fine for me but I cannot see any code for the pixel processing. You have to set a shader or setup the fixed function pixel processing pipeline, too.
Got it. I had to put

g_engine->GetDevice()->SetTexture( 0, NULL );
Marco Tapia

This topic is closed to new replies.

Advertisement