I'm pretty new to DirectX and still learning and I think my lack of understanding is not that advanced to find a good direction to solve my problem.
I'm using here Direct3D-9 and trying to render a texture in certain uv coordinates of a vertex buffer.
Here is the vertex buffer and the uv coordinates:
VertexXYZColorT1 * m_pVB = new VertexXYZColorT1[10];
m_pVB[0].Set( 0.0f, 0.1f, 0.0f, m_dwCurrColor, 0.5f, 0.5f);
m_pVB[9].Set(-0.5f, 0.1f, -0.5f, m_dwCurrColor, 0.0f, 1.0f);
m_pVB[8].Set( 0.0f, 0.1f, -0.5f, m_dwCurrColor, 0.5f, 1.0f);
m_pVB[7].Set( 0.5f, 0.1f, -0.5f, m_dwCurrColor, 1.0f, 1.0f);
m_pVB[6].Set( 0.5f, 0.1f, 0.0f, m_dwCurrColor, 1.0f, 0.5f);
m_pVB[5].Set( 0.5f, 0.1f, 0.5f, m_dwCurrColor, 1.0f, 0.0f);
m_pVB[4].Set( 0.0f, 0.1f, 0.5f, m_dwCurrColor, 0.5f, 0.0f);
m_pVB[3].Set(-0.5f, 0.1f, 0.5f, m_dwCurrColor, 0.0f, 0.0f);
m_pVB[2].Set(-0.5f, 0.1f, 0.0f, m_dwCurrColor, 0.0f, 0.5f);
m_pVB[1].Set(-0.5f, 0.1f, -0.5f, m_dwCurrColor, 0.0f, 1.0f);
Here is a picture to visualize the coordinates:
Now I wonder if there is any way of positioning the texture in certain location of the vertex buffer, i.e top left while the vertex buffer still in the center?
Here is a picture of what I mean:
Now instead of moving the whole vertex buffer to top left as I do here:
I want to draw the texture on top left side of the vertex buffer while keeping the vertex buffer centered so I can draw something like this:
I was reading many articles and also in the book of Introduction to 3D game programming with DirectX 9.0
where he talks about the texturing and that we can set the d3d-device to:
s_lpD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
s_lpD3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
And also checking the documentation of Microsoft here:
https://docs.microsoft.com/en-us/windows/desktop/direct3d9/wrap-texture-address-mode
I can't seem to find a good direction to solve my problem and I would really appreciate your help or explanation of how to achieve this goal. Basically my goal is using this texture and draw it 4 times to make a full circle.
I guess it has also to do with rotation the uv coordinates or something like that? or would I need to draw 4 vertex buffers for this and 1 texture for each vertex buffer?
Or am I making things too complicated and it has something to do with telling directx to render 4 textures using this flag?:
const DWORD FVF_XYZCOLORT4 = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX4;
Then how would I rotate this texture to draw a full circle?
Thanks in advance for your help and time!