## How converts to this?

### How converts to this?

DX8.1 Vertex Shader Declaration code

DWORD  declBasicTr[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3 ),  // position
D3DVSD_REG(D3DVSDE_BLENDWEIGHT, D3DVSDT_FLOAT2 ), // 2 blending
weights
D3DVSD_REG(D3DVSDE_BLENDINDICES, D3DVSDT_UBYTE4 ), // 4 indices
D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT3 ),  // normal for light
calcula
D3DVSD_REG(D3DVSDE_TEXCOORD0,D3DVSDT_FLOAT2 ),  // texture
co-ordinates
D3DVSD_END()
};

how convert to DX9.0?

please answer me.

### How converts to this?

Look up D3DVERTEXELEMENT9.

Quote:> DX8.1 Vertex Shader Declaration code

> DWORD  declBasicTr[] =
>       {
>       D3DVSD_STREAM(0),
>       D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3 ),  // position
>       D3DVSD_REG(D3DVSDE_BLENDWEIGHT, D3DVSDT_FLOAT2 ), // 2 blending
> weights
>       D3DVSD_REG(D3DVSDE_BLENDINDICES, D3DVSDT_UBYTE4 ), // 4 indices
>       D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT3 ),  // normal for light
> calcula
>       D3DVSD_REG(D3DVSDE_TEXCOORD0,D3DVSDT_FLOAT2 ),  // texture
> co-ordinates
>       D3DVSD_END()
>      };

> how convert to DX9.0?

> please answer me.

### How converts to this?

Look at SDKdoc->DirectX Graphics->Programming Guide->Programmable
Pipeline->VertexShaders->Decoupling Vertex Shaders and Vertex Declarations.

There is a section on mapping DX8 to DX9.

Francisco

Quote:> DX8.1 Vertex Shader Declaration code

> DWORD  declBasicTr[] =
>       {
>       D3DVSD_STREAM(0),
>       D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3 ),  // position
>       D3DVSD_REG(D3DVSDE_BLENDWEIGHT, D3DVSDT_FLOAT2 ), // 2 blending
> weights
>       D3DVSD_REG(D3DVSDE_BLENDINDICES, D3DVSDT_UBYTE4 ), // 4 indices
>       D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT3 ),  // normal for light
> calcula
>       D3DVSD_REG(D3DVSDE_TEXCOORD0,D3DVSDT_FLOAT2 ),  // texture
> co-ordinates
>       D3DVSD_END()
>      };

> how convert to DX9.0?

> please answer me.

I need to convert a DIB to a DDB and all I have is the handle to the DIB
I found C++ code to do it, but I don't know C very well at all.
I've converted what I could to VB code, I need a little help with the rest.

All the stuff in RED is still C...can someone please convert it for me, or
help me with VB code to do it otherwise.

Private Function DibtoDDB(hDIB As Long) As Long
Dim lpbi As BITMAPINFOHEADER
Dim lpbi2 As BITMAPINFO
lpbi2.bmiHeader

Dim hbm As BITMAP
Dim pal As Long, poldpal As Long, dc As Long

If (hDIB = 0) Then Exit Function
lpbi = (LPBITMAPINFOHEADER)hDIB;
Dim nColors As Long

nColors = lpbi.biClrUsed ? lpbi.biClrUsed : 1 << lpbi.biBitCount

Dim bmInfo As BITMAPINFO
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB ;
LPVOID lpDIBBits;
if  bmInfo.bmiHeader.biBitCount > 8  then
lpDIBBits = ((bmInfo.bmiColors + bmInfo.bmiHeader.biClrUsed) + _
((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
Else
lpDIBBits = bmInfo.bmiColors + nColors
End if
'    // Create and select a logical palette if needed
If (nColors <= 256 And (dc.GetDeviceCaps(RASTERCAPS) And RC_PALETTE))
Then

Dim nSize As Long
nSize = Len(LOGPALETTE) + (Len(PALETTEENTRY) * nColors)
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];

pLP.palVersion = &H300
pLP.palNumEntries = nColors

For i = 0 To nColors - 1
pLP.palPalEntry(i).peRed = bmInfo.bmiColors(i).rgbRed
pLP.palPalEntry(i).peGreen = bmInfo.bmiColors(i).rgbGreen
pLP.palPalEntry(i).peBlue = bmInfo.bmiColors(i).rgbBlue
pLP.palPalEntry(i).peFlags = 0
Next

pal.CreatePalette(pLP)
delete[] pLP;

'        // Select and realize the palette
poldpal = dc.SelectPalette(pal, False)
dc.RealizePalette ()
End If

hbm = CreateDIBitmap(dc.GetSafeHdc(), lpbi, CBM_INIT, lpDIBBits,  lpbi,
DIB_RGB_COLORS );
If pal.GetSafeHandle() Then dc.SelectPalette(poldpal, False)

DibtoDDB = hbm

End Function