Exemple #1
0
static void blit_to_texture(void *data, const void *frame,
   unsigned width, unsigned height, unsigned pitch)
{
   d3d_video_t *d3d = (d3d_video_t*)data;

   if (d3d->last_width != width || d3d->last_height != height)
      clear_texture(data);

   D3DLOCKED_RECT d3dlr;
   D3DTexture_LockRect(d3d->tex, 0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK);

#if defined(_XBOX360)
   D3DSURFACE_DESC desc;
   d3d->tex->GetLevelDesc(0, &desc);
      XGCopySurface(d3dlr.pBits, d3dlr.Pitch, width, height, desc.Format, NULL, frame,
                                        pitch, desc.Format, NULL, 0, 0);
#elif defined(_XBOX1)
   for (unsigned y = 0; y < height; y++)
   {
      const uint8_t *in = (const uint8_t*)frame + y * pitch;
      uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch;
      memcpy(out, in, width * d3d->pixel_size);
   }
#endif
}
void d3d_texture_blit(unsigned pixel_size,
      LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
      unsigned width, unsigned height, unsigned pitch)
{
#ifdef _XBOX
   D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK);
#if defined(_XBOX360)
   D3DSURFACE_DESC desc;
   tex->GetLevelDesc(0, &desc);
   XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL,
      frame, pitch, desc.Format, NULL, 0, 0);
#elif defined(_XBOX1)
   unsigned y;
   for (y = 0; y < height; y++)
   {
      const uint8_t *in = (const uint8_t*)frame + y * pitch;
      uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
      memcpy(out, in, width * pixel_size);
   }
#endif
   D3DTexture_UnlockRect(tex, 0);
#else
   if (SUCCEEDED(tex->LockRect(0, lr, NULL, D3DLOCK_NOSYSLOCK)))
   {
      unsigned y;
      for (y = 0; y < height; y++)
      { 
         const uint8_t *in = (const uint8_t*)frame + y * pitch;
         uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
         memcpy(out, in, width * pixel_size);
      }
      tex->UnlockRect(0);
   }
#endif
}
Exemple #3
0
void d3d_texture_blit(void *data, unsigned pixel_size,
      LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
      unsigned width, unsigned height, unsigned pitch)
{
   unsigned y;
	d3d_video_t *d3d = (d3d_video_t*)data;

   (void)y;

   if (!d3d)
	   return;

#ifdef _XBOX
   /* Set the texture to NULL so D3D doesn't complain about it being in use... */
   d3d_set_texture(d3d->dev, 0, NULL); 
   D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK);
#if defined(_XBOX360)
   D3DSURFACE_DESC desc;
   tex->GetLevelDesc(0, &desc);
   XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL,
      frame, pitch, desc.Format, NULL, 0, 0);
#elif defined(_XBOX1)
   for (y = 0; y < height; y++)
   {
      const uint8_t *in = (const uint8_t*)frame + y * pitch;
      uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
      memcpy(out, in, width * d3d->pixel_size);
   }
#endif
   D3DTexture_UnlockRect(tex, 0);
#else
   if (SUCCEEDED(tex->LockRect(0, lr, NULL, D3DLOCK_NOSYSLOCK)))
   {
      for (y = 0; y < height; y++)
      { 
         const uint8_t *in = (const uint8_t*)frame + y * pitch;
         uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
         memcpy(out, in, width * pixel_size);
      }
      tex->UnlockRect(0);
   }
#endif
}
void d3d_texture_blit(unsigned pixel_size,
      LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
      unsigned width, unsigned height, unsigned pitch)
{
   if (d3d_lock_rectangle(tex, 0, lr, NULL, 0, 0))
   {
#if defined(_XBOX360) && defined(_XBOX360)
      D3DSURFACE_DESC desc;
      tex->GetLevelDesc(0, &desc);
      XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL,
            frame, pitch, desc.Format, NULL, 0, 0);
#else
      unsigned y;
      for (y = 0; y < height; y++)
      {
         const uint8_t *in = (const uint8_t*)frame + y * pitch;
         uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
         memcpy(out, in, width * pixel_size);
      }
#endif
      d3d_unlock_rectangle(tex);
   }
}