Jump to content
  • Advertisement
Sign in to follow this  

Trouble With D3DX10CreateEffectFromFile

This topic is 2337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, i'm using D3DX10CreateEffectFromFile and its returning E_FAIL. However the issue arises with the ID3D10Blob output on the function, its returning nothing. I don't know whether this means somethings wrong with the arguments I'm passing or that DirectX just really does not like me.

Here is the code if anyone can help.
Specific function where its called.

bool gShaderHandle::buildFX(LPCWSTR filename)

ID3D10Blob* errorTwo = 0;

hr = D3DX10CreateEffectFromFile(filename,

MessageBoxA(0, (char*)errorTwo->GetBufferPointer(), 0, 0);
gTech = gEffect->GetTechniqueByName("techPass");
return true;

Class its part of

class gShaderHandle
ID3D10Effect* gEffect;
ID3D10EffectTechnique* gTech;
ID3D10InputLayout* gVertexLayout;
ID3D10Device* device;

bool buildFX(LPCWSTR filename);
bool buildVertexLayouts();

ID3D10Effect* returnEffect();
ID3D10EffectTechnique* returnTech();

gShaderHandle(ID3D10Device* *device = NULL);
gShaderHandle(ID3D10Device* *device, bool WTF);

void modDevice(ID3D10Device* *d3ddevice);

Effect File
cbuffer cbPerObject
float4x4 gWVP;

void vs(float3 iPosL : POSITION,
float4 iColor : COLOR,
out float4 oPosH : SV_POSITION,
out float4 oColor : COLOR)
oPosH = mul(float4(iPosL, 1.0f), gWVP);
oColor = iColor;

float4 ps(float4 posH : SV_POSITION,
float4 color : COLOR) : SV_Target
return color;

technique10 techPass
pass P0
SetVertexShader( CompileShader( vs_4_0, vs() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, ps() ) );

Share this post

Link to post
Share on other sites
Make sure you create your device with the DEBUG flag enabled, and make sure that you link to d3dx10d.lib. If you do this, you will get detailed error messages in the debug output.

Share this post

Link to post
Share on other sites

Make sure you create your device with the DEBUG flag enabled, and make sure that you link to d3dx10d.lib. If you do this, you will get detailed error messages in the debug output.

It is made with the DEBUG flag enabled and the d3dx10d.lib is linked. Still fails without placing a proper error message in ID3D10Blob.

Share this post

Link to post
Share on other sites
Okay, fixed that issue ran into a whole new issue. Everything is running fine until I try to render a set of 8 cubes. Currently all that shows up are my FPS displays and camera displays. Nothing else. Massive dump of code incoming.

DirectX 10 Initialization Code

int g_DXInit::initD3D10(HWND* hWnd)
//Create a pointer to the window handle. Why? Because hWnd is not part of g_DXInit and we need it for the swapChain.
InitHW = hWnd;
GetClientRect(*InitHW, &RC);
gameState = CONTROLLOCK;


width = RC.right - RC.left;
height = RC.bottom - RC.top;

if(!initSwapChain()) return 1;
gShader.gShaderHandle::gShaderHandle(&pD3DDevice, true);
if(!gShader.buildFX(L"test.hlsl")) return 6;

if(!setViewports()) return 2;
if(!setupRasterize()) return 5;
if(!readyRenderTarget()) return 3;

font = D3DFonts.InitFont(font, pD3DDevice);

if(font == NULL)
return 4;

D3DX10CreateSprite(pD3DDevice, 0, &p_Sprite);
gEffect = gShader.returnEffect();
gTech = gShader.returnTech();

gfxWVP = gEffect->GetVariableByName("gWVP")->AsMatrix();

gameState = GAMENORMAL;

renderList = testWorld.returnAllMesh();

return 0;
bool g_DXInit::initSwapChain()
ZeroMemory(&swapChain, sizeof(swapChain));
//Buffer Settings
swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Width = width;
swapChainDesc.BufferDesc.Height = height;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

//Refresh Rate
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;

//Swap Chain Sample Settings
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;

//Outputting Window Handle

swapChainDesc.OutputWindow = *InitHW;
swapChainDesc.Windowed = true;

swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Flags = 0;

swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

if( FAILED(D3D10CreateDeviceAndSwapChain( NULL,
&pD3DDevice))) return false;

return true;
bool g_DXInit::readyRenderTarget()
//Setup Back Buffer and render targets. Shadow Mapping is kept separate for readability
backBuffer = 0;
if( FAILED(swapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*) &backBuffer))) return false;
if( FAILED(pD3DDevice->CreateRenderTargetView(backBuffer, 0, &pRTV))) return false;

//Re;ease Back Buffer now that swapChain and D3D10 Device have used it.

//Ready Render Target, specifically create 2D Texture and depth stencil view
D3D10_TEXTURE2D_DESC depthStencil;

depthStencil.Width = width;
depthStencil.Height = height;
depthStencil.MipLevels = 1;
depthStencil.ArraySize = 1;
depthStencil.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencil.SampleDesc.Count = 1;
depthStencil.SampleDesc.Quality = 0;
depthStencil.Usage = D3D10_USAGE_DEFAULT;
depthStencil.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencil.CPUAccessFlags = 0;
depthStencil.MiscFlags = 0;

//depth stencil done, use it now

depthView.Format = depthStencil.Format;
depthView.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
depthView.Texture2D.MipSlice = 0;

if(FAILED(pD3DDevice->CreateTexture2D(&depthStencil, 0, &depthStencilTex))) return false;
if(FAILED(pD3DDevice->CreateDepthStencilView(depthStencilTex, &depthView, &depthSV))) return false;
pD3DDevice->OMSetRenderTargets(1, &pRTV, depthSV);
return true;

bool g_DXInit::setViewports()
//Setup Viewport

D3D10_VIEWPORT viewPort;

viewPort.TopLeftX = 0;
viewPort.TopLeftY = 0;
viewPort.Width = width;
viewPort.Height = height;
viewPort.MinDepth = 0;
viewPort.MaxDepth = 1.0f;

//ViewPort setup, finalize by running magic functions of D3D10!

pD3DDevice->RSSetViewports(1, &viewPort);

return true;

bool g_DXInit::setupRasterize()

ZeroMemory(&rsDesc, sizeof(D3D10_RASTERIZER_DESC));
rsDesc.FillMode = D3D10_FILL_SOLID;
rsDesc.CullMode = D3D10_CULL_NONE;
rsDesc.FrontCounterClockwise = true;
rsDesc.DepthBias = false;
rsDesc.DepthBiasClamp = 0;
rsDesc.SlopeScaledDepthBias = 0;
rsDesc.DepthClipEnable = true;
rsDesc.ScissorEnable = false;
rsDesc.MultisampleEnable = false;
rsDesc.AntialiasedLineEnable = true;

pD3DDevice->CreateRasterizerState(&rsDesc, &noCullRS);

return true;

If any other parts are needed just let me know, Effect files info is already in the OP.

Once again already fixed, the sprite I was drawing text info to was messing with the viewport or covering up what I was rendering or something. Edited by darkreign

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!