   Z-Values other than 0.0f causes black screen
  *sigh*Sorry for my 3rd post about that topic, but after I didn't get any answers on my last question (regarding the use of the IDXSPRITE-Interface) I spent a lot of time trying to figure it out myself - and I finally succeded. It will take a lot of time re-writing nearly my whole code from having dozens of sprites to only have on sprite and use it to render all textures at the needed possitions.. but anyway, I encounter another problem:Whethever value for z I use other than 0.0f, the grafic isn't drawn at all. First thing I checked is if the z-buffer is switched on. It is, because deactivating it will show all grafics, even with not null z-values.But beside of this, I don't have a single Idea.So, I stepped back to a former backup from somewhere around juli where I didn't have much more stuff than a background and some basic features, to make sure there is nothing in my code that could possibly cause that issues. Still, any value other than 0.0f would cause the texture not to be drawn (or, in a few cases I get a very strange looking grafic issues, seems like some parts of the texture are drawn and others are not).I uploaded a sample of that problem here:http://rapidshare.com/files/431443436/SideScrollerEngine.rarIt's basically a project showing that issue (there is some unnessacary stuff in it, sry for that), including source code and one pre-compiled exe.What you will see if you open it is: one blue grafic drawn a bit apart from 0,0 , and in between the graphic all black.Now look at this code:void CSprite::Draw(void){m_vPosition.x = 0;m_vPosition.y = 0;m_vPosition.z = 0.1f;    DWORD ModulateColor = 0xFFFFFFFF;    m_lpSprite->Begin(D3DXSPRITE_SORT_DEPTH_FRONTTOBACK | D3DXSPRITE_ALPHABLEND);    // Sprite zeichnen    m_lpSprite->Draw(m_lpTexture,  NULL,  NULL,  &m_vPosition,  ModulateColor);m_vPosition.x = 100;m_vPosition.y = 100;m_vPosition.z = 0.0f;m_lpSprite->Draw(m_lpTexture,    NULL,    NULL,    &m_vPosition,    ModulateColor);    m_lpSprite->End();}If you change the linem_vPosition.z = 0.1f;to m_vPosition.z = 0.0f;the grafic will appear. Does anybode have an idea, or maybe want to take a look at the project I uploaded? I would really appreciate this, that issue is just nasty (man, I figured out all that other crap why my z-buffer aint working, now I still can't use it because it doesn't allow any other values than 0.0f?? holy crap..) and I'm currently running in more and more situations while programming where a z-value would be really nice. thx in advance..
  Post the code where you set up your projection matrix. Sounds like your near and far clip plane are too close together for what you're trying to do.-me   ;  Well, uhm... I don't use any projection matrix at all oO or I just don't set up one, dunno.. maybe thats the problem? I'm currently just setting up all that Direct3D-Stuff, and thats it. To move the scene/camera, I just move it. Though I read that I shouldn't do this it works quite fine, and I don't have any issues right now. But could you tell me how to use such a matrix? I would regret not to use it to move the camera, but if I have to only set it up to use z-buffer, I'd do that, if I knew how (all my books/tutorials somehow don't cover that topic, except for 3D-Graphics; btw I'm doing a 2D-Game, thought that this would be clear)..   ;  The projection matrix doesn't position the camera, but defines the "lens" it uses. A great reference is the DX SDK docs,   ;  Thanks so far for explaining this... but it won't work eigther.Tried it this way:D3DXMATRIX Matrix;D3DXMatrixOrthoLH(&Matrix, 1024, 768, 0.0f, 1.0f);m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&Matrix);in the method to set up my Direct3D-Device:BOOL CDirect3D::Init(HWND hWnd, BOOL bWindowed){    // Direct3D-Objekt erzeugen    m_lpD3D = Direct3DCreate9(D3D_SDK_VERSION);    if(NULL == m_lpD3D)    {   // Fehler, D3D-Objekt wurde nicht erzeugt   return FALSE;    }    // Parameter fuer den Modus festlegen    D3DPRESENT_PARAMETERS PParams;    ZeroMemory(&PParams, sizeof(PParams));    PParams.SwapEffect  = D3DSWAPEFFECT_DISCARD;    PParams.hDeviceWindow    = hWnd;    PParams.Windowed    = bWindowed;PParams.PresentationInterval = true;    PParams.BackBufferWidth  = 1024;    PParams.BackBufferHeight = 768;    PParams.BackBufferFormat = D3DFMT_A8R8G8B8;PParams.EnableAutoDepthStencil = 1;PParams.AutoDepthStencilFormat = D3DFMT_D16;PParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;    HRESULT hr;    // Direct3D-Geraet anlegen    if(FAILED(hr = m_lpD3D->CreateDevice(   D3DADAPTER_DEFAULT,    D3DDEVTYPE_HAL,    hWnd,    D3DCREATE_SOFTWARE_VERTEXPROCESSING,    &PParams,    &m_lpD3DDevice)))    {   // Fehler, Geraet kann nicht angelegt werden   const WCHAR* Err = DXGetErrorDescription(hr);   DXTRACE_MSG(Err);   return FALSE;    }    // Schrift erzeugen    m_lpD3DDevice->SetRenderState ( D3DRS_ZENABLE, TRUE);D3DXMATRIX Matrix;D3DXMatrixOrthoLH(&Matrix, 1024, 768, 0.0f, 1.0f);m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&Matrix);    CreateFont();    // Zeiger auf dem Hintergrundpuffer holen    m_lpD3DDevice->GetBackBuffer(0, 0,    D3DBACKBUFFER_TYPE_MONO,    &m_lpBackBuffer);m_lpD3DDevice->Clear(0, 0, D3DCLEAR_TARGET, m_ClearColor,0, 0);    return TRUE;}Did I forget anything? Maybe handing some parameter to the Device (I thought I read something about that somewhere in that forums)..   ;  First, are you using Debug Runtime? If not, do that. It will give you a lot of information.Second, even though you want a 2D app, you should work through several of the examples in the SDK to learn how to setup DirectX. I understand they're 3D but you need to learn the basics.With regard to the code you posted, you have several problems.If you're setting up in windowed mode, don't set the backbuffer width and height in the present parameters. CreateDevice will take the dimensions of the client area of the window to size the backbuffer for you.For readability, it's always a good idea to match variable types when setting a parameter. E.g., EnableAutoDepthStencil is a BOOL. Set it to TRUE or FALSE, not "1".Never set the near-plane of your projection to 0. You can set it to a small value if you like, such as 0.1f, etc.Also, you should set up a viewport. Look at the documentation and some example code to see how to do that.   ;  Thx for the advice, gonna check that out and correct it. I don't use the debug routine yet, but I tried it out, thats what I get:Direct3D9: :====> ENTER: DLLMAIN(00e2e6e0): Process Attach: 000015d8, tid=000015d4Direct3D9: :====> EXIT: DLLMAIN(00e2e6e0): Process Attach: 000015d8Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFODirect3D9: (INFO) :======================= Hal HWVP device selectedDirect3D9: (INFO) :HalDevice Driver Style 9Direct3D9: :BackBufferCount not specified, considered default 1 Direct3D9: :DoneExclusiveModeWell, anyway, is there no solution for my actual problem? It seems to be not a problem of projection, but.. chaning values in my Matrix for the projection doesn't do a damn thing, even if I use all 0.0f-values for the sprites. I'm getting fed up.. it can't be so hard making that damn z-buffer to work. I mean, how many people in the forum have done that correctly? Can't somebody say whats wrong with my code, or is everything alright here (everything that has something to do with the problem of the z-buffer)?   ;  This is you setting your projection matrix:D3DXMatrixOrthoLH(&Matrix, 1024, 768, 0.0f, 1.0f);0.0 -> near clip plane1.0 -> far clip planeI believe that with a projection matrix like you have, it will only render objects with z coordinates of  -1.0 -> 0.0 (if your camera is pointing down the negative z axis. i.e. looking "down").  Your far clip plane is 1.0 units away along the camera's view axis.  Since your camera is probably looking down the negative z axis, this is why your objects aren't showing up with > 0.0 z. You can easily test this experimentally by setting the z = -0.1. It should render.  You can then either work with negative z values [-1.0..0.0] or you can change your near plane to -1.0 and your far plane to 0.0 which will allow z values of [0.0..1.0]-me   ;[qoute]I believe that with a projection matrix like you have, it will only render objects with z coordinates of -1.0 -> 0.0 (if your camera is pointing down the negative z axis. i.e. looking "down"). Your far clip plane is 1.0 units away along the camera's view axis. Since your camera is probably looking down the negative z axis, this is why your objects aren't showing up with > 0.0 z. You can easily test this experimentally by setting the z = -0.1. It should render. You can then either work with negative z values [-1.0..0.0] or you can change your near plane to -1.0 and your far plane to 0.0 which will allow z values of [0.0..1.0]Thx, I tried it out, but still no render, only black screen. Tried out both, setting near and far plane to your values or changing the sprites z to a negative value. Won't work eigther..Well, anyway, a strange thing that I found out was that my screen renders at a z value of 0.0f (which we already know), BUT no matter what the Matrix I  use is set to. For example, even that things like:D3DXMatrixOrthoLH(&Matrix, 232, 500, -110.0f, 120.0f);D3DXMatrixOrthoLH(&Matrix, 21488, 2400, 110.0f, 120.0f);will give me a fine render when using 0.0f for z, otherwise a black screen. Could it be that my transform isn't set correctly? Although the debugger doesn't show anything like that.. if I do this:if(!m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&Matrix))int i = 0;and put a halting point to the second line, it always will jump to that line. But i quess thats just how that function works.. I tried it out with FAILED() as well, but that value is not true, so I quess thats just speculations.. Any other ideas? Or can I somehow find a complete tutorial or source code that uses sprites with the z-stencil-buffer? DirectX SDK doc might be helpful but not if you have no idea why something isn't working.. with a source where sprites are used properly I might be able to figure out whats wrong.;  YEAHHH!!!I found it finally out. Had nothing to do with Viewport or projection matrices (which aren't even used at all for 2 grafics from what I figured out. Viewport works, but if I set a special projection it doesn't change a damn thing).The solution:m_lpD3DDevice->BeginScene()m_lpD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(255,255,255),1.0f,0);I didn't know that I had to clear the buffer (although it was so plain logical -.-), found it out using google..  Wasn't mentioned in my books eigther oODid nobody knew that our did everybode just assumed that I was already doing this? oOBut anyway, now it won't even matter if I use more than one Sprite-Interface, they are all aligned perfectly at the z-value.*sigh* at least I got that stuff out of the way.. only have to edit the code to only use 1 sprite interface but just for speed improvements..   