Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Vertex shader problem

chick80chick80 Member Posts: 349
Ok, I'm trying to use vertex shader, but I have some problem...
Here's the code I'm using (note that the shader doesn't really do anything... it just expects the world*view*projection matrix in c0->c4 and then passes the data through as it is):

[code]
const char VertexShader[] =
"vs.1.1
"
"m4x4 oPos, v0, c0
"
"mov oT0, v7";
ID3DXBuffer *VertexShaderBuffer;

DWORD declaration[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3),
D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT3),
D3DVSD_REG(D3DVSDE_TEXCOORD0, D3DVSDT_FLOAT2),
D3DVSD_END()
};

if (FAILED(D3DXAssembleShader(VertexShader, lstrlen(VertexShader), D3DXASM_DEBUG, NULL, &VertexShaderBuffer, NULL)))
return false;

if (FAILED(D3DDevice->CreateVertexShader(declaration, (DWORD*)VertexShaderBuffer->GetBufferPointer(), &VertexShaderHandle, 0)))
return false;

VertexShaderBuffer->Release();
return true;
[/code]

The problem is with CreateVertexShader that returns D3DERR_INVALIDCALL.
I don't really understand where's the error, so I hope that someone out there can find it for me!!! ;-)

Thank you
nICO

[hr]
[italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
JOHN KEATS

Comments

  • Vorsin S.V.Vorsin S.V. Member Posts: 25
    : Ok, I'm trying to use vertex shader, but I have some problem...
    : Here's the code I'm using (note that the shader doesn't really do anything... it just expects the world*view*projection matrix in c0->c4 and then passes the data through as it is):
    :
    : [code]
    : const char VertexShader[] =
    : "vs.1.1
    "
    : "m4x4 oPos, v0, c0
    "
    : "mov oT0, v7";
    : ID3DXBuffer *VertexShaderBuffer;
    :
    : DWORD declaration[] =
    : {
    : D3DVSD_STREAM(0),
    : D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3),
    : D3DVSD_REG(D3DVSDE_NORMAL, D3DVSDT_FLOAT3),
    : D3DVSD_REG(D3DVSDE_TEXCOORD0, D3DVSDT_FLOAT2),
    : D3DVSD_END()
    : };
    :
    : if (FAILED(D3DXAssembleShader(VertexShader, lstrlen(VertexShader), D3DXASM_DEBUG, NULL, &VertexShaderBuffer, NULL)))
    : return false;
    :
    : if (FAILED(D3DDevice->CreateVertexShader(declaration, (DWORD*)VertexShaderBuffer->GetBufferPointer(), &VertexShaderHandle, 0)))
    : return false;
    :
    : VertexShaderBuffer->Release();
    : return true;
    : [/code]
    :
    : The problem is with CreateVertexShader that returns D3DERR_INVALIDCALL.
    : I don't really understand where's the error, so I hope that someone out there can find it for me!!! ;-)
    :
    : Thank you
    : nICO
    :
    : [hr]
    : [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    : JOHN KEATS
    :
    :


    Try to use this:
    : [code]
    : if (FAILED(D3DXAssembleShader(VertexShader, lstrlen(VertexShader)-1, D3DXASM_DEBUG, NULL, &VertexShaderBuffer, NULL)))
    : return false;
    : [/code]


  • chick80chick80 Member Posts: 349
    Thank you, but I found that the error wasn't there, but in the function that chooses the device to use. It choosed a device which has no vertex shader support so I didn't see anything.
    Btw, now it's all working!

    nICO

    [hr]
    [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    JOHN KEATS


Sign In or Register to comment.