Пример #1
0
		void AsyncRenderer::AddSprite(IImage *img, Vector3 center,
									  float radius, float rotation){
			SPADES_MARK_FUNCTION();
			rcmds::AddSprite *cmd = generator->AllocCommand<rcmds::AddSprite>();
			cmd->img = img;
			img->AddRef();
			cmd->center = center;
			cmd->radius = radius;
			cmd->rotation = rotation;
		}
Пример #2
0
		void AsyncRenderer::AddLongSprite(IImage *img, Vector3 p1, Vector3 p2,
									  float radius){
			SPADES_MARK_FUNCTION();
			rcmds::AddLongSprite *cmd = generator->AllocCommand<rcmds::AddLongSprite>();
			cmd->img = img;
			img->AddRef();
			cmd->p1 = p1;
			cmd->p2 = p2;
			cmd->radius = radius;
		}
Пример #3
0
		IModel *AsyncRenderer::RegisterModel(const char *filename) {
			SPADES_MARK_FUNCTION();
			
			class RegisterModelDispatch: public ConcurrentDispatch {
				IRenderer *base;
				const char *fn;
				IModel *result;
				std::string error;
			public:
				RegisterModelDispatch(IRenderer *base, const char *fn):
				base(base), fn(fn), result(NULL){}
				virtual void Run(){
					try{
						result = base->RegisterModel(fn);
					}catch(const std::exception& ex){
						error = ex.what();
					}
				}
				IModel *GetResult() {
					if(!error.empty()){
						SPRaise("Error while RegisterImageDispatch:\n%s", error.c_str());
					}else{
						return result;
					}
				}
			};
			
			std::map<std::string, IModel *>::iterator it = models.find(filename);
			if(it == models.end()) {
				FlushCommands();
				RegisterModelDispatch dispatch(base, filename);
				dispatch.StartOn(queue);
				dispatch.Join();
				IModel *img = dispatch.GetResult();
				models[filename] = img;
				img->AddRef();
				return img;
			}
			return it->second;
		}