Hey, I *finally* got it working, and I see bitmaps on my screen. I really thank everyone for taking me this far, but there are still just a few more questions I have, if you don't mind.
1) What exactly do all of the SetRenderState() functions do? I read MSDN on a few of the constants you can set, particularly the Alphablend state, for SRCBLEND, etc. The alpha blending modes are very confusing, I don't understand. Here is some code:
m_Device->SetRenderState(D3DRS_LIGHTING, FALSE); m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); m_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); m_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); m_Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
2) My bitmaps seem to be a little bit off on measurements. First thing I notice is that my bitmaps are blittered in a "blurry" state, or anti-aliased. For example, pixels in the bitmap are blurred, I don't know why this is happening. They shouldn't be filtered like that.
3) the RIGHT and BOTTOM edges of my bitmaps seem to be a few pixels short. It seems like these pixels aren't even being copied. Why is this so?
I'm sure most of this has to do with the way I set up my vertex structure. If you could look at my math and possibly lead me in the right direction, I would be much appreciative. Below you will find an updated version of my blitter function.
Take note that this is a method inside an interface of mine. Most of the declarations are hidden from you, yet most of this should be very evident. This function returns 0 on failure, or 1 for success:
int CBitmap::Blitter(int dest_x, int dest_y, RECT* source){ //--Variables--------------------------------------------------- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BitmapVertex* Quad = 0; //-------------------------------------------------------------- if(!m_Display->IsInitialized()) return 0; if(!m_Loaded) return 0; if(m_VertexBuffer->Lock(0, 0, (void**)&Quad, 0) != D3D_OK) return 0; Quad[0].x = (float)dest_x; Quad[0].y = (float)dest_y; Quad[0].z = 0.0; Quad[0].rhw = 1.0; Quad[0].Color = 0xffffffff; Quad[0].tu = (float)source->left / m_TexInfo.Width; Quad[0].tv = (float)source->top / m_TexInfo.Height; Quad[1].x = (float)dest_x + (source->right - source->left); Quad[1].y = (float)dest_y; Quad[1].z = 0.0; Quad[1].rhw = 1.0; Quad[1].Color = 0xffffffff; Quad[1].tu = (float)(source->left + (source->right - source->left)) / m_TexInfo.Width; Quad[1].tv = (float)source->top / m_TexInfo.Height; Quad[2].x = (float)dest_x + (source->right - source->left); Quad[2].y = (float)dest_y + (source->bottom - source->top); Quad[2].z = 0.0; Quad[2].rhw = 1.0; Quad[2].Color = 0xffffffff; Quad[2].tu = (float)(source->left + (source->right - source->left)) / m_TexInfo.Width; Quad[2].tv = (float)(source->top + (source->bottom - source->top)) / m_TexInfo.Height; Quad[3].x = (float)dest_x; Quad[3].y = (float)dest_y + (source->bottom - source->top); Quad[3].z = 0.0; Quad[3].rhw = 1.0; Quad[3].Color = 0xffffffff; Quad[3].tu = (float)source->left / m_TexInfo.Width; Quad[3].tv = (float)(source->top + (source->bottom - source->top)) / m_TexInfo.Height; m_VertexBuffer->Unlock(); if(m_Display->GetDevice()->SetStreamSource(0, m_VertexBuffer, 0, sizeof(BitmapVertex)) != D3D_OK) return 0; if(m_Display->GetDevice()->SetFVF(m_VertexFormat) != D3D_OK) return 0; if(m_Display->GetDevice()->SetTexture(0, m_Texture) != D3D_OK) return 0; if(m_Display->GetDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2) != D3D_OK) return 0; return 1;}