public PostEffectRenderCommand(ShaderProgram sp, int width, int height) { pipelineState.shaderState.shaderProgram = sp; pipelineState.vaoState.vao = theVao; pipelineState.generateId(); renderState.setUniform(new UniformData(0, Uniform.UniformType.Float, (float)TimeSource.currentTime())); renderState.setUniform(new UniformData(1, Uniform.UniformType.Float, (float)width)); renderState.setUniform(new UniformData(2, Uniform.UniformType.Float, (float)height)); }
public bool tick(double minSeconds, double maxSeconds) { processedMessages = 0; double startTime = TimeSource.clockTime(); double minTime = minSeconds == -1.0 ? startTime : startTime + minSeconds; double maxTime = maxSeconds == -1.0 ? startTime + 1000000.0 : startTime + maxSeconds; myIsTicking = true; //determine number of messages to process for this frame int count = myEventQueue.Count; int runningTasks = 0; //keep looping if we have time while (TimeSource.currentTime() < maxTime && processedMessages < count) { Event e; //no message available, sleep until min time is met if (!myEventQueue.TryDequeue(out e)) { break; } processedMessages++; //is it time to process this event (i.e enough delay has passed) if (TimeSource.currentTime() - e.timeStamp < e.delay) { //still has time left, put it back on the queue myEventQueue.Enqueue(e); continue; } EventResult res = dispatchEvent(e); } //wait for running tasks to finish while (runningTasks > 0) { System.Threading.Thread.Sleep(0); } myIsTicking = false; //handle any changes that may have occurred during event processing //can't do this during event processing since it may invalidate //iterators EventListenerInfo eli; while (myPendingAdds.TryDequeue(out eli)) { registerEvent(eli.eventName); myRootEventListener.addEventListener(eli.func, eli.eventName); } while (myPendingRemoves.TryDequeue(out eli)) { myRootEventListener.removeEventListener(eli.func, eli.eventName); } //sleep for the rest of the time double now = TimeSource.clockTime(); if (now < minTime) { double sleepTime = minTime - now; Thread.Sleep((int)(sleepTime * 1000.0f)); } return(true); }