I'm pretty new to direct x, if you've seen my other posts, you probably know that. I'm trying to copy the middle section of the back buffer to a different surface and then copy that back to the top half of the back buffer. My plan later on is to do this twice, copying the back buffer to 2 different surfaces, then modifying those surfaces, and finally copying them back to the back buffer in a sort of splitscreen fashion (so that one surface copies to the top half of the back buffer, and the other surface copies to the bottom half of the back buffer).

First: take unbird's advice. The sequence you posted could (and probably does) have several errors.

1. Is the format of frame1 the same as the backbuffer?

SetRect(&r1, GetHeight()/4, 0, GetWidth(), ((GetHeight()*3)/4)-1);

2. The rectangle you specify looks strange - you set the rect left x value to the GetHeight()/4, and set the right x to GetWidth()?? If GetWidth() is the width of the backbuffer, that makes the width of the surface greater than the width of the backbuffer.

The source surface must have been created with D3DPOOL_SYSTEMMEM. (i.e., in your case, both surfaces)
The destination surface must have been created with D3DPOOL_DEFAULT. (i.e., in your case, both surfaces)
The source and dest rects must fit within the surface.
The source format must match the dest format.

I haven't worked in DX9 for a while, but I think you're going to have to try GetRenderTargetData to start with, to get the backbuffer (video memory) into system memory. Then go from there, possibly with StretchRect, likely needing 2 or 3 surfaces overall.

Edited by Buckeye, 15 August 2014 - 10:02 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

You'll notice that I did not check for the HResults, that is because I have a different question having to do with those before I write them in.

So I checked out the article that Unbird linked. I opened up the directx control panel and set it up for debug mode, however nothing came out. After googling I found that I needed to declare #define D3D_DEBUG_INFO so I did that, in this fashion:

I'm not really sure where I'm supposed to retrieve the debug info though. Alternatively, I would settle for just being able to output some info, like with println(); but the program I am altering simply becomes a plugin for another piece of software. Therefore, i don't know where to find the output. I don't have a lot of experience with the command line, but I am wondering "Is there something there I could do?"

EDIT: This has to do with my question about HRESULT, which is essentially, "How can I make some custom text output that I can reference, while in this plugin?"

Lastly, I just wanted to say, I'm a senior college student with no prior graphics programming experience. Is this project too demanding for someone from my position? Further, do you have any general advice for someone in my position?

As mentioned in unbird's referenced article, debugview may serve your purpose with regard to debug output if you're not using Visual Studio.

This has to do with my question about HRESULT, which is essentially, "How can I make some custom text output that I can reference, while in this plugin?"

If the app has a console window (which it should, if it doesn't), std::cout ( or printf() ) would work. Or launch the app from a cmd window. Otherwise, take a look at OutputDebugString(). The latter outputs c-strings, which requires you to format your output string if you want to output numbers. Again, if you're not launching it from Visual Studio, you'll have to find a debug message monitor like debugview.

I'm a senior college student with no prior graphics programming experience. Is this project too demanding for someone from my position? Further, do you have any general advice for someone in my position?

Too demanding? If you're not working from within Visual Studio, you may have a long row to hoe. But you seem to be willing to give things a try, and you've got gamedev. Go for it! I would suggest, however, that you read the documentation for each function you use, if you're not familiar with it and/or not positive of the input/output requirements. And you can google for example code in a lot of cases. Or, at worst, find out what won't work.

EDIT: an alternative, depending on how much time you have to work on your project - download Visual Studio (you can get a free version, maybe even a full-blown version being a college student). Create a version of your plugin as a standalone, test it thoroughly there and create another version as the plugin. Actually, you may save time overall by doing that. At worst, you appear to be interested in that type of programming so get into Visual Studio.

Edited by Buckeye, 15 August 2014 - 02:42 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I'm not exactly sure what the inflection is here. Are you saying this is too early for a programmer to learn graphics programming or too late, or are you stated that I am currently getting experience? I don't mean to sound condescending I'm just wondering what you meant and where that means I am now (I.E. ahead of the curve, behind, doesn't matter where)

EDIT: an alternative, depending on how much time you have to work on your project - download Visual Studio (you can get a free version, maybe even a full-blown version being a college student). Create a version of your plugin as a standalone, test it thoroughly there and create another version as the plugin. Actually, you may save time overall by doing that. At worst, you appear to be interested in that type of programming so get into Visual Studio.

I have been using visual c++ 2008 express edition. It was recommended by my client, because it can compile the byte code within 1KB. I do have Visual studio somewhere on this computer and I think that it is a full version (because I'm a student). I guess I should be giving that a try? I will try it.

This has to do with my question about HRESULT, which is essentially, "How can I make some custom text output that I can reference, while in this plugin?"

If the app has a console window (which it should, if it doesn't), std::cout ( or printf() ) would work. Or launch the app from a cmd window. Otherwise, take a look at OutputDebugString(). The latter outputs c-strings, which requires you to format your output string if you want to output numbers. Again, if you're not launching it from Visual Studio, you'll have to find a debug message monitor like debugview.

For clarity's sake let me say that back as I understood it to make sure I have it right. If I use Visual Studio it should give me a debug message monitor. How do I access this monitor? Do I need to do anything special with my .dll file? I really have no idea how to test it, except to build it and launch the main app, and then use the plugin to see what happens. An alternative quicker or more custom-message-friendly testing method would be showered with my love.

EDIT: What did you think of my process I outlined in my previous post? Did it look appropriate?

That's pretty much it. Just sayin' you've jumped into some relatively deep water and appear to still be breathing. With no programming experience, you're making some pretty good guesses in your coding. They don't work, but they're good guesses.

I guess I should be giving that a try? I will try it.

Definitely. With intellisense and on-board help (click on some word in your code and hit F1) it'll make life a bit easier. And, as suggested, you may want to write a basic DX9 engine and test your routines that way. I'm guessing you have the June 2010 SDK and you could steal a DX9 base engine from one of the examples. If you do that, the debug output goes to the Visual Studio output window automatically when you run your app from VS. With regard to other running apps, I'm afraid I don't know if VS monitors other debug output.

I don't know, but suspect, that debugview or the like will monitor messages to a debug output from a DLL. Also, I've never tried it, but I would think if you launch the main app from a command prompt window that std::cout << "some message\n" or printf("debug message %d", msgNum) could provide you info.

What did you think of my process I outlined? Did it look appropriate?

Without doing a lot of DX9 review and lookups of the docs, I couldn't say. As mentioned, review the docs for functions. A quick look at GetRenderTargetData indicates that what you've got won't work. You don't create the surface before you use it to receive the data. Dx9 (and 10 and 11, for that matter) have requirements for function arguments listed. Don't guess at them, read the docs. Or, as we use to say at work, RTFM!

Just scanning the code without looking anything up, you get the render target data (which, though you call it that, is not the "actual" backbuffer). That's just copied data. You do some manipulations with it, but nothing goes back to the backbuffer.

Edited by Buckeye, 15 August 2014 - 04:36 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

You can implement split screen without doing any copying of render targets.

The way you to that is to use viewports - the default viewport you get when you set a render target is a full size one, but you can change that to cover a different portion of the render target to do things like split screen.

The main advantage of that approach is that it will perform better than copying. Especially if your copies go back and forth to system memory instead of staying on the GPU.

If you really need to copy bits of render target around, I'd suggest using StretchRect() with the help of GetSurfaceLevel(). That will avoid the copying to and from system memory.