changing pixmaps within an image

BlitzMax Forums/BlitzMax Programming/changing pixmaps within an image

an update to klepto2's function with opengl checking

Function UpdatePixmapInImage:Int(image:TImage,frame:Int=0)
	
	' if not opengl, use the standard blitzmax way of updating the pixmap frame
	If TGLMax2DDriver(_max2dDriver) = Null Then
		' directx maybe
		image.seqs[frame]=0
		Return True
	EndIf
	
	' open GL
	' based on klepto2 version of quick upload of pixmap to frame
	Local pixmap:TPixmap
	pixmap = image.pixmaps[frame]
	
	Local ImgF:TGLImageFrame = TGLImageframe(image.frame(frame))
	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_RGBA,GL_UNSIGNED_BYTE,pixmap.pixels
		glPixelStorei GL_UNPACK_ROW_LENGTH,0
		glBindtexture GL_TEXTURE_2D,0
	EndIf
	
	Return True
End Function