Directx9 SlideShow

Started by
9 comments, last by zoki 16 years, 3 months ago
Hello, I'm making a directx 9 slide show. I'm doing that with CreateOffscreenPlainSurface, D3DXLoadSurfaceFromFile and drawing with StretchRect. Everything is OK, but images bigger than 2400x1600 is not working correctly. What should I do? bye.
Advertisement
Quote:Original post by zoki
What should I do?
Tell us what you mean by is "not working". Does your application crash? If so, what error and where? Does some D3D call fail? Are you using the Debug Runtimes? Do they give any relevant debug output?

Also, what graphics card do you have? If it;s an old-ish card, it's likely that it'll require power-of-two surfaces, so your 2400x1600 surface is being scaled to 4096x2048 (Or 4096x4096 if the card needs square textures). 4k by 2k at 32-bit is 32MB, and if you have a frontbuffer, backbuffer, depth buffer and the source surface, that's 128MB which may exceed your cards VRAM.
Quote:Original post by Evil Steve
Quote:Original post by zoki
What should I do?
Tell us what you mean by is "not working". Does your application crash? If so, what error and where? Does some D3D call fail? Are you using the Debug Runtimes? Do they give any relevant debug output?

Also, what graphics card do you have? If it;s an old-ish card, it's likely that it'll require power-of-two surfaces, so your 2400x1600 surface is being scaled to 4096x2048 (Or 4096x4096 if the card needs square textures). 4k by 2k at 32-bit is 32MB, and if you have a frontbuffer, backbuffer, depth buffer and the source surface, that's 128MB which may exceed your cards VRAM.


Two solutions to the problem of hitting the maximum supported texture size would be to downscale/upscale the image or put it together using two or more smaller parts (that do fit).
No it doesn't crash. Only one part is shown.
I'm working this for a school project and I'm new in directx. So I download the DirectX SDK April 2007 and do with DXUT. I have to do also effects like fade-in, fade-out, ... but I don't know how. So I would beg you for help.
Quote:Original post by zoki
No it doesn't crash. Only one part is shown.
I'm working this for a school project and I'm new in directx. So I download the DirectX SDK April 2007 and do with DXUT. I have to do also effects like fade-in, fade-out, ... but I don't know how. So I would beg you for help.
What do you mean "part" of it? Which part? Just the top? Bottom? Left? Top left? Are you using the debug runtimes? Anything from them?
Quote:Original post by Evil Steve
Quote:Original post by zoki
No it doesn't crash. Only one part is shown.
I'm working this for a school project and I'm new in directx. So I download the DirectX SDK April 2007 and do with DXUT. I have to do also effects like fade-in, fade-out, ... but I don't know how. So I would beg you for help.
What do you mean "part" of it? Which part? Just the top? Bottom? Left? Top left? Are you using the debug runtimes? Anything from them?


Original picture:
http://shrani.si/f/5/du/1hmjVYAj/slika4.jpg

Only part of the original:
http://shrani.si/f/1q/RB/3sL2iydW/onepart.jpg

I'm running it in debug. Release doesn't look different.

Have you double checked the parameters you pass to StretchRect? That looks like you're taking an area the size of the window from the source image, and stretching that onto an area the size of the image. I.e. check your source and dest rects are the correct way around.

Also, Do you mean the debug runtimes? Or do you mean a debug build of your app?
Quote:Original post by Evil Steve
Have you double checked the parameters you pass to StretchRect? That looks like you're taking an area the size of the window from the source image, and stretching that onto an area the size of the image. I.e. check your source and dest rects are the correct way around.

Also, Do you mean the debug runtimes? Or do you mean a debug build of your app?


I was meaning a debug build of my app.

Here is my code:
void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ){	int cas = g_Nastavitve.GetSlider( IDC_CAS )->GetValue();	if (g_bIzvajaj && ((fTime - g_timeStart) > cas || g_slika == NULL) && !g_SettingsDlg.IsActive())	{		SAFE_RELEASE(g_slika);		while (g_slika == NULL)		{			if (g_pozicija >= (g_vSlike.capacity() - 1) || g_vSlike.capacity() == 0)				g_pozicija = 0;			g_slika = GetSurfaceFromImage(pd3dDevice, g_vSlike.at(g_pozicija));			g_pozicija++;		}		g_timeStart = fTime;	}}IDirect3DSurface9* GetSurfaceFromImage(IDirect3DDevice9* pd3dDevice, std::wstring filename){	HRESULT hr;	IDirect3DSurface9* surface = NULL;	D3DXIMAGE_INFO imageInfo;	// Get the width and height info from this bitmap	V(D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo))	V(pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL));	V(D3DXLoadSurfaceFromFile(surface, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL));	return surface;}void Render(){	if (!g_bIzvajaj)		return;	HRESULT hr;	IDirect3DSurface9* backbuffer;	IDirect3DDevice9* pd3dDevice = g_DialogResourceManager.GetD3DDevice();		V(pd3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO, &backbuffer));	pd3dDevice->StretchRect(g_slika, NULL, backbuffer, NULL, D3DTEXF_POINT );	SAFE_RELEASE(backbuffer);}


If you need more code to help me I'll post it.

[Edited by - zoki on January 5, 2008 4:05:10 PM]
Can some please tell me if using a surface is the right approach in my project of creating a slideshow. I have to finish that to the end of the month and I'm a little desperate. I don't know what to do. Please help me.
It's working now.
V(pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL));

Problem was in the imageInfo.Width and the imageInfo.Height.

This topic is closed to new replies.

Advertisement