Esempio n. 1
0
void tglMakeCurrent(TGlContext context)
{
	if (context)
		reinterpret_cast<QGLContext *>(context)->makeCurrent();
	else
		tglDoneCurrent(tglGetCurrentContext());
}
Esempio n. 2
0
DrawableTextureDataP texture_utils::getTextureData(const TXsheet *xsh,
                                                   int frame) {
  // Check if an xsheet texture already exists
  const std::string &texId = ::getImageId(xsh, frame);

  DrawableTextureDataP data(
      TTexturesStorage::instance()->getTextureData(texId));
  if (data) return data;

  // No available texture - we must build and load it
  TRaster32P tex(
      1024,
      1024);  // Fixed texture size. It's the same that currently happens with
              // vector images' textures - and justified since this is camstand
  // mode, and besides we want to make sure that textures are limited.

  // Retrieve the sub-xsheet bbox (world coordinates of the sub-xsheet)
  TRectD bbox(xsh->getBBox(frame));

  // Since xsh represents a sub-xsheet, its camera affine must be applied
  const TAffine &cameraAff =
      xsh->getPlacement(xsh->getStageObjectTree()->getCurrentCameraId(), frame);
  bbox = (cameraAff.inv() * bbox).enlarge(1.0);

// Render the xsheet on the specified bbox
#ifdef MACOSX
  xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine());
#else
  // The call below will change context (I know, it's a shame :( )
  TGlContext currentContext = tglGetCurrentContext();
  {
    tglDoneCurrent(currentContext);
    xsh->getScene()->renderFrame(tex, frame, xsh, bbox, TAffine());
    tglMakeCurrent(currentContext);
  }
#endif

  TRop::depremultiply(tex);  // Stored textures are rendered nonpremultiplied

  // Store the texture for future retrieval
  return TTexturesStorage::instance()->loadTexture(texId, tex, bbox);
}