void Graphics::RefreshSceneRect() { // GFade is drawn after the scene buffer, so this is in window space UpdateScreenSize(windowWidth(), windowHeight()); /* Calculates the rectangle within the back buffer that the scene will be drawn in. This accounts for "fit to width/height" scenarios where the back buffer has a different aspect ratio. */ float w = static_cast<float>(windowWidth()); float h = static_cast<float>(windowHeight()); float wFactor = (float)w / config.renderWidth; float hFactor = (float)h / config.renderHeight; mSceneScale = std::min(wFactor, hFactor); int screenW = (int)round(mSceneScale * config.renderWidth); int screenH = (int)round(mSceneScale * config.renderHeight); // Center on screen RECT rect; rect.left = (mWindowWidth - screenW) / 2; rect.top = (mWindowHeight - screenH) / 2; rect.right = rect.left + screenW; rect.bottom = rect.top + screenH; mSceneRect = rect; }
// creation du contexte openGL et d'une fenetre TP( ):gk::App() { // specifie le type de contexte openGL a creer : gk::AppSettings settings; settings.setGLVersion(3,3); // version 3.3 settings.setGLCoreProfile(); // core profile settings.setGLDebugContext(); // version debug pour obtenir les messages d'erreur en cas de probleme width=512; height=512; // cree le contexte et une fenetre if(createWindow(width,height, settings) < 0) closeWindow(); m_widgets.init(); m_widgets.reshape(windowWidth(), windowHeight()); }
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: attachSexyAPI(); break; case 1: { QStringList _r = exec((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; case 2: { QStringList _r = exec((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; case 3: alert((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 4: quit(); break; case 5: windowMinimize(); break; case 6: windowMaximize(); break; case 7: windowResize((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 8: { int _r = windowWidth(); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 9: { int _r = windowHeight(); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 10: { QStringList _r = getOpenFileName((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; case 11: { QStringList _r = getOpenFileName((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; case 12: { QStringList _r = getOpenFileName(); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; case 13: { QString _r = getSaveFileName((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 14: { QString _r = getSaveFileName((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 15: { QString _r = getSaveFileName(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 16: { QString _r = getDirectory((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 17: { QString _r = getDirectory(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 18: { QStringList _r = getArgs(); if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; } break; default: ; } _id -= 19; } return _id; }
int draw( ) { keys(); // glViewport(0, 0, windowWidth(), windowHeight()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // mesurer le temps d'execution m_time->start(); // dessiner quelquechose /*glUseProgram(m_program->name); // parametrer le shader m_program->uniform("mvpMatrix")= T.matrix(); // transformation model view projection m_program->uniform("diffuse_color")= gk::VecColor(1, 1, 0); // couleur des fragments // selectionner un ensemble de buffers et d'attributs de sommets glBindVertexArray(m_vao->name); // dessiner un maillage indexe glDrawElements(GL_TRIANGLES, m_indices_size, GL_UNSIGNED_INT, 0);*/ // nettoyage glUseProgram(0); glBindVertexArray(0); // mesurer le temps d'execution m_time->stop(); // afficher le temps d'execution { m_widgets.begin(); m_widgets.beginGroup(nv::GroupFlags_GrowDownFromLeft); m_widgets.doLabel(nv::Rect(), m_time->summary("draw").c_str()); m_widgets.endGroup(); m_widgets.end(); } // afficher le dessin present(); // continuer return 1; }
// MainWnd HWND CustomWindow::Criar(HINSTANCE hInst, LPCTSTR wndName) { this->_hWnd = CreateWindowEx(0L, _WndClsEx.lpszClassName, wndName, WS_OVERLAPPEDWINDOW, windowX(), windowY(), windowWidth(), windowHeight(), (HWND)HWND_DESKTOP, NULL, hInst, this); // Se a janela não foi criada if (this->_hWnd != NULL) { SetWindowLongPtr(this->_hWnd, GWLP_USERDATA, (long)this); this->hInst = hInst; return _hWnd; } return NULL; }
int Kore::System::desktopWidth() { return windowWidth(0); }
// --------------------------------------------------------------------------- // analyze // --------------------------------------------------------------------------- //! Analyze a range of (mono) samples at the given sample rate //! (in Hz) and store the extracted Partials in the Analyzer's //! PartialList (std::list of Partials). Use the specified envelope //! as a frequency reference for Partial tracking. //! //! \param bufBegin is a pointer to a buffer of floating point samples //! \param bufEnd is (one-past) the end of a buffer of floating point //! samples //! \param srate is the sample rate of the samples in the buffer //! \param reference is an Envelope having the approximate //! frequency contour expected of the resulting Partials. // void Analyzer::analyze( const double * bufBegin, const double * bufEnd, double srate, const Envelope & reference ) { // configure the reassigned spectral analyzer, // always use odd-length windows: // Kaiser window double winshape = KaiserWindow::computeShape( sidelobeLevel() ); long winlen = KaiserWindow::computeLength( windowWidth() / srate, winshape ); if (! (winlen % 2)) { ++winlen; } debugger << "Using Kaiser window of length " << winlen << endl; std::vector< double > window( winlen ); KaiserWindow::buildWindow( window, winshape ); std::vector< double > windowDeriv( winlen ); KaiserWindow::buildTimeDerivativeWindow( windowDeriv, winshape ); ReassignedSpectrum spectrum( window, windowDeriv ); // configure the peak selection and partial formation policies: SpectralPeakSelector selector( srate, m_cropTime ); PartialBuilder builder( m_freqDrift, reference ); // configure bw association policy, unless // bandwidth association is disabled: std::unique_ptr< AssociateBandwidth > bwAssociator; if( m_bwAssocParam > 0 ) { debugger << "Using bandwidth association regions of width " << bwRegionWidth() << " Hz" << endl; bwAssociator.reset( new AssociateBandwidth( bwRegionWidth(), srate ) ); } else { debugger << "Bandwidth association disabled" << endl; } // reset envelope builders: m_ampEnvBuilder->reset(); m_f0Builder->reset(); m_partials.clear(); try { const double * winMiddle = bufBegin; // loop over short-time analysis frames: while ( winMiddle < bufEnd ) { // compute the time of this analysis frame: const double currentFrameTime = long(winMiddle - bufBegin) / srate; // compute reassigned spectrum: // sampsBegin is the position of the first sample to be transformed, // sampsEnd is the position after the last sample to be transformed. // (these computations work for odd length windows only) const double * sampsBegin = std::max( winMiddle - (winlen / 2), bufBegin ); const double * sampsEnd = std::min( winMiddle + (winlen / 2) + 1, bufEnd ); spectrum.transform( sampsBegin, winMiddle, sampsEnd ); // extract peaks from the spectrum, and thin Peaks peaks = selector.selectPeaks( spectrum, m_freqFloor ); Peaks::iterator rejected = thinPeaks( peaks, currentFrameTime ); // fix the stored bandwidth values // KLUDGE: need to do this before the bandwidth // associator tries to do its job, because the mixed // derivative is temporarily stored in the Breakpoint // bandwidth!!! FIX!!!! fixBandwidth( peaks ); if ( m_bwAssocParam > 0 ) { bwAssociator->associateBandwidth( peaks.begin(), rejected, peaks.end() ); } // remove rejected Breakpoints (needed above to // compute bandwidth envelopes): peaks.erase( rejected, peaks.end() ); // estimate the amplitude in this frame: m_ampEnvBuilder->build( peaks, currentFrameTime ); // collect amplitudes and frequencies and try to // estimate the fundamental m_f0Builder->build( peaks, currentFrameTime ); // form Partials from the extracted Breakpoints: builder.buildPartials( peaks, currentFrameTime ); // slide the analysis window: winMiddle += long( m_hopTime * srate ); // hop in samples, truncated } // end of loop over short-time frames // unwarp the Partial frequency envelopes: builder.finishBuilding( m_partials ); // fix the frequencies and phases to be consistent. if ( m_phaseCorrect ) { fixFrequency( m_partials.begin(), m_partials.end() ); } // for debugging: /* if ( ! m_ampEnv.empty() ) { LinearEnvelope::iterator peakpos = std::max_element( m_ampEnv.begin(), m_ampEnv.end(), compare2nd<LinearEnvelope::iterator::value_type> ); notifier << "Analyzer found amp peak at time : " << peakpos->first << " value: " << peakpos->second << endl; } */ } catch ( Exception & ex ) { ex.append( "analysis failed." ); throw; } }
void Controller::setWindowHeight(int height) { engine.getRoomsManager()->setRoomSize(windowWidth(), height); emit windowHeightChanged(); }