Sign up ×
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;, ifstream::in | ifstream::binary);
    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);[0], vs_size);

    result = device->CreateVertexShader(&vs_data, vs_size, 0, &m_vertexShader);
        return false;
    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

1 Answer 1

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

Your Answer


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.