OpenBve.OpenBVEGame.RunInRenderThread C# (CSharp) Méthode

RunInRenderThread() static private méthode

This method is used during loading to run commands requiring an OpenGL context in the main render loop
static private RunInRenderThread ( ThreadStart job ) : void
job ThreadStart The OpenGL command
Résultat void
		internal static void RunInRenderThread(ThreadStart job)
		{
			object locker = new object();
			lock (jobLock)
			{
				jobs.Enqueue(job);
				locks.Enqueue(locker);
				//Don't set the job to available until after it's been loaded into the queue
				Loading.JobAvailable = true;
			}
			lock (locker)
			{
				//Failsafe: If our job has taken more than a second, terminate it
				//A missing texture is probably better than an infinite loadscreen
				Monitor.Wait(locker, 1000);
			}
		}
	}

Usage Example

Exemple #1
0
 /// <summary>Registers a texture and returns a handle to the texture.</summary>
 /// <param name="path">The path to the file or folder that contains the texture.</param>
 /// <param name="parameters">The parameters that specify how to process the texture.</param>
 /// <param name="handle">Receives the handle to the texture.</param>
 /// <param name="loadTexture">Whether the texture is to be pre-loaded</param>
 /// <returns>Whether loading the texture was successful.</returns>
 public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false)
 {
     if (File.Exists(path) || Directory.Exists(path))
     {
         Texture data;
         if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out data))
         {
             handle = data;
             if (loadTexture)
             {
                 OpenBVEGame.RunInRenderThread(() =>
                 {
                     LoadTexture(data, OpenGlTextureWrapMode.ClampClamp);
                 });
             }
             return(true);
         }
     }
     else
     {
         ReportProblem(ProblemType.PathNotFound, path);
     }
     handle = null;
     return(false);
 }
All Usage Examples Of OpenBve.OpenBVEGame::RunInRenderThread