I was able to make my ImageViewer work with separate thread properly.
Execute doesn't free on exit but it sets Finished variable true. Main application loop checks in its start if Finished is set and then do the Finish; to bind texture and fill the data in with glTexImage2D().
ps. missing pascal tags...Code:TLoadThread = class(TThread) private fn: string; texIndex: integer; finished: boolean; public constructor Create(_texIndex: integer; _fn: string); procedure Execute; override; procedure Finish; end; constructor TLoadThread.Create(_texIndex: integer; _fn: string); begin inherited Create(False); texIndex:=_texIndex; fn:=_fn; finished:=false; FreeOnTerminate:=True; end; procedure TLoadThread.Execute; begin tex.LoadTextureData(@tex.texture[texIndex],fn); if terminated then exit; finished:=true; end; procedure TLoadThread.Finish; begin tex.Restore(texIndex); form1.loader:=nil; form1.MakeDispList; Terminate; end;
Bookmarks