Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.