🔒 Locked
Sprite Draw order
Advertisement
Original Post
Ok, i have 2 sprites, one covers the entire screen and one is small. When i call draw, i'm calling "order_fronttoback" the sprite that covers the screen is at 1.0f and the other is at 0.0f, but i only see the bigger one... when i don't draw it, then i see the smaller one, so i know both are being drawn but for some reason the bigger one is one TOP of the smaller one... even though i have the "order_fronttoback" flag triggered...
depth buffer? in the IDirect3D9 object?
ok, i just enabled depth buffer... wasn't there b4 (ha..) but now whenever i try to clear the screen with "targetzbuffer" it fails.. y's this?
// init code
m_pD3dDeviceCOM->SetRenderState( D3DRS_ZENABLE, m_bZBuffer);
// frame code
m_pD3dDeviceCOM->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0)
the Clear function is what breaks the program
m_pD3dDeviceCOM->SetRenderState( D3DRS_ZENABLE, m_bZBuffer);
// frame code
m_pD3dDeviceCOM->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0)
the Clear function is what breaks the program
Quote:If you have the debug runtime installed, with the debug output level pumped up enough, it'll say why it fails.
Original post by EvilKnuckles666
ok, i just enabled depth buffer... wasn't there b4 (ha..) but now whenever i try to clear the screen with "targetzbuffer" it fails.. y's this?
Are you setting the EnableAutoDepthStencil member of your presentation parameters to true and chosing a depth format?
ohhhh, i thought the depth stencil was for stencilling not the Zbuffer.. and what's the format for? like A8R8G8B8?
Edit: nv/md, i found the right format: "D3DFMT_D16"
Edit: nv/md, i found the right format: "D3DFMT_D16"
wow... ok, it works know, BUT the bigger texture isn't drawing... what should i clear the screen with?
Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 0.0f, 0)
or
Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0)
or what?
i'm using all sprites (it's a 2D game) so all my Z's are between 0.0f and 1.0f
Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 0.0f, 0)
or
Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0)
or what?
i'm using all sprites (it's a 2D game) so all my Z's are between 0.0f and 1.0f
also, does this matter? instead of doing Draw(pTex, pRect, pCenter, pPos, Color)
pPos is NULL. the way i'm moving the sprites is by storing the XYZ coordinates in floats, then having a transform matrix and SetTransform()'ing the sprite, then drawing it with a NULL pointer to the position.. does that matter?
pPos is NULL. the way i'm moving the sprites is by storing the XYZ coordinates in floats, then having a transform matrix and SetTransform()'ing the sprite, then drawing it with a NULL pointer to the position.. does that matter?
know what i mean?
Hi there EvilKnuckles666,
How are you doing?
The Problem
Big sprite might be covering the smaller sprite
The Solution
I might be shooting in the dark here but have you tried testing if the order is correct. Render just 2 sprites and see if the way you order them are correct.
Your theory is correct. Would it be possible to see your Sprite declaration and specific draw calls?
I think the big sprite might be covering the little one and causing you to not see it.
Take care buddy. I hope this helps a bit.
PS: Just as a test, swop them around. If this fails please paste the code.
How are you doing?
The Problem
Big sprite might be covering the smaller sprite
The Solution
I might be shooting in the dark here but have you tried testing if the order is correct. Render just 2 sprites and see if the way you order them are correct.
Your theory is correct. Would it be possible to see your Sprite declaration and specific draw calls?
I think the big sprite might be covering the little one and causing you to not see it.
Take care buddy. I hope this helps a bit.
PS: Just as a test, swop them around. If this fails please paste the code.
well that was the problem for a while, but now the big sprite isn't even drawing...
the only time the bigger one actually draws now is if i put it at the same Z as the littler one (0.0f) but then again the bigger again is covering the littler one... y isn't it drawing at 1.0f Z?
Hi there EvilKnuckles666,
Buddy, it's me again ;)
The Problem
Sprites not rendering correctly (order/format problem)
The Solution
I would say that the following might fix your problem
1) Make sure you have enable the AutoDepthStencil
eg: presentParams.EnableAutoDepthStencil = true;
2) Set the AutoDepthStencilFormat
eg: presentParams.AutoDepthStencilFormat = D3DFMT_D24S8;
3) Make sure that you are clearing the depth buffer.
eg: If you don't clear your Z Buffer (Depth buffer) only the sprite at
Z = 0.0f will render
4) Make sure your sprite ordering is correct.
eg: Render sprite at Z = 0.0f
Render sprite at Z = 1.0f
I hope this helps a bit buddy.
Buddy, it's me again ;)
The Problem
Sprites not rendering correctly (order/format problem)
The Solution
I would say that the following might fix your problem
1) Make sure you have enable the AutoDepthStencil
eg: presentParams.EnableAutoDepthStencil = true;
2) Set the AutoDepthStencilFormat
eg: presentParams.AutoDepthStencilFormat = D3DFMT_D24S8;
3) Make sure that you are clearing the depth buffer.
eg: If you don't clear your Z Buffer (Depth buffer) only the sprite at
Z = 0.0f will render
4) Make sure your sprite ordering is correct.
eg: Render sprite at Z = 0.0f
Render sprite at Z = 1.0f
I hope this helps a bit buddy.
i did everything you said, every thing is set correctly but the bigger sprite still won't render at anything but 0.0f... i'm clearing the depth buffer to 1.0f, i even tried to clear it at 0.0f and nothing's working...
clearing the depth buffer to a float, what's that mean?
clearing the depth buffer to a float, what's that mean?
Could it be a problem with what float i'm clearing the depth buffer with? that's the only thing i can think of...
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement