Functions | |
| HRESULT | D3DConfigureShaderFilter (CVD3DSHADER d3dShader, DWORD dwWidth, DWORD dwHeight) |
| The function configures a shader that executes a filter operation. | |
| HRESULT | D3DCreateShaderFromFile (CVD3D d3d, const char *pFileName, const char *pFunctionName, BOOL bDisplayErrorMessage, TShaderVersion shaderVersion, CVD3DSHADER &d3dShader) |
| Creates a shader from a HLSL file. | |
| HRESULT | D3DCreateShaderFromString (CVD3D d3d, const char *pShader, const char *pFunctionName, BOOL bDisplayErrorMessage, TShaderVersion shaderVersion, CVD3DSHADER &d3dShader) |
| Creates a shader from a HLSL string. | |
| HRESULT | D3DCreateTexture (CVD3D d3d, DWORD dwWidth, DWORD dwHeight, TColorFormat tcf, CVD3DOBJECT &d3dObject) |
| Creates a texture render target. | |
| HRESULT | D3DCreateTextureEntrance (CVD3D d3d, DWORD dwWidth, DWORD dwHeight, TColorFormat tcf, CVD3DOBJECT &d3dObject) |
| Creates a source texture. | |
| HRESULT | D3DGetFloat (CVD3DSHADER d3dShader, const char *VarName, float &VarValue) |
| The function reads the value of a global float variable in the given shader. | |
| HRESULT | D3DGetInfo (CVD3D d3d, DWORD &dwWidth, DWORD &dwHeight, HWND &hWnd) |
| Returns information about the given CVD3D object. | |
| HRESULT | D3DGetObjectInfo (CVD3DOBJECT d3dObject, DWORD &dwWidth, DWORD &dwHeight, TColorFormat &tcf) |
| This function returns information about the given CVD3DOBJECT object. | |
| HRESULT | D3DGetShaderConstantInfo (CVD3DSHADER d3dShader, DWORD dwIndex, TConstantInfo &ConstantInfo) |
| The function returns information about variables and constants used in the given shader function. | |
| HRESULT | D3DGetShaderFunctionName (CVD3DSHADER d3dShader, char *FuncName, size_t &Length) |
| This function returns the name of the function used by the given shader program. | |
| BOOL | D3DIsRenderSource (CVD3DOBJECT d3dObject) |
| This function checks if the given object can be used as a source for render operations or not. | |
| BOOL | D3DIsRenderTarget (CVD3DOBJECT d3dObject) |
| This function checks if the given object can be used as a target for render operations or not. | |
| BOOL | D3DIsShader (OBJ d3dShader) |
| This function checks if the given handle points to a CVD3DSHADER type or not. | |
| HRESULT | D3DRender (CVD3DOBJECT d3dObjectSource, CVD3DOBJECT d3dObjectTarget, CVD3DSHADER d3dShader) |
| This function renders a given source texture to a given destination texture using the given shader. | |
| HRESULT | D3DSetFloat (CVD3DSHADER d3dShader, const char *VarName, float VarValue) |
| The function writes the value of a global float variable in the given shader. | |
| HRESULT | D3DSetTextureIndex (CVD3DSHADER d3dShader, CVD3DOBJECT d3dObject, DWORD dwIndex) |
| This function is used to set the texture index of a given CVD3DOBJECT for the given shader program. | |
| HRESULT D3DConfigureShaderFilter | ( | CVD3DSHADER | d3dShader, |
| DWORD | dwWidth, | ||
| DWORD | dwHeight | ||
| ) |
The function configures a shader that executes a filter operation.
During the execution the pixel shader has to access pixels in a neighbourhood of the current pixel. These pixels' addresses are constant offsets which normally have to be calculated for each and every pixel. For performance reasons it may make sense to pre-calculate these offsets which is the purpose of the D3DConfigureShaderFilter function. The function estimates the size of the filter kernel based on the name of the pixel shader function. If the shader function name is e.g., MyFilter5x5 then the function assumes a kernel size of 5 and it will pre-calculate the offset to the individual kernel elements for a 2x5x5 (x and y coordinates * kernel size) floating point array. Instead of calculating the pixel addresses in the shader program you can use the pre-calculated array.
| [in] | d3dShader | The shader object to be initialised. |
| [in] | dwWidth | The width of the image to be filtered. |
| [in] | dwHeight | The height of the image to be filtered. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DCreateShaderFromFile | ( | CVD3D | d3d, |
| const char * | pFileName, | ||
| const char * | pFunctionName, | ||
| BOOL | bDisplayErrorMessage, | ||
| TShaderVersion | shaderVersion, | ||
| CVD3DSHADER & | d3dShader | ||
| ) |
Creates a shader from a HLSL file.
A HLSL file is a simple text file containing one or more shader functions. The default extension of a shader file is *.FX. The shader file might be stored encrypted in an encrypted form using a CVB serial number. To encrypt a shader file use the Shader Protection tool installed in the CVB%/Applications directory. The file extension of an encrypted shader file is *.FXENC.
The shader program will be compiled at load time.
ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject. | [in] | d3d | The D3D context. |
| [in] | pFileName | The filename to the HLSL shader file. |
| [in] | pFunctionName | The name of the HLSL function to be loaded. |
| [in] | bDisplayErrorMessage | Flag to control compiler messages to be displayed or not. If TRUE a MessageBox will be shown on any HLSL compiler errors showing the compiler error message, FALSE otherwise. |
| [in] | shaderVersion | The version of the shader used to compile the file. See TShaderVersion for supported shader versions. |
| [out] | d3dShader | Handle to the newly created CVD3DSHADER object. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DCreateShaderFromString | ( | CVD3D | d3d, |
| const char * | pShader, | ||
| const char * | pFunctionName, | ||
| BOOL | bDisplayErrorMessage, | ||
| TShaderVersion | shaderVersion, | ||
| CVD3DSHADER & | d3dShader | ||
| ) |
Creates a shader from a HLSL string.
A HLSL string is a simple memory file containing one or more shader functions.
The shader program will be compiled at load time.
ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject. | [in] | d3d | The D3D context. |
| [in] | pShader | The shader code as a string. |
| [in] | pFunctionName | The name of the HLSL function to be loaded. |
| [in] | bDisplayErrorMessage | Flag to control compiler messages to be displayed or not. If TRUE a MessageBox will be shown on any HLSL compiler errors showing the compiler error message |
| [in] | shaderVersion | The version of the shader used to compile the file. See TShaderVersion for supported shader versions. |
| [out] | d3dShader | Handle to the newly created CVD3DSHADER object. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DCreateTexture | ( | CVD3D | d3d, |
| DWORD | dwWidth, | ||
| DWORD | dwHeight, | ||
| TColorFormat | tcf, | ||
| CVD3DOBJECT & | d3dObject | ||
| ) |
Creates a texture render target.
The object can be used to render another object to itself. It can also be used as a source for rendering operations. To transfer the image back to the host call D3DUpdate after rendering.
ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject. | [in] | d3d | The D3D context. |
| [in] | dwWidth | The width of the image (has to be less or equal to the maximum width of the D3D context). |
| [in] | dwHeight | The height of the image (has to be less or equal to the maximum height of the D3D context). |
| [in] | tcf | The colour format of the image. See TColorFormat for possible values. |
| [out] | d3dObject | Handle to the newly created CVD3DOBJECT object. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DCreateTextureEntrance | ( | CVD3D | d3d, |
| DWORD | dwWidth, | ||
| DWORD | dwHeight, | ||
| TColorFormat | tcf, | ||
| CVD3DOBJECT & | d3dObject | ||
| ) |
Creates a source texture.
Typically you will write a host image to this texture using D3DWriteImageToObject and use it as a source for render operations.
ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject. | [in] | d3d | The D3D context. |
| [in] | dwWidth | The width of the image (has to be less or equal to the maximum width of the D3D context). |
| [in] | dwHeight | The height of the image (has to be less or equal to the maximum height of the D3D context).//The height of the surface |
| [in] | tcf | The colour format of the image. See TColorFormat for possible values. |
| [out] | d3dObject | Handle to the newly created CVD3DOBJECT object. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DGetFloat | ( | CVD3DSHADER | d3dShader, |
| const char * | VarName, | ||
| float & | VarValue | ||
| ) |
The function reads the value of a global float variable in the given shader.
Variables can't be read back to the host so the function always caches the values when D3DSetFloat is called. If you need to physically access a variable used in a shader program by the host application you can write the value of the variable to a pixel in the image (e.g., the last or the first pixel).
| [in] | d3dShader | The shader object. |
| [in] | VarName | The name of the variable to be read within the shader. |
| [out] | VarValue | The value assigned in the last call to D3DSetFloat. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DGetInfo | ( | CVD3D | d3d, |
| DWORD & | dwWidth, | ||
| DWORD & | dwHeight, | ||
| HWND & | hWnd | ||
| ) |
Returns information about the given CVD3D object.
| [in] | d3d | The CVD3D object. |
| [out] | dwWidth | Maximum width of an image that can be created. |
| [out] | dwHeight | Maximum height of an image that can be created. |
| [out] | hWnd | The window handle associated with the object. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DGetObjectInfo | ( | CVD3DOBJECT | d3dObject, |
| DWORD & | dwWidth, | ||
| DWORD & | dwHeight, | ||
| TColorFormat & | tcf | ||
| ) |
This function returns information about the given CVD3DOBJECT object.
| [in] | d3dObject | The CVD3DOBJECT object. |
| [out] | dwWidth | The width of the image. |
| [out] | dwHeight | The height of the image. |
| [out] | tcf | The colour format of the image. See TColorFormat for possible values. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DGetShaderConstantInfo | ( | CVD3DSHADER | d3dShader, |
| DWORD | dwIndex, | ||
| TConstantInfo & | ConstantInfo | ||
| ) |
The function returns information about variables and constants used in the given shader function.
The variables and constants are accessed using a zero based index. To enumerate available variables/constants call this function with increasing values for dwIndex until it returns with an error code, meaning any value different to 0.
| [in] | d3dShader | The shader object to be initialised. |
| [in] | dwIndex | Zero based index of the variable/constant list of the shader program. |
| [out] | ConstantInfo | Information about the variable/constant. See TConstantInfo of its structure. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DGetShaderFunctionName | ( | CVD3DSHADER | d3dShader, |
| char * | FuncName, | ||
| size_t & | Length | ||
| ) |
This function returns the name of the function used by the given shader program.
The retrieve the required length of the string to hold the function name pass NULL as FuncName to the function. In this case Length is filled with the required length.
| [in] | d3dShader | The shader object. |
| [out] | FuncName | A pointer to a string allocated by the caller to be filled with the name of the shader function. The buffer must be long enough to hold the function name. A length of 128 byte may be used as a reasonable default. |
| [out] | Length | The length of the string returned when NULL being passed as FuncName. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | BOOL D3DIsRenderSource | ( | CVD3DOBJECT | d3dObject | ) |
This function checks if the given object can be used as a source for render operations or not.
| [in] | d3dObject | Handle to the object to be processed. |
TRUE it can be used as a render source, FALSE otherwise. | BOOL D3DIsRenderTarget | ( | CVD3DOBJECT | d3dObject | ) |
This function checks if the given object can be used as a target for render operations or not.
| [in] | d3dObject | Handle to the object to be processed. |
TRUE it can be used as a render target, FALSE otherwise. | BOOL D3DIsShader | ( | OBJ | d3dShader | ) |
This function checks if the given handle points to a CVD3DSHADER type or not.
| [in] | d3dShader | Handle to the object to be processed. |
TRUE if it's a CVD3DSHADER object, FALSE otherwise. | HRESULT D3DRender | ( | CVD3DOBJECT | d3dObjectSource, |
| CVD3DOBJECT | d3dObjectTarget, | ||
| CVD3DSHADER | d3dShader | ||
| ) |
This function renders a given source texture to a given destination texture using the given shader.
The image will be stretched during rendering if the image sizes don't match. The function is executed in parallel to the host application and it will return immediately.
To fill the source texture with the image data use D3DWriteImageToObject. To transfer the target image back to the host call D3DUpdate. D3DUpdate will wait for the rendering to be finished before it returns.
| XRGB Targets | XRGB Source | |||
| SurfaceEntrance | Surface | TextureEntrance | Texture | |
| Render to Backbuffer | not applicable | not applicable | ok | ok |
| Render to Surface | not applicable | not applicable | ok | ok |
| Render to Texture | not applicable | not applicable | ok | ok |
| [in] | d3dObjectSource | The source texture. |
| [in] | d3dObjectTarget | The destination texture. |
| [in] | d3dShader | The shader to be used or NULL to bypass the pixel shader. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DSetFloat | ( | CVD3DSHADER | d3dShader, |
| const char * | VarName, | ||
| float | VarValue | ||
| ) |
The function writes the value of a global float variable in the given shader.
Cached variables can be read back using D3DGetFloat after calling this function. If you need to physically access a variable used in a shader program by the host application you can write the value of the variable to a pixel in the image (e.g., the last or the first pixel).
| [in] | d3dShader | The shader object. |
| [in] | VarName | The name of the variable within the shader. |
| [in] | VarValue | The new value to be assigned. |
0 if no error occurred, otherwise a value != 0 indicates the error code. | HRESULT D3DSetTextureIndex | ( | CVD3DSHADER | d3dShader, |
| CVD3DOBJECT | d3dObject, | ||
| DWORD | dwIndex | ||
| ) |
This function is used to set the texture index of a given CVD3DOBJECT for the given shader program.
You can use up to 16 textures in one pixel shader program. To identify a texture in your pixel shader program set the index of the texture. Afterwards you can access the texture via a sampler type in your shader program such as sampler texture0 : register(s0); sampler texture1 : register(s1);. Refer to A First Shader Program for more information.
| [in] | d3dShader | The shader object. |
| [in] | d3dObject | The texture object. |
| [in] | dwIndex | The index to be used for the texture in this shader program. |
0 if no error occurred, otherwise a value != 0 indicates the error code.