Jump to content
  • Advertisement
Sign in to follow this  

Alpha square

This topic is 4358 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!