Present() = pixelated

Started by
12 comments, last by pathon 15 years, 5 months ago
Hi, I currently use IDirect3DDevice9::Present(NULL, NULL, NULL, NULL) to display graphics. It works great and scales in window mode if I resize or maximize. The problem is when using window mode on Vista SP1: -It works great, but when I have aero enabled it causes slight performance degradation. -Although when I have aero disabled, the graphics will be fine but when I resize or maximize the window - Present() starts scaling it turns bad. Instead of scaling normally and the graphics being nicely stretched - the graphics now looked horrible quality - kinda like POINT vs BILINEAR (if you know what I mean)
Advertisement
Which is why most people Reset their device with a backbuffer the new size of the client rect. Is there a reason you're leaving the backbuffer at the old size?
I play in a resolution of 640x480 either in fullscreen or windowed.

If I started in window mode and maximized, the game will look similar to if I started in fullscreen. This is why I don't reset() - also because I get much lower FPS in high resolution and I prefer the size of everything when rendered at 640x480.

To keep tight control over the stretching/filtering, you could render your entire scene to a render target and display that on a 'fullscreen' quad at the end of the frame (fullscreen meaning, fitting the client area). When rendering the quad, you'll effectively be re-sampling the scene with whatever filtering you want.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
Could you post some example pseudo-code for this?
Look like you don't handle WM_SIZE message, that's why you have stretched display.

Take a look at this sample.
As I said before - I do not desire or need to call Reset().

Stretching via Present() works perfectly except when running with Aero disabled on Vista.
Not desiring to do something, doesn't mean that you are right, only maybe lack of skill/experience to do some tasks, or know certain things.

The first error will show, when you start your program and change desktop resolution with program running, so handling lost devices is kind of essential in this case. That means that you will need to handle reseting of device if you want to have your program running without bugs.

Normally AERO is handled from directx, meaning that when aero is enabled, possibly you have pre-setted the render states of your device, and when the aero is disabled, those render states are different.

Eventually comparing render states when aero is on/off, will show you differences, and what you need to set, to work it properly.

Quote:Original post by pathon
Could you post some example pseudo-code for this?


It's basically the typical post-processing setup, going a bit like this each frame:


  1. (begin drawing)
  2. Set render target on the device
  3. Render entire scene to the target
  4. Wrap up rendering to the target, iirc using EndScene
  5. Set the render target as a texture on the device
  6. Draw a fullscreen quad with the texture applied and the filtering of your choice
  7. Present
  8. (done)


I'm not quite sure how various steps need to be implemented in C++/DX, but I think the DX SDK has a few samples (look for post-processing and be sure to check the help on that SetRenderTarget method) and many only tutorials should also provide info on how to set this up.

Rereading pathon's last comment though, if there really are differences in the render states/sampler filter settings you might want to try explicitly setting the differing states to the values that work for you. It sure beats going the long way around with my suggestion, unless you were planning to do some post-processing anyway.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
I set different values for samplerstates and it didn't help, I also read the sdk post-processing tutorial and didn't understand it. I followed some tutorials and they didn't work. :(

This topic is closed to new replies.

Advertisement