void hack_draw (xstuff_t * XStuff, double currentTime, float frameTime) { static double lastSettingsChange = -1; if (lastSettingsChange == -1) lastSettingsChange = currentTime; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); getAll (); glTranslatef(0.0, 0.0, -3.0f); glLineWidth (blurWidth * sqrt((GLfloat) (XStuff->windowWidth * XStuff->windowHeight) / (500 * 400))); glColor4f (blurColor[0], blurColor[1], blurColor[2], 0.2); drawAll (); glLineWidth(1); glColor4f (lineColor[0], lineColor[1], lineColor[2], 0.4); drawAll (); if (currentTime - lastSettingsChange > timeInterval) { lastSettingsChange = currentTime; changeSettings (); } equationBase += speed * (frameTime / (1.0 / 30.0)); glFlush (); }
void MainWindow::Init() { this->show(); R = ui->graphicsView; R->setDrawingArea(xmin,xmax,ymin,ymax); R->Scene->setSceneRect(0,0,R->geometry().width()-3,R->geometry().height()-3); ui->graphicsView->setMouseTracking(true); connect(R,SIGNAL(repaint_all()),this,SLOT(drawAll())); //Scenario senario = new Scenario(); QString sf,sg; senario->load(sf,sg); ui->textf->setPlainText(sf); ui->textg->setPlainText(sg); Simu = new simulation(); sivia = NULL; on_push_run_clicked(); }
//Gestion redimensionnement void MainWindow::resizeEvent(QResizeEvent* event){ QMainWindow::resizeEvent(event); if(R!=NULL && this->isVisible()){ R->Scene->setSceneRect(0,0,R->geometry().width()-3,R->geometry().height()-3); drawAll(); } }
void PlayerPainter::draw( QPainter & painter ) { if ( ! Options::instance().showPlayer() || Options::instance().minimumMode() ) { return; } DispConstPtr disp = M_main_data.getDispInfo( M_main_data.index() ); if ( ! disp ) { return; } const rcss::rcg::BallT & ball = disp->show_.ball_; for ( int i = 0; i < rcss::rcg::MAX_PLAYER*2; ++i ) { drawAll( painter, disp->show_.player_[i], ball ); } if ( Options::instance().showOffsideLine() ) { drawOffsideLine( painter, disp->show_ ); } }
void B9Projector::setCPJ(CrushedPrintJob * pCPJ) { qDebug() << "calling b9projector setCPJ"; m_iLevel = -1; mpCPJ = pCPJ; drawAll(); }
//-------------------------------------------------------------- void ofxNumberAnimation::draw() { if (status == before) { return; } else if (status == after) { drawAll(); return; } ofPushStyle(); ofSetColor(_color); float animatingTimeMs = ofGetElapsedTimeMillis() - startTimeMs; if (animatingTimeMs > _animationTimeMs) { status = after; return; } else { switch (mode) { case fromLeft: drawFromLeft(animatingTimeMs); break; case fromRight: drawFromRight(animatingTimeMs); break; case atOnce: drawAtOnce(animatingTimeMs); break; default: break; } } ofPopStyle(); }
/* * BOUCLE D'AFFICHAGE */ bool SceneManager::execute(SDL_Window* window, unsigned int w, unsigned int h) { init3D(w,h); init2D(); initSounds(); unsigned int debut ,fin; /* VARIABLES DE GESTION DU TEMPS */ float period = 1.0 / FPS_LIMIT,fps,time; while(!m_input.terminer()) /* BOUCLE D'EXECUTION */ { debut = SDL_GetTicks(); /* ON RELEVE LE TEMPS DE DEBUT DE BOUCLE */ onPreRender(); /* ON MET À JOUR LES MODELES DYNAMIQUES */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* NETTOYAGE DE LA FENETRE */ m_input.update(); /* MISE A JOUR DES EVENEMENTS */ updateCameras(); /* MISE À JOUR DES CAMERAS */ if(m_input.getKey(SDL_SCANCODE_ESCAPE)) break; /* QUITTER EN APPUYANT SUR ESPACE */ if(m_input.getKeyRelease(SDL_SCANCODE_V)) changeCamera(); /* CHANGER DE CAMERA EN APPUYANT SUR ESPACE */ if(m_input.getKeyRelease(SDL_SCANCODE_SPACE)) m_soundMgr.playEffect("laser",127/2); drawAll(); /* AFFICHAGE DE TOUS LES MODELES DU MONDE 3D */ SDL_GL_SwapWindow(window); /* RAFRAICHISSEMENT DE LA FENETRE */ fin = SDL_GetTicks(); /* ON RELEVE LE TEMPS DE FIN DE BOUCLE */ time = (float)(fin - debut); /* ON CALCULE LE TEMPS D'EXECUTION DE LA BOUCLE */ fps = 1000.0/time; /* ON CALCULE LA FREQUENCE MAXIMALE */ std::ostringstream streamTitle; streamTitle << "fps: " << fps; SDL_SetWindowTitle(window,streamTitle.str().c_str()); /* ON AFFICHE LA FREQUENCE COMME TITRE DE LA FENETRE */ if(time < period) SDL_Delay((unsigned int)(period - time)); /* ON LIMITE LA FREQUENCE A 60 FPS */ } printf("toto\n"); return true; }
//专门用来某些情况下动画的显示和延时 //中间可以插入一个函数补充些什么,想不到更好的方法了 int Element::drawAndPresent(int times, std::function<void(void*)> func, void* data) { if (times < 1) { return 0; } if (times > 100) { times = 100; } for (int i = 0; i < times; i++) { dealEventSelfChilds(false); drawAll(); if (func) { func(data); } present(); if (exit_) { break; } } return times; }
drawRateOfGrowth(SimView *view) { short x, y; drawAll(view); for (x = 0; x < SmX; x++) { for (y = 0; y < SmY; y++) { short val, z = RateOGMem[x][y]; if (z > 100) val = VAL_VERYPLUS; else { if (z > 20) val = VAL_PLUS; else { if (z < -100) val = VAL_VERYMINUS; else { if (z < -20) val = VAL_MINUS; else val = VAL_NONE; } } } maybeDrawRect(view, val, x * 24, y * 24, 24, 24); } } }
void gqbView::SaveAsImage(const wxString &fileName, wxBitmapType imgType) { updateModelSize(NULL, true); if (modelSize.GetWidth() == 0 || modelSize.GetHeight() == 0) { wxMessageBox(_("Nothing to be saved!"), _("Save As an image"), wxOK | wxICON_INFORMATION); return; } int width = 0, height = 0; GetVirtualSize(&width, &height); /* * Create the bitmap from the Explain window */ wxMemoryDC memDC; wxBitmap tempBitmap(width, height); memDC.SelectObject(tempBitmap); memDC.Clear(); // Draw the diagram on the bitmap (Memory Device Context) drawAll(memDC, false); memDC.SelectObject(wxNullBitmap); if (!tempBitmap.SaveFile(fileName, imgType)) { wxLogError(_("Could not write the file %s: Errcode=%d."), fileName.c_str(), wxSysErrorCode()); } }
void PrimitiveSet::draw(RenderContext* renderContext) { drawBegin(renderContext); drawAll(renderContext); drawEnd(renderContext); }
void B9Projector::showProjector(int x, int y, int w, int h) { setWindowTitle("Preview"); setGeometry(x,y,w,h); if(m_bIsPrintWindow) showFullScreen(); else show(); mImage = QImage(width(),height(),QImage::Format_ARGB32_Premultiplied); createNormalizedMask(); drawAll(); }
void display(void){ tempo(&lastFrameTime, &elapsedTime); preformCheck(&onGame, &winlose, bloco, bola); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawAll(onGame, bloco, &xbarra, k, &elapsedTime, &bola, preStart, winlose); glutSwapBuffers(); }
void StructView::paintEvent( QPaintEvent * /*pe*/ ) { if( ! sch ) { return; } devTp = 0; QPainter p( this ); drawAll( p ); p.end(); }
void B9Projector::resizeEvent ( QResizeEvent * pEvent ) { pEvent->accept(); QImage newImage(width(),height(),QImage::Format_ARGB32_Premultiplied); QPainter painter(&newImage); painter.drawImage(QPoint(0,0), mImage); mImage = newImage; createNormalizedMask(); drawAll(); QDesktopWidget dt; emit newGeometry (dt.screenNumber(), geometry()); }
drawFireRadius(SimView *view) { short x, y; drawAll(view); for (x = 0; x < SmY; x++) { for (y = 0; y < SmY; y++) { maybeDrawRect(view, GetCI(FireRate[x][y]), x * 24, y * 24, 24, 24); } } }
drawPoliceRadius(SimView *view) { short x, y; drawAll(view); for (x = 0; x < SmX; x++) { for (y = 0; y < SmY; y++) { maybeDrawRect(view, GetCI(PoliceMapEffect[x][y]), x * 24, y * 24, 24, 24); } } }
drawPopDensity(SimView *view) { short x, y; drawAll(view); for (x = 0; x < HWLDX; x++) { for (y = 0; y < HWLDY; y++) { maybeDrawRect(view, GetCI(PopDensity[x][y]), x * 6, y * 6, 6, 6); } } }
drawLandMap(SimView *view) { short x, y; drawAll(view); for (x = 0; x < HWLDX; x++) { for (y = 0; y < HWLDY; y++) { maybeDrawRect(view, GetCI(LandValueMem[x][y]), x * 6, y * 6, 6, 6); } } }
drawPolMap(SimView *view) { short x, y; drawAll(view); for (x = 0; x < HWLDX; x++) { for (y = 0; y < HWLDY; y++) { maybeDrawRect(view, GetCI(10 + PollutionMem[x][y]), x * 6, y * 6, 6, 6); } } }
void Frame::run() { while(isOpen()) { calculate_bounds(); calculate_mouse_pos(); while(pollEvent(_event)) { eventHandling(); } drawAll(); } }
void Puzzle_Window::draw() { if (!valid()) { ::init(); // should only be called when context created, but // fltk does not give an indication of that... W = w(); H = h(); glViewport(0, 0, W, H); glGetIntegerv(GL_VIEWPORT, viewport); } glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, viewport[2]*1.0/viewport[3], 0.1, 100.0); drawAll(); }
void InternalWindow::draw() { if(_firstDraw) { _firstDraw = false; //Make sure that all components added to this window are placed relative to //our position so that (0,0) is topleft corner in this InternalWindow for(const std::shared_ptr<GUIComponent> &component : ComponentContainer::iterator()) { component->setPosition(component->getX()+getX(), component->getY()+getY()); } } drawAll(); }
void redraw(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, 1.0, 0.1, 100.0); drawAll(); if (doubleBuffer) glutSwapBuffers(); else glFinish(); }
void MainWindow::on_push_run_clicked() { ui->push_run->setEnabled(true); //Run MonteCarlo Simulation ui->timeBar->setMaximum(ui->t_max->text().toDouble()/Simu->dt); Simu->simuMonteCarlo(ui->t_max->text().toDouble()/Simu->dt+1); //Rune SIVIA //Loading parameters QScriptEngine e; double _box[4][2]; _box[0][0] = (ui->x_min->text()).toDouble(); _box[0][1] = (ui->x_max->text()).toDouble(); _box[1][0] = (ui->y_min->text()).toDouble(); _box[1][1] = (ui->y_max->text()).toDouble(); _box[2][0] = str2double(ui->th_min->text()); _box[2][1] = str2double(ui->th_max->text()); _box[3][0] = (ui->t_min->text()).toDouble(); _box[3][1] = (ui->t_max->text()).toDouble(); if(sivia!=NULL) delete sivia; IntervalVector box(4, _box); //cout << box; QTime t; QString info; t.start(); sivia = new Sivia(*R,ui->epsilonBox->value(), box); double tsiv = t.elapsed()/1000.0; info += "Elapsed time: " + QString::number(tsiv) + " s\n"; info += "\nInitial box:\n\tx:\t[" + QString::number(_box[0][0]) + "," + QString::number(_box[0][1]) + "]\n"; info += "\ty:\t[" + QString::number(_box[1][0]) + "," + QString::number(_box[1][1]) + "]\n"; info += "\ttheta:\t[" + QString::number(_box[2][0]) + "," + QString::number(_box[2][1]) + "]\n"; info += "\tt:\t[" + QString::number(_box[3][0]) + "," + QString::number(_box[3][1]) + "]\n"; info += "\tepsilon: " + QString::number(ui->epsilonBox->value()) + "\n"; info += "\nNumber of boxes: " + QString::number(sivia->Sout.size()+sivia->Sp.size()); info += "\nUnsafe boxes: " + QString::number(sivia->Sp.size()); QMessageBox::information(this,"Sivia report",info); drawAll(); }
//TODO: HACK (no multithreading yet) void DebugObjectLoadingState::singleThreadRedrawHack(const std::string &loadingText) { // clear the screen gfx_request_clear_screen(); gfx_do_clear_screen(); _toLoad.front()->_loadingText->setText(loadingText); drawAll(); // flip the graphics page gfx_request_flip_pages(); gfx_do_flip_pages(); SDL_PumpEvents(); }
void CNOutBarCtrl::animateFolder(int from, int to) { CClientDC dc(this); CDC memDC; memDC.CreateCompatibleDC(&dc); CRect rc; GetClientRect(rc); CBitmap bm; bm.CreateCompatibleBitmap(&dc, rc.Width(), rc.Height()); CBitmap *oldBitmap = memDC.SelectObject(&bm); getInsideRect(rc); selFolder = to; CRect toInsideRect; getInsideRect(toInsideRect); drawAll(&memDC); if (to > from) { int srcy = (from + 1) * FOLDER_HEIGHT; int y = rc.bottom; while (y > rc.top) { dc.BitBlt(0, y, rc.Width(), toInsideRect.bottom - y, &memDC, 0, srcy, SRCCOPY); y -= FOLDER_HEIGHT; Sleep(10); } } else { drawFolder(&dc, to); int folderHeight = (from - to) * FOLDER_HEIGHT; int h = 0; while (h < rc.Height()) { int height = h + folderHeight; dc.BitBlt(0, toInsideRect.top, rc.Width(), height, &memDC, 0, rc.bottom - height, SRCCOPY); h += FOLDER_HEIGHT; Sleep(10); } } Invalidate(); memDC.SelectObject(oldBitmap); }
void display(){ /* Clear the window */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // ------------------------- MATRICES STUFF ____________ // /* Draw the line */ /* Step 1: Enable the clients for the vertex arrays */ glEnableClientState(GL_VERTEX_ARRAY); /* Set the view matrix */ translation = glm::translate(glm::mat4(1.0f), glm::vec3(islandX, islandY, islandZ)); viewMatrix = glm::rotate(translation, angle, glm::vec3(1.0f, 0.0f, 0.0f)); viewMatrix = glm::rotate(viewMatrix, rotate, glm::vec3(0.0f, 0.0f, 1.0f)); /* Set the model matrix */ //modelMatrix = glm::scale(glm::mat4(1.0), glm::vec3(1.0)); /* Set the projection matrix */ // projMatrix = glm::perspective(glm::radians(45.0f), ( (float) IslandWidth / IslandHeight), 0.1f, 100.0f); projMatrix = glm::perspective(glm::radians(45.0f), ( (float) IslandWidth / IslandHeight), 0.1f, 100.0f); /* Send matrix to shader */ glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(modelMatrix)); glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, glm::value_ptr(viewMatrix)); glUniformMatrix4fv(projMatrixLocation, 1, GL_FALSE, glm::value_ptr(projMatrix)); // Use vertex to draw intensity glUseProgram(shaderProgram); drawAll(circlePointCt); /* Step 3: Disable the clients */ glDisableClientState(GL_VERTEX_ARRAY); // Spin rotate += rotateStep; /* Force execution of OpenGL commands */ glFlush(); /* Swap buffers for animation */ glutSwapBuffers(); }
void newGame() { GLCD.ClearScreen(); GLCD.Display(); delete board; board = new Board; delete current; current = Tetrad::createRandom(board); delete next; next = Tetrad::createRandom(board); score = 0; setLevel(0); drawAll(); }
void loop() { if (!current->moveDown()) { current->crystalise(); delete current; current = next; next = Tetrad::createRandom(board); if (!current->canMoveDown()) newGame(); } int cleared = board->clearLines(); if (cleared) { score += score_multipliers[cleared - 1] * (level + 1); lines += cleared; if (lines >= 10) setLevel(level + 1); } drawAll(); }