示例#1
0
/* calls the routines to set up the sizes and load the data */
int loadSpreadsheetData(spreadStruct *spreadSheet)
{
    /* setup the various values that will be read from Fortran */
    spreadSheet->numRows = 100;
    spreadSheet->numColumns = 100;

    spreadSheet->currentRow = 0;
    spreadSheet->currentColumn = 0;

    spreadSheet->lastRow = 0;
    spreadSheet->lastColumn = 0;

    spreadSheet->cellCharWidth = 12;
    spreadSheet->labelCharWidth = 12;

    /* call the setup routines */
    setupSizes(spreadSheet);
    setupSpreadsheet(spreadSheet);
    setupRowLabels(spreadSheet);
    setupColumnHeadings(spreadSheet);

    return TRUE;
}
bool YUV420PGrabber::setup(int winW, int winH, int framerate) {

  if(!winW || !winH) {
    printf("error: invalid win_w or win_h: %dx%d\n", winW, winH);
    return false;
  }

  if(!framerate) {
    printf("error: invalid fps: %d\n", framerate);
    return false;
  }

  win_w = winW;
  win_h = winH;
  uv_w = vid_w * 0.5;
  uv_h = vid_h * 0.5;
  fps = framerate;

  if(!setupSizes()) {
    printf("error: cannot setup the sizes. did you add any? make sure to call addSize()\n");
    return false;
  }

  if(!setupTextures()) {
    printf("error: cannot setup textures.\n");
    return false;
  }

#if 0
  if(!setupPBO()) {
    printf("error: cannot setup pbox.\n");
    return false;
  }
#endif

  if(!setupFBO()) {
    printf("error: cannot setup fbo.\n");
    return false;
  }

  if(!setupVAO()) {
    printf("error: cannot setup vao.\n");
    return false;
  }

  if(!setupShaders()) {
    printf("error: cannot setup shaders.\n");
    return false;
  }


  image = new unsigned char[tex_w * tex_h];
  if(!image) {
    printf("error: cannot allocate image buffer.\n");
    return false;
  }

  // set the pointers to the image
  for(std::vector<YUV420PSize>::iterator it = sizes.begin(); it != sizes.end(); ++it) {
    YUV420PSize& s = *it;
    s.planes[0] = &image[s.y_offset];
    s.planes[1] = &image[s.u_offset];
    s.planes[2] = &image[s.v_offset];
  }

  frame_delay = (1.0/fps) * 1000 * 1000 * 1000;

  return true;
}