• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Interminable

DirectX sprite movement seems 'glitchy'

35 posts in this topic

I've got a sprite that moves across the screen, slowly. I've noticed as it moves, there appear to be 'imperfections', by that I mean it looks like it changes size by about single pixel in width as it moves along, then changing back, then doing it again, etc.

I can paste code if needed, but I'm wondering if there may simply be some 'fundamental' aspect of drawing sprites in DirectX that I may have missed. Edited by Interminable
0

Share this post


Link to post
Share on other sites
Nope, you haven't missed anything. Thankfully, sprites do move very smoothly :)

I am currently writing a game with sprites alone and initially had poor movement. It was jumpy and ugly, and not smooth. But, it turned out it was the way I was calculating movement speed against framerate and I was using INT for positioning (which sounds logical as I was working in screenspace).

How did I fix it?[list]
[*]Multiply the sprites movement speed against the time since last frame
[*]Position the sprites using [b]float[/b] instead of [b]int[/b]
[/list]
Not having seen any of your code I would check these two things. I would love to know how you go (and happy to help where I can) :)

And if you can share more info on your timers etc, that would be great.
0

Share this post


Link to post
Share on other sites
[quote name='lonewolff' timestamp='1342177538' post='4958738']
Nope, you haven't missed anything. Thankfully, sprites do move very smoothly [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I am currently writing a game with sprites alone and initially had poor movement. It was jumpy and ugly, and not smooth. But, it turned out it was the way I was calculating movement speed against framerate and I was using INT for positioning (which sounds logical as I was working in screenspace).

How did I fix it?[list]
[*]Multiply the sprites movement speed against the time since last frame
[*]Position the sprites using [b]float[/b] instead of [b]int[/b]
[/list]
Not having seen any of your code I would check these two things. I would love to know how you go (and happy to help where I can) [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

And if you can share more info on your timers etc, that would be great.
[/quote]

Here's what I was using to test it:

[CODE]
void Object::Update()
{
coordinates.x += (20 * frameRenderTime);
}
[/CODE]

coordinates is an instance of D3DXVECTOR3. Update() is called from another Update() function in my main Engine class, whose Update() function is called from main, inside the message loop:

[CODE]
try
{
GetSystemTime(&systemTime);
milliseconds = systemTime.wMilliseconds;
if(milliseconds != prevMilliseconds && milliseconds%10 == 0)
{
if(milliseconds<prevMilliseconds)
{
prevMilliseconds -= 1000;
// This will update roughly once every second.
}
frameRenderTime = milliseconds - prevMilliseconds;
frameRenderTime /= 1000;
prevMilliseconds = milliseconds;
mainWindow.enginePointer()->Update();
}

mainWindow.enginePointer()->rendererPointer()->Render();
}
catch(std::exception e)
{
e.what();
return 1;
}
[/CODE] Edited by Interminable
0

Share this post


Link to post
Share on other sites
This might help the issue.

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url] Edited by JWBaker
0

Share this post


Link to post
Share on other sites
[quote name='JWBaker' timestamp='1342195376' post='4958828']
This might help the issue.

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url]
[/quote]

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.
0

Share this post


Link to post
Share on other sites
[quote name='Interminable' timestamp='1342209934' post='4958898']
[quote name='JWBaker' timestamp='1342195376' post='4958828']
This might help the issue.

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url]
[/quote]

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.
[/quote]

Do you mean you are using the Sprite class?

What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.

Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));
0

Share this post


Link to post
Share on other sites
[quote name='JWBaker' timestamp='1342233507' post='4958984']
[quote name='Interminable' timestamp='1342209934' post='4958898']
[quote name='JWBaker' timestamp='1342195376' post='4958828']
This might help the issue.

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url]
[/quote]

What the article describes sounds like it could be related to the issue I'm having.

The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.
[/quote]

Do you mean you are using the Sprite class?

What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.

Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));
[/quote]

I was just altering the coordinates I was drawing it at with Id3DDevice::Draw(). ><

But I recall some of this transformation stuff now, I have a feeling I made a thread on here a while back which involved those but was to do with rotations...

Anyway, in trying to look at how you're doing that particular line, I am unsure how you're doing 'TransformState.Projection'. It doesn't seem to be possible with D3DTRANSFORMSTATETYPE. And that's the required first argument for iD3DXDevice::SetTransform().

In addition I assume there's some specific function for filling the D3DTRANSFORMSTATETYPE struct, but I can't seem to find it. ><


I have altered my code to how I was using SetTransform() in the past. First I have a PrepareTransform() function:

[CODE]

void Renderer::PrepareTransform(int input)
{
transformStateType->Projection;
d3dXSprite->SetTransform(
D3DXMatrixTransformation2D(&d3dMatrix,
NULL,
0.0,
&D3DXVECTOR2(1.0,1.0),
&D3DXVECTOR2(texturesToRender[input].objectPointer->originPointer()->x,texturesToRender[input].objectPointer->originPointer()->y),
0.0f,
&D3DXVECTOR2(texturesToRender[input].objectPointer->coordinatesPointer()->x,texturesToRender[input].objectPointer->coordinatesPointer()->y));

d3dXSprite->SetTransform(&d3dMatrix);
}
[/CODE]

And I draw after that function is called:

[CODE]

if(FAILED(hResult = d3dXSprite->Draw(*texturesToRender[i].objectPointer->texturePointer()->texturePointer(), NULL, NULL, NULL, 0xffffffff)))
{
[/CODE]

Unfortunately the issue still exists, but I would assume this is because I'm not dealing with this projection matrix stuff you're mentioning. Edited by Interminable
0

Share this post


Link to post
Share on other sites
I still think it is to do with your timer. GetSystemTime() seems to be only accurate to the millisecond.

If you have a basic scene you might be rendering faster than 1000 fps, so your scene will be choppy as the timer wont be acurate enough.

On my 3 year old video card my application (that also uses sprites) is rendering at 8000 FPS. This is why I had the same problems that your are experiencing. I had to re-think my timer.

Give my timer a try [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[code]
#pragma once
class Timer
{
public:
Timer()
{
liCurrent.QuadPart=0;
liPrevious.QuadPart=0;
}
~Timer()
{
}
long double TimeSinceLastFrame()
{
QueryPerformanceFrequency(&liPerfFreq);
QueryPerformanceCounter(&liCurrent);
ddFrameTime=(liCurrent.QuadPart-liPrevious.QuadPart)/long double(liPerfFreq.QuadPart)*1000;
liPrevious.QuadPart=liCurrent.QuadPart;
return ddFrameTime;
}
private:
LARGE_INTEGER liCurrent;
LARGE_INTEGER liPrevious;
LARGE_INTEGER liPerfFreq;
LARGE_INTEGER liStart;
long double ddFrameTime;
};
[/code]TimeSinceLastFrame() will return exactly that (but using the performance counters)

I would love to know how you go [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by lonewolff
0

Share this post


Link to post
Share on other sites
[quote name='lonewolff' timestamp='1342256055' post='4959028']
I still think it is to do with your timer. GetSystemTime() seems to be only accurate to the millisecond.

If you have a basic scene you might be rendering faster than 1000 fps, so your scene will be choppy as the timer wont be acurate enough.

On my 3 year old video card my application (that also uses sprites) is rendering at 8000 FPS. This is why I had the same problems that your are experiencing. I had to re-think my timer.

Give my timer a try [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[code]
#pragma once
class Timer
{
public:
Timer()
{
liCurrent.QuadPart=0;
liPrevious.QuadPart=0;
}
~Timer()
{
}
long double TimeSinceLastFrame()
{
QueryPerformanceFrequency(&liPerfFreq);
QueryPerformanceCounter(&liCurrent);
ddFrameTime=(liCurrent.QuadPart-liPrevious.QuadPart)/long double(liPerfFreq.QuadPart)*1000;
liPrevious.QuadPart=liCurrent.QuadPart;
return ddFrameTime;
}
private:
LARGE_INTEGER liCurrent;
LARGE_INTEGER liPrevious;
LARGE_INTEGER liPerfFreq;
LARGE_INTEGER liStart;
long double ddFrameTime;
};
[/code]TimeSinceLastFrame() will return exactly that (but using the performance counters)

I would love to know how you go [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

I'll give it a try...but I'm also updating how far they should move using the time it takes to render the last frame. They appear to move smoothly already, just with minute changes in size as they go. Anyway, I'll EDIT this post with how I get on (or reply in a new post if there have been further responses).

EDIT: TimeSinceLastFrame()'s first return value is insanely high (eg 9029811) and screws up anything that relies on it for moving etc at the very beginning of the program. It eventually settles down to values of hundreds.

EDIT2: It appears to do this regardless of when the first call to it was, so I call it a few times needlessly at the beginning of my program to make it settle down a little before I start actually needing to use it.

Unfortunately the issue I am experiencing with the minute changes in size remains. Edited by Interminable
0

Share this post


Link to post
Share on other sites
[quote name='Interminable' timestamp='1342257151' post='4959032']I'll give it a try...but I'm also updating how far they should move using the time it takes to render the last frame.[/quote]

No probs, but all you need to do is multiply your movement speed against TimeSinceLastFrame() [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by lonewolff
0

Share this post


Link to post
Share on other sites
Personally I do not believe this is a timing issue. I think JWBaker was on the right track with regard to texture distortion. I just have no idea how to properly move it (by that I mean without the distortion) with SetTransform(), trouble is I'm unsure what step I need to do for Projection Matrices (as per my question a few posts back [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] ).

EDIT: I could have sworn when I edited my previous post that your post was not originally there. My edits explain what happened. Edited by Interminable
0

Share this post


Link to post
Share on other sites
Sorry to bump this but I am still experiencing this issue. I completely rewrote how I was drawing sprites to use textured quads instead of ID3DXSPRITE but I'm still getting the issue.

I did read that I should adjust the coordinates of my quad by -0.5, but this hasn't helped.

This is exactly what happens:

* My sprite moves across the screen from left to right at a steady rate (calculated using the time it took to render each frame).
* As a sprite moves along, at some point it will appear to shrink by what appears to be one pixel on the right side.
* After it has moved along a bit more it will appear to expand by one pixel on the left side, thus returning to its original size.
* It will repeat this process whilst it moves along.

I'm not using any custom defined Projection Matrices or anything like that.

This is the code I'm using for configuring my vertices, it's based on some other code I found online a while back.

[CODE]
void Sprite::ConfigureVertices()
{
if(vertexBuffer)
{
vertexBuffer->Release();
}
if(FAILED(hResult = (*mTexturePointer->rendererPointer()->d3dDevicePointer())->CreateVertexBuffer
(sizeof(TLVERTEX)*4,
D3DUSAGE_WRITEONLY,
mTexturePointer->rendererPointer()->GetD3DFVF_CUSTOMVERTEXFORMAT(),
D3DPOOL_MANAGED,
&vertexBuffer,
NULL)))
{
logWindow.AddLogEntry(3, TEXT("IDirect3DDevice9::CreateVertexBuffer() FAILED"), hResult, GetLastError());
MessageBox(*mTexturePointer->rendererPointer()->hwndPointer(), TEXT("IDirect3DDevice9::CreateVertexBuffer() failed! This program will now close."), TEXT("CRITICAL FAILURE"), MB_OK | MB_ICONERROR | MB_TOPMOST);
CheckCriticalExit();
}
else
logWindow.AddLogEntry(6, TEXT("IDirect3DDevice9::CreateVertexBuffer() succeeded"), hResult);
vertices.resize(4);
vertices[0].colour = 0xFFFF00FF;
vertices[0].x = (float) objectPointer->coordinatesPointer()->x - 0.5f; // Left
vertices[0].y = (float) objectPointer->coordinatesPointer()->y - 0.5f; // Top
vertices[0].z = 0.0f;
vertices[0].rhw = 1.0f;
vertices[0].u = 0.0f;
vertices[0].v = 0.0f;
vertices[1].colour = 0xFFFF00FF;
vertices[1].x = vertices[0].x+mTexturePointer->textureDescPointer()->Width;// - 0.5f; // Right
vertices[1].y = objectPointer->coordinatesPointer()->y - 0.5f; // Top
vertices[1].z = 0.0f;
vertices[1].rhw = 1.0f;
vertices[1].u = 1.0f;
vertices[1].v = 0.0f;
vertices[2].colour = 0xFFFF00FF;
vertices[2].x = (float) vertices[0].x+mTexturePointer->textureDescPointer()->Width;// - 0.5f; // Right
vertices[2].y = (float) vertices[0].y+mTexturePointer->textureDescPointer()->Height;// - 0.5f; // Bottom
vertices[2].z = 0.0f;
vertices[2].rhw = 1.0f;
vertices[2].u = 1.0f;
vertices[2].v = 1.0f;
vertices[3].colour = 0xFFFF00FF;
vertices[3].x = (float) objectPointer->coordinatesPointer()->x - 0.5f; // Left
vertices[3].y = (float) vertices[0].y+mTexturePointer->textureDescPointer()->Height;// - 0.5f; // Bottom
vertices[3].z = 0.0f;
vertices[3].rhw = 1.0f;
vertices[3].u = 0.0f;
vertices[3].v = 1.0f;

if(FAILED(hResult = vertexBuffer->Lock(0,0, (void**)&vertexVoidPointer, 0)))
{
logWindow.AddLogEntry(3, TEXT("IDirect3DVertexBuffer9::Lock() FAILED"), hResult, GetLastError());
MessageBox(*mTexturePointer->rendererPointer()->hwndPointer(), TEXT("IDirect3DVertexBuffer9::Lock() failed! This program will now close."), TEXT("CRITICAL FAILURE"), MB_OK | MB_ICONERROR | MB_TOPMOST);
CheckCriticalExit();
}
else
logWindow.AddLogEntry(6, TEXT("IDirect3DVertexBuffer9::Lock() succeeded"), hResult);

memcpy(vertexVoidPointer, vertices.data(), (sizeof(TLVERTEX)*vertices.capacity()));
vertexBuffer->Unlock();
}
[/CODE]

I would greatly appreciate any assistance with this issue, I've searched online and found stuff relating to texel-pixel inconsistencies and whatnot. This SOUNDS like my issue, but what I tried to do to compensate for it (based on stuff I read online) does not appear to be doing anything to help. Edited by Interminable
0

Share this post


Link to post
Share on other sites
Hi,

try to round the x- and y-coordinates to the nearest integer when translating.
0

Share this post


Link to post
Share on other sites
What kind of filtering are you using?

I'm not sure if filtering applies to the edges of sprite renders but it may be worth looking at, since it's just changing a flag.
1

Share this post


Link to post
Share on other sites
[quote name='Khatharr' timestamp='1343286202' post='4963209']
What kind of filtering are you using?

I'm not sure if filtering applies to the edges of sprite renders but it may be worth looking at, since it's just changing a flag.
[/quote]

This. If Im understanding the issue right, thats definitely the problem. In the texture sampler filter, set everything to POINT instead of LINEAR. I remember finding the same "issue" the first time I did my pixel perfect sprite class.

Linear is good if you will rotate the sprite, but for translation it leaves a ghost when the sprite moves/lies across/on coords that arent pixel perfect ( i.e. 1.06 pixels to righ)
0

Share this post


Link to post
Share on other sites
If you want pixel perfect sprites you have to make sure that coordinates get mapped exactly to pixels. I think that is the problem you seem to experience.
0

Share this post


Link to post
Share on other sites
[quote name='Icebone1000' timestamp='1343338380' post='4963437']
[quote name='Khatharr' timestamp='1343286202' post='4963209']
What kind of filtering are you using?

I'm not sure if filtering applies to the edges of sprite renders but it may be worth looking at, since it's just changing a flag.
[/quote]
This. If Im understanding the issue right, thats definitely the problem. In the texture sampler filter, set everything to POINT instead of LINEAR. I remember finding the same "issue" the first time I did my pixel perfect sprite class.
Linear is good if you will rotate the sprite, but for translation it leaves a ghost when the sprite moves/lies across/on coords that arent pixel perfect ( i.e. 1.06 pixels to righ)
[/quote]

I just tried doing as you describe with no discernible effect on the issue I am experiencing. Unless I'm doing something wrong.

To write the lines below I used this page for help which I found from Googling what you stated: [url="http://www.toymaker.info/Games/html/sampler_states.html"]http://www.toymaker....ler_states.html[/url]

If I have misinterpreted your instructions or not carried them out appropriately please let me know.

[CODE]
md3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
md3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
md3dDevice->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
md3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
md3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
md3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT );
[/CODE]

[quote name='Madhed' timestamp='1343340877' post='4963448']
If you want pixel perfect sprites you have to make sure that coordinates get mapped exactly to pixels. I think that is the problem you seem to experience.
[/quote]

I understand this to most likely be the case, but my last post here was about how it wasn't fixing the issue (or indeed making any noticeable change).

EDIT:

[quote name='JWBaker' timestamp='1342233507' post='4958984']
[quote name='Interminable' timestamp='1342209934' post='4958898']
[quote name='JWBaker' timestamp='1342195376' post='4958828']
This might help the issue.

[url="http://msdn.microsof...0(v=vs.85"]http://msdn.microsof...0(v=vs.85[/url]).aspx
[/quote]
What the article describes sounds like it could be related to the issue I'm having.
The problem is, I'm not drawing a 2D texture to a surface. It's a standalone sprite. I'm unsure how I can deal with this.
[/quote]
Do you mean you are using the Sprite class?
What you need to do is shift your Projection Matrix to account for the issue. This is how i setup mine and it seems to work. I'm not a DX master by any means but give it a shot and see if it helps. My Coordinate system has 0,0 at the center of the screen and +Y is up.
Device.SetTransform(TransformState.Projection, Matrix.Translation(-0.5f, 0.5f, 0.0f) * Matrix.OrthoLH(_form.ClientSize.Width, _form.ClientSize.Height, 0, 1));
[/quote]

I've finally worked out that the reason I can't find these DirectX functions is because they don't exist, they're part of .NET but I'm not using it, I'm using the pure Win32 API. Do you know how I can replicate what you're doing here using normal DirectX functions?

Having since altered my code so I set the View Matrix and Projection Matrix, I'm currently setting my Projection Matrix in this manner:

[CODE]
D3DXMATRIXA16 projectionMatrix;
D3DXMatrixPerspectiveFovLH(&projectionMatrix, fieldOfView, aspectRatio, closestZLimit, furthestZLimit);
md3dDevice->SetTransform(D3DTS_PROJECTION, &projectionMatrix);
[/CODE] Edited by Interminable
0

Share this post


Link to post
Share on other sites
JWBaker, based on your original post I have eventually managed to put together this which I 'think' is the equivalent of what you put, however this may not be the case as it does not fix the issue unfortunately.

[CODE]
void Renderer::SetProjectionMatrix(float fieldOfView, float aspectRatio, float closestZLimit, float furthestZLimit)
{
D3DXMATRIXA16 projectionMatrix;
//D3DXMatrixPerspectiveFovLH(&projectionMatrix, fieldOfView, aspectRatio, closestZLimit, furthestZLimit);

D3DXMatrixTranslation(&projectionMatrix, -0.5f, 0.5f, 0.0f);
D3DXMatrixOrthoLH(&projectionMatrix, window_width, window_height, 0, 1);
md3dDevice->SetTransform(D3DTS_PROJECTION, &projectionMatrix);
}
[/CODE] Edited by Interminable
0

Share this post


Link to post
Share on other sites
[quote name='lonewolff' timestamp='1343647159' post='4964451']
Out of interest, is this a windowed application?
[/quote]

It is indeed a windowed application.
0

Share this post


Link to post
Share on other sites
I believe that this is your answer.

If you have a Window of 800x600 for example. The client area is less (eg 792x594 or something like that).

If you have set your D3DPRESENTPARAMETERS to 800 x 600 the DX screen will differ from your actual client area.

So, your sprites will be getting resized to fit and you will definately get the phenomenon that you are having.

If you run full screen, do you have the same problem (I am guessing not).
0

Share this post


Link to post
Share on other sites
[quote name='lonewolff' timestamp='1343649700' post='4964463']
I believe that this is your answer.

If you have a Window of 800x600 for example. The client area is less (eg 792x594 or something like that).

If you have set your D3DPRESENTPARAMETERS to 800 x 600 the DX screen will differ from your actual client area.

So, your sprites will be getting resized to fit and you will definately get the phenomenon that you are having.

If you run full screen, do you have the same problem (I am guessing not).
[/quote]

You're right, in fullscreen the issue does not appear to be present!

However, when trying to set the present parameters to the client area size, it didn't fix the issue when running it in a window.

This is what I was doing:

[CODE]
RECT tempRect;
GetClientRect(hwndInput, &tempRect);
d3dPresentationParameters.BackBufferWidth = tempRect.right;
d3dPresentationParameters.BackBufferHeight = tempRect.bottom;
[/CODE] Edited by Interminable
0

Share this post


Link to post
Share on other sites
[quote name='Interminable' timestamp='1343652839' post='4964473']
[quote name='lonewolff' timestamp='1343649700' post='4964463']
I believe that this is your answer.

If you have a Window of 800x600 for example. The client area is less (eg 792x594 or something like that).

If you have set your D3DPRESENTPARAMETERS to 800 x 600 the DX screen will differ from your actual client area.

So, your sprites will be getting resized to fit and you will definately get the phenomenon that you are having.

If you run full screen, do you have the same problem (I am guessing not).
[/quote]

You're right, in fullscreen the issue does not appear to be present!

However, when trying to set the present parameters to the client area size, it didn't fix the issue when running it in a window.

This is what I was doing:

[CODE]
RECT tempRect;
GetClientRect(hwndInput, &tempRect);
d3dPresentationParameters.BackBufferWidth = tempRect.right;
d3dPresentationParameters.BackBufferHeight = tempRect.bottom;
[/CODE]
[/quote]

How are you building your window? You have to do some math in order to get the client size correct by taking into accound the size of the windows border, its been a while since i have programmed that kind of thing, but lets see your window creation.
0

Share this post


Link to post
Share on other sites
[quote name='JWBaker' timestamp='1343660204' post='4964508']
[quote name='Interminable' timestamp='1343652839' post='4964473']
[quote name='lonewolff' timestamp='1343649700' post='4964463']
I believe that this is your answer.

If you have a Window of 800x600 for example. The client area is less (eg 792x594 or something like that).

If you have set your D3DPRESENTPARAMETERS to 800 x 600 the DX screen will differ from your actual client area.

So, your sprites will be getting resized to fit and you will definately get the phenomenon that you are having.

If you run full screen, do you have the same problem (I am guessing not).
[/quote]

You're right, in fullscreen the issue does not appear to be present!

However, when trying to set the present parameters to the client area size, it didn't fix the issue when running it in a window.

This is what I was doing:

[CODE]
RECT tempRect;
GetClientRect(hwndInput, &tempRect);
d3dPresentationParameters.BackBufferWidth = tempRect.right;
d3dPresentationParameters.BackBufferHeight = tempRect.bottom;
[/CODE]
[/quote]

How are you building your window? You have to do some math in order to get the client size correct by taking into accound the size of the windows border, its been a while since i have programmed that kind of thing, but lets see your window creation.
[/quote]

This is what GetClientRect() does, or at least that's my understanding of it. GetWindowRect() would get the size including the border, etc.

EDIT: Interestingly, if I run it fullscreen at a resolution other than my native one (or the one I'm currently on I'm assuming), IDirect3DDevice9::Present() fails, but checking the HRESULT says the operation completed successfully. I have no idea what's wrong there. Edited by Interminable
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0