• Advertisement
Sign in to follow this  

Problems with windowed mode

This topic is 3971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an issue with clipping in windowed mode. I think pictures would explain best. Okay, so this is what the picture looks like in the middle of the screen. The picture itself is irrevelent. Now I move it to the right (or bottom) and it looks normal. It's what you'd expect, the right side is clipped off. but when I move it to the left, the left side of the window is clipped like it should be but the right side of the picture is clipped off again. I'd like to fix it so that the side that is off screen is the side that is clipped from the picture. I'm not sure if it's relevent but I'm using the ID3DXSprite helper class. I'm not sure where the problem is. Oh, something weird that I've noticed. As I drag it to the left it's okay but when I release the mouse button it redraws with this weird clipping. BUT the entire time I'm moving the window back onto screen from the left it acts weird like this. Some reason it's normal when dragging it out of screen to the left until I let go. Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
It seems to me like you're accidentally setting the x-position of the background sprite to the leftmost clipping edge. In other words, I think when you're calculating your clipping bounds, somewhere you're trying to realign the sprite's position. If you're calculating a visible window rectangle, for example, and persistently moving the sprite around, seems something like that would be giving you the effect you're seeing.

On a side note, that wallpaper image looks kind of cool. Fushigi no umi no Nadia. Any good?

Share this post


Link to post
Share on other sites
Quote:
Original post by Omega147
It seems to me like you're accidentally setting the x-position of the background sprite to the leftmost clipping edge. In other words, I think when you're calculating your clipping bounds, somewhere you're trying to realign the sprite's position. If you're calculating a visible window rectangle, for example, and persistently moving the sprite around, seems something like that would be giving you the effect you're seeing.

On a side note, that wallpaper image looks kind of cool. Fushigi no umi no Nadia. Any good?


I thought about that but when you do ID3DXSprite->Draw and you send it a RECT with the coord to draw to, it's the coord of the window, not the screen correct? so I would figure that if I put top=0 and left=0 that it should always start drawing from the top-left corner of the window and it would ignore if the pixel is on screen or not. Tell me if I'm understanding this right or not. thanks.

Oh thanks. I found that pic a long time ago. I used to be in anime but only during the 90's. I'm not into modern anime. Something about it. Yeah, it's nadia. I'm not too sure what you're japanese says, I learned some japanese a couple years ago but I don't remember any of it now.

Share this post


Link to post
Share on other sites
I just don't get it, I mean, it acts so weird too. why doesn't it clip like that when I drag it off, why is it only like that when I set the window off to the left and when I drag it back. that's weird.

Share this post


Link to post
Share on other sites
It must be something with starting coordinates. Why don't you paste your code?

Share this post


Link to post
Share on other sites
Here's my render. There are a few bad programming practices here, such as creating the texture and destroying it within the render. It's just because I'm trying to cut out complication to figure out what's wrong.


void DEngine::render()
{

if (SpriteNode::zChanged)
{
spriteList.sort(SpriteNode::sortSpriteByZ);
SpriteNode::zChanged = false;
}

D3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );
D3DDevice->BeginScene();


//RENDER STARTS!
D3DSprite->Begin( D3DXSPRITE_DONOTSAVESTATE );

D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);


std::string filename = "C:\\Documents and Settings\\Joey Selah\\My Documents\\Visual Studio Projects\\Game\\images/nadia_3_800.bmp";
IDirect3DTexture9 * tex;
RECT box;
box.right = 1024;
box.left = 0;
box.top = 0;
box.bottom = 768;
D3DXCreateTextureFromFile(D3DDevice, filename.c_str(), &tex);
D3DSprite->Draw(tex, &box, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,0,0), 0xFFFFFFFF);

SAFE_RELEASE(tex);

D3DSprite->End();

D3DDevice->EndScene();
D3DDevice->Present( NULL, NULL, NULL, NULL );
}


Share this post


Link to post
Share on other sites
Why you load texture every time you call render? You need to do it just once when you initialize your application.
Also, you don't need this:
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

try this:

IDirect3DTexture9 * tex = 0;
void DEngine::init()
{
std::string filename = "C:\\Documents and Settings\\Joey Selah\\My Documents\\Visual Studio Projects\\Game\\images/nadia_3_800.bmp";


D3DXCreateTextureFromFile(D3DDevice, filename.c_str(), &tex);
}
void DEngine::exit()
{
if(tex) tex->Release();
}
void DEngine::render()
{

/*if (SpriteNode::zChanged)
{
spriteList.sort(SpriteNode::sortSpriteByZ);
SpriteNode::zChanged = false;
}*/


D3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );
D3DDevice->BeginScene();

RECT box;
box.right = 1024;
box.left = 0;
box.top = 0;
box.bottom = 768;
//RENDER STARTS!
D3DSprite->Begin( D3DXSPRITE_ALPHABLEND );
D3DSprite->Draw(tex, &box, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,0,0), 0xFFFFFFFF);
D3DSprite->End();

D3DDevice->EndScene();
D3DDevice->Present( NULL, NULL, NULL, NULL );
}


Share this post


Link to post
Share on other sites
Quote:
Original post by streamer
Why you load texture every time you call render? You need to do it just once when you initialize your application.
Also, you don't need this:
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

try this:
*** Source Snippet Removed ***


I mentioned that why I load it and destroy it everytime. It's not the issue, I did that just to simplify my code to see where things went wrong, I've contained what I believe to be the issue and can't find where it's going wrong. I have the set render state for an alphablendable pic. I don't think that's causing the issue but I can check.

Share this post


Link to post
Share on other sites
I really have no clue meanwhile why this happens, but I can guess why while dragging the window it appears fine: While you drag a window by its title bar, your message loop is completely stuck thanks to DispatchMessage () which won't return till you release the left mouse mouse, and thus no rendering is done. So while you drag the window off the screen, the area that is not visible within the window will just be not drawn and no redrawing of the window will be done, and it will appear fine. At the exact moment that you release the left mouse button from dragging the window, the message loop will start working again and will immediately draw the scene, which will cause the other problem.

BTW: WM_PAINT messages will still be receieved, because they aren't passed through the message loop anyway (they are sent immediately), but since you drag the window off the screen, no painting is required so no message will be generated. However, when you start dragging the window back, WM_PAINT message will be constantly generated, so assuming your WindowProc calls the Engine::Render () on response to WM_PAINT messages, the weird problem WILL happen during the dragging of the window back.

[Edited by - UriKiller on May 29, 2007 7:06:30 PM]

Share this post


Link to post
Share on other sites
Hi ,guys,I encounter the same problem too.
See this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=449821
I did not use D3DXSPRITE,just use D3DPT_TRIANGLELIST,but the same bug appears too.
How to post image here?
Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement