1
\$\begingroup\$

I've got an extremely simple vertex shader that Visual Studio 2012 compiles into a .cso file. Now I want to load this file and create a vertex shader on the graphics device using the ID3D11Device::CreateVertexShader function.

So far I have the following code:

ifstream vs_stream;
size_t vs_size;
char* vs_data;

vs_stream.open(vsCompiledPath, ifstream::in | ifstream::binary);
if(vs_stream.good())
{
    vs_stream.seekg(0, ios::end);
    vs_size = size_t(vs_stream.tellg());
    vs_data = new char[vs_size];
    vs_stream.seekg(0, ios::beg);
    vs_stream.read(&vs_data[0], vs_size);
    vs_stream.close();

    result = device->CreateVertexShader(&vs_data, vs_size, 0, &m_vertexShader);
    if(FAILED(result))
    {
        return false;
    }
}
else
{
    return false;
}

I seem to be able to load the file fine, I get sane values in vs_size and vs_data however CreateVertexShader returns E_INVALIDARG and sets m_vertexShader to null.

How can I fix this error?

note that I can't use anything in the d3dx* headers since they are not supported in the Windows 8 App store

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

I found the error:

result = device->CreateVertexShader(&vs_data, vs_size, 0, &m_vertexShader);

Should be

result = device->CreateVertexShader(vs_data, vs_size, 0, &m_vertexShader);

(I wrongly dereferenced the pointer to the data)

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .