Blitz3D buffer and C++ ?

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

Filax(Posted 2005) [#1]
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:



The DECLS file


The blitz code


Any idea ? ! :)


big10p(Posted 2005) [#2]
Shouldn't that be:
HR = SetTexture(0,TextureBuffer(Texture))

?


Filax(Posted 2005) [#3]
I have made an error when i have post the code ! sorry :)
but don't solve my problem ? it's very strange ?


seyhajin(Posted 2005) [#4]
Any Idea ?

I want get buffer to :)


skyfire1(Posted 2005) [#5]
hey filax, did you turn on debug mode?


TartanTangerine (was Indiepath)(Posted 2005) [#6]
Are you sure you've got the correct handle to the DirectX7 Device?


OJay(Posted 2005) [#7]
i doubt its possible to access a texturebuffer like this, since texturebuffer() returns a handle to a blitz internal structure rather than a real dx texturebuffer...

you will have to work with banks to accomplish that...


big10p(Posted 2005) [#8]
OJay: I thought 'Texture' is the handle to the internal blitz structure and TextureBuffer(Texture) returns the actual pointer to the buffer. If not, what's the point of the TextureBuffer() function?


N(Posted 2005) [#9]
OJay: I thought 'Texture' is the handle to the internal blitz structure and TextureBuffer(Texture) returns the actual pointer to the buffer. If not, what's the point of the TextureBuffer() function?


Texture buffer returns an internal Blitz pixel buffer. When you lock the texture it creates a pixel buffer and gives it to the user, and when it's unlocked the data is sent back to the texture. The abstraction is what allows you to use WritePixel/etc. on buffers without having to use WriteTexturePixel or WriteImagePixel and whatnot. This is all based on the assumption that Blitz3D works in a logical and abstracted manner. If I'm wrong, then god have mercy on Mark's soul.


seyhajin(Posted 2005) [#10]
i have tested it, for localized the IDirectDrawSurface7 pointeur, i'm used the memorylib with parameter on blitz3D SetTexture(Stage,PeekMemInt(TextureBuffer)+12), but i don't arrived to modify the Blend with TextureStage :(, anyone say how to do it ? maybe Mark :o)


OJay(Posted 2005) [#11]
did you LOCK the buffer before BEFORE your setTexture() and UNLOCK it AFTER it?


seyhajin(Posted 2005) [#12]
yes it' worked too with simple ReadPixel 0,0,Texturebuffer(Texture) :) his a same


Tom(Posted 2005) [#13]
To obtain valid DX7 surface pointers from B3D textures or images, pass their handle & frame

i.e
tex = LoadTexture("mytexture.jpg")

MyDxFunction(tex,0)


BBDECL void BBCALL MyDxFunction(unsigned int bbHandle, unsigned int bbFrame)
{
  IDirectDrawSurface7 *srcTex=NULL;
  srcTex = FromBBTexHandle(bbHhandle, bbFrame)
  ...
}

IDirectDrawSurface7* FromBBTexHandle(unsigned int handle,int frame)
{
	handle = (unsigned int) *((int*)(handle));
	handle = (unsigned int) *((int*)(handle+12));
	handle = (unsigned int) *((int*)(handle+(4 * frame)));
	if(handle==0) return 0;
	IDirectDrawSurface7 *srcTex=NULL;
	return (IDirectDrawSurface7*) *((int*)(handle+12));
}

IDirectDrawSurface7* FromBBImgHandle(unsigned int handle,int frame)
{
	handle = (unsigned int) *((int*)(handle+4));
	handle = (unsigned int) *((int*)(handle+(4 * frame)));
	if(handle==0) return 0;
	IDirectDrawSurface7 *srcTex=NULL;
	return (IDirectDrawSurface7*) *((int*)(handle+12));
}


Seyhajin, I'll get that code to you shortly! :)


seyhajin(Posted 2005) [#14]
oh really good Tom :o)

but it's possible to used a TextureStage for modify a native Blitz3D Blend ? i tried to wrap all TextureStage functions, but it's not worked :o(, any idea ?

thanks again ! :o)