Skip to main content
gamedev.net
🔒 Locked

Copying surface to backbuffer?

Started by Mike29936 Apr 17, 2004 at 12:47 AM 3 replies 1.2k views
Original Post
Mike29936
Mike29936
[history] Before, I had a nice abstraction over DirectDraw 7.0, with lots of things, and allowed you to lock the backbuffer and use GDI if it didn''t have something. However, I added some debugging statements, and it stopped drawing graphics. I removed the dubugging information, and it was still broken. So I re-put the debugging stuff in(except this time I used the RTF logger I found in an article on gamedev.net), and it reported everything was drawing okay, which it wasn''t. I rewrote it to use DirectX 9.0, using textures and ID3DXSprite, but textures only support sizes with powers of 2. I still have textures, but if a picture has a non-power of 2 size, I load it into a IDirect3DSurface9 instead, so it''ll hopefully work. [/history] I need to know how to copy the picture in the IDirect3DSurface9 into a backbuffer, so I''ll be able to use non-power of 2 pictures.
neneboricua19
neneboricua19
You can use non-power of 2 textures as long as your graphics card supports it.

To copy a surface to the back buffer, use StretchRect.

neneboricua
Mike29936
Mike29936
My graphics card is a pretty cheap one, so I doubt it has non-power of 2 textures supported. I can''t get a new one, because I''m 14 and have no money.

Turns out my code doesn''t even load the surface correctly, according to the log files.


IDirect3DSurface9 *surface;//Declare surface
D3DXIMAGE_INFO picturedata;//Declare structure to hold picture information
HRESULT h = D3DXGetImageInfoFromFile(file,&picturedata);//Get information from picture file
if (FAILED(h)) {
string debugstring = "Couldn''t get image info: ";
debugstring += ErrorCodeRet(h);
debugger.LogMessage("draw::LoadSurface",debugstring,logger::MSG_ERROR);
return h;
}
//Create surface with information obtained from file
h = device->CreateOffscreenPlainSurface(
picturedata.Width,
picturedata.Height,
picturedata.Format,
D3DPOOL_SYSTEMMEM,
&surface,
NULL);

//Load file data into surface
int check = D3DXLoadSurfaceFromFile(surface,NULL,NULL,file,NULL,D3DX_DEFAULT,background,NULL);
if (FAILED(check)) {
string debugstring = "Couldn''t load picture: ";
debugstring+=file;
debugstring+=": ";
debugstring+=ErrorCodeRet(check);
debugger.LogMessage("draw::LoadSurface",debugstring,logger::MSG_ERROR);
}


The log file consists of a bunch of these, and then nothing, possibly because the program aborts after trying to draw the non-loaded textures:

Couldn''t load picture: pictures/target.bmp: Invalid call

So could anyone help with the surface-loading code?
S1CA
S1CA
1) Link your application with D3DX9D.LIB instead of D3DX9.LIB.
Note the extra 'D', that's the Debug version of the D3DX library - it has more extensive parameter checking as well as more descriptive debug error reports.

2) Run your application in a debugger. If you're using MSVC, press F5 or go to the Debug->Start menu option. Alternatively run a debug event viewer such as dbmon.exe which comes with the DirectX SDK or DebugView from http://www.sysinternals.com

3) Once the problem has occurred, look at the Output pane in MSVC or the output in the logger; usually D3DX will provide a more detailed description of WHY it returned an D3DERR_INVALIDCALL error.


Simon O'Connor
Game Programmer &
Microsoft DirectX MVP

[edited by - s1ca on April 18, 2004 1:57:15 AM]
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Muhammad Haggag
Muhammad Haggag
quote:
Original post by S1CA
1) Link your application with D3DX9D.LIB instead of D3DX9.LIB.
Note the extra ''D'', that''s the Debug version of the D3DX library - it has more extensive parameter checking as well as more descriptive debug error reports.

2) Run your application in a debugger. If you''re using MSVC, press F5 or go to the Debug->Start menu option. Alternatively run a debug event viewer such as dbmon.exe which comes with the DirectX SDK or DebugView from http://www.sysinternals.com

3) Once the problem has occurred, look at the Output pane in MSVC or the output in the logger; usually D3DX will provide a more detailed description of WHY it returned an D3DERR_INVALIDCALL error.


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

[edited by - s1ca on April 18, 2004 1:57:15 AM]

Hey, so you''re finally back?

I believe the GDNet forums missed you a lot.

Muhammad Haggag,
Optimize
Bitwise account: MHaggag -

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.