Stream video to texture/update texture

BlitzMax Modules Forums/MiniB3D/Stream video to texture/update texture

I want to build a small game in 3D over network, sort of shuffle puck/pong like game where you push the ball/puck back to the other side of the gamefield where you can see your opponent by making use of a webcam.

The game itself won't be much of a problem and I'll be using the Escapi.dll for the webcam and UDP as connection. I'm using MiniB3D 0.51 at this moment.

The only thing I don't know is how to update a texture using a pixmap or plain data without making it too slow or using tons of videomem.
A small example would be nice.
the webcam image received will be 320x240 or 640x480 depending on the speed.

The reason behind this is all to make internet games a bit more personal. You can see your friends on the other side of the world while playing a game against them in fullscreen.

Function UploadPixtoImg(tex:TTexture,Pixmap:TPixmap)
	Local mip_level:Int = 0
		
		If tex <> Null Then
			If Pixmap.width <> tex.width Or Pixmap.height <> Pixmap.height Then
			ResizePixmap(Pixmap , tex.width , tex.height) 
			End If
			glBindtexture GL_TEXTURE_2D,tex.gltex[0]
			glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
			glTexSubImage2D GL_TEXTURE_2D,mip_level,0,0,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels
			glPixelStorei GL_UNPACK_ROW_LENGTH,0
			glBindtexture GL_TEXTURE_2D , 0
		EndIf
End Function


This function should help you. It is not tested but it should work. Maybe you have to call ClearTextureFilters() at the start. But i think it should work from the beginning.
Also you should create textures with the same size as the received pixmaps to avoid pixmap resizing.

Thanks for the quick reply, I'll give it a go as soon as I get home from work.

Didn't thought it could be this simple, too bad I'm not too familiar with the gl commands yet.

I'll give a reply after I tested it :-)

Thanks a lot Klepto.

I had some troubles getting it to work at start and then I did find the following topic.

http://www.blitzmax.com/Community/posts.php?topic=71915#803971

The example from you with the pantson mpeg mod in minib3d helped me a lot and I got it working now.