4

I'm a noob with DirectX and running through [this][1] tutorial in Visual Studio. At compile time, I run into this error: "error X3501: 'main': entrypoint not found." Now some googling lead me to [this answer][2], which says to enter in the properties of my shader files, set Shader type and the entrypoint to your desired entry point. Now as great of an answer that provided, I have no idea what my entrypoint should be. At first I thought it should be where I actually call D3DX11CompileFromFile() which is in ColorShaderClass::InitializeShader, yet I'm again met with error X3501. What do?


My files are as follows

ColorVS.hlsl
ColorPS.hlsl

The methods which use the names

bool ColorShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
{
    bool result;


    // Initialize the vertex and pixel shaders.
    result = InitializeShader(device, hwnd, L"ColorVS.hlsl", L"ColorPS.hlsl");
    if (!result)
    {
        return false;
    }

    return true;
}

and

bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
    HRESULT result;
    ID3D10Blob* errorMessage;
    ID3D10Blob* vertexShaderBuffer;
    ID3D10Blob* pixelShaderBuffer;
    D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
    unsigned int numElements;
    D3D11_BUFFER_DESC matrixBufferDesc;

// Initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;

    // Compile the vertex shader code.
    result = D3DX11CompileFromFile(vsFilename, NULL, NULL, "ColorVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL,
    &vertexShaderBuffer, &errorMessage, NULL);
if (FAILED(result))
{
    // If the shader failed to compile it should have writen something to the error message.
    if (errorMessage)
    {
        OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
    }
    // If there was nothing in the error message then it simply could not find the shader file itself.
    else
    {
        MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
    }

    return false;
}

// Compile the pixel shader code.
result = D3DX11CompileFromFile(psFilename, NULL, NULL, "ColorPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL,
    &pixelShaderBuffer, &errorMessage, NULL);
if (FAILED(result))
{
    // If the shader failed to compile it should have writen something to the error message.
    if (errorMessage)
    {
        OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
    }
    // If there was  nothing in the error message then it simply could not find the file itself.
    else
    {
        MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
    }

    return false;
}
//more code
}

EDIT

As tsandy answered, the entrypoints were the functions that actually performed the shading. For anyone who is following the tutorial and uses the same scheme as I did with the shader files

ColorPS.hlsl had the entry point "ColorPixelShader"

ColorVS.hlsl had the entry point "ColorVertexShader"

OKUZA
  • 129
  • 1
  • 12

1 Answers1

3

For each hlsl file, the entry point should be the name of the function in the hlsl file that does the shading. E.g. in the following pixel shader hlsl:

struct PixelInputType
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
};

float4 ColorPixelShader(PixelInputType input) : SV_TARGET
{
    return input.color;
}

you would use ColorPixelShader for the entry point.

tsandy
  • 911
  • 4
  • 10