Exemple #1
0
void Buffer::createFromDrawable(Drawable &obj) {
   shouldDelete = true;

   if (obj.getW() > 512 || obj.getH() > 512)
      throw RubyException(rb_eRuntimeError, "Drawable too big for a buffer.");

   int width = obj.getW();
   int height = obj.getH();
   img = oslCreateImage(width, height, OSL_IN_VRAM, OSL_PF_8888);
   if (!img) {
      img = oslCreateImage(width, height, OSL_IN_RAM, OSL_PF_8888);
      if (!img)
	 throw RubyException(rb_eRuntimeError, "Buffer could not be created");
   }
   else {
      Buffer::registerInVram(img);
   }

   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();

   obj.clearMove();
   obj.setPos(0, 0);
   obj.draw();
   obj.cancelMove();

   oslSetDrawBuffer(old);
}
Exemple #2
0
Buffer::Buffer(Drawable &obj): shouldDelete(true) {
   setClass("Buffer");

   if (obj.getW() > 512 || obj.getH() > 512)
      throw RubyException(rb_eRuntimeError, "Drawable too big for a buffer.");
   
   img = oslCreateImage(obj.getW(), obj.getH(), OSL_IN_VRAM, OSL_PF_8888);
   if (!img)
      throw RubyException(rb_eRuntimeError, "Buffer could not be created");
   
   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();

   obj.clearMove();
   obj.setPos(0, 0);
   obj.draw();
   obj.cancelMove();

   oslSetDrawBuffer(old);
}