Solved

DirectDraw + Pitch

Posted on 2000-02-17
6
501 Views
Last Modified: 2013-12-03
When would the pitch change? Do I have to use the value returned by the lock function every time or can I assume that the value returned by the lock function will stay the same as long as the application doesn't change the surfaces layout?
If I create a surface, do some blitting, restore it when it has gone and than continue blitting, will the Pitch value stay the same?
So one call to a lock function can give me the Pitch value for the rest of the "life" of the surface?
0
Comment
Question by:upanishadiii
  • 3
  • 2
6 Comments
 

Author Comment

by:upanishadiii
ID: 2530503
Or if it changes, when would the Pitch change?
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2531046
Why would you *not* use the value returned from the Lock function? I don't see why it's any harder than storing the value you first got and using it ad infinitum. I'd imagine the Pitch for a surface at a particular colour depth and resolution will be fixed, *providing* you're running in exclusive full-screen mode--if this is on a window on the desktop the user could change resolutions or colour depths between the two Locks, which would certainly change the Pitch.

Incidentally, if by "blitting" you mean the normal DirectDraw ->Blt() functions, I don't think they work on locked surfaces.
0
 
LVL 4

Accepted Solution

by:
nils pipenbrinck earned 20 total points
ID: 2531554
if you're blitting from one surface to another make sure, that your surface is _not_ locked! this might work on your driver, but the behaviour is undefined. I would expect that the blits are queued until you unlock your surface, but that's only a guess...

To the pitch..  it's very unlikely, that the pitch will change from one loock to the next, but - happy windows world - I would ever use the pitch from the current lock.. just to be sure... (does it really makes a difference in your code? my rendering stuff is pitch independant, and it was neither a coding nor a performance problem..)

Nils
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:upanishadiii
ID: 2532192
I use direct surface acces to put my image on a surface, and I get it from a file. I need to do a lot of iterations before the image appears on the surface, and if I could 'trust' a certain pitch value, I only need to preform a memcpy function in the time the surface is locked and unlocked. I was told that the time between lock and unlock should be minimized strongly. So therfor I need this value.

I've solved it this way. I keep the previous Pitch Value returned from the Lock function in a variable and I check if it changes the next time. If it does change, I have 1 "extensive" lock-unlock procedure, otherwise I just copy previous buffered data based on the previous lock value to the video memory. I think this is the best solution for my case. I've checked and in all situations I encountered the pitch value stays the same about 752 for a 748 pixels width surface. If it should change, my function will intercept this and give an image based on the new pitch value.


So in my case I need to build my data buffer after the lock function if I can't trust the pitch value, otherwise this data has been build before and I only need to flush them to the video memory.

Off course the blitting appears after I unlocked it, sorry for the misunderstanding.
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
ID: 2534152
I do a memcpy for each scanline I copy to the framebuffer.

internally my bitmap is pitch==width, and I convert it on the fly when I copy it to  the framebuffer..


nils
0
 

Author Comment

by:upanishadiii
ID: 2535136
That was my initial Draw Procedure, but I tried to make it faster by having an exact framebuffer in memory before the lock function, than just copy the whole thing and unlock instead of converting it on the fly. This because I had been advised to minimize the time between lock and unlock. If that is done, the blitting would be faster.

If you say it doesn't matter where I contruct the buffer and just use the pitch returned from Lock to set the framebuffer up on the fly, I guess I could keep using that. Are you sure there was no performance problem?
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
how to bring to back always mid parent image form 21 79
Need to create an object factory 2 46
Visual Studio: built-in keystroke automation 2 64
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question