示例#1
0
void program::

link()
{
  if(id_ != 0) clear();

  id_ = glCreateProgram();

  if(id_ != 0)
  {
    for(auto it(stages_.begin()) ; it != stages_.end() ; ++it)
    {
      stage* stage_ptr(it->get());

      if(stage_ptr != nullptr)
      {
        GLuint stage_id(stage_ptr->compile());

        if(stage_id != 0) glAttachShader(id_,stage_id);
      }
    }

    glLinkProgram(id_);
    clear_stages();

    if(!link_feedback()) clear();
  }
}
stage_ptr ministage::get_stage_ptr(ai_context &context)
{
	if (stage_) {
		return stage_;
	}

	std::vector<stage_ptr> stages;
	engine::parse_stage_from_config(context,cfg_,std::back_inserter(stages));
	if (stages.empty()) {
		return stage_ptr();
	}
	stage_ = stages.front();
	return stage_;
}
void engine_fai::do_parse_stage_from_config( ai_context &context, const config &cfg, std::back_insert_iterator<std::vector< stage_ptr > > b )
{
	if (!cfg) {
		return;
	}
	const std::string &name = cfg["name"];
	stage_ptr st_ptr;

	//dropped from 1.8, as it's not ready
	//if (name=="rca_formulas") {
	//	st_ptr = stage_ptr(new stage_rca_formulas(context,cfg,formula_ai_));

	if (name=="side_formulas") {
		st_ptr = stage_ptr(new stage_side_formulas(context,cfg,formula_ai_));
	} else if (name=="unit_formulas") {
		st_ptr = stage_ptr(new stage_unit_formulas(context,cfg,formula_ai_));
	} else {
		ERR_AI_ENGINE_FAI << "unknown type of formula_ai stage: ["<< name <<"]"<<std::endl;
	}
	if (st_ptr) {
		st_ptr->on_create();
		*b = st_ptr;
	}
}
示例#4
0
void engine_lua::do_parse_stage_from_config( ai_context &context, const config &cfg, std::back_insert_iterator<std::vector< stage_ptr > > b )
{
	if (!cfg) {
		return;
	}

	if (!lua_ai_context_) {
		return;
	}

	stage_ptr st_ptr = stage_ptr(new lua_stage_wrapper(context,cfg,*lua_ai_context_));
	if (st_ptr) {
		st_ptr->on_create();
		*b = st_ptr;
	}
}
示例#5
0
void program::

clear_stages() const
{
  for(auto it(stages_.begin()) ; it != stages_.end() ; ++it)
  {
    stage* stage_ptr(it->get());

    if(stage_ptr != nullptr)
    {
      if(id_ != 0) glDetachShader(id_,stage_ptr->id());

      stage_ptr->clear();
    }
  }
}