int SettingsWindowProc(PASSPROCVARS Params){ int r=0; r+=cbHighScores.ProcFunction(Params); r+=cbPlay.ProcFunction(Params); r+=cbExit.ProcFunction(Params); r+=cbOptions.ProcFunction(Params); r+=cbCredits.ProcFunction(Params); if(r){ //DrawString("Setting up alpha table/@", 0, 10, 8); //DrawString("Setting up alpha table/@", 0, 20, 12); //DrawString("Setting up alpha table/@", 0, 35, 13); //DrawString("Setting up alpha table/@", 0, 50, 21); Flip(Pass.DDFront); Blit(Pass.DDBack, ScreenUnhighlighted, 0,0,640,480,0,0); } switch(Params.uMsg){ case WM_PAINT: settingsRedrawScreen(); break; case WM_CLOSE: Pass.SettingsInfo=SETTINGS_EXIT; Pass.ProgramFlow=PF_EXIT; break; } return 0; }
void GSDevice::Present(const GSVector4i& r, int shader) { GSVector4i cr = m_wnd->GetClientRect(); int w = std::max<int>(cr.width(), 1); int h = std::max<int>(cr.height(), 1); if(!m_backbuffer || m_backbuffer->GetWidth() != w || m_backbuffer->GetHeight() != h) { if(!Reset(w, h)) { return; } } GL_PUSH("Present"); ClearRenderTarget(m_backbuffer, 0); if(m_current) { static int s_shader[5] = {0, 5, 6, 8, 9}; // FIXME Present(m_current, m_backbuffer, GSVector4(r), s_shader[shader]); } Flip(); GL_POP(); }
/* * BITBLT */ BOOL XM7_BitBlt(int nDestLeft, int nDestTop, int nWidth, int nHeight, int nSrcLeft, int nSrcTop) { AG_Rect srcrect, dstrect; if(bUseOpenGL) { Flip(); return TRUE; } srcrect.x = nSrcLeft; srcrect.y = nSrcTop; srcrect.w = (Uint16) nWidth; srcrect.h = (Uint16) nHeight; dstrect.x = nDestLeft; dstrect.y = nDestTop; dstrect.w = (Uint16) nWidth; dstrect.h = (Uint16) nHeight; /* * データ転送 */ /* * 擬似インタレース設定をここでやる */ if (bOldFullScan != bFullScan) { if (!bFullScan) { RenderSetOddLine(); } else { RenderFullScan(); } } bOldFullScan = bFullScan; return TRUE; }
int CreditsProc(PASSPROCVARS Params){ int r=0; r+=ccbOK.ProcFunction(Params); if(r){ //we have to flip the screen Flip(Pass.DDFront); Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0); } //now handle some messages switch(Params.uMsg){ case WM_CLOSE: Pass.ProgramFlow=PF_EXIT; CreditsInfo=CREDITS_EXIT; break; case WM_PAINT: ddsCredits->Restore(); ddsCreditsh->Restore(); DDReLoadBitmap(ddsCredits,BMP_CREDITS); DDReLoadBitmap(ddsCreditsh,BMP_CREDITSH); Blit(Pass.DDFront, ddsCredits, 0, 0, 640, 480, 0, 0); Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0); break; case WM_KEYDOWN: switch(Params.wParam){ case VK_ESCAPE: CreditsInfo=CREDITS_EXIT; break; } break; } return 0; }
////FUNCTIONS////////////////// //----------------------------------------------------------------------------- // Name: Main() // Desc: Where all work is done //----------------------------------------------------------------------------- bool main() { static int nFrames = 0; //static CVECTOR shipsVelVector(0.f,0.f,0.f); if(GetKeyStatus(VK_ESCAPE) == true) return(0); //Clear the surface if(!ClrS(lpddsSecondary,&wndRect))//can't be within a lock-Unlock block or u can't blt return(0); DynamicStarField(NULL,800,Sprites[0].physProp.VelVector,nFrames); //Sprites[0].DrawSprite(lpddsSecondary); MoveShip(); if(bDebugMode) DebugInfo(nFrames); //Flip primary and secondary surfaces Flip(); //Sleep(1000); fFrameTime = frameTimer.EndTimerAndRestart(); nFrames++; return(1); }
Overlay::Overlay(renderer* parent) : parent(parent) { { CoreSuspender suspend; //parent->zoom(df::zoom_commands::zoom_reset); good_viewscreen = false; ReadTileLocations(); copy_from_inner(); } front_mutex = al_create_mutex(); int32_t flags = al_get_new_bitmap_flags(); if(al_get_current_display() != NULL){ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_ALPHA_TEST); } front = al_create_bitmap(0,0); if(al_get_current_display() != NULL){ al_set_new_bitmap_flags(al_get_bitmap_flags(al_get_backbuffer(al_get_current_display()))); } back = al_create_bitmap(0,0); al_set_new_bitmap_flags(flags); Flip(); };
//////////////////////////////////////////////////////////// // Draw Tetris Title //////////////////////////////////////////////////////////// void DrawTitleDown(int y_cur) { int x, y; int y_start_in_image; int y_start_in_screen = 0; int width, y_temp; // For performance y_start_in_image = TETRIS_TITLE_HEIGHT - y_cur; if(y_start_in_image < 0) { y_start_in_screen = 0-y_start_in_image; y_start_in_image = 0; } EraseScreenNoFlip(); width = TETRIS_TITLE_WIDTH / 2; for(y = y_start_in_image; y < TETRIS_TITLE_HEIGHT; y++) { y_temp = (y - y_start_in_image) + y_start_in_screen; for(x = 0; x < width; x++) { PlotPixel(x+10,y_temp, tetrisTitleData[(y*width)+x]); } } WaitForVblank(); Flip(); }
bool CxImageSKA::Decode(CxFile *hFile) { if (hFile==NULL) return false; // read the header SKAHEADER ska_header; hFile->Read(&ska_header,sizeof(SKAHEADER),1); ska_header.Width = ntohs(ska_header.Width); ska_header.Height = ntohs(ska_header.Height); ska_header.dwUnknown = ntohl(ska_header.dwUnknown); // check header if (ska_header.dwUnknown != 0x01000000 || ska_header.Width > 0x7FFF || ska_header.Height > 0x7FFF || ska_header.BppExp != 3) return false; if (info.nEscape == -1){ head.biWidth = ska_header.Width ; head.biHeight= ska_header.Height; info.dwType = CXIMAGE_FORMAT_SKA; return true; } int bpp = 1<<ska_header.BppExp; Create(ska_header.Width,ska_header.Height,bpp,CXIMAGE_FORMAT_SKA); if (!IsValid()) return false; // read the palette int nColors = 1<<bpp; rgb_color* ppal = (rgb_color*)malloc(nColors*sizeof(rgb_color)); if (!ppal) return false; hFile->Read(ppal,nColors*sizeof(rgb_color),1); SetPalette(ppal,nColors); free(ppal); //read the image hFile->Read(GetBits(),ska_header.Width*ska_header.Height,1); //reorder rows if (GetEffWidth() != ska_header.Width){ BYTE *src,*dst; src = GetBits() + ska_header.Width*(ska_header.Height-1); dst = GetBits(ska_header.Height-1); for(int y=0;y<ska_header.Height;y++){ memcpy(dst,src,ska_header.Width); src -= ska_header.Width; dst -= GetEffWidth(); } } Flip(); return true; }
bool wxIDirectFBSurface::FlipToFront(const DFBRegion *region) { // Blit to the front buffer instead of exchanging front and back ones. // Always doing this ensures that back and front buffer have same content // and so painting to the back buffer will never lose any previous // drawings: return Flip(region, DSFLIP_BLIT); }
//---------------------------------------------------------------------------- bool TestTriTri::OnLButtonDown (int iXPos, int iYPos, unsigned int) { if ( !m_bMouseDown ) { m_bMouseDown = true; SetCapture(ms_hWnd); m_hDragDC = GetDC(ms_hWnd); m_iTriangle = -1; m_iSelect = -1; if ( 0 <= iXPos && iXPos < GetWidth() && 0 <= iYPos && iYPos < GetHeight() ) { COLORREF kColor = GetPixel(m_hDragDC,iXPos,iYPos); iYPos = Flip(iYPos); int i; for (i = 0; i < 3; i++) { if ( MouseNearVertex(iXPos,iYPos,m_aiX0[i],m_aiY0[i]) ) { m_iTriangle = 0; m_iSelect = i; return true; } } for (i = 0; i < 3; i++) { if ( MouseNearVertex(iXPos,iYPos,m_aiX1[i],m_aiY1[i]) ) { m_iTriangle = 1; m_iSelect = i; return true; } } if ( MouseInTriangle(iXPos,iYPos,m_aiX0,m_aiY0) ) { m_iTriangle = 0; m_iXMouseStart = iXPos; m_iYMouseStart = iYPos; return true; } if ( MouseInTriangle(iXPos,iYPos,m_aiX1,m_aiY1) ) { m_iTriangle = 1; m_iXMouseStart = iXPos; m_iYMouseStart = iYPos; return true; } } } return true; }
bool CBounceBomb::IsValidLocation() { CBaseEntity *pAvoidObject = NULL; float flAvoidForce = 0.0f; CAI_Hint *pHint; CHintCriteria criteria; criteria.SetHintType( HINT_WORLD_INHIBIT_COMBINE_MINES ); criteria.SetFlag( bits_HINT_NODE_NEAREST ); criteria.AddIncludePosition( GetAbsOrigin(), 12.0f * 15.0f ); pHint = CAI_HintManager::FindHint( GetAbsOrigin(), criteria ); if( pHint ) { pAvoidObject = pHint; flAvoidForce = 120.0f; } else { // Look for other mines that are too close to me. CBaseEntity *pEntity = gEntList.FirstEnt(); Vector vecMyPosition = GetAbsOrigin(); while( pEntity ) { if( pEntity->m_iClassname == m_iClassname && pEntity != this ) { // Don't lock down if I'm near a mine that's already locked down. if( vecMyPosition.DistToSqr(pEntity->GetAbsOrigin()) < MINE_MIN_PROXIMITY_SQR ) { pAvoidObject = pEntity; flAvoidForce = 60.0f; break; } } pEntity = gEntList.NextEnt( pEntity ); } } if( pAvoidObject ) { // Build a force vector to push us away from the inhibitor. // Start by pushing upwards. Vector vecForce = Vector( 0, 0, VPhysicsGetObject()->GetMass() * 200.0f ); // Now add some force in the direction that takes us away from the inhibitor. Vector vecDir = GetAbsOrigin() - pAvoidObject->GetAbsOrigin(); vecDir.z = 0.0f; VectorNormalize( vecDir ); vecForce += vecDir * VPhysicsGetObject()->GetMass() * flAvoidForce; Flip( vecForce, AngularImpulse( 100, 0, 0 ) ); // Tell the code that asked that this position isn't valid. return false; } return true; }
void CGSHandler::SetVBlank() { { Flip(); } std::lock_guard<std::recursive_mutex> registerMutexLock(m_registerMutex); m_nCSR |= CSR_VSYNC_INT; }
sPerfMonGpu::sPerfMonGpu(sAdapter *adapter,const char *name) : sPerfMonBase(name) { Adapter = adapter; MostRecentFrame = GetFrame(); MostRecentFrame->Frequency = 1000*1000; Current = 0; Flip(); sPerfMonSubsystem_.Add(this); }
void CGSHandler::SetVBlank() { if(m_flipMode == FLIP_MODE_VBLANK) { Flip(); } std::lock_guard<std::recursive_mutex> registerMutexLock(m_registerMutex); m_nCSR |= CSR_VSYNC_INT; }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void ManagerImplemented::BeginUpdate() { m_renderingSession.Enter(); if( m_autoFlip ) { Flip(); } m_sequenceNumber++; }
//////////////////////////////////////////////////////////// // Clear PRESS START image from screen //////////////////////////////////////////////////////////// void ClearPressStart() { int x, y; for(y = 0; y < TETRIS_TITLE_PRESS_START_HEIGHT; y++) { for(x = 0; x < TETRIS_TITLE_PRESS_START_WIDTH/2; x++) { PlotPixel(x+38,y+115,0x00); } } WaitForVblank(); Flip(); }
bool gmGarbageCollector::Collect() { if(m_fullThrottle) { m_workLeftToGo = GM_MAX_INT32; } else { m_workLeftToGo = m_workPerIncrement; } m_doneTracing = false; if(m_firstCollectionIncrement) { // Scan each root object and gray it GM_ASSERT(m_scanRootsCallback); m_scanRootsCallback(m_gmMachine, this); m_firstCollectionIncrement = false; return false; } // If any grays exist, scan them first if(m_colorSet.AnyGrays()) { if(BlackenGrays()) // Returns 0 if no more grays, and 1 if done with an increment of collection. { return false; // Out of time, so exit function } } m_doneTracing = true; #if GM_GC_TURN_OFF_ABLE // Turn off gc until almost out of memory. // Can only do when allocating black. m_gcTurnedOff = true; #endif //GM_GC_TURN_OFF_ABLE // Let the collect continue until garbage memory has been reclaimed // This could be done as an external phase if(ReclaimSomeFreeObjects()) { return false; } #if !GM_GC_TURN_OFF_ABLE Flip(); #endif //!GM_GC_TURN_OFF_ABLE return true; }
void game::gameloop(){ // Mix_SetPostMix(band_separate, &au); //Mix_PlayMusic( music, -1 ); int score = 0; int cooldown = 20; while(shouldIQuit() == false) { if ((cooldown<0)&&au->poll_beat(0)){ //srand(au.poll_sig(4)); for (int i =0; i<rand()%10; i++) { baddie *b = new baddie(this); sprite_list.push_back(b); cooldown = 10; } } cooldown--; keys = SDL_GetKeyState( NULL ); bg->updateBackground(getWindowSurface()); std::list<sprite*>::iterator i; for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { sprite *bees = *i; if (bees->removeMe) { i = sprite_list.erase(i); delete bees; } } for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { (*i)->moveSprite(); } for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { (*i)->renderSprite(); } h->displayText(10,10,"Score: %i0",score/10); if ((*sprite_list.begin())->currentState==IDLE){ if(2*(*sprite_list.begin())->xpos>SCREEN_WIDTH) { score+=2;} else {score++;}} if ((*sprite_list.begin())->currentState==DYING)score-=3; if ((*sprite_list.begin())->currentState==DEAD)score-=6; if (score <0) score = 0; Flip(); } }
//////////////////////////////////////////////////////////// // Draw PRESS START image to screen //////////////////////////////////////////////////////////// void DrawPressStart() { int x, y; for(y = 0; y < TETRIS_TITLE_PRESS_START_HEIGHT; y++) { for(x = 0; x < TETRIS_TITLE_PRESS_START_WIDTH/2; x++) { PlotPixel(x+38,y+115,tetrisTitlePressStartData[(y*TETRIS_TITLE_PRESS_START_WIDTH/2)+x]); } } WaitForVblank(); Flip(); }
Sprite::Sprite(const std::string& filename, GameEngine::GameContext& context, const glm::vec4& destRect, const glm::vec4& uvRect, float depth, float angle, const GameEngine::Rendering::ColourRGBA8& colour, bool flip) : m_texture(context.GetResourceManager().GetTexture(filename)), m_destRect(destRect), m_uvRect(uvRect), m_depth(depth), m_colour(colour), m_angle(angle) { if (flip) { Flip(); } }
int state_see(state_t *state, int move) { uint64_t attackers = util_attacks_to(state, MoveFrom(move)) & ~(1ull << MoveFrom(move)); int attacked = eval_piece_values[MovePiece(move)]; int color = Flip(state->turn); int ply = 1; int attacker; int swapstack[64]; swapstack[0] = eval_real_pvalues[MoveCapture(move)]; while (attackers) { uint64_t hits; for (attacker = PAWN; attacker <= KING; ++attacker) { hits = state->pieces[color][attacker] & attackers; if (hits) { break; } } if (attacker > KING) break; attackers ^= hits & -hits; swapstack[ply] = -swapstack[ply - 1] + attacked; attacked = eval_real_pvalues[attacker]; color = Flip(color); ply += 1; } while (--ply) swapstack[ply - 1] = -Max(-swapstack[ply - 1], swapstack[ply]); return swapstack[0]; }
////FUNCTIONS////////////////// //----------------------------------------------------------------------------- // Name: Main() // Desc: Where all work is done //----------------------------------------------------------------------------- bool main() { static int frames=0; static float fps=0.0f, frametime=0.0f; static char buffer[1024]; frames++; //if(frames == 1) // bitmap.LoadBitmapFile24(); if(GetKeyStatus(VK_ESCAPE) == true) return(0); //Clear the surface if(!ClrS(lpddsSecondary,&wndRect))//can't be within a lock-Unlock block or u can't blt return(0); //Lock the surface for drawing //if(!Lock(lpddsPrimary)) // return(0); /* UCHAR *imagebuffer=NULL; imagebuffer = (UCHAR*)ddsd.lpSurface; for(int y=0; y<bitmap.GetHeight(); y++) { memcpy( &imagebuffer[y*ddsd.lPitch], &bitmap.GetImageData()[y*bitmap.GetWidth()*4], bitmap.GetWidth()*4 ); } */ //Unlock the surface //if(!UnLock(lpddsPrimary)) // return(0); Sprites[0].DrawSprite(lpddsSecondary); Sprites[1].DrawSprite(lpddsSecondary); Sprites[2].DrawSprite(lpddsSecondary); frametime = Frametimer.EndTimerAndRestart(); //----Output FPS---- sprintf(buffer,"Render Time= %g",frametime); DrawStringGDI(lpddsSecondary,0,0,buffer); fps = ((float)frames)/((float)(gametimer.GetStartElapsedTime())*0.001f); sprintf(buffer,"FPS= %g",fps); DrawStringGDI(lpddsSecondary,0,20,buffer); //----End FPS---- //Flip primary and secondary surfaces Flip(); return(1); }
u32 randomRanged(Range r, Range p, double biasForPrefRange) { double rval; Range *s; if (Flip(biasForPrefRange)) { s = &r; } else { s = &p; } rval = (rand() / (RAND_MAX + 1.0)) * (s->max - s->min) + s->min; return (u32)rval; }
void Print(const T &lattice , U nx) { auto counter = 0; auto flipped_lattice = Flip(lattice, nx); for (auto node : flipped_lattice) { std::cout << std::fixed << std::setprecision(2) << node << " "; if (++counter % nx == 0) { std::cout << std::endl; counter = 0; } } // lat std::cout << std::endl; }
void Sprite::Load(const std::string& filename, GameEngine::GameContext& context, const glm::vec4& destRect, const glm::vec4& uvRect, float depth, float angle, const GameEngine::Rendering::ColourRGBA8& colour, bool flip) { m_texture = context.GetResourceManager().GetTexture(filename); m_destRect = destRect; m_uvRect = uvRect; m_depth = depth; m_angle = angle; m_colour = ColourRGBA8(colour); if (flip) { Flip(); } }
int CFfConvert::ConvertFB( AVFrame* src, sqbind::CSqBinary *dst ) {_STT(); if ( !m_psc ) return 0; _STT_SET_CHECKPOINT( 10 ); // Ensure source buffer is large enough if ( !src ) return 0; // Allocate memory for destination image if ( dst->Size() < ( m_dst_size + FF_INPUT_BUFFER_PADDING_SIZE * 2 ) && !dst->Allocate( m_dst_size + FF_INPUT_BUFFER_PADDING_SIZE * 2 ) ) return 0; _STT_SET_CHECKPOINT( 11 ); // Fill in picture data AVPicture apSrc, apDst; // Copy source information oexZero( apSrc ); for ( int i = 0; i < (int)oexSizeOfArray( apSrc.linesize ); i++ ) apSrc.data[ i ] = src->data[ i ], apSrc.linesize[ i ] = src->linesize[ i ]; if ( !CFfFmt::FillAVPicture( &apDst, m_dst_fmt, m_dst_width, m_dst_height, dst->_Ptr() ) ) return 0; _STT_SET_CHECKPOINT( 12 ); if ( m_flip ) Flip( m_src_fmt, m_src_height, &apSrc ); _STT_SET_CHECKPOINT( 13 ); int nRet = sws_scale( m_psc, apSrc.data, apSrc.linesize, 0, m_src_height, apDst.data, apDst.linesize ); _STT_SET_CHECKPOINT( 14 ); if ( 0 >= nRet ) return 0; dst->setUsed( m_dst_size ); return 1; }
void TEXTEDITBOX::UpdateBox(){ //updates the display of the box. //first re-copy the box and then draw the letters again, then flip it. LRESULT Result; Result=Blit(Pass.DDBack, EditBoxSurface, 0, 0,TEXTENTRYBOX_WIDTH, TEXTENTRYBOX_HEIGHT,TEXTENTRYBOX_LEFT,TEXTENTRYBOX_TOP); char str[100]; lstrcpy(str, this->String); //now figure out what we need to put on the screen if(this->StringLength >15){ //it's too big to fit the whole thing, so truncate it lstrcpy(str, &(this->String[this->StringLength-15])); } DrawString(str, TEB_TEXT_LEFT, TEB_TEXT_TOP, 12); Flip(Pass.DDFront); }
// This function is called when there are no free objects in the colorset. // If the gc is turned off, it calls flip to reclaim any garbage objects // that have been found by the garbage collector. void gmGarbageCollector::ReclaimObjectsAndRestartCollection() { #if GM_GC_TURN_OFF_ABLE // The garbage collector only gets turned off if we are allocating // black. GC is turned off after finishing tracing and before // doing a gc flip. So if there are no free objects left, first // flip the GC and turn white objects into free. Hopefully, this // will provide more free objects for allocation. if(m_gcTurnedOff) { Flip(); } #endif //GM_GC_TURN_OFF_ABLE }
void Ultra1::App::FadeTo( int ms, int r, int g, int b ) { // Make a deep copy of the screen Sim::Image bg = screen; unsigned int time_end = SDL_GetTicks( ) + ms; while( time_end > SDL_GetTicks( ) ) //Fade out { float per_done = 1.0f - ( ( (float)SDL_GetTicks() - time_end ) /(float)ms ); //Calculate alpha SDL_SetAlpha( bg.image, SDL_SRCALPHA | SDL_RLEACCEL, (Uint8)(per_done*255.0f) ); // Blit it... Clear( r, g, b ); SDL_BlitSurface( bg.image, NULL, screen, NULL ); Flip( ); } // Clear to the color... Clear( r, g, b ); Flip( ); }
int main() { Setup(); SetupBoard(); while (!(key[KEY_ESC]) && RedLeft > 0 && BlackLeft > 0) { DrawBackGround(); Clicks(); CheckPlay(); Flip(); } destroy_bitmap(buffer2); destroy_bitmap(buffer); unload_datafile(data); }