Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 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.