Solved

DirectDraw + Pitch

Posted on 2000-02-17
6
485 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now