本文整理匯總了C++中AddResource函數的典型用法代碼示例。如果您正苦於以下問題:C++ AddResource函數的具體用法?C++ AddResource怎麽用?C++ AddResource使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AddResource函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: BeginLoad
iResourceBase* cImageManager::CreateInFrame(const tString& asName, int alFrameHandle)
{
cResourceImage *pImage = NULL;
tString sPath;
BeginLoad(asName);
pImage = FindImage(asName, sPath);
if(!pImage)
{
if(sPath != "")
{
iBitmap2D *pBmp;
pBmp = mpLowLevelResources->LoadBitmap2D(sPath);
if(pBmp==NULL){
Error("Imagemanager Couldn't load bitmap '%s'\n", sPath.c_str());
EndLoad();
return NULL;
}
pImage = AddToFrame(pBmp, alFrameHandle);
hplDelete(pBmp);
if(pImage==NULL){
Error("Imagemanager couldn't create image '%s'\n", asName.c_str());
}
if(pImage) AddResource(pImage);
}
}
else
{
//Log("Found '%s' in stock!\n",asName.c_str());
}
if(pImage)pImage->IncUserCount();
else Error("Couldn't load image '%s'\n",asName.c_str());
//Log("Loaded image %s, it has %d users!\n", pImage->GetName().c_str(),pImage->GetUserCount());
//Log(" frame has %d pics\n", pImage->GetFrameTexture()->GetPicCount());
EndLoad();
return pImage;
}
示例2: J2dTraceLn
// REMIND: this method is currently unused; consider removing it later...
HRESULT D3DResourceManager::CreateOSPSurface(UINT width, UINT height,
D3DFORMAT fmt,
D3DResource** ppSurfaceResource/*out*/)
{
HRESULT res;
IDirect3DDevice9 *pd3dDevice;
J2dTraceLn(J2D_TRACE_INFO, "D3DRM::CreateOSPSurface");
J2dTraceLn2(J2D_TRACE_VERBOSE, " w=%d h=%d", width, height);
if (pCtx == NULL || ppSurfaceResource == NULL ||
(pd3dDevice = pCtx->Get3DDevice()) == NULL)
{
return E_FAIL;
}
if (FAILED(res = pd3dDevice->TestCooperativeLevel())) {
return res;
}
// since the off-screen plain surface is intended to be used with
// the UpdateSurface() method, it is essential that it be created
// in the same format as the destination and allocated in the
// SYSTEMMEM pool (otherwise UpdateSurface() will fail)
D3DFORMAT format;
if (fmt == D3DFMT_UNKNOWN) {
format = pCtx->GetPresentationParams()->BackBufferFormat;
} else {
format = fmt;
}
D3DPOOL pool = D3DPOOL_SYSTEMMEM;
IDirect3DSurface9 *pSurface = NULL;
res = pd3dDevice->CreateOffscreenPlainSurface(width, height,
format, pool,
&pSurface, NULL);
if (SUCCEEDED(res)) {
J2dTraceLn1(J2D_TRACE_VERBOSE, " created OSP Surface: 0x%x ",pSurface);
*ppSurfaceResource = new D3DResource((IDirect3DResource9*)pSurface);
res = AddResource(*ppSurfaceResource);
} else {
DebugPrintD3DError(res, "D3DRM::CreateOSPSurface failed");
ppSurfaceResource = NULL;
}
return res;
}
示例3: XineramifyXv
void XineramifyXv(void)
{
XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey());
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
int i, j, k;
XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
if (!xvsp0 || !XvXRTPort) return;
SetResourceTypeErrorValue(XvXRTPort, _XvBadPort);
for(i = 0; i < xvsp0->nAdaptors; i++) {
Bool isOverlay;
XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i;
if(!(refAdapt->type & XvInputMask)) continue;
MatchingAdaptors[0] = refAdapt;
isOverlay = hasOverlay(refAdapt);
FOR_NSCREENS_FORWARD_SKIP(j)
MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
/* now create a resource for each port */
for(j = 0; j < refAdapt->nPorts; j++) {
PanoramiXRes *port = malloc(sizeof(PanoramiXRes));
if(!port)
break;
FOR_NSCREENS(k) {
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
port->info[k].id = MatchingAdaptors[k]->base_id + j;
else
port->info[k].id = 0;
}
AddResource(port->info[0].id, XvXRTPort, port);
}
}
/* munge the dispatch vector */
XvProcVector[xv_PutVideo] = XineramaXvPutVideo;
XvProcVector[xv_PutStill] = XineramaXvPutStill;
XvProcVector[xv_StopVideo] = XineramaXvStopVideo;
XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute;
XvProcVector[xv_PutImage] = XineramaXvPutImage;
XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage;
}
示例4: BeginLoad
iFontData *cFontManager::CreateFontData(const tString &a_sName, int a_lSize, unsigned short a_lFirstChar,
unsigned short a_lLastChar)
{
tString sPath;
iFontData *pFont;
tString a_sNewName = cString::ToLowerCase(a_sName);
BeginLoad(a_sName);
pFont = static_cast<iFontData*>(this->FindLoadedResource(a_sNewName, sPath));
if (pFont==NULL && sPath!="")
{
pFont = m_pGraphics->GetLowLevel()->CreateFontData(a_sNewName);
pFont->SetUp(m_pGraphics->GetDrawer(), m_pLowLevelResources, m_pGui);
tString sExt = cString::ToLowerCase(cString::GetFileExt(a_sName));
if (sExt == "ttf")
{
if (pFont->CreateFromFontFile(sPath, a_lSize, a_lFirstChar, a_lLastChar)==false)
{
efeDelete(pFont);
EndLoad();
return NULL;
}
}
else
{
Error("Font '%s' has an uknown extension!\n", a_sName.c_str());
efeDelete(pFont);
EndLoad();
return NULL;
}
AddResource(pFont);
}
if (pFont)pFont->IncUserCount();
else Error("Couldn't create font '%s'\n", a_sName.c_str());
EndLoad();
return pFont;
}
示例5: AddResource
void
ResourcesContainer::AssimilateResources(ResourcesContainer &container)
{
// Resistance is futile! ;-)
int32 newCount = container.CountResources();
for (int32 i = 0; i < newCount; i++) {
ResourceItem *item = container.ResourceAt(i);
if (item->IsLoaded())
AddResource(item);
else {
// That should not happen.
// Delete the item to have a consistent behavior.
delete item;
}
}
container.fResources.MakeEmpty();
container.SetModified(true);
SetModified(true);
}
示例6: CBullet
void CBulletManager::AddBullet(Vect3f &_Position, Vect3f &_Direction, CCharacter* player, float _Speed, float _Damage)
{
CBillboard *l_pBillboard = CORE->GetBillboardManager()->GetBillboardCore("bLaserHalo");
CBullet * l_pBullet = new CBullet (*l_pBillboard);
std::string l_sBulletName = GetBulletName();
l_pBullet->SetPos(_Position+Vect3f(0.0f, 0.025f, 0.0f));
l_pBullet->SetDirection(_Direction);
l_pBullet->SetBulletSpeed(_Speed);
l_pBullet->SetFirstPos(_Position);
l_pBullet->SetDamage(_Damage);
l_pBullet->SetName(l_sBulletName);
l_pBullet->SetLight(GetLight());
l_pBullet->Init(player);
m_iCounter++;
AddResource(l_sBulletName,l_pBullet);
}
示例7: CRenderableObjectsManager
CRenderableObjectsManager* CLayerManager::AddLayer(CXMLTreeNode &TreeNode)
{
CRenderableObjectsManager *l_ROManager = new CRenderableObjectsManager();
std::string l_LayerName=TreeNode.GetPszProperty("name","");
if(!AddResource(l_LayerName, l_ROManager))
{
if (l_ROManager != NULL) delete(l_ROManager); l_ROManager = NULL;
}
else
{
l_ROManager->SetName(l_LayerName);
bool l_Default=TreeNode.GetBoolProperty("default",false);
if(l_Default)
m_DefaultLayer=l_ROManager;
}
return l_ROManager;
}
示例8: RRModeCreate
static RRModePtr
RRModeCreate (xRRModeInfo *modeInfo,
const char *name,
ScreenPtr userScreen)
{
RRModePtr mode, *newModes;
if (!RRInit ())
return NULL;
mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
if (!mode)
return NULL;
mode->refcnt = 1;
mode->mode = *modeInfo;
mode->name = (char *) (mode + 1);
memcpy (mode->name, name, modeInfo->nameLength);
mode->name[modeInfo->nameLength] = '\0';
mode->userScreen = userScreen;
if (num_modes)
newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr));
else
newModes = xalloc (sizeof (RRModePtr));
if (!newModes)
{
xfree (mode);
return NULL;
}
mode->mode.id = FakeClientID(0);
if (!AddResource (mode->mode.id, RRModeType, (pointer) mode))
return NULL;
modes = newModes;
modes[num_modes++] = mode;
/*
* give the caller a reference to this mode
*/
++mode->refcnt;
return mode;
}
示例9: AddPassiveGrabToList
/**
* Prepend the new grab to the list of passive grabs on the window.
* Any previously existing grab that matches the new grab will be removed.
* Adding a new grab that would override another client's grab will result in
* a BadAccess.
*
* @return Success or X error code on failure.
*/
int
AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
{
GrabPtr grab;
Mask access_mode = DixGrabAccess;
int rc;
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) {
if (GrabMatchesSecond(pGrab, grab, (pGrab->grabtype == CORE))) {
if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource)) {
FreeGrab(pGrab);
return BadAccess;
}
}
}
if (pGrab->keyboardMode == GrabModeSync ||
pGrab->pointerMode == GrabModeSync)
access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, pGrab->device, access_mode);
if (rc != Success)
return rc;
/* Remove all grabs that match the new one exactly */
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) {
if (GrabsAreIdentical(pGrab, grab)) {
DeletePassiveGrabFromList(grab);
break;
}
}
if (!pGrab->window->optional && !MakeWindowOptional(pGrab->window)) {
FreeGrab(pGrab);
return BadAlloc;
}
pGrab->next = pGrab->window->optional->passiveGrabs;
pGrab->window->optional->passiveGrabs = pGrab;
if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer) pGrab))
return Success;
return BadAlloc;
}
示例10: GetResource
CTexture* CTextureManager::GetTexture(const std::string &fileName)
{
CTexture* l_Tex = GetResource(fileName);
if( l_Tex == NULL )
{
l_Tex = new CTexture();
if( l_Tex->Load(fileName) )
{
LOGGER->AddNewLog(ELL_INFORMATION, "CTextureManager::GetTexture->Textura cargada: %s", fileName.c_str() );
AddResource(fileName, l_Tex);
}
else
{
CHECKED_DELETE(l_Tex);
return GetResource(m_NoTextureName);
}
}
return l_Tex;
}
示例11: GetResource
CAnimatedCoreModel* CAnimatedModelManager::GetCore(const std::string &_szName, const std::string &_szPath)
{
LOGGER->AddNewLog(ELL_INFORMATION,"CAnimatedModelManager::GetCore Carregant la core \"%s\" a \"%s\"",_szName.c_str(),_szPath.c_str());
CAnimatedCoreModel* l_pAnimatedCoreModel = GetResource(_szName);
if(l_pAnimatedCoreModel)
{
LOGGER->AddNewLog(ELL_INFORMATION,"CAnimatedModelManager::GetCore Fent Reload");
l_pAnimatedCoreModel->Reload(_szPath);
} else {
l_pAnimatedCoreModel = new CAnimatedCoreModel(_szName);
if(l_pAnimatedCoreModel->Load(_szPath))
{
LOGGER->AddNewLog(ELL_INFORMATION,"CAnimatedModelManager::GetCore Carregat correctament");
AddResource(_szName,l_pAnimatedCoreModel);
} else {
LOGGER->AddNewLog(ELL_WARNING,"CAnimatedModelManager::GetCore No s'ha pogut carregar, borrant la core");
CHECKED_DELETE(l_pAnimatedCoreModel)
}
}
return l_pAnimatedCoreModel;
}
示例12: SecurityEventSelectForAuthorization
static int
SecurityEventSelectForAuthorization(
SecurityAuthorizationPtr pAuth,
ClientPtr client,
Mask mask)
{
OtherClients *pEventClient;
for (pEventClient = pAuth->eventClients;
pEventClient;
pEventClient = pEventClient->next)
{
if (SameClient(pEventClient, client))
{
if (mask == 0)
FreeResource(pEventClient->resource, RT_NONE);
else
pEventClient->mask = mask;
return Success;
}
}
pEventClient = malloc(sizeof(OtherClients));
if (!pEventClient)
return BadAlloc;
pEventClient->mask = mask;
pEventClient->resource = FakeClientID(client->index);
pEventClient->next = pAuth->eventClients;
if (!AddResource(pEventClient->resource, RTEventClient,
(pointer)pAuth))
{
free(pEventClient);
return BadAlloc;
}
pAuth->eventClients = pEventClient;
return Success;
} /* SecurityEventSelectForAuthorization */
示例13: ProcXFixesCreateRegionFromPicture
int
ProcXFixesCreateRegionFromPicture (ClientPtr client)
{
#ifdef RENDER
RegionPtr pRegion;
PicturePtr pPicture;
REQUEST (xXFixesCreateRegionFromPictureReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
VERIFY_PICTURE(pPicture, stuff->picture, client, DixReadAccess,
RenderErrBase + BadPicture);
switch (pPicture->clientClipType) {
case CT_PIXMAP:
pRegion = BITMAP_TO_REGION(pPicture->pDrawable->pScreen,
(PixmapPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
case CT_REGION:
pRegion = XFixesRegionCopy ((RegionPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
default:
return BadImplementation; /* assume sane server bits */
}
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
#else
return BadRequest;
#endif
}
示例14: BeginLoad
iSoundData *cSoundManager::CreateSoundData(const tString &a_sName, bool a_bStream, bool a_bLoopStream)
{
tString sPath;
iSoundData *pSound = NULL;
BeginLoad(a_sName);
pSound = FindData(a_sName, sPath);
if (pSound == NULL && sPath != "")
{
pSound = m_pSound->GetLowLevel()->LoadSoundData(cString::GetFilePath(a_sName),sPath,"", a_bStream,a_bLoopStream);
if (pSound)
{
AddResource(pSound);
pSound->SetSoundManager(m_pResources->GetSoundManager());
}
}
EndLoad();
return pSound;
}
示例15: Destroy
void CMaterialManager::Load(const std::string &Filename)
{
m_Filename = Filename;
Destroy();
CXMLTreeNode l_XML;
if (l_XML.LoadFile(Filename.c_str()))
{
CXMLTreeNode l_Input = l_XML["materials"];
if (l_Input.Exists())
{
for (int i = 0; i < l_Input.GetNumChildren(); ++i)
{
CXMLTreeNode l_Element = l_Input(i);
if (l_Element.GetName() == std::string("material"))
{
AddResource(l_Element.GetPszProperty("name"),new CMaterial(l_Element));
}
}
}
}
}