本文整理汇总了C++中Up函数的典型用法代码示例。如果您正苦于以下问题:C++ Up函数的具体用法?C++ Up怎么用?C++ Up使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Up函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: currentState
void Keyboard::Update(void)
{
Device::Update();
//poll
HRESULT hr = m_pDevice->GetDeviceState(N_KEYS*sizeof(unsigned char), (void*) currentState());
switch(hr){
case DI_OK:
break; //everything is fine
case DIERR_INPUTLOST:
case DIERR_NOTACQUIRED:
m_pDevice->Acquire(); //get the device back
return;
case E_PENDING: //not ready yet, maybe next frame
return;
default:
assert(hr != DIERR_NOTINITIALIZED);
assert(hr != DIERR_INVALIDPARAM);
}
/* emit events */
for (unsigned int i=0; i<N_KEYS; i++)
{
if (Up(currentState(), i) && Down(oldState(), i))
EVENT(KeyReleasedEvent(i));
else if (Down(currentState(), i) && Up(oldState(), i))
EVENT(KeyPressedEvent(i));
}
flipBuffers();
}
示例2: EnvReadInsert
void EnvReadInsert(FILE_NUM fnum, int offset, OBJECT env)
{ int pos; OBJECT x, loser;
debug3(DET, DD, "EnvReadInsert(%s, %d, env %d)",
FileName(fnum), offset, (int) env);
/* to limit the cache size, remove least recently used entry if full */
if( cache_count >= MAX_CACHE )
{
Child(loser, Down(env_cache));
DeleteLink(Up(loser));
DisposeChild(Up(loser));
cache_count--;
}
/* insert the new entry */
hash2(pos, fnum, offset);
if( tab[pos] == nilobj ) New(tab[pos], ACAT);
New(x, ACAT);
env_fnum(x) = fnum;
env_offset(x) = offset;
env_read(x) = TRUE;
Link(tab[pos], x);
Link(env_cache, x);
Link(x, env);
cache_count++;
debug1(DET, DD, "EnvReadInsert returning (cache_count = %d)", cache_count);
} /* end EnvReadInsert */
示例3: proc_insertBuff
// insert a written block.
int proc_insertBuff(int index,int pathIndex,struct block *buff,loff_t pos, size_t count,context *ct)
{
loff_t* f_pos,spos;
size_t left = count, wrt;
int ret;
if(RELEASE(index)) return count;
if(pathIndex==INDEX_PATH_NUM) {
spos = ((pipes[index].ct)[CONTEXT]).bpos + pos;
} else {
spos=pos;
}
f_pos=(loff_t *)&spos;
while(1) {
Down(index);
wrt = left;
ret = dev_insertBuff(&((pipes[index]).device), f_pos,buff, &left, ct);
if(pathIndex==INDEX_PATH_NUM)
POS(ct)=*f_pos-((pipes[index].ct)[CONTEXT]).bpos;
else
POS(ct)=*f_pos;
if(ret == DEV_FAULT) {Up(index); return -EFAULT;}
if(wrt && !R_ABLE(ct)) {
R_ABLE(ct) = 1;
if(ret == DEV_SEEK) {
wake_up_interruptible_sync(&(RQ(index)));
}
else {
wake_up_interruptible(&(RQ(index)));
}
}
if(ret == DEV_SEEK) {Up(index); return -P_ESEEK;}
if(ret == DEV_FULL) {
W_ABLE(ct) = 0; Up(index);
PDEBUG("<%d>: device full, sleep, left %d\n", current->pid, (int)left);
Wait_Event(WQ(index), RELEASE(index)||W_ABLE(ct));
if(RELEASE(index)) return count;
continue;
}
Up(index);
if(left <= 0) break;
}
return count;
}
示例4: DetachGalley
void DetachGalley(OBJECT hd)
{ OBJECT prnt, index;
assert( type(hd) == HEAD && Up(hd) != hd, "DetachGalley: precondition!" );
debug1(DGA, D, "DetachGalley( %s )", SymName(actual(hd)));
Parent(prnt, Up(hd));
assert( Up(prnt) != prnt, "DetachGalley: parent!" );
New(index, UNATTACHED);
pinpoint(index) = nilobj;
MoveLink(Up(hd), index, PARENT);
Link(NextDown(Up(prnt)), index);
debug0(DGA, D, "DetachGalley returning.");
} /* end DetachGalley */
示例5: dimensionedInternalField
void myMovingWallVelocityFvPatchVectorField::updateCoeffs()
{
if ( updated() )
{
return;
}
// Info << "void myMovingWallVelocityFvPatchVectorField::updateCoeffs()" <<endl;
const fvMesh & mesh = dimensionedInternalField().mesh();
const fvPatch & p = patch();
const polyPatch & pp = p.patch();
if ( myTimeIndex_ < mesh.time().timeIndex() )
{
oldoldFc_ = oldFc_;
oldFc_ = Fc_;
Fc_ = pp.faceCentres();
myTimeIndex_ = mesh.time().timeIndex();
}
// const pointField& oldPoints = mesh.oldPoints();
const volVectorField & U = mesh.lookupObject<volVectorField>( dimensionedInternalField().name() );
scalar deltaT = mesh.time().deltaT().value();
scalar deltaT0 = mesh.time().deltaT0().value();
if ( U.oldTime().timeIndex() == U.oldTime().oldTime().timeIndex() || U.oldTime().oldTime().timeIndex() < 0 )
{
deltaT0 = GREAT;
}
// Set coefficients based on deltaT and deltaT0
scalar coefft = 1 + deltaT / (deltaT + deltaT0);
scalar coefft00 = deltaT * deltaT / ( deltaT0 * (deltaT + deltaT0) );
scalar coefft0 = coefft + coefft00;
tmp<vectorField> Up = (coefft * Fc_ - coefft0 * oldFc_ + coefft00 * oldoldFc_) / mesh.time().deltaT().value();
scalarField phip = p.patchField<surfaceScalarField, scalar>( fvc::meshPhi( U ) );
tmp<vectorField> n = p.nf();
const scalarField & magSf = p.magSf();
tmp<scalarField> Un = phip / (magSf + VSMALL);
vectorField::operator=( Up() + n() *( Un() - ( n() & Up() ) ) );
fixedValueFvPatchVectorField::updateCoeffs();
}
示例6: main
int main()
{
COORD pos;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
int i, leftB, rightB, upB, downB;
leftB = 11;
rightB = 67;
upB = 11;
downB = 13;
pos.Y = 12;
pos.X = 66;
for (i = 0; i < 12; i++)
{
pos = Left (pos, leftB);
leftB--;
pos = Up (pos, upB);
upB--;
pos = Right (pos, rightB);
rightB++;
pos = Down (pos, downB);
downB++;
}
pos = Left (pos, leftB);
leftB--;
if (leftB == 0)
{
printf("*");
}
pos.X = 0;
pos.Y = 25;
SetConsoleCursorPosition(hConsole, pos);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
return 0;
}
示例7: Parent
FULL_CHAR *SymName(OBJECT s)
{ OBJECT p;
if( s == nilobj ) return AsciiToFull("<nilobj>");
Parent(p, Up(s));
assert( is_word(type(p)), "SymName: !is_word(type(p))!" );
return string(p);
} /* end SymName */
示例8: move
void Camera :: move(double value)
{
Point3 Eye(eye.x, eye.y+value, eye.z);
Point3 Look = lookAt;
Vector3 Up(0.0, 1.0, 0.0);
set(Eye, Look, Up);
}
示例9: Init
bool Init()
{
Vector3f Pos(-10.0f, 0.0f, -10.0f);
Vector3f Target(1.0f, 0.0f, 1.0f);
Vector3f Up(0.0, 1.0f, 0.0f);
m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up);
unsigned int Indices[] = { 0, 2, 1,
0, 3, 2};
CreateIndexBuffer(Indices, sizeof(Indices));
CreateVertexBuffer(Indices, ARRAY_SIZE_IN_ELEMENTS(Indices));
m_pEffect = new LightingTechnique();
if (!m_pEffect->Init())
{
printf("Error initializing the lighting technique\n");
return false;
}
m_pEffect->Enable();
m_pEffect->SetTextureUnit(0);
m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png");
if (!m_pTexture->Load()) {
return false;
}
return true;
}
示例10: Init
bool Init()
{
Vector3f Pos(5.0f, 1.0f, -3.0f);
Vector3f Target(0.0f, 0.0f, 1.0f);
Vector3f Up(0.0, 1.0f, 0.0f);
m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up);
CreateVertexBuffer();
m_pEffect = new LightingTechnique();
if (!m_pEffect->Init())
{
printf("Error initializing the lighting technique\n");
return false;
}
m_pEffect->Enable();
m_pEffect->SetTextureUnit(0);
m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png");
if (!m_pTexture->Load()) {
return false;
}
return true;
}
示例11: DrawDebugDirectionalArrow
void DrawDebugDirectionalArrow(const UWorld* InWorld, FVector const& LineStart, FVector const& LineEnd, float ArrowSize, FColor const& Color, bool bPersistentLines, float LifeTime, uint8 DepthPriority)
{
// no debug line drawing on dedicated server
if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
{
if (ArrowSize <= 0)
{
ArrowSize = 10.f;
}
DrawDebugLine(InWorld, LineStart, LineEnd, Color, bPersistentLines, LifeTime);
FVector Dir = (LineEnd-LineStart);
Dir.Normalize();
FVector Up(0, 0, 1);
FVector Right = Dir ^ Up;
if (!Right.IsNormalized())
{
Dir.FindBestAxisVectors(Up, Right);
}
FVector Origin = FVector::ZeroVector;
FMatrix TM;
// get matrix with dir/right/up
TM.SetAxes(&Dir, &Right, &Up, &Origin);
// since dir is x direction, my arrow will be pointing +y, -x and -y, -x
float ArrowSqrt = FMath::Sqrt(ArrowSize);
FVector ArrowPos;
DrawDebugLine(InWorld, LineEnd, LineEnd + TM.TransformPosition(FVector(-ArrowSqrt, ArrowSqrt, 0)), Color, bPersistentLines, LifeTime, DepthPriority);
DrawDebugLine(InWorld, LineEnd, LineEnd + TM.TransformPosition(FVector(-ArrowSqrt, -ArrowSqrt, 0)), Color, bPersistentLines, LifeTime, DepthPriority);
}
}
示例12: main
int main() {
while (~scanf("%d %d", &n, &m)) {
init(n);
for (int i = 1; i <= n; ++i) {
scanf("%I64d", s + i);
s[i] += s[i - 1];
}
dp[1] = s[1] * s[1] + m;
q.push_back(0);
for (int i = 1; i <= n; ++i) {
while (q.size() >= 2 && Up(q[1], q.front()) <= s[i] * Down(q[1], q.front())) {
// printf(" %d\n", q[1]);
// printf("--- %I64d %d\n", dp[i], q.size());
q.pop_front();
}
if (!q.empty())
Dp(i, q.front());
// printf("%I64d %d\n", dp[i], q.size());
while (q.size() >= 2 /*&& 1, printf("--- %I64d %d\n *** %I64d %I64d\n", dp[i], q.back(), Up(i, q.back()) * Down(q.back(), q[q.size() - 2]), Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) */&& Up(i, q.back()) * Down(q.back(), q[q.size() - 2]) <= Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) {
// ;
// printf(" %d\n", q[1]);
q.pop_back();
}
q.push_back(i);
// printf(" %d\n", q.size());
}
printf("%I64d\n", dp[n]);
}
}
示例13: qDebug
void Keyboard::Deinit()
{
qDebug() << "Killing keyboard\n";
// Release all keys
ModifierUp(ModCtrlL);
ModifierUp(ModCtrlR);
ModifierUp(ModCtrl);
ModifierUp(ModAltL);
ModifierUp(ModAltR);
ModifierUp(ModAlt);
ModifierUp(ModShiftL);
ModifierUp(ModShiftR);
ModifierUp(ModShift);
ModifierUp(ModMetaL);
ModifierUp(ModMetaR);
ModifierUp(ModMeta);
/*
for (Keycode i = 0; i < std::numeric_limits<Keycode>::max(); ++i)
{
Up(i);
}
Up(std::numeric_limits<Keycode>::max());
*/
// Just unpress ASCII printing characters
for (Keycode i = 32; i < 127; ++i)
{
Up(i);
}
}
示例14: GetAbsOrigin
void CASWEnvSpark::CreateSpark( void )
{
CUtlReference<CNewParticleEffect> pEffect = CNewParticleEffect::CreateOrAggregate( NULL, "asw_env_sparks", GetAbsOrigin(), NULL );
if ( pEffect )
{
pEffect->SetControlPoint( 0, GetAbsOrigin() );
pEffect->SetControlPointOrientation( 0, Forward(), -Left(), Up() );
pEffect->SetControlPoint( 2, Vector( GetRenderColorR(), GetRenderColorG(), GetRenderColorB() ) );
float flMagnitude = m_flMagnitude/100;
float flElecReduction = 1.0f;
float flCollide = (m_flPercentCollide/100);
float flAmtElectrical = 0;
if ( m_bElectrical )
{
flAmtElectrical = flMagnitude;
flElecReduction = 0.6;
}
pEffect->SetControlPoint( 3, Vector( ((1.0f-flCollide)* flMagnitude)*flElecReduction, (flCollide*flMagnitude)*flElecReduction, flMagnitude ) );
pEffect->SetControlPoint( 4, Vector( flAmtElectrical, 0, 0 ) );
//Msg( "Spark - Magnitude = %f\n", flMagnitude );
}
if ( m_bPlaySound )
{
EmitSound( "DoSpark" );
}
}
示例15: p_sock_read
ssize_t p_sock_read(int index, struct file *filp, char *buf, size_t count, loff_t *f_pos)
{
// context *ct=getct(index,*f_pos);
pipe_file *pp=&(pipes[index]);
kpipe_setup *pipeSetup=&(pipeManage.threads[index].pipeSetup[0]);
size_t len;
int type;
loff_t tmp_pos=*f_pos;
sock_pos_t *sockPos=filp->private_data;
if(!filp->private_data) {
HDEBUG("first read,malloc sock_pos_t\n");
sockPos=kmalloc(sizeof(sock_pos_t),GFP_KERNEL);
memset(sockPos,0,sizeof(sock_pos_t));
sockPos->magic = SOCK_POS_MAGIC;
filp->private_data = sockPos;
}
Down(index);
if(tmp_pos >= ((pp->ct)[CONTEXT]).bpos) {
HDEBUG("read idx\n");
if(pipeSetup->pathIndex!=INDEX_PATH_NUM)
pipeSetup++;
tmp_pos -=((pp->ct)[CONTEXT]).bpos;
}
type=pipeSetup->type;
Up(index);
len = p_close_createAndRead(sockPos,pipeSetup,buf,count,&tmp_pos);
if(len>=0) {
*f_pos +=len;
sockPos->pos = tmp_pos+len;
}
return len;
}