   creating empty textures and changing pixel data
  Hi,I would like to make a simple ray tracing program in c++, and want to draw to the screen using direct3d. I have done some research and found D3DXCreateTexture which creates an empty texture and found out how to lock it and access/manipulate the pixel data.My code is as follows:if(  FAILED(    D3DXCreateTexture(d3ddev, 128, 64, 1, D3DUSAGE_DYNAMIC, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &tex)  ))assert(0 && "D3DCreateTexture failed!");  D3DLOCKED_RECT locked;HRESULT hr = tex->LockRect(0, &locked, NULL, 0);  BYTE *bytePointer = (BYTE*)locked.pBits;  for (DWORD y = 0;y < 128;y[increment]){  for (DWORD x = 0;x < 64;x[increment])  {    DWORD index = (x * 4 [plus] (y * locked.Pitch)); // Blue    bytePointer[index] = 255;    // Green    bytePointer[index+1] = 0;    // Red    bytePointer[index+2] = 0;    // Alpha    bytePointer[index+3] = 0;    }}I put the code after i initialise direct3d and before i start the main loop with the render function, which uses a sprite to draw the texture.Except that the texture does not get created.The D3DCreateTexture always gives a failure and i get the assertion failure message.Could someone please tell me what i am doing wrong?Thanks in advance,Nazdreg   
  Try using the debug runtime.BTW, you can write the assert more compactly as:assert(!"D3DCreateTexture failed!");   ;  You are calling UnlockRect when you are finished aren't you?I don't see it in your code...   ;  oh woops, i did forget to unlock, but the program doesnt resch the locking anyway.Gage64, i dont know how to use the debugger :((I have tried to figure out, but when i add a watch for an hresult iv added which gets the result of the D3DXCreateTexture call, but the debugger says error, symbol "hresult" not found.Would someone be able to give me a link to a tutorial on how to use the vc++ 2008 debugger?Thanks   ;Link.   ;  Thanks, i got the return value of D3DXCreateTexture, which is -858993460.Do you know where i can find out what different error codes mean?   ;  You can use the DXERR macros or the DirectX Error Lookup tool to get descriptions of the HRESULTS that DirectX components return.In this case, the error is "unknown". What do you see on the debug output window?Also, does the device creation succeed before you run that code?   ;  Im not sure about the creation of the device, when i put it into fullscreen mode the resolution changed, but i dont know if that means that the device has been made.The debug output:'Screen Test.exe': Loaded 'C:\Programming\...\Debug\Screen Test.exe', Symbols loaded.'Screen Test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\user32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\D3dx9d_41.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\secur32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\version.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\winmm.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\imm32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\msctf.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime''Screen Test.exe': Loaded 'C:\WINDOWS\system32\ole32.dll''Screen Test.exe': Loaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Unloaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Unloaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Loaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Unloaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Unloaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Loaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Unloaded 'C:\Program Files\Hotbar\bin\11.0.120.0\HotbarSAHook.dll''Screen Test.exe': Unloaded 'C:\WINDOWS\system32\oleaut32.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll''Screen Test.exe': Loaded 'C:\WINDOWS\system32\d3dx9d_33.dll'Direct3D9: :====> ENTER: DLLMAIN(00e5e6e0): Process Attach: 00001688, tid=00001270Direct3D9: :====> EXIT: DLLMAIN(00e5e6e0): Process Attach: 00001688Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMD3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFODirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (INFO) :======================= Hal SWVP device selectedDirect3D9: (INFO) :HalDevice Driver style 6Direct3D9: :BackBufferCount not specified, considered default 1 Direct3D9: :DoneExclusiveModeDirect3D9: (INFO) :Using P4 PSGPDirect3D9: (WARN) :Ignoring redundant SetRenderState - 137Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7;  Okay, the device creation is successful.The lines of interest:Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMD3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFODirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMThe warnings seem to suggest that your hardware and/or driver cannot handle texturing directly from dynamic resources. If you think that your hardware should be capable of that, try to update your graphics driver.To get extended debug info, add a following definition before including the D3D headers:#define D3D_DEBUG_INFO;  ok..i added the D3D_DEBUG_INFO, and the output didnt seem to include much more:Direct3D9: :====> ENTER: DLLMAIN(00e5e6e0): Process Attach: 000016f8, tid=00001214Direct3D9: :====> EXIT: DLLMAIN(00e5e6e0): Process Attach: 000016f8Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEMDirect3D9: (INFO) :======================= Hal SWVP device selectedDirect3D9: (INFO) :HalDevice Driver style 6Direct3D9: :BackBufferCount not specified, considered default 1 Direct3D9: :DoneExclusiveModeDirect3D9: (INFO) :Using P4 PSGPD3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 0.0078125f.  This is ok.Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7my graphics card is only an oldish SiS card, doesnt support pixel shading :(and uses shared memory (im using a laptop)would it be unusual for a graphics card to not handle textures from dynamic resources?   