   D3D8 Memory Access Violation
  Greetings,Recently I downloaded Shawn Holmes's RTS tutorial source code, which can be gotten here.  After also downloading the DirectX 9.0b SDK (the same version as the DirectX drivers on my computer, which runs Windows 2000 Professional), I tried to run the tutorials one after another.  However, at the 7th tutorial, I encountered a problem in the texture-loading code, namely involving this part://copy data from image surface to textureIDirect3DSurface8* pTextureSurface ;//grab surface levelpTexture->GetSurfaceLevel ( 0 , &pTextureSurface ) ;When the second line is executed, it attempts to access memory at location 0x00000000, which I believe is system memory (!) and therefore protected.  An execution exception occurs as a result.  Does anyone know what the problem could be?  Caveat: the source code was written back in 2001, so it's very well possible that the parameters for the GetSurfaceLevel() have changed since then.  I don't know personally, since I am very new to DirectX.Thanks,Rob   
  Is pTexture when you make the call to GetSurfaceLevel?;  Don has it. pTexture is NULL (0x00000000), so calling any method on it results in an access violation.My guess is that texture loading fails, so you have a NULL pointer.   ;  Thanks, Don and EvilSteve.  That makes sense.  So the question is, why is pTexture still NULL at that point?Here is where the texture is created://create texturepDevice->CreateTexture ( bmp.bmWidth , bmp.bmHeight , 1 , 0 , format , D3DPOOL_DEFAULT , &pTexture ) ;pDevice is a pointer to an IDirect3DDevice8 object that is passed into the texture-loading function.- Rob   ;  Is the CreateTexture call failing?  What's the returned HRESULT?  Have you enabled the D3D Debug Runtime through the DX Control Panel applet then looked at the debug output pane in the debugger to see why it's failing?;  No, I haven't done that yet.  I will let you know what I come up with.  Thanks for the tips!- Rob   ;  It wouldn't be hugely surprising if CreateTexture() failed. The height, width and format parameters are highly dependent on the underlying hardware. It's quite possible that the values you're trying to use simply aren't valid for your hardware/drivers.You might want to look into "Enumeration" to verify the parameters. IDirect3DDevice8::GetDeviceCaps() will return a D3DCAPS8 that  has MaxTextureWidth and MaxTextureHeight fields. Checking D3DCAPS8::TextureCaps for the power-of-2/non-power-of-2 values is a good idea as well. IDirect3D8::CheckDeviceFormat() should be used to validate the pixel format.hthJack   ;  Okay, I ran the program through the debugger and got this:Loaded 'C:\WINNT\system32\ntdll.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\USER32.DLL', no matching symbolic information found.Loaded 'C:\WINNT\system32\GDI32.DLL', no matching symbolic information found.Loaded 'C:\WINNT\system32\KERNEL32.DLL', no matching symbolic information found.Loaded 'C:\WINNT\system32\d3d8.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\d3d8thk.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\msvcrt.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\ADVAPI32.DLL', no matching symbolic information found.Loaded 'C:\WINNT\system32\rpcrt4.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\version.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\lz32.dll', no matching symbolic information found.Loaded 'C:\Documents and Settings\Administrator\Local Settings\Temp\IadHide5.dll', no matching symbolic information found.Loaded 'C:\Program Files\Logitech\SetPoint\lgscroll.dll', no matching symbolic information found.Loaded 'C:\WINNT\system32\d3d8d.dll', no matching symbolic information found.Direct3D8: (INFO) :======================= Hal SWVP device selectedDirect3D8: (INFO) :Using X3D PSGPDirect3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\vwport.cpp Line: 150Direct3D8: (ERROR) :Viewport outside the render target surfaceDirect3D8: (ERROR) :SetViewport failed.First-chance exception in rts_06.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.Direct3D8: (ERROR) :Device does not support non-pow2 width for textureDirect3D8: (ERROR) :Failure trying to create a textureFirst-chance exception in rts_06.exe: 0xC0000005: Access Violation.The program 'C:\My Programs\RTS\rts_06\Debug\rts_06.exe' has exited with code 0 (0x0).Any idea as to what it means?Thanks,Rob   ;  Your errors:===================================================================Direct3D8: (ERROR) :Viewport outside the render target surfaceDirect3D8: (ERROR) :SetViewport failed.===================================================================The parameters to SetViewport() are too big.===================================================================Direct3D8: (ERROR) :Device does not support non-pow2 width for textureDirect3D8: (ERROR) :Failure trying to create a texture===================================================================This means that your hardware does not support non POWer Of 2 width textures and thus cannot create the texture. So your texture width needs to be something like 256 (2^8) rather than something like 235.