• 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
pas059

Window resizing

13 posts in this topic

Hi,

I'm porting an MDX application to SlimDX (targetting Direct9). Everything seems to goes fine, except when i resize the window (a Windows.Form) and so the Control it contains. Every parts are just stretched.
In the overrided OnResize() method of the Control, i tried to redefine the Viewport of my Device, but without success; i also tried to call the Reset() method of the device but this gives an D3DERR_INVALIDCALL exception.

Someone can tell what must be done to correct this problem?

thanks in advance,
Pascal
0

Share this post


Link to post
Share on other sites
You need to reset the device for Direct3D 9, however, in order to reset it you must also provide proper arguments and clean up existing resources.

However, there is a better way if you intend to resize it a lot, I don't have the code right now, but what you do is make the primary backbuffer 1x1 and instead create your own backbuffer to replace the default one, your own backbuffer can now be recreated without resetting the device.
0

Share this post


Link to post
Share on other sites
Hi Syranide,

I tried to Reset the device and the parameters are correct, but i always get en exception D3DERR_INVALIDCALL.

Someone can gives a code sample?

thanks in advance,
Pascal,
0

Share this post


Link to post
Share on other sites
In general, any resources you've allocated that required passing in the Direct3D9Device need to be be freed before calling Reset(). In reality it depends on the resource pool used, but more than likely you've used the default pool, which requires explicit freeing of the resource.

My screen resize code does the following:

1) Free all resources
2) Update the backbuffer size
3) Reset the device
4) Load all resources (if required).
0

Share this post


Link to post
Share on other sites
Hi Postie,

Do you mean that objects like VertexBuffer, Mesh have to be freed? and then recreated after updating? this can take many time in some cases.

As it was not necessary to do this in MDX, i'm suprising.

Do you have a link?

thanks again,

Pascal
0

Share this post


Link to post
Share on other sites
[quote name='pas059' timestamp='1327998785' post='4907924']
Hi Postie,

Do you mean that objects like VertexBuffer, Mesh have to be freed? and then recreated after updating? this can take many time in some cases.

As it was not necessary to do this in MDX, i'm suprising.

Do you have a link?

thanks again,

Pascal
[/quote]

Sadly that is the case, with Direct3D 9, Direct3D 9Ex does not require it I believe.
Anyway, as above, you can create your own backbuffer to replace the default one, that backbuffer can then be recreated at will without resetting the device. I don't know what MDX is really, but I would assume it's using one of the above.
0

Share this post


Link to post
Share on other sites
Hi again,

Indeed, after disposing ressources resetting the device no longer generates an exception (of course), but as recreating all can takes times (in some cases) the solution consisting on recreating the backbuffer seems more elegant to me.
But, i haven't seen how to create a backbuffer with SlimDX/D3D9.
Do you have an example, a link,...?

thanks in advance
Pascal
0

Share this post


Link to post
Share on other sites
3rd reply here [url="http://www.codeguru.com/forum/showthread.php?t=492308"]http://www.codeguru....ad.php?t=492308[/url] has the solution I believe.
Also, I realize that I've been calling it the backbuffer, but you of course need to replace the entire swap chain.
0

Share this post


Link to post
Share on other sites
Hi,

i tried this by Disposing the BackBuffer, then to recreate one with the new Size, but this gives the same result. Concerning the SwapChain, it can not be created directly. On the link you give, Syranide, this is also what they observed, and then they concluded that the "Elements" have to be recreated. I saw in the SlimDX sample that this is also the method they used.
If you could show us your code, this would nice.

Thanks again,
Pascal
0

Share this post


Link to post
Share on other sites
[code]
LPDIRECT3DSURFACE9 rendersurf_old;
LPDIRECT3DSURFACE9 depthsurf_old;
m_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &rendersurf_old);
m_device->GetDepthStencilSurface(&depthsurf_old);
rendersurf_old->Release();
depthsurf_old->Release();

RECT rect;
GetClientRect(m_hwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
m_d3dpp.BackBufferWidth = m_width = width;
m_d3dpp.BackBufferHeight = m_height = height;
DXASSERT(m_device->CreateAdditionalSwapChain(&m_d3dpp, &m_swapchain));
DXASSERT(m_swapchain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_rendersurface));
DXASSERT(m_device->CreateDepthStencilSurface(m_width, m_height, m_d3dpp.AutoDepthStencilFormat, m_d3dpp.MultiSampleType, m_d3dpp.MultiSampleQuality, TRUE, &m_depthsurface, 0));
[/code]

Is the basic code I'm using and I'm pretty sure it's based on the code from that post.
0

Share this post


Link to post
Share on other sites
Hi Syranide,

Thanks your code, which is in native C++. With SlimDX (and also SharpDX and MDX) which are managed frameworks desgned to used with .Net languages (C#, C++ managed, VB,...), not all the methods of Direct3D9 are exposed, and notably [color="#660066"]CreateAdditionalSwapChain[/color]().

So, i started to use the "traditional" way: disposing ressources that must be disposed, reseting device, recreate resources. The first results seems sufficient, but this takes more time to code and the execution is probably slower. Anyway, i think that i have no other choice.

Thanks again,
Pascal
0

Share this post


Link to post
Share on other sites
[quote name='pas059' timestamp='1328091126' post='4908325']
Hi Syranide,

Thanks your code, which is in native C++. With SlimDX (and also SharpDX and MDX) which are managed frameworks desgned to used with .Net languages (C#, C++ managed, VB,...), not all the methods of Direct3D9 are exposed, and notably [color=#660066]CreateAdditionalSwapChain[/color]().

So, i started to use the "traditional" way: disposing ressources that must be disposed, reseting device, recreate resources. The first results seems sufficient, but this takes more time to code and the execution is probably slower. Anyway, i think that i have no other choice.

Thanks again,
Pascal
[/quote]

Yeah, if it isn't exposed then that would be hard to say the least, unless you can just patch it in there yourself.

Also, as I believe I mentioned above Direct3D9Ex pretty much prevents lost devices from occuring entirely (on Vista and up), but I would assume that your library doesn't support that either then, as I feel like it should've just done that internally for you if it supports it.

Your last option would be to use the D3DPOOL_MANAGED for textures if exposed, however, it's not without issues and doesn't actually solve the problem, it just makes a bit faster as a copy of the texture is kept in system memory at all times.
0

Share this post


Link to post
Share on other sites
Hi,
sorry for late reply, i was out of office

I tried with Direct3D9Ex (on vista), this gives the same (bad) results. So the "traditional" way seems to be the only one method. This is what i done, and this works (fortunately).

thanks again
Pascal
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