当前位置: 首页>>代码示例>>C++>>正文


C++ InitBuffer函数代码示例

本文整理汇总了C++中InitBuffer函数的典型用法代码示例。如果您正苦于以下问题:C++ InitBuffer函数的具体用法?C++ InitBuffer怎么用?C++ InitBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InitBuffer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitBuffer

void gs_vertex_buffer::BuildBuffers()
{
	InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->points,
			&vertexBuffer);

	if (vbd.data->normals)
		InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->normals,
				&normalBuffer);

	if (vbd.data->tangents)
		InitBuffer(sizeof(vec3), vbd.data->num, vbd.data->tangents,
				&tangentBuffer);

	if (vbd.data->colors)
		InitBuffer(sizeof(uint32_t), vbd.data->num, vbd.data->colors,
				&colorBuffer);

	for (size_t i = 0; i < vbd.data->num_tex; i++) {
		struct gs_tvertarray *tverts = vbd.data->tvarray+i;

		if (tverts->width != 2 && tverts->width != 4)
			throw "Invalid texture vertex size specified";
		if (!tverts->array)
			throw "No texture vertices specified";

		ComPtr<ID3D11Buffer> buffer;
		InitBuffer(tverts->width * sizeof(float), vbd.data->num,
				tverts->array, &buffer);

		uvBuffers.push_back(buffer);
		uvSizes.push_back(tverts->width * sizeof(float));
	}
}
开发者ID:AmesianX,项目名称:obs-studio,代码行数:33,代码来源:d3d11-vertexbuffer.cpp

示例2: State

		State()
			: buffVert(InitBuffer())
			, buffIndx(InitBuffer())
			, buffNorm(InitBuffer())
			, buffText(InitBuffer())
			, drawMode(UNDEFINED_DRAW_MODE)
			, textureId(UNDEFINED_TEXTURE_ID)
			, indxCnt(0)
		{}
开发者ID:skryvokhizhyn,项目名称:TransportMania,代码行数:9,代码来源:ModelDrawer.cpp

示例3: InitBuffer

/**
 * @param pszStrData - data source.
 * @param nLength - string length.
 */
void CStrStream::InitData(PCTSTR pszStrData, size_t nLength)
{
	if (pszStrData && *pszStrData)
	{
		size_t nSize = nLength + 1;
		InitBuffer(nSize);
		_tcsncpy_s(m_pszData, nSize, pszStrData, nLength);
		m_nLength = nLength;
	}
	else
		InitBuffer();
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:16,代码来源:StrStream.cpp

示例4: MultiByteToWideChar

/**
 * @param pszStrData - data source.
 */
void CStrStream::InitData(PCSTR pszStrData)
{
	if (pszStrData && *pszStrData)
	{
		int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0);
		_ASSERTE(nSize > 0);
		InitBuffer(nSize);
		MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pszData, nSize);
		m_nLength = nSize - 1;
	}
	else
		InitBuffer();
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:16,代码来源:StrStream.cpp

示例5: WideCharToMultiByte

/**
 * @param pszStrData - data source.
 */
void CStrStream::InitData(PCWSTR pszStrData)
{
	if (pszStrData && *pszStrData)
	{
		size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL);
		_ASSERTE(nSize > 0);
		InitBuffer(nSize);
		WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pszData, (int)nSize, NULL, NULL);
		m_nLength = nSize - 1;
	}
	else
		InitBuffer();
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:16,代码来源:StrStream.cpp

示例6: InitUser

/* Init most of all firms of client
 */
void InitUser (struct client * user, struct clientlist *clList, int fd)
{
	//user->number = clList->cnt; It's not need.fn better GetUserId()
	user->next = NULL;

	user->contact = (struct settings*)malloc(sizeof(struct settings));
	InitSettings (user->contact, fd, clList->cnt);

	user->f = (struct userFlags *) malloc (sizeof(struct userFlags));
	InitFlags (user->f);

	user->sell = (struct auction *) malloc (sizeof(struct auction));
	InitBuyOrSell (user->sell);

	user->buy = (struct auction *) malloc (sizeof(struct auction));
	InitBuyOrSell (user->buy);

	user->data = (struct stuff *) malloc (sizeof(struct stuff));
	InitStuff (user->data);

	user->buf = (struct buffer * ) malloc (sizeof(struct buffer));
	InitBuffer (user->buf);

	user->cmd = (struct command * ) malloc (sizeof(struct command));
	InitCommand (user->cmd);
	
}
开发者ID:artyrian,项目名称:c-gameserv,代码行数:29,代码来源:client.c

示例7: switch

void TestApp::InitScene()
{
		for (int i=0; i<_sceneData->getObjects().size(); i++)
	{
		SceneObject* obj = _sceneData->getObjects()[i];
		switch (obj->getType())
		{
		case SceneObjType::mesh:
			{
				ObjModelObject* mesh = (ObjModelObject*)obj;
				//GLMmodel* model = glmReadOBJ(mesh->getObjFileName().c_str());
				IGLUOBJReader::Ptr objReader  = new IGLUOBJReader( (char*)mesh->getObjFileName().c_str());
				//IGLUOBJReader::Ptr objReader  = new IGLUOBJReader( model,IGLU_OBJ_COMPACT_STORAGE);
				_objReaders.push_back(objReader);
				glm::mat4 trans = (mesh->getTransform());					
				_objTransforms.push_back(IGLUMatrix4x4(&trans[0][0]));
				
				break;
			}
		default:
			break;
		}
	}
	// We've loaded all our materials, so prepare to use them in rendering
	IGLUOBJMaterialReader::FinalizeMaterialsForRendering(IGLU_TEXTURE_REPEAT);

	InitBuffer();

}
开发者ID:sunf71,项目名称:IGLUApp,代码行数:29,代码来源:TestApp.cpp

示例8: StreamingBufferInsertAt

/**
 *  \param offset offset relative to StreamingBuffer::stream_offset
 */
int StreamingBufferInsertAt(StreamingBuffer *sb, StreamingBufferSegment *seg,
                            const uint8_t *data, uint32_t data_len,
                            uint64_t offset)
{
    BUG_ON(seg == NULL);

    if (offset < sb->stream_offset)
        return -1;

    if (sb->buf == NULL) {
        if (InitBuffer(sb) == -1)
            return -1;
    }

    uint32_t rel_offset = offset - sb->stream_offset;
    if (!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset)) {
        if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE) {
            AutoSlide(sb);
            rel_offset = offset - sb->stream_offset;
        }
        if (!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset)) {
            if (GrowToSize(sb, (rel_offset + data_len)) != 0)
                return -1;
        }
    }
    BUG_ON(!DATA_FITS_AT_OFFSET(sb, data_len, rel_offset));

    memcpy(sb->buf + rel_offset, data, data_len);
    seg->stream_offset = offset;
    seg->segment_len = data_len;
    if (rel_offset + data_len > sb->buf_offset)
        sb->buf_offset = rel_offset + data_len;
    return 0;
}
开发者ID:serializingme,项目名称:suricata,代码行数:37,代码来源:util-streaming-buffer.c

示例9: StreamingBufferAppendNoTrack

/**
 *  \brief add data w/o tracking a segment
 */
int StreamingBufferAppendNoTrack(StreamingBuffer *sb,
                                 const uint8_t *data, uint32_t data_len)
{
    if (sb->buf == NULL) {
        if (InitBuffer(sb) == -1)
            return -1;
    }

    if (!DATA_FITS(sb, data_len)) {
        if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE)
            AutoSlide(sb);
        if (sb->buf_size == 0) {
            if (GrowToSize(sb, data_len) != 0)
                return -1;
        } else {
            while (!DATA_FITS(sb, data_len)) {
                if (Grow(sb) != 0) {
                    return -1;
                }
            }
        }
    }
    if (!DATA_FITS(sb, data_len)) {
        return -1;
    }

    memcpy(sb->buf + sb->buf_offset, data, data_len);
    sb->buf_offset += data_len;
    return 0;
}
开发者ID:serializingme,项目名称:suricata,代码行数:33,代码来源:util-streaming-buffer.c

示例10: AutoSlide

StreamingBufferSegment *StreamingBufferAppendRaw(StreamingBuffer *sb, const uint8_t *data, uint32_t data_len)
{
    if (sb->buf == NULL) {
        if (InitBuffer(sb) == -1)
            return NULL;
    }

    if (!DATA_FITS(sb, data_len)) {
        if (sb->cfg->flags & STREAMING_BUFFER_AUTOSLIDE)
            AutoSlide(sb);
        if (sb->buf_size == 0) {
            if (GrowToSize(sb, data_len) != 0)
                return NULL;
        } else {
            while (!DATA_FITS(sb, data_len)) {
                if (Grow(sb) != 0) {
                    return NULL;
                }
            }
        }
    }
    if (!DATA_FITS(sb, data_len)) {
        return NULL;
    }

    StreamingBufferSegment *seg = CALLOC(sb->cfg, 1, sizeof(StreamingBufferSegment));
    if (seg != NULL) {
        memcpy(sb->buf + sb->buf_offset, data, data_len);
        seg->stream_offset = sb->stream_offset + sb->buf_offset;
        seg->segment_len = data_len;
        sb->buf_offset += data_len;
        return seg;
    }
    return NULL;
}
开发者ID:serializingme,项目名称:suricata,代码行数:35,代码来源:util-streaming-buffer.c

示例11: degree

FastWHT<CPU, Dtype>::FastWHT(unsigned int _degree)
					: degree(_degree)
{
	buf_len = 1 << _degree;
	wht_tree = wht_get_tree(_degree);
	InitBuffer();
}
开发者ID:Hanjun-Dai,项目名称:graphnn,代码行数:7,代码来源:fast_wht.cpp

示例12: MOZ_ASSERT

MemoryTextureData*
MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
                          gfx::BackendType aMoz2DBackend,
                          LayersBackend aLayersBackend, TextureFlags aFlags,
                          TextureAllocationFlags aAllocFlags,
                          LayersIPCChannel* aAllocator)
{
  // Should have used CreateForYCbCr.
  MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV);

  if (aSize.width <= 0 || aSize.height <= 0) {
    gfxDebug() << "Asking for buffer of invalid size " << aSize.width << "x" << aSize.height;
    return nullptr;
  }

  uint32_t bufSize = ImageDataSerializer::ComputeRGBBufferSize(aSize, aFormat);
  if (!bufSize) {
    return nullptr;
  }

  uint8_t* buf = new (fallible) uint8_t[bufSize];
  if (!InitBuffer(buf, bufSize, aFormat, aAllocFlags, false)) {
    return nullptr;
  }

  bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);

  GfxMemoryImageReporter::DidAlloc(buf);

  BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);

  return new MemoryTextureData(descriptor, aMoz2DBackend, buf, bufSize);
}
开发者ID:nwgh,项目名称:gecko-dev,代码行数:33,代码来源:BufferTexture.cpp

示例13: strdup

//-----FileBatch----------------------------------------------------------------
CPFile_Info::CPFile_Info(const char *_szFileName)
{
  m_bValid = true;
  m_nError = 0;

  char *pcNoPath = NULL;
  struct stat buf;

  // Remove any path from the filename
  if ( (pcNoPath = strrchr(_szFileName, '/')) != NULL)
    m_szFileName = strdup(pcNoPath + 1);
  else
    m_szFileName = strdup(_szFileName);

  if (stat(_szFileName, &buf) < 0)
  {
    m_bValid = false;
    m_nError = errno;
    return;
  }
  m_nFileSize = buf.st_size;

  m_nSize = strlen(m_szFileName) + 21;
  InitBuffer();

  buffer->PackUnsignedShort(0x02);
  // Add all the file names
  buffer->PackString(m_szFileName);
  // Add the empty file name
  buffer->PackString("");
  //Add the file length
  buffer->PackUnsignedLong(m_nFileSize);
  buffer->PackUnsignedLong(0x00);
  buffer->PackUnsignedLong(0x64);
}
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:36,代码来源:icqd-filetransfer.cpp

示例14: InitBuffer

/* static */
wxIDirectFBEventBufferPtr wxGUIEventLoop::GetDirectFBEventBuffer()
{
    if ( !ms_buffer )
        InitBuffer();

    return ms_buffer;
}
开发者ID:beanhome,项目名称:dev,代码行数:8,代码来源:evtloop.cpp

示例15: MOZ_ASSERT

MemoryTextureData*
MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
                          gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
                          TextureAllocationFlags aAllocFlags,
                          ClientIPCAllocator* aAllocator)
{
  // Should have used CreateForYCbCr.
  MOZ_ASSERT(aFormat != gfx::SurfaceFormat::YUV);

  if (aSize.width <= 0 || aSize.height <= 0) {
    gfxDebug() << "Asking for buffer of invalid size " << aSize.width << "x" << aSize.height;
    return nullptr;
  }

  uint32_t bufSize = ImageDataSerializer::ComputeRGBBufferSize(aSize, aFormat);
  if (!bufSize) {
    return nullptr;
  }

  uint8_t* buf = new (fallible) uint8_t[bufSize];
  if (!InitBuffer(buf, bufSize, aFormat, aAllocFlags)) {
    return nullptr;
  }

  auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
  bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat,
                                              fwd->GetCompositorBackendType())
                                   : true;

  GfxMemoryImageReporter::DidAlloc(buf);

  BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);

  return new MemoryTextureData(descriptor, aMoz2DBackend, buf, bufSize);
}
开发者ID:devtools-html,项目名称:gecko-dev,代码行数:35,代码来源:BufferTexture.cpp


注:本文中的InitBuffer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。