Blitz3D buffer and C++ ?

Blitz3D Forums/Blitz3D Programming/Blitz3D buffer and C++ ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I want to wrap the directx7 function with c++ :
SetTexture

but when i try to use with blitz it there is an error message : "Memory access violation"

Here is the C++ code:

BBDECL int BBCALL SetTexture(int Stage,IDirectDrawSurface7 *TextureBuffer)
{
	if (p_D3DDevice)
	{
		if (TextureBuffer)
		{
			int hr = p_D3DDevice->SetTexture(Stage,TextureBuffer);
			if (hr != 0)
				return 1;
		}
		else
		{
			return 2;
		}
	}
	return 0;
}

-----------------------------------------------------------------------------------

BBDECL is macro : extern "C" _desclspec(dllexport)
BBCALL is macro : _stdcall

p_D3DDevice is pointer of D3D Device initialised before with another functions.


The DECLS file
.lib "MyLib.dll"

SetTexture%(Stage,TextureBuffer) : "_SetTexture@8"


The blitz code
Graphics3D 800,600,0,2

; Get your system properties
DX7_GetDX7Handle()

; Simple Texture
Texture = CreateTexture(16,16)
LockBuffer TextureBuffer(Texture)
UnLockBuffer TextureBuffer(Texture)
; C++ Functions <<<<<<<<<<<<<<<<<<<<<<<<<
HR = SetTexture(0,Texturebuffer(Texture))
debuglog HR

Waitkey()
FreeTexture Texture
End


Any idea ? ! :)