本文整理汇总了C++中FTextureID::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ FTextureID::isValid方法的具体用法?C++ FTextureID::isValid怎么用?C++ FTextureID::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTextureID
的用法示例。
在下文中一共展示了FTextureID::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawOneWeapon
static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon)
{
int trans;
// Powered up weapons and inherited sister weapons are not displayed.
if (weapon->WeaponFlags & WIF_POWERED_UP) return;
if (weapon->SisterWeapon && weapon->IsKindOf(weapon->SisterWeapon->GetClass())) return;
trans=0x6666;
if (CPlayer->ReadyWeapon)
{
if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999;
}
FTextureID picnum = GetInventoryIcon(weapon, DI_ALTICONFIRST);
if (picnum.isValid())
{
FTexture * tex = TexMan[picnum];
int w = tex->GetWidth();
int h = tex->GetHeight();
int rh;
if (w>h) rh=8;
else rh=16,y-=8; // don't draw tall sprites too small!
DrawImageToBox(tex, x-24, y, 20, rh, trans);
y-=10;
}
}
示例2: ParseWarp
void FTextureManager::ParseWarp(FScanner &sc)
{
const BITFIELD texflags = TEXMAN_Overridable | TEXMAN_TryAny | TEXMAN_ShortNameOnly;
bool isflat = false;
bool type2 = sc.Compare ("warp2"); // [GRB]
sc.MustGetString ();
if (sc.Compare ("flat"))
{
isflat = true;
sc.MustGetString ();
}
else if (sc.Compare ("texture"))
{
isflat = false;
sc.MustGetString ();
}
else
{
sc.ScriptError (NULL);
}
FTextureID picnum = CheckForTexture (sc.String, isflat ? FTexture::TEX_Flat : FTexture::TEX_Wall, texflags);
if (picnum.isValid())
{
FTexture *warper = Texture(picnum);
// don't warp a texture more than once
if (!warper->bWarped)
{
if (type2) warper = new FWarp2Texture (warper);
else warper = new FWarpTexture (warper);
ReplaceTexture (picnum, warper, false);
}
if (sc.CheckFloat())
{
static_cast<FWarpTexture*>(warper)->SetSpeed(float(sc.Float));
}
// No decals on warping textures, by default.
// Warping information is taken from the last warp
// definition for this texture.
warper->bNoDecals = true;
if (sc.GetString ())
{
if (sc.Compare ("allowdecals"))
{
warper->bNoDecals = false;
}
else
{
sc.UnGet ();
}
}
}
}
示例3: DrawOneWeapon
static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon)
{
int trans;
FTextureID picnum;
// Powered up weapons and inherited sister weapons are not displayed.
if (weapon->WeaponFlags & WIF_POWERED_UP) return;
if (weapon->SisterWeapon && weapon->IsKindOf(RUNTIME_TYPE(weapon->SisterWeapon))) return;
trans=0x6666;
if (CPlayer->ReadyWeapon)
{
if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999;
}
FState * state=NULL, *ReadyState;
FTextureID AltIcon = GetHUDIcon(weapon->GetClass());
picnum = !AltIcon.isNull()? AltIcon : weapon->Icon;
if (picnum.isNull())
{
if (weapon->SpawnState && weapon->SpawnState->sprite!=0)
{
state = weapon->SpawnState;
}
// no spawn state - now try the ready state
else if ((ReadyState = weapon->FindState(NAME_Ready)) && ReadyState->sprite!=0)
{
state = ReadyState;
}
if (state && (unsigned)state->sprite < (unsigned)sprites.Size ())
{
spritedef_t * sprdef = &sprites[state->sprite];
spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()];
picnum = sprframe->Texture[0];
}
}
if (picnum.isValid())
{
FTexture * tex = TexMan[picnum];
int w = tex->GetWidth();
int h = tex->GetHeight();
int rh;
if (w>h) rh=8;
else rh=16,y-=8; // don't draw tall sprites too small!
DrawImageToBox(tex, x-24, y, 20, rh, trans);
y-=10;
}
}
示例4: CheckShortestTex
static inline void CheckShortestTex (FTextureID texnum, fixed_t &minsize)
{
if (texnum.isValid() || (texnum.isNull() && (i_compatflags & COMPATF_SHORTTEX)))
{
FTexture *tex = TexMan[texnum];
if (tex != NULL)
{
fixed_t h = tex->GetScaledHeight()<<FRACBITS;
if (h < minsize)
{
minsize = h;
}
}
}
}
示例5: DrawOneKey
static void DrawOneKey(int xo, int & x, int & y, int & c, AInventory * inv)
{
FTextureID icon = FNullTextureID();
FTextureID AltIcon = GetHUDIcon(inv->GetClass());
if (!AltIcon.Exists()) return;
if (AltIcon.isValid())
{
icon = AltIcon;
}
else if (inv->SpawnState && inv->SpawnState->sprite!=0)
{
FState * state = inv->SpawnState;
if (state && (unsigned)state->sprite < (unsigned)sprites.Size ())
{
spritedef_t * sprdef = &sprites[state->sprite];
spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()];
icon = sprframe->Texture[0];
}
}
if (icon.isNull()) icon = inv->Icon;
if (icon.isValid())
{
x -= 9;
DrawImageToBox(TexMan[icon], x, y, 8, 10);
c++;
if (c>=10)
{
x=xo;
y-=11;
c=0;
}
}
}
示例6: isBright
static bool isBright(DPSprite *psp)
{
if (psp != nullptr && psp->GetState() != nullptr)
{
bool disablefullbright = false;
FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, NULL);
if (lump.isValid())
{
FMaterial * tex = FMaterial::ValidateTexture(lump, false, false);
if (tex)
disablefullbright = tex->tex->gl_info.bDisableFullbright;
}
return psp->GetState()->GetFullbright() && !disablefullbright;
}
return false;
}
示例7: gl_ParseVavoomSkybox
void gl_ParseVavoomSkybox()
{
int lump = Wads.CheckNumForName("SKYBOXES");
if (lump < 0) return;
FScanner sc(lump);
while (sc.GetString())
{
int facecount=0;
int maplump = -1;
FSkyBox * sb = new FSkyBox;
uppercopy(sb->Name, sc.String);
sb->Name[8]=0;
sb->fliptop = true;
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
if (facecount<6)
{
sc.MustGetStringName("{");
sc.MustGetStringName("map");
sc.MustGetString();
maplump = Wads.CheckNumForFullName(sc.String, true);
if (maplump==-1)
Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name);
FTextureID tex = TexMan.FindTextureByLumpNum(maplump);
if (!tex.isValid())
{
tex = TexMan.CreateTexture(maplump, FTexture::TEX_MiscPatch);
}
sb->faces[facecount] = TexMan[tex];
sc.MustGetStringName("}");
}
facecount++;
}
if (facecount != 6)
{
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name);
}
sb->SetSize();
TexMan.AddTexture(sb);
}
}
示例8: ParsePicAnim
void FTextureManager::ParsePicAnim (FScanner &sc, FTextureID picnum, int usetype, bool missing, TArray<FAnimDef::FAnimFrame> &frames)
{
FTextureID framenum;
DWORD min = 1, max = 1;
framenum = ParseFramenum (sc, picnum, usetype, missing);
ParseTime (sc, min, max);
if (picnum.isValid())
{
FAnimDef::FAnimFrame frame;
frame.SpeedMin = min;
frame.SpeedRange = max - min;
frame.FramePic = framenum;
frames.Push (frame);
}
}
示例9: TimedPicCommand
void TimedPicCommand (bool helphack)
{
ParseTimedCommand (helphack);
//
// update the screen, and wait for time delay
//
VW_UpdateScreen ();
//
// wait for time
//
Delay(picdelay);
//
// draw pic
//
if(picnum.isValid())
VWB_DrawGraphic (TexMan(picnum), picx&~7, picy, MENU_CENTER);
}
示例10: Add
// [MH] Mainly for mugshots with skins and SBARINFO
void FImageCollection::Add (const char **patchNames, int numPatches, int namespc)
{
int OldCount = ImageMap.Size();
ImageMap.Resize(OldCount + numPatches);
for (int i = 0; i < numPatches; ++i)
{
FTextureID picnum = TexMan.CheckForTexture(patchNames[i], namespc);
if (!picnum.isValid())
{
int lumpnum = Wads.CheckNumForName(patchNames[i], namespc);
if (lumpnum >= 0)
{
picnum = TexMan.CreateTexture(lumpnum, namespc);
}
}
ImageMap[OldCount + i] = picnum;
}
}
示例11: LoadSkin
FTexture * LoadSkin(const char * path, const char * fn)
{
FString buffer;
buffer.Format("%s%s", path, fn);
int texlump = FindGFXFile(buffer);
if (texlump>=0)
{
FTextureID texno = TexMan.FindTextureByLumpNum(texlump);
if (!texno.isValid())
{
FTexture *tex = FTexture::CreateTexture("", texlump, FTexture::TEX_Override);
TexMan.AddTexture(tex);
return tex;
}
return TexMan[texno];
}
else
{
return NULL;
}
}
示例12: DrawPSprite
void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture)
{
float fU1,fV1;
float fU2,fV2;
float tx;
float x1,y1,x2,y2;
float scale;
float scalex;
float ftexturemid;
// 4:3 16:9 16:10 17:10 5:4 17:10 21:9
static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f, 40.f/51, 4.f/7};
// [BB] In the HUD model step we just render the model and break out.
if ( hudModelStep )
{
gl_RenderHUDModel(psp, sx, sy);
return;
}
// decide which patch to use
bool mirror;
FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, &mirror);
if (!lump.isValid()) return;
FMaterial * tex = FMaterial::ValidateTexture(lump, true, false);
if (!tex) return;
gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture);
float vw = (float)viewwidth;
float vh = (float)viewheight;
FloatRect r;
tex->GetSpriteRect(&r);
// calculate edges of the shape
scalex = xratio[WidescreenRatio] * vw / 320;
tx = sx - (160 - r.left);
x1 = tx * scalex + vw/2;
if (x1 > vw) return; // off the right side
x1 += viewwindowx;
tx += r.width;
x2 = tx * scalex + vw / 2;
if (x2 < 0) return; // off the left side
x2 += viewwindowx;
// killough 12/98: fix psprite positioning problem
ftexturemid = 100.f - sy - r.top;
AWeapon * wi=player->ReadyWeapon;
if (wi && wi->YAdjust != 0)
{
float fYAd = wi->YAdjust;
if (screenblocks >= 11)
{
ftexturemid -= fYAd;
}
else if (!st_scale)
{
ftexturemid -= StatusBar->GetDisplacement () * fYAd;
}
}
scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f);
y1 = viewwindowy + vh / 2 - (ftexturemid * scale);
y2 = y1 + (r.height * scale) + 1;
if (!mirror)
{
fU1=tex->GetSpriteUL();
fV1=tex->GetSpriteVT();
fU2=tex->GetSpriteUR();
fV2=tex->GetSpriteVB();
}
else
{
fU2=tex->GetSpriteUL();
fV1=tex->GetSpriteVT();
fU1=tex->GetSpriteUR();
fV2=tex->GetSpriteVB();
}
if (tex->GetTransparent() || OverrideShader != -1)
{
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
}
gl_RenderState.Apply();
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(x1, y1, 0, fU1, fV1);
ptr++;
ptr->Set(x1, y2, 0, fU1, fV2);
ptr++;
ptr->Set(x2, y1, 0, fU2, fV1);
ptr++;
ptr->Set(x2, y2, 0, fU2, fV2);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
//.........这里部分代码省略.........
示例13: Precache
void FGLInterface::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &actorhitlist)
{
SpriteHits *spritelist = new SpriteHits[sprites.Size()];
SpriteHits **spritehitlist = new SpriteHits*[TexMan.NumTextures()];
TMap<PClassActor*, bool>::Iterator it(actorhitlist);
TMap<PClassActor*, bool>::Pair *pair;
BYTE *modellist = new BYTE[Models.Size()];
memset(modellist, 0, Models.Size());
memset(spritehitlist, 0, sizeof(SpriteHits**) * TexMan.NumTextures());
// this isn't done by the main code so it needs to be done here first:
// check skybox textures and mark the separate faces as used
for (int i = 0; i<TexMan.NumTextures(); i++)
{
// HIT_Wall must be checked for MBF-style sky transfers.
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
{
FTexture *tex = TexMan.ByIndex(i);
if (tex->gl_info.bSkybox)
{
FSkyBox *sb = static_cast<FSkyBox*>(tex);
for (int i = 0; i<6; i++)
{
if (sb->faces[i])
{
int index = sb->faces[i]->id.GetIndex();
texhitlist[index] |= FTextureManager::HIT_Flat;
}
}
}
}
}
// Check all used actors.
// 1. mark all sprites associated with its states
// 2. mark all model data and skins associated with its states
while (it.NextPair(pair))
{
PClassActor *cls = pair->Key;
int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation);
for (int i = 0; i < cls->NumOwnedStates; i++)
{
spritelist[cls->OwnedStates[i].sprite].Insert(gltrans, true);
FSpriteModelFrame * smf = gl_FindModelFrame(cls, cls->OwnedStates[i].sprite, cls->OwnedStates[i].Frame, false);
if (smf != NULL)
{
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
{
if (smf->skinIDs[i].isValid())
{
texhitlist[smf->skinIDs[i].GetIndex()] |= FTexture::TEX_Flat;
}
else if (smf->modelIDs[i] != -1)
{
Models[smf->modelIDs[i]]->PushSpriteMDLFrame(smf, i);
Models[smf->modelIDs[i]]->AddSkins(texhitlist);
}
if (smf->modelIDs[i] != -1)
{
modellist[smf->modelIDs[i]] = 1;
}
}
}
}
}
// mark all sprite textures belonging to the marked sprites.
for (int i = (int)(sprites.Size() - 1); i >= 0; i--)
{
if (spritelist[i].CountUsed())
{
int j, k;
for (j = 0; j < sprites[i].numframes; j++)
{
const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j];
for (k = 0; k < 16; k++)
{
FTextureID pic = frame->Texture[k];
if (pic.isValid())
{
spritehitlist[pic.GetIndex()] = &spritelist[i];
}
}
}
}
}
// delete everything unused before creating any new resources to avoid memory usage peaks.
// delete unused models
for (unsigned i = 0; i < Models.Size(); i++)
{
if (!modellist[i]) Models[i]->DestroyVertexBuffer();
}
// delete unused textures
int cnt = TexMan.NumTextures();
for (int i = cnt - 1; i >= 0; i--)
//.........这里部分代码省略.........
示例14: DrawAmmo
static int DrawAmmo(player_t *CPlayer, int x, int y)
{
int i,j,k;
char buf[256];
AInventory *inv;
AWeapon *wi=CPlayer->ReadyWeapon;
orderedammos.Clear();
if (0 == hud_showammo)
{
// Show ammo for current weapon if any
if (wi) AddAmmoToList(wi);
}
else
{
// Order ammo by use of weapons in the weapon slots
for (k = 0; k < NUM_WEAPON_SLOTS; k++) for(j = 0; j < CPlayer->weapons.Slots[k].Size(); j++)
{
PClassActor *weap = CPlayer->weapons.Slots[k].GetWeapon(j);
if (weap)
{
// Show ammo for available weapons if hud_showammo CVAR is 1
// or show ammo for all weapons if hud_showammo is greater than 1
if (hud_showammo > 1 || CPlayer->mo->FindInventory(weap))
{
AddAmmoToList((AWeapon*)GetDefaultByType(weap));
}
}
}
// Now check for the remaining weapons that are in the inventory but not in the weapon slots
for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory)
{
if (inv->IsKindOf(RUNTIME_CLASS(AWeapon)))
{
AddAmmoToList((AWeapon*)inv);
}
}
}
// ok, we got all ammo types. Now draw the list back to front (bottom to top)
int def_width = ConFont->StringWidth("000/000");
x-=def_width;
int yadd = ConFont->GetHeight();
for(i=orderedammos.Size()-1;i>=0;i--)
{
PClassAmmo * type = orderedammos[i];
AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type);
AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]);
FTextureID AltIcon = GetHUDIcon(type);
FTextureID icon = !AltIcon.isNull()? AltIcon : inv->Icon;
if (!icon.isValid()) continue;
int trans= (wi && (type==wi->AmmoType1 || type==wi->AmmoType2)) ? 0xc000:0x6000;
int maxammo = inv->MaxAmount;
int ammo = ammoitem? ammoitem->Amount : 0;
mysnprintf(buf, countof(buf), "%3d/%3d", ammo, maxammo);
int tex_width= clamp<int>(ConFont->StringWidth(buf)-def_width, 0, 1000);
int fontcolor=( !maxammo ? CR_GRAY :
ammo < ( (maxammo * hud_ammo_red) / 100) ? CR_RED :
ammo < ( (maxammo * hud_ammo_yellow) / 100) ? CR_GOLD : CR_GREEN );
DrawHudText(ConFont, fontcolor, buf, x-tex_width, y+yadd, trans);
DrawImageToBox(TexMan[icon], x-20, y, 16, 8, trans);
y-=10;
}
return y;
}
示例15: ParseAnim
void FTextureManager::ParseAnim (FScanner &sc, int usetype)
{
const BITFIELD texflags = TEXMAN_Overridable | TEXMAN_TryAny;
TArray<FAnimDef::FAnimFrame> frames (32);
FTextureID picnum;
int defined = 0;
bool optional = false, missing = false;
FAnimDef *ani = NULL;
BYTE type = FAnimDef::ANIM_Forward;
sc.MustGetString ();
if (sc.Compare ("optional"))
{
optional = true;
sc.MustGetString ();
}
picnum = CheckForTexture (sc.String, usetype, texflags);
if (!picnum.Exists())
{
if (optional)
{
missing = true;
}
else
{
Printf (PRINT_BOLD, "ANIMDEFS: Can't find %s\n", sc.String);
}
}
// no decals on animating textures, by default
if (picnum.isValid())
{
Texture(picnum)->bNoDecals = true;
}
while (sc.GetString ())
{
if (sc.Compare ("allowdecals"))
{
if (picnum.isValid())
{
Texture(picnum)->bNoDecals = false;
}
continue;
}
else if (sc.Compare ("Oscillate"))
{
if (type == FAnimDef::ANIM_Random)
{
sc.ScriptError ("You cannot use \"random\" and \"oscillate\" together in a single animation.");
}
type = FAnimDef::ANIM_OscillateUp;
}
else if (sc.Compare("Random"))
{
if (type == FAnimDef::ANIM_OscillateUp)
{
sc.ScriptError ("You cannot use \"random\" and \"oscillate\" together in a single animation.");
}
type = FAnimDef::ANIM_Random;
}
else if (sc.Compare ("range"))
{
if (picnum.Exists() && Texture(picnum)->Name.IsEmpty())
{
// long texture name: We cannot do ranged anims on these because they have no defined order
sc.ScriptError ("You cannot use \"range\" for long texture names.");
}
if (defined == 2)
{
sc.ScriptError ("You cannot use \"pic\" and \"range\" together in a single animation.");
}
if (defined == 1)
{
sc.ScriptError ("You can only use one \"range\" per animation.");
}
defined = 1;
ani = ParseRangeAnim (sc, picnum, usetype, missing);
}
else if (sc.Compare ("pic"))
{
if (defined == 1)
{
sc.ScriptError ("You cannot use \"pic\" and \"range\" together in a single animation.");
}
defined = 2;
ParsePicAnim (sc, picnum, usetype, missing, frames);
}
else
{
sc.UnGet ();
break;
}
}
// If base pic is not present, don't add this anim
// ParseRangeAnim adds the anim itself, but ParsePicAnim does not.
if (picnum.isValid() && defined == 2)
{
//.........这里部分代码省略.........