I'm making a loading screen and I have to load some pretty large animated textures(for miniB3D) and was wondering if there was a way to update the game while loading the texture,
I marked the section in which the update code would go with "UPDATE CODE GOES HERE"
Function LoadAnimTexture:TTexture(file$,flags,frame_width,frame_height,first_frame,frame_count,tex:TTexture=Null)
If flags&128 Then Return LoadCubeMapTexture(file$,flags,tex)
If tex=Null Then tex:TTexture=New TTexture
If FileFind(file$)=False Then Return Null
tex.file$=file$
tex.file_abs$=FileAbs$(file$)
' set tex.flags before TexInList
tex.flags=flags
tex.FilterFlags()
' check to see if texture with same properties exists already, if so return existing texture
Local old_tex:TTexture
old_tex=tex.TexInList()
If old_tex<>Null And old_tex<>tex
Return old_tex
Else
If old_tex<>tex
ListAddLast(tex_list,tex)
EndIf
EndIf
' load pixmap
tex.pixmap=LoadPixmap(file$)
' check to see if pixmap contain alpha layer, set alpha_present to true if so (do this before converting)
Local alpha_present=False
If tex.pixmap.format=PF_RGBA8888 Or tex.pixmap.format=PF_BGRA8888 Or tex.pixmap.format=PF_A8 Then alpha_present=True
' convert pixmap to appropriate format
If tex.pixmap.format<>PF_RGBA8888
tex.pixmap=tex.pixmap.Convert(PF_RGBA8888)
EndIf
' if alpha flag is true and pixmap doesn't contain alpha info, apply alpha based on color values
If tex.flags&2 And alpha_present=False
tex.pixmap=ApplyAlpha(tex.pixmap)
EndIf
' if mask flag is true, mask pixmap
If tex.flags&4
tex.pixmap=MaskPixmap(tex.pixmap,0,0,0)
EndIf
' ---
' if tex not anim tex, get frame width and height
If frame_width=0 And frame_height=0
frame_width=tex.pixmap.width
frame_height=tex.pixmap.height
EndIf
' ---
tex.no_frames=frame_count
tex.gltex=tex.gltex[..tex.no_frames]
' ---
' pixmap -> tex
Local xframes=tex.pixmap.width/frame_width
Local yframes=tex.pixmap.height/frame_height
Local startx=first_frame Mod xframes
Local starty=(first_frame/yframes) Mod yframes
Local x=startx
Local y=starty
Local pixmap:TPixmap
For Local i=0 To tex.no_frames-1
' get static pixmap window. when resize pixmap is called new pixmap will be returned.
pixmap=tex.pixmap.Window(x*frame_width,y*frame_height,frame_width,frame_height)
x=x+1
If x>=xframes
x=0
y=y+1
EndIf
' ---
pixmap=AdjustPixmap(pixmap)
tex.width=pixmap.width
tex.height=pixmap.height
Local width=pixmap.width
Local height=pixmap.height
Local name
glGenTextures 1,Varptr name
glBindtexture GL_TEXTURE_2D,name
Local mipmap
If tex.flags&8 Then mipmap=True
Local mip_level=0
Repeat
glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
glTexImage2D GL_TEXTURE_2D,mip_level,GL_RGBA8,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,pixmap.pixels
If Not mipmap Then Exit
If width=1 And height=1 Exit
If width>1 width:/2
If height>1 height:/2
pixmap=ResizePixmap(pixmap,width,height)
mip_level:+1
'UPDATE CODE GOES HERE!!!!'
Forever
tex.no_mipmaps=mip_level
tex.gltex[i]=name
Next
Return tex
End Function
When I put my drawing functions there it displays the loading screen as i'd like but the texture isn't created
|