Exemplo n.º 1
0
 void StructuredBuffer::readBlob(void* pDest, size_t offset, size_t size)   
 {    
     if(size + offset > mSize)
     {
         logWarning("StructuredBuffer::readBlob() - trying to read more data than what the buffer contains. Call is ignored.");
         return;
     }
     readFromGPU();
     memcpy(pDest, mData.data() + offset, size);
 }
Exemplo n.º 2
0
 void StructuredBuffer::getVariable(size_t offset, size_t elementIndex, VarType& value)
 {
     verify_element_index();
     if(checkVariableByOffset<VarType>(offset, 1, mpReflector.get()))
     {
         readFromGPU();
         const uint8_t* pVar = mData.data() + offset + elementIndex * mElementSize;
         value = *(const VarType*)pVar;
     }
 }
Exemplo n.º 3
0
    void StructuredBuffer::getVariableArray(size_t offset, size_t count, size_t elementIndex, VarType value[])
    {
        verify_element_index();

        if (checkVariableByOffset<VarType>(offset, count, mpReflector.get()))
        {
            readFromGPU();
            const uint8_t* pVar = mData.data() + offset;
            const VarType* pMat = (VarType*)(pVar + elementIndex * mElementSize);
            for (size_t i = 0; i < count; i++)
            {
                value[i] = pMat[i];
            }
        }
    }
Exemplo n.º 4
0
bool GlesBox::draw_end(GBConfig& conf) {
  float angle = 0.0f;
  bool need_egl = false, need_fbo = false, need_online = false;
  switch(conf.type) {
  case GB_DRAW_ONLINE_WITHOUT_OPENGLES_CONTEXT:
    need_egl = true;
  case GB_DRAW_ONLINE_WITH_OPENGLES_CONTEXT:
    angle = conf.screen_angle;
    break;
  case GB_DRAW_BOTH_WITH_OPENGLES_CONTEXT:
    need_online = true;
  case GB_DRAW_OFFLINE_WITH_OPENGLES_CONTEXT:
    need_fbo = true;
    angle = conf.offline_angle;
    break;
  case GB_DRAW_BOTH_WITHOUT_OPENGLES_CONTEXT:
    need_online = true;
  case GB_DRAW_OFFLINE_WITHOUT_OPENGLES_CONTEXT:
    need_fbo = true;
    need_egl = true;
    angle = conf.offline_angle;
    break;
  default:
    LOGE("GlesBox: not support this draw type.");
    return false;
  }
  if (need_fbo) {
    //read from GPU and do image translation
    const uint8_t *image = readFromGPU();
    unbindFrameBuffer();
    
    if (conf.screen_width > 0 && conf.screen_height > 0)
      glViewport(conf.screen_x, conf.screen_y, conf.screen_width, conf.screen_height);
    if (need_online)
      swap(conf.screen_angle + angle + 180.0f);

    switch(conf.offline_type) {
    case GB_IMAGE_YUV420:
      libyuv::ABGRToI420((uint8*)image, core_->width_*4,
        conf.offline_data, conf.offline_widthstep,
        conf.offline_data + conf.offline_widthstep * conf.offline_height,
        conf.offline_widthstep >> 1,
        conf.offline_data + conf.offline_widthstep * conf.offline_height * 5 / 4,
        conf.offline_widthstep >> 1,
        conf.offline_width, conf.offline_height);
      break;
    case GB_IMAGE_RGB24:
      libyuv::ARGBToRGB24((uint8*)image, core_->width_*4,
        conf.offline_data, conf.offline_widthstep, conf.offline_width, conf.offline_height);
      break;
    case GB_IMAGE_RGBA32:
      memcpy(conf.offline_data, image, core_->width_*core_->height_*4);
      break;
    case GB_IMAGE_YUY2:
      LOGE("glesbox: will support this image format later.");
      return false;
    case GB_IMAGE_UNKNOWN:
    default:
      LOGE("glesbox: not support this image format.");
      return false;
    }
  }

  if (need_egl)
    unbindEGLContext();
  glViewport(core_->viewport_old_[0], core_->viewport_old_[1],
    core_->viewport_old_[2], core_->viewport_old_[3]);

  return true;
}