Blitz3d Internal Structure

Blitz3D Forums/Blitz3D Userlibs/Blitz3d Internal Structure

Apocalypse(Posted 2005) [#1]
I have been experimenting with passing Blitz3d handles to User Libs and trying to figure out if it is possible to directly manipulate (DataBanks, Image Buffers, etc). I have started with Banks and Images and have found out the following...

1. A Bank handle passed to a userlib is a pointer to a structure 16 bytes long.

2. The 2nd WORD of this structure appears to be a valid memory handle, and returns a size 8+bytes more than the Bank Size.

3. The 3rd WORD of this structure appears to be the size of the Bank.

I have also passed a handle to an Image and there is a similar underlying structure, however there seems to be more layers of pointers. I assume an Image handle must respresent some form of DirectX7 Surface description but I can't find a C+ declaration to see if there are any similarities.

Has anyone else done any tinkering with these handles? Can you share any of your findings?

Thanks
-Vince


Hotcakes(Posted 2005) [#2]
http://www.blitzbasic.com/archive/posts.php?topic=20361

<lengthy search> How come that's the only relevant result I can find? There was another thread that brought the concept in the above thread to a much higher level - many people got involved and all sorts of blitz internal structures were given detailed explanations. But I can't for the life of me find the link.

Well, the problem is that these structures tend to change from update to update - so the thread I was looking for is no doubt obsolete now anyway. But it was a good read...


DJWoodgate(Posted 2005) [#3]
http://www.blitzbasic.com/Community/posts.php?topic=34301

May be of interest. Have a look at his demo code for the video memory address of images. Still works with the latest version of blitz3d.

Not sure what happened to the other thread, probably posted in a now defunct forum.


Apocalypse(Posted 2005) [#4]
I really wouldn't need to do any of this if Blitz3D offered ways of swapping data from RAM(ie.Pointer) to Banks, RAM to Images, and Banks to Images. IMO this would increase the languages power immensly. I would be able to use other languages to do real-time image processing, filtering, even implementing ASM graphics/data routines.


Picklesworth(Posted 2005) [#5]
It would, it would.


Tom(Posted 2005) [#6]
Apocalypse, here's how you can get an IDirectDrawSurface7 pointer from a Blitz3D texture handle, including anim textures:

B3D..
tex1=LoadTexture("mytex1.jpg")
SomeFunction(tex1, 0)


C++
BBDECL HRESULT BBCALL SomeFunction(unsigned int buffer,
         unsigned int srcFrame)
{
  HRESULT hr;
  if(buffer==0) return 1;
  buffer = (unsigned int) *((int*)(buffer));
  buffer = (unsigned int) *((int*)(buffer+12));
  buffer = (unsigned int) *((int*)(buffer+(4 * srcFrame)));
 
  IDirectDrawSurface7 *srcSurf = NULL;
  srcSurf = (IDirectDrawSurface7*) *((int*)(buffer+12));

  ...


Testing incoming pointers for texture or image aint reliable, so you best do texture or image specific code. To use images as the source just adjsut the C++ code like so

BBDECL HRESULT BBCALL SomeFunction(unsigned int buffer,
         unsigned int srcFrame)
{
  HRESULT hr;
  if(buffer==0) return 1;
  buffer = (unsigned int) *((int*)(buffer+4));
  buffer = (unsigned int) *((int*)(buffer+(4 * srcFrame)));

  IDirectDrawSurface7 *srcSurf = NULL;
  srcSurf = (IDirectDrawSurface7*) *((int*)(buffer+12));
  ...



Tom


Apocalypse(Posted 2005) [#7]
I don't suppose you could show me your examples coded in PowerBasic could you? I hate trying to read C++ code. Are taking the initial pointer value and dereferencing it once, then dereferencing it again with a +4 to the pointer value, then dereferencing it again with the value+(4*FrameNum), then dereferencing it again and casting it to a DX7 surface?


Apocalypse(Posted 2005) [#8]
Much progress has been made thus far. Check it out over in the Worklogs section...

http://www.blitzbasic.com/logs/userlog.php?user=7138&log=440