pantson.MPEG - finished + source

BlitzMax Forums/BlitzMax Programming/pantson.MPEG - finished + source

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.

This is coming along very nicely :)

I have a small addition on the openGL side.
You will notice that the DrawPixmap command is very slow and is much slower on low pc specs (a friend of mine got just around 19 fps).

With this small function at the and of the code the fps is about 3 to 4 times faster on lower end machines and incredible faster on mid and highend machines. Instead of Drawing the pixmap an Image with the pixmap uploaded as a texture is drawn.

SuperStrict

Framework brl.max2d

Import brl.glmax2d
Import pantson.mpeg
Import pub.glew



SetGraphicsDriver(GLMax2DDriver())

Local m:Tmpeg
Local p:TPixmap

m = OpenMPEG("intro.mpg")

If m <> Null
	Graphics 640, 480, 0,-1
	
	
	Local P:TPixmap = CreatePixmap(640,MPEGheight(m,640),PF_BGRA8888)
	Local Img:TImage = LoadImage(P)
		
	StartMPEG(m)
	
	
	While Not EOM(m) And Not KeyDown(KEY_ESCAPE)
		
		If DrawMPEG(m,P) = True	
			UploadPixtoImg(Img,P)	
			
		EndIf
		
		
		Cls
		
		SetBlend AlphaBlend
					
		
		DrawImage Img,0,0
						
    	DrawText "Test",20,20
	
		Flip 0
		
		
	Wend
	
	
	CloseMPEG(m)
Else
	DebugStop()
EndIf

End


Function UploadPixtoImg(tex:TImage,Pixmap:TPixmap)
	Local ImgF:TGLImageFrame = TGLImageframe(tex.frame(0))
	Local mip_level:Int = 0

		If ImgF <> Null Then
			glBindtexture GL_TEXTURE_2D,ImgF.name
			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


I hope this is useful for some people.