explicit QuickMenuButtonRenderer(const DialogLook &_look, const TCHAR *_caption) :look(_look), caption(_caption) { text_renderer.SetCenter(); text_renderer.SetVCenter(); text_renderer.SetControl(); }
static void RedrawTextRenderer(TextRenderer& txt_rndr, RectListRgn& r_lst, bool delayed) { delayed ? txt_rndr.DrawForRegionDelayed(r_lst) : txt_rndr.DrawForRegion(r_lst); }
void UpdateScore(const unsigned int updated, TextRenderer &textRenderer, std::vector<std::string> &strVec) { textRenderer.RemoveText(*(strVec.begin() + 1)); (*(strVec.begin() + 1)) = std::to_string(updated); textRenderer.AddTextVerticalAlign(strVec, TextRenderer::Alignment::Right, TextRenderer::Alignment::Top, 20); }
void RedrawText(TextRenderer& txt_rndr, bool delayed) { RectListRgn r_lst; r_lst.push_back(txt_rndr.CalcCursorPlc()); r_lst.push_back(txt_rndr.CalcTextPlc()); //txt_rndr.DrawForRegion(r_lst); RedrawTextRenderer(txt_rndr, r_lst, delayed); }
void PediaMainForm::copySelectionOrAllToClipboard() { TextRenderer* renderer = &infoRenderer_; if (showArticle == displayMode_) renderer = &articleRenderer_; if (renderer->empty()) return; String text; renderer->copySelectionOrAll(); }
bool UpdateLives(unsigned int &lives, TextRenderer &textRenderer, std::vector<std::string> &strVec) { textRenderer.RemoveText(*(strVec.begin() + 1)); (*(strVec.begin() + 1)) = std::to_string(lives); textRenderer.AddTextHorizontalAlign(strVec, TextRenderer::Alignment::Right, TextRenderer::Alignment::Bottom, 20); if(lives == 0) return true; return false; }
//--------------------------------------------------------------------------- void Choice::addItem(const std::string& item) { choiceList.push_back(item); TextRenderer *t = new TextRenderer(item.c_str()); choice_renders.push_back(t); int borderSpace = 12 * 2; // was border size rect.setSize(std::max( (t->getWidth() + borderSpace), rect.getWidth()), TextRenderingSystem::line_height() ); }
void TestComponent::FixedUpdate() { //m_transform.m_position += float2(time::GetDeltaTime(), time::GetDeltaTime()) * 100.0f; LARGE_INTEGER li = m_lastUpdate; QueryPerformanceCounter(&m_lastUpdate); float fups = 1.0f / ((float)(m_lastUpdate.QuadPart - li.QuadPart) / (float)(m_ticksPS.QuadPart)); TextRenderer* t = (TextRenderer*)m_gameObject.GetComponent(TEXT_RENDERER); //m_transform.position = float2(10.f, 10.0f); char str[64]; sprintf_s(str, "FUPS: %f ####", fups); t->SetString(str); }
void QuickMenuButtonRenderer::DrawButton(Canvas &canvas, const PixelRect &rc, bool enabled, bool focused, bool pressed) const { // Draw focus rectangle if (pressed) { canvas.DrawFilledRectangle(rc, look.list.pressed.background_color); canvas.SetTextColor(look.list.pressed.text_color); } else if (focused) { canvas.DrawFilledRectangle(rc, look.focused.background_color); canvas.SetTextColor(enabled ? look.focused.text_color : look.button.disabled.color); } else { if (HaveClipping()) canvas.DrawFilledRectangle(rc, look.background_brush); canvas.SetTextColor(enabled ? look.text_color : look.button.disabled.color); } canvas.Select(*look.button.font); canvas.SetBackgroundTransparent(); text_renderer.Draw(canvas, rc, caption); }
void PendingCursor::SetTimer(TextRenderer& txt_rndr) { Data& dat = (Data&)txt_rndr; BoolFnr fnr = bb::bind(&PendingCursor::OnTimeout, this, &txt_rndr); dat.timer.Connect( fnr, int(CURSOR_PEND_PART*txt_rndr.CursBlinkTime()) ); }
void PrioVR::renderCalibrationCountdown() { #ifdef HAVE_PRIOVR const int COUNTDOWN_SECONDS = 3; int secondsRemaining = COUNTDOWN_SECONDS - _calibrationCountdownStarted.secsTo(QDateTime::currentDateTime()); if (secondsRemaining == 0) { yei_tareSensors(_skeletalDevice); Application::getInstance()->disconnect(this); return; } static TextRenderer textRenderer(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2); QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "..."; textRenderer.draw((Application::getInstance()->getGLWidget()->width() - textRenderer.computeWidth(text.constData())) / 2, Application::getInstance()->getGLWidget()->height() / 2, text); #endif }
/* function to reset our viewport after a window resize */ int setViewport(int width, int height) { /* Height / width ration */ GLfloat ratio; /* Protect against a divide by zero */ if (height == 0) height = 1; ratio = (GLfloat)width / (GLfloat)height; /* Setup our viewport. */ GL(glViewport, (0, 0, (GLsizei)width, (GLsizei)height)); /* change to the projection matrix and set our viewing volume. */ GL(glMatrixMode, (GL_PROJECTION)); GL(glLoadIdentity, ()); /* Set our perspective */ //GL(gluPerspective, (45.0f, ratio, 0.1f, 100.0f)); GL(glOrtho, (0, (GLdouble)width, 0, (GLdouble)height, -1, 1)); /* Make sure we're chaning the model view and not the projection */ GL(glMatrixMode, (GL_MODELVIEW)); /* Reset The View */ GL(glLoadIdentity, ()); text_renderer.setViewportSize(width, height); return 1; }
void initGL() { /* Enable smooth shading */ GL(glShadeModel, (GL_SMOOTH)); /* Set the background black */ GL(glClearColor, (0.0f, 0.0f, 0.0f, 0.0f)); /* Depth buffer setup */ GL(glClearDepth, (1.0f)); /* Enables Depth Testing */ GL(glEnable, (GL_DEPTH_TEST)); /* The Type Of Depth Test To Do */ GL(glDepthFunc, (GL_LEQUAL)); /* Really Nice Perspective Calculations */ GL(glHint, (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)); glewInit(); // Initialize the Text Renderer text_renderer.init(); }
void Viewer_impl::clearDistancedisplay() { distance_is_displayed = false; Q_FOREACH(TextItem* ti, distance_text) { textRenderer->removeText(ti); delete ti; }
//-------------------------------------------------------------------------------------- // //-------------------------------------------------------------------------------------- void InitGUI() { // Initialize dialogs g_SettingsDlg.Init(&g_DialogResourceManager); g_HUD.Init(&g_DialogResourceManager); g_HUD.SetCallback(OnGUIEvent); g_TextRenderer.Init(&g_DialogResourceManager); int iY = 10; g_HUD.AddButton (IDC_TOGGLEFULLSCREEN, L"Toggle full screen" , 35, iY, 160, 22); g_HUD.AddButton (IDC_TOGGLEREF, L"Toggle REF (F3)" , 35, iY += 24, 160, 22, VK_F3); g_HUD.AddButton (IDC_CHANGEDEVICE, L"Change device (F2)" , 35, iY += 24, 160, 22, VK_F2); iY += 20; g_HUD.AddCheckBox(IDC_DEINTERLEAVE, L"Deinterleaved Texturing", 35, iY += 28, 125, 22, g_UseDeinterleavedTexturing); g_HUD.AddCheckBox(IDC_RANDOMIZE, L"Randomize Samples", 35, iY += 28, 125, 22, g_RandomizeSamples); g_HUD.AddCheckBox(IDC_BLUR_AO, L"Blur AO", 35, iY += 28, 125, 22, g_BlurAO); iY += 24; CDXUTComboBox *pComboBox; g_HUD.AddComboBox(IDC_CHANGESCENE, 35, iY += 24, 160, 22, 'M', false, &pComboBox); for (int i = 0; i < ARRAYSIZE(g_MeshDesc); i++) { pComboBox->AddItem(g_MeshDesc[i].Name, NULL); } iY += 24; WCHAR sz[100]; int dy = 20; StringCchPrintf(sz, 100, UI_RADIUS_MULT L"%0.2f", g_AOParams.Radius); g_HUD.AddStatic(IDC_RADIUS_STATIC, sz, 35, iY += dy, 125, 22); g_HUD.AddSlider(IDC_RADIUS_SLIDER, 50, iY += dy, 100, 22, 0, 100, int(g_AOParams.Radius / MAX_RADIUS_MULT * 100)); StringCchPrintf(sz, 100, UI_AO_BIAS L"%g", g_AOParams.Bias); g_HUD.AddStatic(IDC_BIAS_STATIC, sz, 35, iY += dy, 125, 22); g_HUD.AddSlider(IDC_BIAS_SLIDER, 50, iY += dy, 100, 22, 0, 500, int(g_AOParams.Bias * 1000)); StringCchPrintf(sz, 100, UI_POW_EXPONENT L"%0.2f", g_AOParams.PowerExponent); g_HUD.AddStatic(IDC_EXPONENT_STATIC, sz, 35, iY += dy, 125, 22); g_HUD.AddSlider(IDC_EXPONENT_SLIDER, 50, iY += dy, 100, 22, 0, 400, (int)(100.0f*g_AOParams.PowerExponent)); StringCchPrintf(sz, 100, UI_BLUR_SHARPNESS L"%0.2f", g_AOParams.Blur.Sharpness); g_HUD.AddStatic(IDC_BLUR_SHARPNESS_STATIC, sz, 35, iY += dy, 125, 22); g_HUD.AddSlider(IDC_BLUR_SHARPNESS_SLIDER, 50, iY += dy, 100, 22, 0, 1600, (int)(100.0f*g_AOParams.Blur.Sharpness)); UINT ButtonGroup = 0; iY += 24; g_HUD.AddRadioButton( IDC_1xMSAA, ButtonGroup, L"1X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_1X) ); g_HUD.AddRadioButton( IDC_2xMSAA, ButtonGroup, L"2X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_2X) ); g_HUD.AddRadioButton( IDC_4xMSAA, ButtonGroup, L"4X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_4X) ); g_HUD.AddRadioButton( IDC_8xMSAA, ButtonGroup, L"8X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_8X) ); ++ButtonGroup; iY += 24; g_HUD.AddRadioButton( IDC_PER_PIXEL_AO, ButtonGroup, L"PER_PIXEL_AO", 35, iY += 24, 125, 22, (g_AOParams.Output.MSAAMode == GFSDK_SSAO_PER_PIXEL_AO) ); g_HUD.AddRadioButton( IDC_PER_SAMPLE_AO, ButtonGroup, L"PER_SAMPLE_AO", 35, iY += 24, 125, 22, (g_AOParams.Output.MSAAMode == GFSDK_SSAO_PER_SAMPLE_AO) ); }
void BlinkCursor::SetTimer(TextRenderer& txt_rndr) { Data& dat = (Data&)txt_rndr; // sigc::slot<bool> to_slot = sigc::bind(sigc::mem_fun(*this, &BlinkCursor::OnTimeout), &txt_rndr); // dat.timer = // Glib::signal_timeout().connect(to_slot, GetBlinkTime(dat.toShow, txt_rndr.CursBlinkTime()) ); BoolFnr fnr = bb::bind(&BlinkCursor::OnTimeout, this, &txt_rndr); dat.timer.Connect( fnr, GetBlinkTime(dat.toShow, txt_rndr.CursBlinkTime()) ); }
void TextOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } const float MAX_COLOR = 255.0f; xColor backgroundColor = getBackgroundColor(); glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, getBackgroundAlpha()); int left = _bounds.left(); int right = _bounds.right() + 1; int top = _bounds.top(); int bottom = _bounds.bottom() + 1; glm::vec2 topLeft(left, top); glm::vec2 bottomRight(right, bottom); DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight); // Same font properties as textSize() TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT); const int leftAdjust = -1; // required to make text render relative to left edge of bounds const int topAdjust = -2; // required to make text render relative to top edge of bounds int x = _bounds.left() + _leftMargin + leftAdjust; int y = _bounds.top() + _topMargin + topAdjust; glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR); float alpha = getAlpha(); QStringList lines = _text.split("\n"); int lineOffset = 0; foreach(QString thisLine, lines) { if (lineOffset == 0) { lineOffset = textRenderer->calculateHeight(qPrintable(thisLine)); } lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), alpha); const int lineGap = 2; lineOffset += lineGap; } }
void NumberLabel::_maketextures() { if(_num_objects==0) { cout << "make tex" << endl; _textures = new Texture[NUMBERLABEL_NUM_TEX]; const char chars[] = NUMBERLABEL_CHARS; TextRenderer render; for( int i=0; i<NUMBERLABEL_NUM_TEX; ++i ) { stringstream s; s << chars[i]; render.Text2Texture( _textures[i], s.str()); } } _num_objects++; }
void render(SDL_Window *window) { /* Set the background black */ GL(glClearColor, (0.0f, 0.0f, 0.0f, 0.0f)); /* Clear The Screen And The Depth Buffer */ GL(glClear, (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); /* Draw text */ const uint32_t text[] = { 'A', 'B', 'C', 'D', 'g', 'i', ',', 0 }; text_renderer.drawText(text, 0, 4); SDL_GL_SwapWindow(window); }
/*static*/ status_t Overlay::drawInfoPage( const sp<IGraphicBufferProducer>& outputSurface) { status_t err; EglWindow window; err = window.createWindow(outputSurface); if (err != NO_ERROR) { return err; } window.makeCurrent(); int width = window.getWidth(); int height = window.getHeight(); glViewport(0, 0, width, height); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); // Shaders for rendering. Program texProgram; err = texProgram.setup(Program::PROGRAM_TEXTURE_2D); if (err != NO_ERROR) { return err; } TextRenderer textRenderer; err = textRenderer.loadIntoTexture(); if (err != NO_ERROR) { return err; } textRenderer.setScreenSize(width, height); doDrawInfoPage(window, texProgram, textRenderer); // Destroy the surface. This causes a disconnect. texProgram.release(); window.release(); return NO_ERROR; }
//-------------------------------------------------------------------------------------- // Callback function that renders the frame. This function sets up the rendering // matrices and renders the scene and UI. //-------------------------------------------------------------------------------------- void CALLBACK OnD3D11FrameRender(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime, float fElapsedTime, void* pUserContext) { // If the settings dialog is being shown, then render it instead of rendering the app's scene if (g_SettingsDlg.IsActive()) { g_SettingsDlg.OnRender(fElapsedTime); return; } // Reallocate the render targets and depth buffer if the MSAA mode has been changed in the GUI. if (g_RenderTargetsDirty) { g_RenderTargetsDirty = false; ResizeScreenSizedBuffers(pd3dDevice); } SceneMesh *pMesh = g_Scenes[g_CurrentSceneId].pMesh; g_AOParams.UseDeinterleavedTexturing = g_UseDeinterleavedTexturing; g_AOParams.RandomizeSamples = g_RandomizeSamples; g_AOParams.Blur.Enable = g_BlurAO; ID3D11RenderTargetView* pBackBufferRTV = DXUTGetD3D11RenderTargetView(); // does not addref if (pMesh) { RenderAOFromMesh(pd3dDevice, pd3dImmediateContext, pBackBufferRTV, pMesh); } //-------------------------------------------------------------------------------------- // Render the GUI //-------------------------------------------------------------------------------------- if (g_DrawUI) { g_HUD.OnRender(fElapsedTime); g_TextRenderer.OnRender(fElapsedTime); } }
void Load_Fonts() { neuro.Load( "Fonts/neuropol.ttf",20,20, Rgba::WHITE ); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } petitchiffre.Load( "Fonts/neuropol.ttf",12,12, Rgba::WHITE ); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } petitpetitchiffre.Load( "Fonts/neuropol.ttf",10,10, Rgba::WHITE ); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } petitchiffrerouge.Load( "Fonts/neuropol.ttf",12,12, Rgba::RED ); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } circuitlevel.Load( "Fonts/neuropol.ttf",10,10, CouleurLevel); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } circuitfaderlevel.Load( "Fonts/neuropol.ttf",10,10, CouleurFader); if( !neuro ) { allegro_message( "Couldn't load Fonts/europol.ttf!" ); exit( -1 ); } doomblanc.Load( "Fonts/doom.ttf",20,20, Rgba::WHITE); if( !doomblanc ) { allegro_message( "Couldn't load Fonts/doom.ttf!" ); exit( -1 ); } }
void UIPainter::draw(const TextRenderer& text, bool forceCopy) { if (clip) { auto targetClip = clip.get() - text.getPosition(); if (text.getClip()) { targetClip = text.getClip().get().intersection(targetClip); } auto onScreen = Rect4f(Vector2f(), text.getExtents()).intersection(targetClip); if (onScreen.getWidth() > 0.1f && onScreen.getHeight() > 0.1f) { painter.addCopy(text.clone().setClip(clip.get() - text.getPosition()), mask, layer, getCurrentPriority()); } } else { if (forceCopy) { painter.addCopy(text, mask, layer, getCurrentPriority()); } else { painter.add(text, mask, layer, getCurrentPriority()); } } }
Paragraph::Paragraph(TextRenderer& tr):PageObjectBase(tr.renderContext()) ,m_flags(0xf) ,m_font(pango_font_description_new()) ,m_layout(pango_layout_new( pangocontext( tr.handle() ) ) ) {style(s_para_default).style(s_text_default);}
void Text3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } glPushMatrix(); { glTranslatef(_position.x, _position.y, _position.z); glm::quat rotation; if (_isFacingAvatar) { // rotate about vertical to face the camera rotation = Application::getInstance()->getCamera()->getRotation(); } else { rotation = getRotation(); } glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); const float MAX_COLOR = 255.0f; xColor backgroundColor = getBackgroundColor(); glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, getBackgroundAlpha()); glm::vec2 dimensions = getDimensions(); glm::vec2 halfDimensions = dimensions * 0.5f; const float SLIGHTLY_BEHIND = -0.005f; glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND); glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND); DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor); // Same font properties as textSize() TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE); float maxHeight = (float)textRenderer->computeExtent("Xy").y * LINE_SCALE_RATIO; float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight; glTranslatef(-(halfDimensions.x - _leftMargin), halfDimensions.y - _topMargin, 0.0f); glm::vec2 clipMinimum(0.0f, 0.0f); glm::vec2 clipDimensions((dimensions.x - (_leftMargin + _rightMargin)) / scaleFactor, (dimensions.y - (_topMargin + _bottomMargin)) / scaleFactor); glScalef(scaleFactor, -scaleFactor, scaleFactor); enableClipPlane(GL_CLIP_PLANE0, -1.0f, 0.0f, 0.0f, clipMinimum.x + clipDimensions.x); enableClipPlane(GL_CLIP_PLANE1, 1.0f, 0.0f, 0.0f, -clipMinimum.x); enableClipPlane(GL_CLIP_PLANE2, 0.0f, -1.0f, 0.0f, clipMinimum.y + clipDimensions.y); enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y); glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() }; textRenderer->draw(0, 0, _text, textColor); glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE1); glDisable(GL_CLIP_PLANE2); glDisable(GL_CLIP_PLANE3); } glPopMatrix(); }
/// execute the given selection command /// @param controller the controller to execute the selection for void SelectionCommand::execute( TextEditorController* controller ) { // save the selection state TextDocument* document = controller->textDocument(); TextRangeSet* currentSelection = dynamic_cast<TextRangeSet*>( controller->textSelection() ); TextRangeSet* sel = new TextRangeSet(*currentSelection); // start with the current selection bool resetAnchors = !keepSelection_; // handle the select operation switch( unit_ ) { // character movement case MoveCaretByCharacter: sel->moveCarets(amount_); break; // This results in clearing the selection if a selection is present or it results in a movement of the caret. // When clearing a selection the caret is placed next to the selection (which side depends on the direction) case MoveCaretsOrDeselect: if( keepSelection_ ) { sel->moveCarets(amount_); } else { sel->moveCaretsOrDeselect(amount_); } break; case MoveCaretByWord: sel->moveCaretsByCharGroup(amount_, document->config()->whitespaceWithoutNewline(), document->config()->charGroups() ); break; case MoveCaretByLine: TextSelection::moveCaretsByLine( controller, sel, amount_ ); break; case MoveCaretToLineBoundary: sel->moveCaretsToLineBoundary( amount_, document->config()->whitespaceWithoutNewline() ); break; case MoveCaretToDocumentBegin: sel->toSingleRange(); sel->range(0).setCaret(0); break; case MoveCaretToDocumentEnd: sel->toSingleRange(); sel->range(0).setCaret( controller->textDocument()->length() ); break; case MoveCaretByPage: { // make sure the first line of the window is scrolled TextRenderer* renderer = controller->textRenderer(); TextEditorWidget* widget = controller->widget(); int firstVisibleLine = renderer->firstVisibleLine(); int linesPerPage = renderer->viewHeightInLines(); sel->beginChanges(); TextSelection::moveCaretsByPage( controller, sel, amount_ ); if( !keepSelection_ ) { sel->resetAnchors(); // we must reset anchors here because de process-changes will merge carets } sel->endChanges(); firstVisibleLine += linesPerPage * amount_; widget->scrollTopToLine( firstVisibleLine ); break; } case MoveCaretToExactOffset: sel->toSingleRange(); sel->range(0).setCaret(amount_); break; case SelectAll: sel->toSingleRange(); sel->setRange(0, document->buffer()->length() ); resetAnchors = false; // do not reset the anchors break; case SelectWord: sel->expandToWords(document->config()->whitespaces(), document->config()->charGroups()); resetAnchors = false; // do not reset the anchors break; case SelectWordAt: sel->selectWordAt( amount_, document->config()->whitespaces(), document->config()->charGroups() ); resetAnchors = false; break; case ToggleWordSelectionAt: sel->toggleWordSelectionAt( amount_, document->config()->whitespaces(), document->config()->charGroups() ); resetAnchors = false; break; case SelectFullLine: sel->expandToFullLines( amount_); resetAnchors = false; break; case AddCaretAtOffset: sel->addRange( amount_, amount_ ); resetAnchors = false; // do not reset the anchors break; case AddCaretByLine: TextSelection::addRangesByLine( controller, sel, amount_ ); break; case ResetSelection: // when there's a selection ESCAPE clears the selection if( sel->hasSelection() ) { sel->clearSelection(); } else if( sel->rangeCount() > 1 ) { sel->toSingleRange(); } resetAnchors = false; // keep selection break; } if( resetAnchors ) { sel->resetAnchors(); } // no change? if( currentSelection->equals( *sel ) ) { delete sel; return; // 0 } controller->changeAndGiveTextSelection( sel, commandId() ); }
//auto getText = [&]() void getText(TextRenderer &textObj, PerfMon &perfMon, WindowStates &ws) { auto fbWidth = ws.fbWidth; auto fbHeight = ws.fbHeight; auto winWidth = ws.winWidth; auto winHeight = ws.winHeight; stringstream textOut; textOut << "Frame: " << std::fixed << std::setprecision(1) << 1000.0/perfMon.fps.average() << "ms max: " << 1000.0/perfMon.fps.min() << "ms min: " << 1000.0/perfMon.fps.max() << "ms"; textObj.pushBackDebug(textOut); textOut << "cpu time: " << std::fixed << std::setprecision(2) << perfMon.renderTimes.average() << "ms max: " << perfMon.renderTimes.max() << "ms min: " << perfMon.renderTimes.min(); textObj.pushBackDebug(textOut); textOut << "gpu time: " << std::fixed << std::setprecision(2) << perfMon.gpuRenderTimes.average() << "ms max: " << perfMon.gpuRenderTimes.max() << "ms min: " << perfMon.gpuRenderTimes.min(); // << std::accumulate(gpuTimes.begin(), gpuTimes.end(), 0) << "ms"; textObj.pushBackDebug(textOut); textOut << "win " << winWidth << " x " << winHeight << " fb size " << fbWidth << " x " << fbHeight; textObj.pushBackDebug(textOut); //the following code should go into UserInput and GameLogic, not out here textOut << "shadow pass: 1 " << ((renderStage & stage1) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "forward pass: 2 " << ((renderStage & stage2) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "highpass: 3 " << ((renderStage & stage3) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "blur1 pass: 4 " << ((renderStage & stage4) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "blur2 pass: 5 " << ((renderStage & stage5) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "composite pass: 6 " << ((renderStage & stage6) ? "On" : " "); textObj.pushBackDebug(textOut); textOut << "fxaa pass: 7 " << ((renderStage & stage7) ? "On" : " "); textObj.pushBackDebug(textOut); }
int main() { Setup::SetupProgram(KEYBOARD | MOUSE ); Setup::SetupScreen( 1050, 650,WINDOWED, 8 ); Settings::SetAntialiasing( true ); install_joystick(JOY_TYPE_AUTODETECT); calibrate_joystick_name(0); install_timer(); LOCK_VARIABLE(ticks); LOCK_FUNCTION(ticker); install_int_ex(ticker , ticker_rate); LOCK_VARIABLE(ticks_move); LOCK_FUNCTION(ticker_move); if(install_int_ex(ticker_move , ticker_rate)!=0){sprintf(string_joystick_state,"Error Initializing Joystick !");}; if(!num_joysticks){sprintf(string_joystick_state,"No Joystick detected!");} else { sprintf(string_joystick_state,"%d Joysticks detected",num_joysticks);} Load_Fonts(); if(set_display_switch_mode(SWITCH_BACKGROUND)) {set_display_switch_mode(SWITCH_BACKAMNESIA);} Load_Tracker(); prepare_move_values(dock_move_selected);//prepa Prepare_Cross_Spline(dock_move_selected); char udp_buffer[UDPMAX_CAR]; int sinsize; int nbrbytessended=0; SOCKET sock; char broadcast='1'; WSADATA wsa; WSAStartup(MAKEWORD(2,0),&wsa); SOCKADDR_IN sin; sin.sin_family=AF_INET; sin.sin_addr.s_addr=inet_addr(ip); sin.sin_port=htons(udp_port); sock=socket(AF_INET,SOCK_DGRAM,0); //On initialise le socket avec SOCK_DGRAM pour dire qu'on est en UDP sprintf(string_Last_Order,"INIT socket"); if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof broadcast) == -1) { perror("\a\nsetsockopt (SO_BROADCAST)"); exit(1); } bind(sock,(SOCKADDR*)&sin,sizeof(sin)); //Liaison entre la structure et la socket sprintf(string_Last_Order,"BIDING socket"); sinsize=sizeof(sin); memset(udp_buffer,0,sizeof(udp_buffer)); int old_iris=0; int old_focus=0; int old_zoom=0; int old_iris_fine=0; int old_focus_fine=0; int old_zoom_fine=0; sprintf(string_infos,"Compilation 14nov 09 / Pan= %d Tilt= %d Iris= %d Focus= %d Zoom= %d/ IP: %s / Port: %d",xadress,yadress,irisadress,focusadress,zoomadress,ip, udp_port); while(index_quit!=1) { while(ticks == 0) {rest(1);} ticks_passed = ticks; ticks = 0; poll_joystick(); Canvas::Fill(CouleurFond); petitchiffre.Print(string_infos,10,10); tracker_box(xtrack_window, ytrack_window); if(Thetracker_X!=old_trackerX || Thetracker_Y!=old_trackerY || Thetracker_X_fine!=old_trackerX_fine || Thetracker_Y_fine!=old_trackerY_fine || iris_state!= old_iris || focus_state!=old_focus || zoom_state!=old_zoom ) { if(index_rescale_signal==0) { udp_buffer[xadress-1]=buffer_tracker[xadress]+position_defaut[0]; udp_buffer[yadress-1]=buffer_tracker[yadress]+position_defaut[1]; if (buffer_tracker[xadress]+position_defaut[0]<0) {udp_buffer[xadress-1]=0;} if (buffer_tracker[xadress]+position_defaut[0]>255) {udp_buffer[xadress-1]=255;} if (buffer_tracker[yadress]+position_defaut[1]<0) {udp_buffer[yadress-1]=0;} if (buffer_tracker[yadress]+position_defaut[1]>255) {udp_buffer[yadress-1]=255;} } else if(index_rescale_signal==1) {udp_buffer[xadress-1]=buffer_tracker_rescaled[xadress]; udp_buffer[yadress-1]=buffer_tracker_rescaled[yadress];} if(tracker_mode==1){udp_buffer[xadress]=buffer_tracker[xadress+1]; udp_buffer[yadress]=buffer_tracker[yadress+1];} udp_buffer[irisadress-1]=iris_state; udp_buffer[focusadress-1]=focus_state; udp_buffer[zoomadress-1]=zoom_state; nbrbytessended=sendto(sock,udp_buffer,UDPMAX_CAR,0,(SOCKADDR*)&sin,sinsize); old_trackerX=Thetracker_X; old_trackerY=Thetracker_Y; old_trackerX_fine=Thetracker_X_fine; old_trackerY_fine=Thetracker_Y_fine; old_iris=iris_state; old_focus=focus_state; old_zoom=zoom_state; old_iris_fine=iris_state_fine; old_focus_fine=focus_state_fine; old_zoom_fine=zoom_state_fine; } Line( Vec2D( mouse_x-1,mouse_y-1), Vec2D( mouse_x+20,mouse_y+30),3.0).Draw( CouleurFader ); Line( Vec2D( mouse_x+20,mouse_y+30), Vec2D( mouse_x+30,mouse_y+10),3.0).Draw( CouleurFader ); Line( Vec2D( mouse_x+30,mouse_y+10), Vec2D( mouse_x-1,mouse_y-1),3.0).Draw( CouleurFader ); triangle(screen,mouse_x,mouse_y, mouse_x+20,mouse_y+30,mouse_x+30,mouse_y+10,makecol(255,255,255)); if(mouse_b) {triangle(screen,mouse_x,mouse_y, mouse_x+20,mouse_y+30,mouse_x+30,mouse_y+10,makecol(0,0,0)); } Canvas::Refresh(); } remove_timer(); shutdown(sock,2); closesocket(sock); allegro_exit(); return 0; }
void Viewer_impl::showDistance(QPoint pixel) { static bool isAset = false; bool found; CGAL::qglviewer::Vec point; point = viewer->camera()->pointUnderPixel(pixel, found); if(!isAset && found) { //set APoint APoint = point; isAset = true; clearDistancedisplay(); } else if (found) { //set BPoint BPoint = point; isAset = false; // fills the buffers std::vector<float> v; v.resize(6); v[0] = float(APoint.x); v[1] = float(APoint.y); v[2] = float(APoint.z); v[3] = float(BPoint.x); v[4] = float(BPoint.y); v[5] = float(BPoint.z); vao.bind(); buffer.bind(); buffer.allocate(v.data(),6*sizeof(float)); rendering_program_dist.enableAttributeArray("vertex"); rendering_program_dist.setAttributeBuffer("vertex",GL_FLOAT,0,3); buffer.release(); vao.release(); distance_is_displayed = true; double dist = std::sqrt((BPoint.x-APoint.x)*(BPoint.x-APoint.x) + (BPoint.y-APoint.y)*(BPoint.y-APoint.y) + (BPoint.z-APoint.z)*(BPoint.z-APoint.z)); QFont font; font.setBold(true); TextItem *ACoord = new TextItem(float(APoint.x), float(APoint.y), float(APoint.z), QString("A(%1,%2,%3)").arg(APoint.x-viewer->offset().x).arg(APoint.y-viewer->offset().y).arg(APoint.z-viewer->offset().z), true, font, Qt::red, true); distance_text.append(ACoord); TextItem *BCoord = new TextItem(float(BPoint.x), float(BPoint.y), float(BPoint.z), QString("B(%1,%2,%3)").arg(BPoint.x-viewer->offset().x).arg(BPoint.y-viewer->offset().y).arg(BPoint.z-viewer->offset().z), true, font, Qt::red, true); distance_text.append(BCoord); CGAL::qglviewer::Vec centerPoint = 0.5*(BPoint+APoint); TextItem *centerCoord = new TextItem(float(centerPoint.x), float(centerPoint.y), float(centerPoint.z), QString(" distance: %1").arg(dist), true, font, Qt::red, true); distance_text.append(centerCoord); Q_FOREACH(TextItem* ti, distance_text) textRenderer->addText(ti); Q_EMIT(viewer->sendMessage(QString("First point : A(%1,%2,%3), second point : B(%4,%5,%6), distance between them : %7") .arg(APoint.x-viewer->offset().x) .arg(APoint.y-viewer->offset().y) .arg(APoint.z-viewer->offset().z) .arg(BPoint.x-viewer->offset().x) .arg(BPoint.y-viewer->offset().y) .arg(BPoint.z-viewer->offset().z) .arg(dist))); } }
void Text3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } glPushMatrix(); { glTranslatef(_position.x, _position.y, _position.z); glm::quat rotation; if (_isFacingAvatar) { // rotate about vertical to face the camera rotation = Application::getInstance()->getCamera()->getRotation(); } else { rotation = getRotation(); } glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); const float MAX_COLOR = 255.0f; xColor backgroundColor = getBackgroundColor(); glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, getBackgroundAlpha()); glm::vec2 dimensions = getDimensions(); glm::vec2 halfDimensions = dimensions * 0.5f; const float SLIGHTLY_BEHIND = -0.005f; glBegin(GL_QUADS); glVertex3f(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND); glVertex3f(halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND); glVertex3f(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND); glVertex3f(-halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND); glEnd(); const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation // Same font properties as textWidth() TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE); float maxHeight = (float)textRenderer->calculateHeight("Xy") * LINE_SCALE_RATIO; float scaleFactor = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight; glTranslatef(-(halfDimensions.x - _leftMargin), halfDimensions.y - _topMargin, 0.0f); glm::vec2 clipMinimum(0.0f, 0.0f); glm::vec2 clipDimensions((dimensions.x - (_leftMargin + _rightMargin)) / scaleFactor, (dimensions.y - (_topMargin + _bottomMargin)) / scaleFactor); glScalef(scaleFactor, -scaleFactor, 1.0); enableClipPlane(GL_CLIP_PLANE0, -1.0f, 0.0f, 0.0f, clipMinimum.x + clipDimensions.x); enableClipPlane(GL_CLIP_PLANE1, 1.0f, 0.0f, 0.0f, -clipMinimum.x); enableClipPlane(GL_CLIP_PLANE2, 0.0f, -1.0f, 0.0f, clipMinimum.y + clipDimensions.y); enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y); glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR); float alpha = getAlpha(); QStringList lines = _text.split("\n"); int lineOffset = maxHeight; foreach(QString thisLine, lines) { textRenderer->draw(0, lineOffset, qPrintable(thisLine), alpha); lineOffset += maxHeight; } glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE1); glDisable(GL_CLIP_PLANE2); glDisable(GL_CLIP_PLANE3); } glPopMatrix();