void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); float i = 0; for (std::vector<GainInfo *>::iterator gi = gainInfo.begin(); gi != gainInfo.end(); gi++) { GainInfo *gInfo = (*gi); float midPos = -1.0+startPos+spacing*i; gInfo->labelPanel.setSize(spacing/2.0,(15.0/float(ClientSize.y))); gInfo->labelPanel.setPosition(midPos, -barHeight-(20.0/float(ClientSize.y))); gInfo->valuePanel.setSize(spacing/2.0,(15.0/float(ClientSize.y))); gInfo->valuePanel.setPosition(midPos, barHeight+(20.0/float(ClientSize.y))); i+=1.0; } bgPanel.draw(); SwapBuffers(); }
void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->DrawBegin(); int yval = getHoveredSelection(); for (int i = 0; i < numChoices; i++) { if (yval == i && !highlightOverride) { RGBA4f hc = ThemeMgr::mgr.currentTheme->buttonHighlight; glContext->DrawSelector(selections[i].label, i, numChoices, true, hc.r, hc.g, hc.b, 1.0, padX, padY); } else { RGBA4f hc = ThemeMgr::mgr.currentTheme->button; if (highlightOverride) { hc = highlightColor; } glContext->DrawSelector(selections[i].label, i, numChoices, i == currentSelection, hc.r, hc.g, hc.b, 1.0, padX, padY); } } glContext->DrawEnd(); SwapBuffers(); }
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); #ifdef __APPLE__ // force half-rate? glFinish(); #endif const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->BeginDraw(ThemeMgr::mgr.currentTheme->fftBackground.r, ThemeMgr::mgr.currentTheme->fftBackground.g, ThemeMgr::mgr.currentTheme->fftBackground.b); glContext->Draw(spectrum_points, getCenterFrequency(), getBandwidth()); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); for (int i = 0, iMax = demods.size(); i < iMax; i++) { glContext->DrawDemodInfo(demods[i], ThemeMgr::mgr.currentTheme->fftHighlight, getCenterFrequency(), getBandwidth()); } glContext->EndDraw(); SwapBuffers(); }
void init2() { #ifdef OXYGINE_SDL initGLExtensions(SDL_GL_GetProcAddress); #endif Point size = getDisplaySize(); log::messageln("display size: %d %d", size.x, size.y); #if __S3E__ int glversion = s3eGLGetInt(S3E_GL_VERSION); int major_gl = glversion >> 8; if (major_gl == 2) IVideoDriver::instance = new VideoDriverGLES20(); else { OX_ASSERT(!"gl version should be 2"); //IVideoDriver::instance = new VideoDriverGLES11(); } #elif __FLASHPLAYER__ { VideoDriverStage3D *vd = new VideoDriverStage3D(); vd->init(); IVideoDriver::instance = vd; } //IVideoDriver::instance = new VideoDriverNull(); #else IVideoDriver::instance = new VideoDriverGLES20(); #endif checkGLError(); IVideoDriver::instance->setDefaultSettings(); checkGLError(); Renderer::initialize(); Resources::registerResourceType(ResAtlas::create, "atlas"); Resources::registerResourceType(ResBuffer::create, "buffer"); Resources::registerResourceType(ResFontBM::create, "font"); Resources::registerResourceType(ResFontBM::createBM, "bmfc_font"); Resources::registerResourceType(ResFontBM::createSD, "sdfont"); Resources::registerResourceType(ResStarlingAtlas::create, "starling"); checkGLError(); log::messageln("oxygine initialized"); }
void GainCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); bgPanel.draw(); SwapBuffers(); }
void init2() { #ifdef OXYGINE_QT setlocale(LC_ALL, "POSIX"); #endif #ifdef OXYGINE_SDL int missing = initGLExtensions(SDL_GL_GetProcAddress); #endif Point size = getDisplaySize(); log::messageln("display size: %d %d", size.x, size.y); #if __S3E__ int glversion = s3eGLGetInt(S3E_GL_VERSION); int major_gl = glversion >> 8; OX_ASSERT( major_gl == 2 && "gl version should be 2"); IVideoDriver::instance = new VideoDriverGLES20(); #endif IVideoDriver::instance = new VideoDriverGLES20(); CHECKGL(); IVideoDriver::instance->setDefaultSettings(); CHECKGL(); Renderer::initialize(); Resources::registerResourceType(ResAtlas::create, "atlas"); Resources::registerResourceType(ResBuffer::create, "buffer"); Resources::registerResourceType(ResFontBM::create, "font"); Resources::registerResourceType(ResFontBM::createBM, "bmfc_font"); Resources::registerResourceType(ResFontBM::createSD, "sdfont"); Resources::registerResourceType(ResStarlingAtlas::create, "starling"); CHECKGL(); log::messageln("oxygine initialized"); }
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->DrawBegin(); glContext->Draw(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g, ThemeMgr::mgr.currentTheme->generalBackground.b, 0.5, 1.0); if (mouseTracker.mouseInView()) { glContext->Draw(0.4, 0.4, 0.4, 0.5, mouseTracker.getMouseY()); } glContext->Draw(ThemeMgr::mgr.currentTheme->meterLevel.r, ThemeMgr::mgr.currentTheme->meterLevel.g, ThemeMgr::mgr.currentTheme->meterLevel.b, 0.5, (level-level_min) / (level_max-level_min)); if (showUserInput) { glContext->Draw(ThemeMgr::mgr.currentTheme->meterValue.r, ThemeMgr::mgr.currentTheme->meterValue.g, ThemeMgr::mgr.currentTheme->meterValue.b, 0.5, (userInputValue-level_min) / (level_max-level_min)); } glContext->DrawEnd(); SwapBuffers(); }
RendererGL::RendererGL() : m_maxBufferID(0)//, m_rotateX(0), m_rotateY(0), m_rotateZ(0) { initGLExtensions(); }
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { tex_update.lock(); wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); long double currentZoom = zoom; if (mouseZoom != 1) { currentZoom = mouseZoom; mouseZoom = mouseZoom + (1.0 - mouseZoom) * 0.2; if (fabs(mouseZoom-1.0)<0.01) { mouseZoom = 1; } } if (scaleMove != 0) { SpectrumVisualProcessor *sp = wxGetApp().getSpectrumProcessor(); FFTVisualDataThread *wdt = wxGetApp().getAppFrame()->getWaterfallDataThread(); SpectrumVisualProcessor *wp = wdt->getProcessor(); float factor = sp->getScaleFactor(); factor += scaleMove * 0.02; if (factor < 0.25) { factor = 0.25; } if (factor > 10.0) { factor = 10.0; } sp->setScaleFactor(factor); wp->setScaleFactor(factor); } if (freqMove != 0.0) { long long newFreq = getCenterFrequency() + (long long)((long double)getBandwidth()*freqMove) * 0.01; long long minFreq = bandwidth/2; if (newFreq < minFreq) { newFreq = minFreq; } updateCenterFrequency(newFreq); if (!freqMoving) { freqMove -= (freqMove * 0.2); if (fabs(freqMove) < 0.01) { freqMove = 0.0; } } } long long bw; if (currentZoom != 1) { long long freq = wxGetApp().getFrequency(); bw = getBandwidth(); double mpos = 0; float mouseInView = false; if (mouseTracker.mouseInView()) { mpos = mouseTracker.getMouseX(); mouseInView = true; } else if (spectrumCanvas && spectrumCanvas->getMouseTracker()->mouseInView()) { mpos = spectrumCanvas->getMouseTracker()->getMouseX(); mouseInView = true; } if (currentZoom < 1) { bw = (long long) ceil((long double) bw * currentZoom); if (bw < minBandwidth) { bw = minBandwidth; } if (mouseInView) { long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth()); long long mfreqB = getFrequencyAt(mpos, centerFreq, bw); centerFreq += mfreqA - mfreqB; } setView(centerFreq, bw); } else { if (isView) { bw = (long long) ceil((long double) bw * currentZoom); if (bw >= wxGetApp().getSampleRate()) { disableView(); if (spectrumCanvas) { spectrumCanvas->disableView(); } bw = wxGetApp().getSampleRate(); centerFreq = wxGetApp().getFrequency(); } else { if (mouseInView) { long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth()); long long mfreqB = getFrequencyAt(mpos, centerFreq, bw); centerFreq += mfreqA - mfreqB; setBandwidth(bw); } else { setBandwidth(bw); } } } } if (centerFreq < freq && (centerFreq - bandwidth / 2) < (freq - wxGetApp().getSampleRate() / 2)) { centerFreq = (freq - wxGetApp().getSampleRate() / 2) + bandwidth / 2; } if (centerFreq > freq && (centerFreq + bandwidth / 2) > (freq + wxGetApp().getSampleRate() / 2)) { centerFreq = (freq + wxGetApp().getSampleRate() / 2) - bandwidth / 2; } if (spectrumCanvas) { if ((spectrumCanvas->getCenterFrequency() != centerFreq) || (spectrumCanvas->getBandwidth() != bw)) { if (getViewState()) { spectrumCanvas->setView(centerFreq,bw); } else { spectrumCanvas->disableView(); spectrumCanvas->setCenterFrequency(centerFreq); spectrumCanvas->setBandwidth(bw); } } } } glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); if (fft_size_changed.load()) { fft_size = new_fft_size; waterfallPanel.setup(fft_size, waterfall_lines); fft_size_changed.store(false); } glContext->BeginDraw(0,0,0); waterfallPanel.calcTransform(CubicVR::mat4::identity()); waterfallPanel.draw(); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); bool isNew = shiftDown || (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive()); int currentBandwidth = getBandwidth(); long long currentCenterFreq = getCenterFrequency(); ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme; std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) { hoverAlpha += (1.0f-hoverAlpha)*0.1f; if (hoverAlpha > 1.5f) { hoverAlpha = 1.5f; } glContext->setHoverAlpha(hoverAlpha); if (nextDragState == WF_DRAG_RANGE) { float width = (1.0 / (float) ClientSize.x); float rangeWidth = mouseTracker.getOriginDeltaMouseX(); float centerPos; if (mouseTracker.mouseDown()) { if (rangeWidth) { width = rangeWidth; } centerPos = mouseTracker.getOriginMouseX() + width / 2.0; } else { centerPos = mouseTracker.getMouseX(); } glContext->DrawDemod(lastActiveDemodulator, isNew?currentTheme->waterfallHighlight:currentTheme->waterfallDestroy, currentCenterFreq, currentBandwidth); if ((last_type == "LSB" || last_type == "USB") && mouseTracker.mouseDown()) { centerPos = mouseTracker.getMouseX(); glContext->DrawRangeSelector(centerPos, centerPos-width, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover); } else { glContext->DrawFreqSelector(centerPos, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover, width, currentCenterFreq, currentBandwidth); } } else { if (lastActiveDemodulator) { glContext->DrawDemod(lastActiveDemodulator, ((isNew && activeDemodulator == NULL) || (activeDemodulator != NULL))?currentTheme->waterfallHighlight:currentTheme->waterfallDestroy, currentCenterFreq, currentBandwidth); } if (activeDemodulator == NULL) { glContext->DrawFreqSelector(mouseTracker.getMouseX(), ((isNew && lastActiveDemodulator) || (!lastActiveDemodulator) )?currentTheme->waterfallNew:currentTheme->waterfallHover, 0, currentCenterFreq, currentBandwidth); } else { glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHover, currentCenterFreq, currentBandwidth); } } } else { hoverAlpha += (0.0f-hoverAlpha)*0.05f; if (hoverAlpha < 1.0e-5f) { hoverAlpha = 0; } glContext->setHoverAlpha(hoverAlpha); if (activeDemodulator) { glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); } if (lastActiveDemodulator) { glContext->DrawDemod(lastActiveDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); } } glContext->setHoverAlpha(0); for (int i = 0, iMax = demods.size(); i < iMax; i++) { if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) { continue; } glContext->DrawDemod(demods[i], currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); } glContext->EndDraw(); SwapBuffers(); tex_update.unlock(); }
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); ScopeRenderData *avData; while (inputData.try_pop(avData)) { if (!avData->spectrum) { scopePanel.setMode(avData->mode); if (avData->waveform_points.size()) { scopePanel.setPoints(avData->waveform_points); } avData->decRefCount(); } else { if (avData->waveform_points.size()) { spectrumPanel.setPoints(avData->waveform_points); spectrumPanel.setFloorValue(avData->fft_floor); spectrumPanel.setCeilValue(avData->fft_ceil); spectrumPanel.setBandwidth((avData->sampleRate/2)*1000); spectrumPanel.setFreq((avData->sampleRate/4)*1000); spectrumPanel.setFFTSize(avData->fft_size); spectrumPanel.setShowDb(showDb); } avData->decRefCount(); } } glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); if (scopePanel.getMode() == ScopePanel::SCOPE_MODE_XY && !spectrumVisible()) { glDrawBuffer(GL_FRONT); glContext->DrawBegin(false); } else { glDrawBuffer(GL_BACK); glContext->DrawBegin(); bgPanel.setFillColor(ThemeMgr::mgr.currentTheme->scopeBackground * 3.0, RGBA4f(0,0,0,1)); bgPanel.calcTransform(CubicVR::mat4::identity()); bgPanel.draw(); } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glLoadMatrixf(CubicVR::mat4::perspective(45.0, 1.0, 1.0, 1000.0)); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); CubicVR::mat4 modelView = CubicVR::mat4::lookat(0, 0, -1.205f, 0, 0, 0, 0, -1, 0); float panelWidth = 1.0; float panelInterval = (panelWidth * 2.0 + panelSpacing); if (!mouseTracker.mouseDown()) { ctrTarget = round(ctr / panelInterval); if (ctrTarget < -1.0) { ctrTarget = -1.0; } else if (ctrTarget > 0.0) { ctrTarget = 0.0; } ctrTarget *= panelInterval; if (!dragAccel) { if (ctr != ctrTarget) { ctr += (ctrTarget-ctr)*0.2; } if (abs(ctr - ctrTarget) < 0.001) { ctr=ctrTarget; } } else { dragAccel -= dragAccel * 0.1; if ((abs(dragAccel) < 0.2) || (ctr < (ctrTarget-panelInterval/2.0)) || (ctr > (ctrTarget+panelInterval/2.0)) ) { dragAccel = 0; } else { ctr += dragAccel; } } } float roty = 0; scopePanel.setPosition(ctr, 0); if (scopeVisible()) { scopePanel.contentsVisible = true; roty = atan2(scopePanel.pos[0],1.2); scopePanel.rot[1] = -(roty * (180.0 / M_PI)); } else { scopePanel.contentsVisible = false; } spectrumPanel.setPosition(panelInterval+ctr, 0); if (spectrumVisible()) { spectrumPanel.setFillColor(ThemeMgr::mgr.currentTheme->scopeBackground * 2.0, RGBA4f(0,0,0,1)); spectrumPanel.contentsVisible = true; roty = atan2(spectrumPanel.pos[0],1.2); spectrumPanel.rot[1] = -(roty * (180.0 / M_PI)); } else { spectrumPanel.contentsVisible = false; } parentPanel.calcTransform(modelView); parentPanel.draw(); if (spectrumVisible()) { spectrumPanel.drawChildren(); } glLoadMatrixf(scopePanel.transform); if (!deviceName.empty()) { glContext->DrawDeviceName(deviceName); } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glContext->DrawTunerTitles(ppmMode); glContext->DrawEnd(); if (scopePanel.getMode() != ScopePanel::SCOPE_MODE_XY || spectrumVisible()) { SwapBuffers(); } }
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); if (!visualDataQueue.empty()) { SpectrumVisualData *vData; visualDataQueue.pop(vData); if (vData) { spectrumPanel.setPoints(vData->spectrum_points); spectrumPanel.setPeakPoints(vData->spectrum_hold_points); spectrumPanel.setFloorValue(vData->fft_floor); spectrumPanel.setCeilValue(vData->fft_ceiling); vData->decRefCount(); } } if (resetScaleFactor) { scaleFactor += (1.0-scaleFactor)*0.05; if (fabs(scaleFactor-1.0) < 0.01) { scaleFactor = 1.0; resetScaleFactor = false; } updateScaleFactor(scaleFactor); } glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->BeginDraw(0,0,0); spectrumPanel.setFreq(getCenterFrequency()); spectrumPanel.setBandwidth(getBandwidth()); spectrumPanel.calcTransform(CubicVR::mat4::identity()); spectrumPanel.draw(); glLoadIdentity(); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); for (int i = 0, iMax = demods.size(); i < iMax; i++) { if (!demods[i]->isActive()) { continue; } glContext->DrawDemodInfo(demods[i], ThemeMgr::mgr.currentTheme->fftHighlight, getCenterFrequency(), getBandwidth(), activeDemodulator==demods[i]); } if (waterfallCanvas && !activeDemodulator) { MouseTracker *wfmt = waterfallCanvas->getMouseTracker(); if (wfmt->mouseInView()) { int snap = wxGetApp().getFrequencySnap(); long long freq = getFrequencyAt(wfmt->getMouseX()); if (snap > 1) { freq = roundf((float)freq/(float)snap)*snap; } DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); bool isNew = (((waterfallCanvas->isShiftDown() || (lastActiveDemodulator && !lastActiveDemodulator->isActive())) && lastActiveDemodulator) || (!lastActiveDemodulator)); glContext->DrawFreqBwInfo(freq, wxGetApp().getDemodMgr().getLastBandwidth(), isNew?ThemeMgr::mgr.currentTheme->waterfallNew:ThemeMgr::mgr.currentTheme->waterfallHover, getCenterFrequency(), getBandwidth(), true, true); } } glContext->EndDraw(); spectrumPanel.drawChildren(); SwapBuffers(); }