/* QuickTextureOverlay3d::draw
 * Draws the overlay to [width],[height]
 *******************************************************************/
void QuickTextureOverlay3d::draw(int width, int height, float fade)
{
	// Don't draw if invisible
	if (fade < 0.001f)
		return;

	// Draw background
	glColor4f(0.0f, 0.0f, 0.0f, fade * 0.6f);
	glDisable(GL_TEXTURE_2D);
	Drawing::drawFilledRect(0, height - 120, width, height);

	// Draw current tex name
	glEnable(GL_TEXTURE_2D);

	// Draw textures
	double x = ((double)width * 0.5) - (anim_offset * 136.0);
	glColor4f(1.0f, 1.0f, 1.0f, fade);
	for (unsigned a = 0; a < textures.size(); a++)
	{
		// Skip until first texture to show on left
		if (x < -96)
		{
			x += 136;
			continue;
		}

		// Draw texture
		drawTexture(a, x, height - 18, determineSize(x, width), fade);
		x += 136;

		// Stop when we get to the right edge of the screen
		if (x > width + 96)
			break;
	}
}
Example #2
0
   bool D3DUniformBuffer::create(Device& device, UNIFORM_BUFFER_DESC* pdescs, int nr)
   {
      D3DDevice& d3ddevice = static_cast<D3DDevice&>(device);

      int bytes = determineSize(pdescs, nr);

      D3D11_BUFFER_DESC constantBufferDesc = {0};
      constantBufferDesc.ByteWidth = bytes;
      constantBufferDesc.Usage = D3D11_USAGE_DEFAULT;
      constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
      constantBufferDesc.CPUAccessFlags = 0;
      constantBufferDesc.MiscFlags = 0;
      constantBufferDesc.StructureByteStride = 0;

      HRESULT hr = d3ddevice.getDevice().CreateBuffer(&constantBufferDesc, NULL, &mpBuffer);
      if ( FAILED(hr) )
         return false;

      return true;
   }
Example #3
0
/*
 * We populate the fields of the on-disk superblock.
 * Many of these calculations depend on the size of the specific disk, 
 * and illegal geometries are not identified until later in the process.
 */
void buildSuperBlock(void)
{
  /* we allocate a block to hold the superblock */
  SB = (struct wufs_super_block*)malloc(WUFS_BLOCKSIZE);
  if (!SB) {
    fprintf(stderr,"Could not allocate superblock memory.\n");
    exit(1);
  }
  /* clear the memory */
  memset(SB,0,WUFS_BLOCKSIZE);

  /* identify this as a WUFS */
  SB->sb_magic = WUFS_MAGIC;

  /* figure out how many bytes there are on the device */
  int size = determineSize(Device);
  if (size == 0) {
    fprintf(stderr,"Could not determine the size of device %s\n",Device);
    exit(1);
  }

  /* compute the number of blocks that fit on this device (rounds down) */
  SB->sb_blocks = minimum(size/WUFS_BLOCKSIZE,0xffff);

  /* compute the number of inodes needed (fills out block) */
  int ipb = WUFS_INODES_PER_BLOCK;
  SB->sb_inodes = SB->sb_blocks/3;
  /* ...round up to fill out block */
  SB->sb_inodes = (SB->sb_inodes+(ipb-1))/ipb*ipb;

  /* compute the number of blocks needed for inode map (rounds up) */
  SB->sb_imap_bcnt = fullChunks(SB->sb_inodes,WUFS_BLOCKSIZE*8);

  /* compute the number of blocks occupied by the block map
   * (this is overkill -- the first few blocks are always used, but
   *  the approach is simple and has the advantage that smaller maps
   *  can be written into the same space at a later date, if needed)
   */
  SB->sb_bmap_bcnt = fullChunks(SB->sb_blocks,WUFS_BLOCKSIZE*8);

  /* compute the index of the first data block */
  SB->sb_first_block = 2                 /* boot + super */ + 
                       SB->sb_imap_bcnt  /* for inode map */ +
                       SB->sb_inodes/ipb /* blocks of inodes */ +
                       SB->sb_bmap_bcnt  /* for block map */;

  /* do a sanity check: is there enough space to hold even the headers? */
  if (SB->sb_first_block >= SB->sb_blocks) {
    fprintf(stderr,"Device is too small to support file system.\n");
    exit(1);
  }

  /* compute the maximum file size in blocks (this file system...is a dog) */
  SB->sb_max_fsize = WUFS_INODE_PTR_CT*WUFS_BLOCKSIZE;

  /* set the state appropriately */
  SB->sb_state = WUFS_VALID_FS;

  /* report on what we've done */
  if (Verbose) {
    fprintf(stderr,"block 0 reserved to hold boot sector\n");
    fprintf(stderr,"block 1 holds super block\n");
    fprintf(stderr,"%d data blocks available\n",SB->sb_blocks);
    fprintf(stderr,"   %d block(s) reserved for block map\n",SB->sb_bmap_bcnt);
    fprintf(stderr,"%d inodes allocated\n",SB->sb_inodes);
    fprintf(stderr,"   inodes contain   %d direct pointers\n",WUFS_INODE_DIRECT);
    fprintf(stderr,"                    %d indirect pointers, with %d direct pointers each\n", WUFS_INODE_INDIRECT, WUFS_BPTRS_PER_BLOCK);
    fprintf(stderr,"   %d block(s) reserved for inode map\n",SB->sb_imap_bcnt);
    fprintf(stderr,"   %d block(s) reserved for %d byte inodes\n",SB->sb_inodes/ipb,
	    (int)sizeof(struct wufs_inode));
    fprintf(stderr,"first data block is block %d\n",SB->sb_first_block);
    fprintf(stderr,"maximum file size is %d blocks\n",SB->sb_max_fsize);
    fprintf(stderr,"size of directory entry: %d\n",(int)sizeof(struct wufs_dirent));
  }
  
}