?
Solved

DirectDraw + Pitch

Posted on 2000-02-17
6
Medium Priority
?
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 60 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

741 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