Do DirectDrawSurfaces ever move?

Started by
6 comments, last by Kaijin 22 years, 3 months ago
Does the memory of DirectDraw surfaces ever change? What I mean is if I lock a surface and obtain a pointer to the memory location of the surface will I always get a pointer back to the same memory location each time I lock that surface? - Kaijin
Advertisement
in many cases it might be so but it''s not a rule. You should lock/unlock your surface each time, because the pointer can change.

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/
With best regards, Mirek Czerwiñski
So it is not safe to assume that the pointer will be the same each time?

- Kaijin
quote:Original post by Kaijin
So it is not safe to assume that the pointer will be the same each time?

Nope, absolutely not. And there really isn''t any need to, so it''s not much of a limitation.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Though you should not lock/unlock you surfaces too much for it''s an expensive operation, try to design you things in a way that will lock/unlock anly when it is absolutely needed.

Rusenec
Rusenec
Ok, I just wanted to make sure. Unforunatley it is a bit of a limitaion for my.

Basically I''m writing a games engine in Java using JNI, C++ and DirectX and there''s a new feature in Java 1.4 that allows Java and native code (i.e. C++ code) to both have direct access to the same area in memory. I just wanted to add some low level surface accessd to my library.

I''m using a buffer object that will represent the area in memory when I lock the surface. However, the buffer object is immutable so it will always point to the same area in memory. I just wanted to see if I could avoid creating a new object each time I locked the surface.

I guess what I''ll have have to do is each time the buffer is accessed check if the location it points to is that same as the address returned from lock() and if so use the same buffer, and if not allocate a new buffer object to point to the new memory location.

- Kaijin
quote:Original post by Rusenec
Though you should not lock/unlock you surfaces too much for it''s an expensive operation, try to design you things in a way that will lock/unlock anly when it is absolutely needed.

Rusenec


I''ve always been aware that locking a surface is an expenisve operation but just how expensive is it?

It''s pretty much unavoidable if you want to draw directly to the surface using geometric operations. What I do is do all of my drawing in one go then release the surface.

- Kaijin
Well if you can not avoid and you need doing such operations, then you are on the right way, doing as much as you can with one only lock and then unlock it
Rusenec

This topic is closed to new replies.

Advertisement