Example #1
0
ref_ptr<ShaderInput> ShaderInput::copy(const ref_ptr<ShaderInput> &in, GLboolean copyData)
{
  ref_ptr<ShaderInput> cp = create(in->name(), in->dataType(), in->valsPerElement());
  cp->stride_ = in->stride_;
  cp->offset_ = in->offset_;
  cp->inputSize_ = in->inputSize_;
  cp->elementSize_ = in->elementSize_;
  cp->elementCount_ = in->elementCount_;
  cp->numVertices_ = in->numVertices_;
  cp->numInstances_ = in->numInstances_;
  cp->divisor_ = in->divisor_;
  cp->buffer_ = 0;
  cp->bufferStamp_ = 0;
  cp->normalize_ = in->normalize_;
  cp->isVertexAttribute_ = in->isVertexAttribute_;
  cp->isConstant_ = in->isConstant_;
  cp->transpose_ = in->transpose_;
  cp->stamp_ = in->stamp_;
  cp->forceArray_ = in->forceArray_;
  cp->data_ = new byte[cp->inputSize_];

  if(copyData && in->data_!=NULL) {
    std::memcpy(cp->data_, in->data_, cp->inputSize_);
  }
  // make data_ stack root
  cp->dataStack_.push(cp->data_);

  return cp;
}
Example #2
0
void FeedbackState::addFeedback(const ref_ptr<ShaderInput> &in)
{
  // remove if already added
  if(feedbackAttributeMap_.count(in->name())>0)
  { removeFeedback(in.get()); }

  GLuint feedbackCount = (feedbackCount_==0 ? in->numVertices() : feedbackCount_);
  feedbackCount_ = feedbackCount;

  // create feedback attribute
  ref_ptr<ShaderInput> feedback = ShaderInput::create(
      in->name(), in->dataType(), in->valsPerElement());
  feedback->set_inputSize(feedbackCount * feedback->elementSize());
  feedback->set_numVertices(feedbackCount);
  feedbackAttributes_.push_front(feedback);
  feedbackAttributeMap_[in->name()] = feedbackAttributes_.begin();

  requiredBufferSize_ += feedback->inputSize();
}