wie krieg ich meinen shader code in die gra****karte?



  • moin leutz

    ich will einen shader programmieren. mein problem ist nur. wie krieg ich mein shader code/programm in die gra****karte rein? 🙄



  • Mit Herstellerspezifischen Extensions bei OpenGL oder mit DirectX



  • HRESULT D3DXAssembleShaderFromFile(
    LPCTSTR pSrcFile,
    DWORD Flags,
    LPD3DXBUFFER* ppConstants,
    LPD3DXBUFFER* ppCompiledShader,
    LPD3DXBUFFER* ppCompilationErrors
    );

    Parameters
    pSrcFile
    [in] Pointer to the source file name.
    Flags
    [in] A combination of the D3DXASM flags, specifying assembly options.
    ppConstants
    [out] Returns a pointer to an ID3DXBuffer interface, representing the returned constant declarations. These constants are returned as a vertex shader declaration fragment. It is up to the application to insert the contents of this buffer into their declaration. For pixel shaders this parameter is meaningless because constant declarations are included in the assembled shader. This parameter is ignored if it is NULL.
    ppCompiledShader
    [out] Returns a pointer to an ID3DXBuffer interface, representing the returned compiled object code. This parameter is ignored if it is NULL.
    ppCompilationErrors
    [out] Returns a pointer to an ID3DXBuffer interface, representing the returned ASCII error messages. This parameter is ignored if it is NULL.
    Return Values
    If the function succeeds, the return value is D3D_OK.

    If the function fails, the return value can be one of the following values.

    D3DERR_INVALIDCALL
    D3DXERR_INVALIDDATA
    E_OUTOFMEMORY

    Remarks
    This method supports both Unicode and ANSI strings.

    The following example wrapper function, PreprocessAndAssembleShaderFromFile, shows how you can invoke the C preprocessor on your vertex shader code before invoking the assembler with D3DXAssembleShaderFromFile.

    HRESULT PreprocessAndAssembleShaderFromFile(
    LPCSTR szFile,
    DWORD Flags,
    LPD3DXBUFFER* ppConstants,
    LPD3DXBUFFER* ppCode,
    LPD3DXBUFFER* ppErrors)
    {
    char szPath[_MAX_PATH];
    char szTemp[_MAX_PATH];
    char szCmd [_MAX_PATH];

    GetTempPath(sizeof(szPath), szPath);
    GetTempFileName(szPath, "vsa", 0, szTemp);

    _snprintf(szCmd, sizeof(szCmd), "cl /nologo /E %s > %s", szFile, szTemp);

    if(0 != system(szCmd))
    return D3DERR_INVALIDCALL;

    return D3DXAssembleShaderFromFile(szTemp, Flags, ppConstants, ppCode, ppErrors);
    }

    Note that for this function to work you must have Microsoft® Visual C++® installed and your environment set up so that Cl.exe is in your path.

    Requirements
    Header: Declared in D3dx8core.h.
    Import Library: Use D3dx8.lib.

    See Also
    D3DXAssembleShaderFromResource

    Requirements
    Header: Declared in D3dx8core.h.
    Import Library: Use D3dx8.lib.
    See Also
    D3DXAssembleShaderFromResource

    Ist noch aus der alten D3D8 Doku
    Dürfte aber in 9.x net viel anders sein..


Anmelden zum Antworten