   Error Using FX File With Texture
  I was finally able to use my shader on a 3D plane to color it so I decided to try my hand at texturing. I created a shader in FXComposer that worked perfectly for applying a texture to an object. However, when I try to use it in my program, nothing gets drawn and I get a lot of this output. Any help is really appreciated.Direct3D9: (ERROR) :DrawPrimitive failed.D3D9 Helper: IDirect3DDevice9::DrawPrimitive failed: D3DERR_INVALIDCALLDirect3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 15Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 16Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 17Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 18Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 19Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 20Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 21Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 30Here's what my FX file and main.cpp file look like:float4x4 wvp : WORLDVIEWPROJECTION;struct VS_INPUT {   float4 Position : POSITION;   float2 TexCoord : TEXCOORD;};struct VS_OUTPUT {   float4 Position : POSITION;   float2 TexCoord : TEXCOORD;};VS_OUTPUT Effect_Group_1_Effect1_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input ){   VS_OUTPUT Output;   Output.Position = mul( Input.Position, wvp );   Output.TexCoord = Input.TexCoord; return( Output );   }texture fireTex<   string ResourceName = "FireBase.tga";>;sampler textureSampler = sampler_state{   Texture = (fireTex);};float4 Effect_Group_1_Effect1_Pass_0_Pixel_Shader_ps_main(float4 Position : POSITION0, float2 TexCoord : TEXCOORD0) : COLOR0{   return tex2D(textureSampler, TexCoord);}technique Effect1{   pass Pass_0   { VertexShader = compile vs_2_0 Effect_Group_1_Effect1_Pass_0_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 Effect_Group_1_Effect1_Pass_0_Pixel_Shader_ps_main();   }}#define WIN32_LEAN_AND_MEAN#include <d3d9.h>#include <d3dx9.h>#include <windows.h>#include <math.h>#include "SimWindowManager.h"#include "SimD3DContext.h"#include "SimUtilities.h"//we need a global variable for the rendering function to referenceSimD3DContext context;D3DXMATRIX viewMatrix, projectionMatrix, worldMatrix;IDirect3DVertexBuffer9 *vbo;int width = 800, height = 600;struct SimVertex{D3DXVECTOR3 position;D3DXVECTOR2 texCoord;};const DWORD vertex_fvf = D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0);SimVertex verts[4];ID3DXEffect *effect;IDirect3DTexture9 *texture;D3DXHANDLE effectHandle;void Render(){context.Device()->Clear(0, NULL, D3DCLEAR_TARGET, 0xFF000000, 1, 0);context.Device()->BeginScene();effect->SetMatrix("wvp", &(worldMatrix * viewMatrix * projectionMatrix));effect->SetTechnique(effectHandle);UINT numPasses;effect->Begin(&numPasses, 0);effect->BeginPass(0);context.Device()->SetStreamSource(0, vbo, 0, sizeof(SimVertex));context.Device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);effect->EndPass();effect->End();context.Device()->EndScene();context.Device()->Present(NULL, NULL, NULL, NULL);}void Exit(WPARAM wParam){if(effect != NULL)effect->Release();if(vbo != NULL)vbo->Release();if(texture != NULL)texture->Release();}int APIENTRY WinMain(HINSTANCE ,HINSTANCE ,LPSTR ,int ){bool fullscreen = GetFullscreenOption();context.InitializeWindowClass("SimEngine");context.InitializeWindow(width, height);context.SetRenderFunction(Render);context.SetExitFunction(Exit);D3DPRESENT_PARAMETERS pp;ZeroMemory(&pp,sizeof(D3DPRESENT_PARAMETERS));pp.BackBufferCount = 1;  //We only need a single back bufferpp.MultiSampleType = D3DMULTISAMPLE_NONE; //No multi-samplingpp.MultiSampleQuality = 0; //No multi-samplingpp.SwapEffect = D3DSWAPEFFECT_DISCARD;  // Throw away previous frames, we don't need thempp.Flags = 0;  //No flags to setpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; //Default Refresh Ratepp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;   //Default Presentation ratepp.EnableAutoDepthStencil = FALSE; //No depth/stencil bufferif(fullscreen){pp.Windowed = FALSE;pp.BackBufferWidth = width;pp.BackBufferHeight = height;pp.BackBufferFormat = D3DFMT_R5G6B5;}else{pp.Windowed = TRUE;pp.BackBufferFormat = D3DFMT_UNKNOWN;}context.SetDeviceParameters(pp);HRESULT hr = context.InitializeDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DCREATE_SOFTWARE_VERTEXPROCESSING);if(FAILED(hr))DisplayErrorDialog("Error Initializing Direct3D Device", hr);D3DXVECTOR3 eye = D3DXVECTOR3(8.0f, 10.0f, 8.0f);D3DXVECTOR3 look = D3DXVECTOR3(0.0f, 0.0f, 0.0f);D3DXVECTOR3 up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);D3DXMatrixLookAtLH(&viewMatrix, &eye, &look, &up);context.Device()->SetTransform(D3DTS_VIEW, &viewMatrix);D3DXMatrixPerspectiveFovLH(&projectionMatrix, D3DX_PI / 4, ((float)width / (float)height), 0.01f, 1000.0f);context.Device()->SetTransform(D3DTS_PROJECTION, &projectionMatrix);D3DXMatrixIdentity(&worldMatrix);context.Device()->SetTransform(D3DTS_WORLD, &worldMatrix);context.Device()->SetRenderState(D3DRS_LIGHTING, FALSE);hr = D3DXCreateEffectFromFile(context.Device(), "Effect.fx", NULL, NULL, 0, NULL, &effect, NULL);if(FAILED(hr))DisplayErrorDialog("Error creating effect", hr);hr = effect->FindNextValidTechnique(NULL, &effectHandle);if(FAILED(hr))DisplayErrorDialog("Error finding valid technique", hr);D3DXCreateTextureFromFile(context.Device(), "FireBase.tga", &texture);effect->SetTexture("fireTex", texture); verts[0].position = D3DXVECTOR3(-2, 0, -2); verts[0].texCoord = D3DXVECTOR2(0, 0); verts[1].position = D3DXVECTOR3(-2, 0, 2); verts[1].texCoord = D3DXVECTOR2(0, 1); verts[2].position = D3DXVECTOR3(2, 0, -2); verts[2].texCoord = D3DXVECTOR2(1, 0); verts[3].position = D3DXVECTOR3(2, 0, 2); verts[3].texCoord = D3DXVECTOR2(1, 1);context.Device()->CreateVertexBuffer(4 * sizeof(SimVertex), D3DUSAGE_WRITEONLY, vertex_fvf, D3DPOOL_MANAGED, &vbo, NULL);void *vboData;vbo->Lock(0, 0, &vboData, 0);memcpy(vboData, verts, 4 * sizeof(SimVertex));vbo->Unlock();context.DisplayWindow();context.EventLoop();return 0;}
  I went through your code really quickly and couldn't find a call to Device->SetFVF() or Device->SetDeclaration(). You'd need to call at least one of these to set the correct format.This might not be the only issue, but it surely is one.Hope this helps.   ;  What level of debug output have you got (in the DirectX control panel)? In my experience you usually get a better description of why the call failed - try increasing the debug output to "maximum" and see if it'll tell you why.hthJack   ;  Yeah you'll need to set up a vertex declation that matches your SimVertex strucure e.g.:D3DVERTEXELEMENT9 SimVertexFormat[] ={{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },D3DDECL_END()};Create it with CreateVertexDeclaration:IDirect3DVertexDeclaration9* pDecl;context.Device()->CreateVertexDeclaration(SimVertexFormat, &pDecl);Then apply before you render:context.Device()->SetVertexDeclaration(pDecl);;  I'm using the vertex declaration now and both that and the FVF work fine. I think the other problem may have been my placement of the texture iteself. But, though it is drawing correctly, I'm still getting all those warnings. Here's the full output from my last run. I have the DirectX debug version on maximum output.'SimEngine.exe': Loaded 'D:\Programming\SimEngine\debug\SimEngine.exe', Symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\d3dx9d_30.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\Program Files\Trillian\events.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\comdlg32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\Program Files\Trillian\msvcr71.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded.'SimEngine.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded.Direct3D9: :====> ENTER: DLLMAIN(00ecd6e0): Process Attach: 00000a40, tid=000008f8Direct3D9: :====> EXIT: DLLMAIN(00ecd6e0): Process Attach: 00000a40Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: (INFO) :======================= Hal SWVP device selectedDirect3D9: (INFO) :HalDevice Driver Style 9Direct3D9: :DoneExclusiveModeDirect3D9: (INFO) :Failed to create driver indexbufferD3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.44115e+017f.  This is ok.D3DX: (INFO) Using SSE2 InstructionsDirect3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 15Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 16Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 17Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 18Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 19Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 20Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 21Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 30Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 15Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 16Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 17Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 18Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 19Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 20Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 21Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 30D3DX: Matrix should be 16-byte aligned for better performanceDirect3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 15Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 16Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 17Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 18Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 19Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 20Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 21Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 30Direct3D9: :====> ENTER: DLLMAIN(00ecd6e0): Process Detach 00000a40, tid=000008f8Direct3D9: (INFO) :MemFini!Direct3D9: (WARN) :Memory still allocated!  Alloc count = 130Direct3D9: (WARN) :Current Process (pid) = 00000a40SimEngine.exe has triggered a breakpointThe program '[2624] SimEngine.exe: Native' has exited with code 0 (0x0).;  I don't think that warning is relevant you get it all the time with max DX debug level.  Does it render correctly ?;Quote:Original post by griffin2000I don't think that warning is relevant you get it all the time with max DX debug level.  Does it render correctly ?Everything appears to render perfectly. I guess I'll ignore it until something stops working, then.   