Archived

This topic is now archived and is closed to further replies.

Kaijin

Do DirectDrawSurfaces ever move?

Recommended Posts

Kaijin    163
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

Share this post


Link to post
Share on other sites
MirekCz    132
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/

Share this post


Link to post
Share on other sites
Rusenec    126
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

Share this post


Link to post
Share on other sites
Kaijin    163
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

Share this post


Link to post
Share on other sites
Kaijin    163
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

Share this post


Link to post
Share on other sites
Ruseneca    122
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

Share this post


Link to post
Share on other sites