|
-
Jun 18th, 2001, 09:33 PM
#1
Thread Starter
Good Ol' Platypus
GetLockedArray I am BEGGING YOU to show me how to do this...
Does anyone have a GOOD tutorial on GetLockedArray, it keeps lockin' up on my system.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 19th, 2001, 09:35 AM
#2
Retired VBF Adm1nistrator
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jun 19th, 2001, 02:47 PM
#3
Thread Starter
Good Ol' Platypus
The ancient code one helped a lot .
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 21st, 2001, 11:21 AM
#4
Frenzied Member
Hey, I managed to make it so it didn't lock up when you get an error. Here's the code:
Code:
'Get an array from each of the surfaces
Dim EmptyRect As RECT
Dim SrcArray() As Byte, DestArray() As Byte
SourceSurface.Lock EmptyRect, SourceDescription, DDLOCK_NOSYSLOCK Or DDLOCK_WAIT, 0
SourceSurface.GetLockedArray SrcArray()
DestSurface.Lock EmptyRect, DestDescription, DDLOCK_NOSYSLOCK Or DDLOCK_WAIT, 0
DestSurface.GetLockedArray DestArray()
'Edit them here :p
'ALWAYS remember to unlock the surfaces!
ErrHandler:
'Unlock the surfaces (IMPORTANT)
SourceSurface.Unlock EmptyRect
DestSurface.Unlock EmptyRect
Hope that helps 
I used this code for my game's special effects
-
Jun 21st, 2001, 03:08 PM
#5
Thread Starter
Good Ol' Platypus
Seems to work like a charm, thanks.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 21st, 2001, 03:16 PM
#6
-
Jun 22nd, 2001, 02:21 AM
#7
Retired VBF Adm1nistrator
Whats this bolloxology do anyway ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jun 22nd, 2001, 03:05 AM
#8
-
Jun 22nd, 2001, 03:07 AM
#9
Retired VBF Adm1nistrator
Jotaf ; *cough*more special effects*cough*
Possibly someone will be implimenting this soon ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jun 22nd, 2001, 03:19 AM
#10
Frenzied Member
Hey look here, I posted a demo on how to make lights:
http://forums.vb-world.net/showthrea...&postid=403362
-
Jun 22nd, 2001, 05:59 AM
#11
-
Jun 22nd, 2001, 07:02 AM
#12
Retired VBF Adm1nistrator
Well If you want it performance tested, I'm running a P-III 650MHz w/128Mb Ram and an S3 Savage IX w/8MB VRam on Windows 98SE....
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jun 22nd, 2001, 03:55 PM
#13
Member
Hmmm... any ideas on how to do this in directx8?
-
Jun 22nd, 2001, 04:21 PM
#14
Thread Starter
Good Ol' Platypus
You can't; no ddraw in DX8. DDRAW has disappeared. So you must use DX7 (dont worry DX7's Visual Basic DLL (Dx7vb.DLL) can still be used)
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 24th, 2001, 06:20 AM
#15
Frenzied Member
-
Jun 30th, 2001, 01:45 PM
#16
Member
I think it IS possible to do this in DX8, I have found a LockRect method which you can use on textures and surfaces, the problem is I can't find the GetLockedArray, so I guess there must be some other way to manipulate the bitmap in memory. Are there any tutorials on how to do this?
The LockRect function returns a D3DLOCKED_RECT variable, which consists of two Long vars:
Type D3DLOCKED_RECT
pBits As Long
Pitch As Long
End Type
pBits - The locked bits. If a RECT was provided to the LockRect call, pBits will be appropriately offset from the start of the surface.
Pitch - Pitch of surface, in bytes
However, pBits is NOT an array, and I have no idea what it is (besides a large number )
If anyone knows more about this, please let me know.
-
Jul 1st, 2001, 07:21 PM
#17
Frenzied Member
Stef, that Long is just a pointer to a C++ array. But you'll need someone that knows more about CopyMemory() API in order to use it
-
Jul 29th, 2001, 01:30 PM
#18
Member
So pBits is a pointer to the start of the C array? Is Pitch the length of it (in bytes)? If not, how do I get the length? Any code examples?
Code:
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, ByVal Length As Long)
-
Jul 29th, 2001, 02:33 PM
#19
Thread Starter
Good Ol' Platypus
Wow, this thread is old =)
Try VarPtr:
VB Code:
Dim A() As Byte
A = VarPtr(d3dl_r.pBits)
I'm not sure if this will work.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jul 31st, 2001, 05:37 PM
#20
Frenzied Member
(D*mn, it's the 3rd time I try to write this reply )
Try UR's site, http://www.ur.co.nz/ (direct memory access)
-
Aug 25th, 2001, 01:50 AM
#21
Addicted Member
I wrote a C++ DLL that...
The value of pBits is the index of the beginning of the array.
Simply convert CopyMemory's Source to ByVal Source As Long, and then pass pBits to it. To access each byte of the array, increment pBits by the Pitch.
Calculating array location from X,Y:
Location = pBits + (X * Pitch) + (Y * (Width * Pitch))
Good Luck
"1 4m 4 1337 #4xz0r!'
Janus
-
Aug 25th, 2001, 05:26 PM
#22
Frenzied Member
So, the code would look something like this:
-Create a dynamic array
-Redim it to (Pitch, Height)
-Use the "new version" of CopyMemory to copy pBits to your array
-Modify the array as you want
-Copy it again to the structure
Is that right?
-
Aug 25th, 2001, 08:14 PM
#23
Addicted Member
Well, yes...
Yes, you could do that...
Or you could use CopyMemory to copy the individual pixels back and forth from a long variable, thus saving RAM. I use the RAM-saving method because it works for any bit depth and is simple, even in C++.
"1 4m 4 1337 #4xz0r!'
Janus
-
Aug 26th, 2001, 07:13 AM
#24
Frenzied Member
-
Aug 26th, 2001, 10:36 PM
#25
Addicted Member
No...
I've done lots of tests, the overhead involved in creating a copy of the array, and then copying back, etc, is immense compared to modifying pixel-by-pixel. the cpu can cache if you do it a few pixels at a time.
"1 4m 4 1337 #4xz0r!'
Janus
-
Aug 27th, 2001, 11:32 AM
#26
Frenzied Member
Hum... ok... but in my opinion a big loop with lots of copymemory's is slower than a single loop to copy the memory in assembler or whatever they used to make copymemory
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|