Target window and render target = different sizes

Started by
6 comments, last by stromchin 12 years, 11 months ago
I am currently making a tool to join textures in one window.
my device is linked to a picturebox, and the picturebox size should be the resolution of a console for example. (It can be changed)

Now, while rendering 2D textures in there, I have no problem at all.
Now the problem is when I use my preview window.
I use a swap chain for that window, and I can change the buffer size if it's smaller than the original picturebox...
but if it's bigger, then it displays a black screen

So basically, I want to have a big backbuffer, but I think it's linked to the picturebox! so if if I try to change the backbuffer, it won't matter in the end (at least for the swap chain)
Because somehow the backbuffer is always the size of the picturebox.

I'm making this in c# with mdx, but I guess any kind of directx help would work.
Advertisement
If I understand what you are doing correctly, couldn't you just scale the picture to fix in the constrains of your picture box in your preview?
Using something along the lines of the equivalent of stretchrect in directx.

You could also dynamically resize your window and picture box depending on the size of the texture you are drawing to it.

If I understand what you are doing correctly, couldn't you just scale the picture to fix in the constrains of your picture box in your preview?
Using something along the lines of the equivalent of stretchrect in directx.

You could also dynamically resize your window and picture box depending on the size of the texture you are drawing to it.


Thanks for replying.

I can do that with the second one. (The preview). The window fits the texture perfectly.
but the first one has to have a size specified by the user. And in most cases, this size is usually smaller than the textures.

So the second window (with the preview) can show pictures perfectly, as long as they are smaller than the original window (which is usually tiny)
If they images are bigger than the original window, then it just displays a black screen.

I've gone through all the options I could, but the thing I'm trying now, is to have the device's back-buffer bigger than the window it's using to display it.
Unfortunately it seems that it automatically re-sizes the buffer to the maximum size of the main window.

since this is a tool and not a real game, having a bigger back-buffer wouldn't be an inconvenience. Something like 2048 x 2048 would be ideal.
I kind of solved it with a small hack.

The problem was that the device's backbuffer wouldn't get bigger than the window where it was supposed to present it.
Well, the window is in fact a picturebox, and now that picturebox is huge, but in the "present" I tell it to present only a rectangle the size of what the actual window is supposed to be

this way I can have my big buffer for my swap chain, and only have a small size main window... even though it's bigger.
This makes auto-scroll bar appear when it's not necessary, but oh well. it's just a tool after all.
Mind if I ask why you're using managed directx with C# instead of using XNA+C#?

Mind if I ask why you're using managed directx with C# instead of using XNA+C#?


yes, you may.
I'm using this because it's what they have been using at my workplace.
I just started working here. And I "inherited" this unfinished tool.
Next time I'll try not to use something so old. But this time it wasn't up to me.

I got really sad when I saw that this was deprecated already :(

This makes auto-scroll bar appear when it's not necessary, but oh well. it's just a tool after all.


There should be a way to tell to window when you create it that you do not want auto scroll bars, although I am not sure exactly how to do it.
Should be a flag, or you may have to send a message to the window.

[quote name='stromchin' timestamp='1304919569' post='4808384']
This makes auto-scroll bar appear when it's not necessary, but oh well. it's just a tool after all.


There should be a way to tell to window when you create it that you do not want auto scroll bars, although I am not sure exactly how to do it.
Should be a flag, or you may have to send a message to the window.
[/quote]

oh don't worry. I did want scrollbars.
But they would appear all the time, I fixed that also.
I put it all in another container (a panel), and this container's size is the actual size of the picture to display. Even when resizing it. So the scrollbars only appear when they have to appear.
:D

This topic is closed to new replies.

Advertisement