//! Returns a 3d ray which would go through the 2d screen coodinates. core::line3d<f32> CSceneCollisionManager::getRayFromScreenCoordinates( core::position2d<s32> pos, ICameraSceneNode* camera) { core::line3d<f32> ln(0,0,0,0,0,0); if (!SceneManager) return ln; if (!camera) camera = SceneManager->getActiveCamera(); if (!camera) return ln; const scene::SViewFrustum* f = camera->getViewFrustum(); core::vector3df farLeftUp = f->getFarLeftUp(); core::vector3df lefttoright = f->getFarRightUp() - farLeftUp; core::vector3df uptodown = f->getFarLeftDown() - farLeftUp; const core::rect<s32>& viewPort = Driver->getViewPort(); core::dimension2d<s32> screenSize(viewPort.getWidth(), viewPort.getHeight()); f32 dx = pos.X / (f32)screenSize.Width; f32 dy = pos.Y / (f32)screenSize.Height; if (camera->isOrthogonal()) ln.start = f->cameraPosition + (lefttoright * (dx-0.5f)) + (uptodown * (dy-0.5f)); else ln.start = f->cameraPosition; ln.end = farLeftUp + (lefttoright * dx) + (uptodown * dy); return ln; }
void KoPictureEps::draw(QPainter& painter, int x, int y, int width, int height, int sx, int sy, int sw, int sh, bool fastMode) { if ( !width || !height ) return; QSize screenSize( width, height ); //kdDebug() << "KoPictureEps::draw screenSize=" << screenSize.width() << "x" << screenSize.height() << endl; QPaintDeviceMetrics metrics (painter.device()); kdDebug(30003) << "Metrics: X: " << metrics.logicalDpiX() << " x Y: " << metrics.logicalDpiX() << " (in KoPictureEps::draw)" << endl; if ( painter.device()->isExtDev() ) // Is it an external device (i.e. printer) { kdDebug(30003) << "Drawing for a printer (in KoPictureEps::draw)" << endl; // For printing, always re-sample the image, as a printer has never the same resolution than a display. QImage image( scaleWithGhostScript( screenSize, metrics.logicalDpiX(), metrics.logicalDpiY() ) ); // sx,sy,sw,sh is meant to be used as a cliprect on the pixmap, but drawImage // translates it to the (x,y) point -> we need (x+sx, y+sy). painter.drawImage( x + sx, y + sy, image, sx, sy, sw, sh ); } else // No, it is simply a display { scaleAndCreatePixmap(screenSize, fastMode, metrics.logicalDpiX(), metrics.logicalDpiY() ); // sx,sy,sw,sh is meant to be used as a cliprect on the pixmap, but drawPixmap // translates it to the (x,y) point -> we need (x+sx, y+sy). painter.drawPixmap( x + sx, y + sy, m_cachedPixmap, sx, sy, sw, sh ); } }
void PictureImage::draw(QPainter& painter, int x, int y, int width, int height, int sx, int sy, int sw, int sh, bool fastMode) { //kDebug(30508) <<"KoImage::draw currentSize:" << currentSize.width() <<"x" << currentSize.height(); if (!width || !height) return; QSize origSize = getOriginalSize(); const bool scaleImage = dynamic_cast<QPrinter*>(painter.device()) != 0 // we are printing && ((width <= origSize.width()) || (height <= origSize.height())); if (scaleImage) { // use full resolution of image qreal xScale = qreal(width) / qreal(origSize.width()); qreal yScale = qreal(height) / qreal(origSize.height()); painter.save(); painter.translate(x, y); painter.scale(xScale, yScale); // Note that sx, sy, sw and sh are unused in this case. Not a problem, since it's about printing. // Note 2: we do not cache the QPixmap. As we are printing, the next time we will probably // need again the screen version. painter.drawImage(0, 0, m_originalImage); painter.restore(); } else { QSize screenSize(width, height); //kDebug(30508) <<"PictureImage::draw screenSize=" << screenSize.width() <<"x" << screenSize.height(); scaleAndCreatePixmap(screenSize, fastMode); // sx,sy,sw,sh is meant to be used as a cliprect on the pixmap, but drawPixmap // translates it to the (x,y) point -> we need (x+sx, y+sy). painter.drawPixmap(x + sx, y + sy, m_cachedPixmap, sx, sy, sw, sh); } }
void BenchCairo::runBlitImageF(BenchOutput& output, const BenchParams& params) { cairo_t* cr = cairo_create(screenCairo); configureContext(cr, params); BenchRandom rPts(app); Fog::SizeI screenSize( params.screenSize.w - params.shapeSize, params.screenSize.h - params.shapeSize); uint32_t spriteIndex = 0; uint32_t spritesLength = (uint32_t)sprites.getLength(); uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++) { Fog::PointF pt(rPts.getPointF(screenSize)); cairo_set_source_surface(cr, spritesCairo[spriteIndex], pt.x, pt.y); cairo_rectangle(cr, double(pt.x), double(pt.y), double(params.shapeSize), double(params.shapeSize)); cairo_fill(cr); if (++spriteIndex >= spritesLength) spriteIndex = 0; } cairo_destroy(cr); }
void SceneGraph::setupView() { auto use_cam = camera_; auto use_projector = projector_; if (render_mode_ == RenderInfo::SHADOW) { use_cam = shadow_camera_; use_projector = shadow_projector_; } T3_NULL_ASSERT(use_cam); const Mtx44& view_mtx = use_cam->viewMatrix(); const Mtx44& proj_mtx = use_projector->projectionMatrix(); auto view_projection = proj_mtx * view_mtx; pushAndSetMatrix(view_projection); cross::RenderSystem::setViewport( 0, 0, static_cast<int>(use_projector->screenSize().x_), static_cast<int>(use_projector->screenSize().y_) ); }
int main(int argc, char* argv[]) { QApplication app(argc, argv); app.setOrganizationName(PROJECT_COMPANYNAME); app.setOrganizationDomain(PROJECT_COMPANYNAME_DOMAIN); app.setApplicationName(PROJECT_NAME); app.setApplicationVersion(PROJECT_VERSION); app.setAttribute(Qt::AA_UseHighDpiPixmaps); app.setWindowIcon(fastonosql::gui::GuiFactory::instance().logoIcon()); // default icon for app #ifdef NDEBUG SET_LOG_LEVEL(common::logging::L_INFO); #else SET_LOG_LEVEL(common::logging::L_DEBUG); #endif fastonosql::gui::MainWindow win; QRect screenGeometry = app.desktop()->availableGeometry(); QSize screenSize(screenGeometry.width(), screenGeometry.height()); #ifdef OS_ANDROID win.resize(screenSize); #else QSize size(screenGeometry.width() / 2, screenGeometry.height() / 2); if (preferedSize.height() <= screenSize.height() && preferedSize.width() <= screenSize.width()) { win.resize(preferedSize); } else { win.resize(size); } QPoint center = screenGeometry.center(); win.move(center.x() - win.width() * 0.5, center.y() - win.height() * 0.5); #endif win.show(); return app.exec(); }
int main(int argc, char* argv[]) { av_register_all(); QApplication app(argc, argv); app.setOrganizationName(PROJECT_COMPANYNAME); app.setApplicationName(PROJECT_NAME); app.setApplicationVersion(PROJECT_VERSION); app.setAttribute(Qt::AA_UseHighDpiPixmaps); MainWindow win; QRect screenGeometry = app.desktop()->availableGeometry(); QSize screenSize(screenGeometry.width(), screenGeometry.height()); #ifdef OS_ANDROID win.resize(screenSize); #else QSize size(screenGeometry.width()/2, screenGeometry.height()/2); if (preferedSize.height() <= screenSize.height() && preferedSize.width() <= screenSize.width()) { win.resize(preferedSize); } else { win.resize(size); } QPoint center = screenGeometry.center(); win.move(center.x() - win.width() * 0.5, center.y() - win.height() * 0.5); #endif win.show(); return app.exec(); }
QDpi QEglFSHooks::logicalDpi() const { QSizeF ps = physicalScreenSize(); QSize s = screenSize(); return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); }
void Game::OnResize(int newWidth, int newHeight) { D3DXVECTOR2 screenSize(static_cast<float>(newWidth), static_cast<float>(newHeight)); graphics::GlobalShaderParams::SetValue<D3DXVECTOR2&>("ScreenSize", screenSize); graphics::GlobalShaderParams::SetValue("Projection", &m_camera->m_Projection); graphics::RenderTexture::OnResize(newWidth, newHeight); }
//----------------------------------------------------------------------------------- void lines2d::add_line(const math::vec2f &point1, const math::vec2f point2, math::Color color) { math::vec2f screenSize(800, 600); //virtual screen size math::vec2f vFrontBufferSize= render::render_device::get().getBackBufferSize(); math::vec2f m_scale = vFrontBufferSize / screenSize; m_vertices->push_back(Point(point1 * m_scale, color)); m_vertices->push_back(Point(point2 * m_scale, color)); }
void TestEngine::Display() { int width, height; glfwGetWindowSize(&width, &height); glClear(GL_COLOR_BUFFER_BIT); if (simulate) { Step(); } char buf[128]; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, current->GetTextureID(0)); shaders["RtoRGB"]->Use(); shaders["RtoRGB"]->Uniforms["baseTex"].SetValue(0); float imgWidth = (float)current->Width / width; imgWidth *= 2.0f; float imgHeight = (float)current->Height / height; imgHeight *= 2.0f; sprintf(buf, "width: %f, height: %f", imgWidth, imgHeight); glfwSetWindowTitle(buf); QuadDrawer::DrawQuad(Vec2(-0.8, 1.0 - imgHeight), Vec2(-0.8 + imgWidth, 1.0)); glBindTexture(GL_TEXTURE_2D, last->GetTextureID(0)); QuadDrawer::DrawQuad(Vec2(-1.0, 0.8), Vec2(-0.8, 1.0)); glBindTexture(GL_TEXTURE_2D, next->GetTextureID(0)); QuadDrawer::DrawQuad(Vec2(-1.0, 0.6), Vec2(-0.8, 0.8)); glBindTexture(GL_TEXTURE_2D, DebugGetFontTexID()); QuadDrawer::DrawQuad(Vec2(-1.0, -1.0), Vec2(1.0, -0.8)); if (blah) { //glGetError(); blah = false; } Vec2 screenSize(width, height); sprintf(buf, "Equation: %s, timeStep: %f, spaceStep: %f", equationShaders[currentEq % equationShaders.size()]->GetName(), timeStep, spaceStep); PrintText(screenSize, Vec2(-400, -460), buf, Colour::White); sprintf(buf, "Iterations: %d", iterations); PrintText(screenSize, Vec2(-400, -500), buf, Colour::White); sprintf(buf, "Left/Right arrows: change space step"); PrintText(screenSize, Vec2(-400, -540), buf, Colour::White); sprintf(buf, "Up/Down arrows: change time step"); PrintText(screenSize, Vec2(-400, -580), buf, Colour::White); sprintf(buf, "Number keys: cycle images"); PrintText(screenSize, Vec2(-400, -620), buf, Colour::White); sprintf(buf, "[/]: change equation"); PrintText(screenSize, Vec2(-400, -660), buf, Colour::White); }
void run() { Vector screenSize(640+2*8, 400+2*8); Vector size = screenSize*Vector(5, 8); Bitmap<SRGB> output(size); output.fill(SRGB(0, 0, 0)); for (int y = 0; y < size.y; ++y) { int yMaj = y/screenSize.y; int yMin = y%screenSize.y; static const int portValueTable[8] = { 0x1a00, 0x1e00, 0x0a00, 0x0a10, 0x0a20, 0x0a30, 0x0e20, 0x0e30}; int overscan = ((yMin - 8)/12) & 0x0f; int portValues = portValueTable[yMaj] | overscan; bool bpp1 = ((portValues & 0x1000) != 0); bool bw = ((portValues & 0x0400) != 0); bool backGroundI = ((portValues & 0x10) != 0); bool colorSel = ((portValues & 0x20) != 0); int pal[4]; pal[0] = overscan; pal[1] = 2; pal[2] = 4; pal[3] = 6; if (colorSel || bw) { pal[1] = 3; pal[3] = 7; } if (colorSel && !bw) pal[2] = 5; if (backGroundI) { pal[1] += 8; pal[2] += 8; pal[3] += 8; } char topLine[40]; memcpy(topLine, " 0 1 2 3 4 5 6 7 8 9 A B C D E F ", 40); topLine[0] = nybble(portValues >> 12); topLine[1] = nybble(portValues >> 8); topLine[2] = nybble(portValues >> 4); topLine[3] = nybble(portValues); for (int x = 0; x < screenSize.x; ++x) { if (yMin < 8) { char ch = topLine[x/16]; // TODO continue; } int pattern = (x - 8)/40; if (x < 8 || x >= 640 + 8) pattern = 0; } } RawFileFormat raw(size); raw.save(output, File("chart.raw")); }
void Draw::DrawPoint(const fPoint &pos, const cColorRGBA &color) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(1); fVector3 pos2d(pos.x, pos.y, 0.0f); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); buffer->SetPosition(pos2d/screenSize); buffer->SetColor(color); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_POINTLIST); }
void Draw::DrawLine(const fPoint &start, const fPoint &end, const cColorRGBA &color) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(2); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); buffer[0].SetPosition(fVector3(start)/screenSize); buffer[0].SetColor(color); buffer[1].SetPosition(fVector3(end)/screenSize); buffer[1].SetColor(color); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_LINELIST); }
QDpi QEGLDeviceIntegration::logicalDpi() const { const QSizeF ps = physicalScreenSize(); const QSize s = screenSize(); if (!ps.isEmpty() && !s.isEmpty()) return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); else return QDpi(100, 100); }
Point2d View::screenSizeInDisplayCoords(Point2f &frameSize) { Point2d screenSize(0,0); if (frameSize.x() == 0.0 || frameSize.y() == 0.0) return screenSize; screenSize.x() = tan(fieldOfView/2.0) * heightAboveSurface() * 2.0; screenSize.y() = screenSize.x() / frameSize.x() * frameSize.y(); return screenSize; }
void Calibration::mouseReleaseEvent(QMouseEvent *event) { // Map from device coordinates in case the screen is transformed QSize screenSize(qt_screen->width(), qt_screen->height()); QPoint p = qt_screen->mapToDevice(event->pos(), screenSize); data.devPoints[pressCount] = p; if (++pressCount < 5) repaint(); else accept(); }
void Calibration::paintEvent(QPaintEvent*) { QPainter p(this); p.fillRect(rect(), Qt::white); QPoint point = data.screenPoints[pressCount]; // Map to logical coordinates in case the screen is transformed QSize screenSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()); point = qt_screen->mapFromDevice(point, screenSize); p.fillRect(point.x() - 6, point.y() - 1, 13, 3, Qt::black); p.fillRect(point.x() - 1, point.y() - 6, 3, 13, Qt::black); }
int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); QGuiApplication app(argc, argv); QSize baseSize(1280,1024); QSize screenSize(app.primaryScreen()->size()); if(!FKUtility::loadImageset("images",screenSize)){ qDebug("unable load images"); } if(!FKUtility::loadImageset("skillIcons",screenSize)){ qDebug("unable load skillIcons"); } FKUtility::ResourceLocator resources; if(resources.load("music")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load music resource"); } if(!resources.load("models")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load models resource"); } if(!resources.load("sprites")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load sprites resource"); } qreal sizeSet=std::max(((qreal)screenSize.height())/((qreal)baseSize.height()), ((qreal)screenSize.width ())/((qreal)baseSize.width ())); QQmlApplicationEngine engine; ADD_QML_TYPE(BalancedComponent); ADD_QML_TYPE(PlayerBase); ADD_QML_TYPE(HeroObject); ADD_QML_TYPE(PathMap); ADD_QML_TYPE(PathFinder); ADD_QML_ABSTRACT_TYPE(PathFinderAlgorithm); ADD_QML_TYPE(PathFinderAStarAlgorithm); engine.rootContext()->setContextProperty("sizeSet",sizeSet); engine.rootContext()->setContextProperty("baseHeight",baseSize.height()); engine.rootContext()->setContextProperty("baseWidth",baseSize.width()); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); QMetaObject::invokeMethod(engine.rootObjects().at(0),"show"); return app.exec(); }
virtual void sdlEvent(SDL_Event& event) { bool shiftDown = leftShiftDown || rightShiftDown; switch (event.type) { case SDL_MOUSEMOTION: { int dx = event.motion.xrel; int dy = event.motion.yrel; if (leftButtonDown) { if (shiftDown) { if (dy) { float scale = exp((float)dy * -.03f); viewPos *= scale; viewZoom *= scale; } } else { if (dx || dy) { viewPos += Tensor::Vector<float,2>(-(float)dx * aspectRatio / (float)screenSize(0), (float)dy / (float)screenSize(1)); } } } } break; case SDL_MOUSEBUTTONDOWN: if (event.button.button == SDL_BUTTON_LEFT) { leftButtonDown = true; } break; case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) { leftButtonDown = false; } break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_LSHIFT) { leftShiftDown = true; } else if (event.key.keysym.sym == SDLK_RSHIFT) { rightShiftDown = true; } break; case SDL_KEYUP: if (event.key.keysym.sym == SDLK_LSHIFT) { leftShiftDown = false; } else if (event.key.keysym.sym == SDLK_RSHIFT) { rightShiftDown = false; } } }
wxBitmap RectangleDrawer::GetScreenShot(wxDC& dc) { const size_t HEIGHT = ConfigReader::GetInstance()->GetFileConfigIntValue("CANVAS_HEIGHT"); const size_t WIDTH = ConfigReader::GetInstance()->GetFileConfigIntValue("CANVAS_WIDTH"); const size_t SCALING_COEFF = ConfigReader::GetInstance()->GetFileConfigIntValue("CANVAS_SCALE"); const size_t SHIFT_X = ConfigReader::GetInstance()->GetFileConfigIntValue("CANVAS_SHIFT_X"); const size_t SHIFT_Y = ConfigReader::GetInstance()->GetFileConfigIntValue("CANVAS_SHIFT_Y"); wxSize screenSize(wxGetDisplaySize().x, wxGetDisplaySize().y); wxBitmap bitmap(WIDTH * SCALING_COEFF + 2, HEIGHT * SCALING_COEFF + 2); wxMemoryDC memDC; memDC.SelectObject(bitmap); memDC.Blit(0, 0, wxGetDisplaySize().x, wxGetDisplaySize().y, &dc, SHIFT_X, SHIFT_Y); memDC.SelectObject(wxNullBitmap); return bitmap; }
ViewportConfiguration::Parameters ViewportConfiguration::textDocumentParameters() { Parameters parameters; #if PLATFORM(IOS) parameters.width = static_cast<int>(screenSize().width()); #else // FIXME: this needs to be unified with ViewportArguments on all ports. parameters.width = 320; #endif parameters.widthIsSet = true; parameters.allowsUserScaling = true; parameters.allowsShrinkToFit = false; parameters.minimumScale = 0.25; parameters.maximumScale = 5; return parameters; }
void MainMenuScene::onRedraw() { video::IVideoDriver* driver = appContext.getDevice()->getVideoDriver(); core::dimension2du screenSize(driver->getScreenSize()); const core::recti headerRect = staticImagesRects[HashedString("title")]; const core::position2di headerPos( screenSize.Width/2 - headerRect.getWidth()/2, 0); driver->beginScene(true, true, COLOR_CORNFLOWER_BLUE); const core::recti tileRect = staticImagesRects[HashedString("tile")]; irr::u32 time = appContext.getDevice()->getTimer()->getTime(); irr::u32 offset = (time/30) % tileRect.getWidth(); // draw tiled background for (int x = -1; x < (int)screenSize.Width/tileRect.getWidth() + 1; x++) { for (int y = -1; y < (int)screenSize.Height/tileRect.getHeight() + 1; y++) { driver->draw2DImage(staticImages, core::position2di(offset + x * tileRect.getWidth(), offset + y * tileRect.getHeight()), tileRect, 0, video::SColor(255,255,255,255), false); } } // draw header driver->draw2DImage(staticImages, headerPos, headerRect, 0, video::SColor(255,255,255,255), true); core::dimension2du bounds(arcadeMenu->getBounds()); core::vector2df topLeft( screenSize.Width/2 - bounds.Width/2, screenSize.Height*2/3 - bounds.Height/2); arcadeMenu->render(topLeft); appContext.getDevice()->getSceneManager()->drawAll(); appContext.getDevice()->getGUIEnvironment()->drawAll(); driver->endScene(); }
void Draw::DrawBox(const fRect &rect, float rotation, const cColorRGBA &color, Texture *texture, Shader *shader) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); fRect rectInProj = rect / screenSize; fPoint rightTop(rect.width, 0.0f); fPoint rightBottom(rect.width, rect.height); fPoint leftBottom(0.0f, rect.height); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(fVector3(rectInProj.xy(), 0.0f)); buffer[0].SetColor(color); buffer[0].SetTexcoord(fVector2(0.0f, 0.0f)); buffer[1].SetPosition(fVector3(leftBottom, 0.0f)); buffer[1].SetColor(color); buffer[1].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[2].SetPosition(fVector3(rightTop, 0.0f)); buffer[2].SetColor(color); buffer[2].SetTexcoord(fVector2(1.0f, 0.0f)); buffer[3].SetPosition(fVector3(leftBottom, 0.0f)); buffer[3].SetColor(color); buffer[3].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[4].SetPosition(fVector3(rightBottom, 0.0f)); buffer[4].SetColor(color); buffer[4].SetTexcoord(fVector2(1.0f, 1.0f)); buffer[5].SetPosition(fVector3(rightTop, 0.0f)); buffer[5].SetColor(color); buffer[5].SetTexcoord(fVector2(1.0f, 0.0f)); if(shader == NULL) { if(texture) { DrawCommand::BindTexture(0, texture); } else { DrawCommand::BindTexture(0, RenderContext::GetSingleton().GetDefaultTexture(RenderContext::DefaultTextureTypeWhite)); } } LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST, shader); }
void Renderer::DrawField(const Field::PelletStatus &pellets) { sf::Vector2f screenSize(SFData::Window->getSize()); sf::Vector2f fieldSize = 8.f * sf::Vector2f(FIELD_WIDTH, FIELD_HEIGHT); sf::Vector2f scaledSize = Scale * fieldSize; sf::Vector2f offset = (screenSize - scaledSize) / 2.f; sf::Vertex vertices[] = { sf::Vertex( offset, sf::Vector2f(0.f, 1.f)), sf::Vertex( sf::Vector2f(offset.x, offset.y + scaledSize.y), //sf::Vector2f(0.f, fieldSize.y)), sf::Vector2f(0.f, 0.f)), sf::Vertex( sf::Vector2f(offset.x + scaledSize.x, offset.y), //sf::Vector2f(fieldSize.x, 0.f)), sf::Vector2f(1.f, 1.f)), sf::Vertex( offset + scaledSize, //fieldSize) sf::Vector2f(1.f, 0.f)) }; sf::Image pellet_mask; pellet_mask.create(FIELD_WIDTH, FIELD_HEIGHT); for (std::size_t i = 0; i < FIELD_WIDTH; i++) { for (std::size_t j = 0; j < FIELD_HEIGHT; j++) { if (pellets.IsEaten(i, j)) { pellet_mask.setPixel(i, j, sf::Color(255, 255, 255)); } } } pellet_mask.flipVertically(); SFData::PelletTexture.update(pellet_mask); sf::RenderStates renderStates(&SFData::FieldShader); SFData::Window->draw(vertices, 4, sf::TrianglesStrip, renderStates); }
void Sprite::Draw(const iRect &frame, const iRect &rect, float rotation) { if (_texture) DrawCommand::BindTexture(0, _texture); fSize texSize(_texture->GetSize()); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fRect frameInProj = frame / texSize; fRect rectInProj = rect / screenSize; fPoint rightTop(float(rect.width), 0.0f); fPoint rightBottom(float(rect.width), float(rect.height)); fPoint leftBottom(0.0f, float(rect.height)); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(rectInProj.xy()); buffer[0].SetColor(0xffffffff); buffer[0].SetTexcoord(fVector2(frameInProj.x, frameInProj.y)); buffer[1].SetPosition(leftBottom); buffer[1].SetColor(0xffffffff); buffer[1].SetTexcoord(fVector2(frameInProj.x, frameInProj.y+frameInProj.height)); buffer[2].SetPosition(rightTop); buffer[2].SetColor(0xffffffff); buffer[2].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y)); buffer[3].SetPosition(leftBottom); buffer[3].SetColor(0xffffffff); buffer[3].SetTexcoord(fVector2(frameInProj.x, frameInProj.y + frameInProj.height)); buffer[4].SetPosition(rightBottom); buffer[4].SetColor(0xffffffff); buffer[4].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y + frameInProj.height)); buffer[5].SetPosition(rightTop); buffer[5].SetColor(0xffffffff); buffer[5].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y)); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST); }
Renderer::Renderer() { myEngine = Engine::GetInstance(); CU::Vector2<float> screenSize(static_cast<float>(Engine::GetInstance()->GetWindowSize().x) , static_cast<float>(Engine::GetInstance()->GetWindowSize().y)); for (int i = 0; i < MAX_NUMBER_OF_SCENES; ++i) { mySceneData[i].myScene = new Texture(); mySceneData[i].myScene->Init(screenSize.x, screenSize.y , D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL , DXGI_FORMAT_R32G32B32A32_FLOAT); mySceneData[i].myFinished = new Texture(); mySceneData[i].myFinished->Init(screenSize.x, screenSize.y , D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL , DXGI_FORMAT_R32G32B32A32_FLOAT); } myFinalTexture = new Texture(); myFinalTexture->Init(screenSize.x, screenSize.y , D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL , DXGI_FORMAT_R32G32B32A32_FLOAT); myCombineMiddleMan = new Texture(); myCombineMiddleMan->Init(screenSize.x, screenSize.y , D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL , DXGI_FORMAT_R32G32B32A32_FLOAT); myFullScreenHelper = new FullScreenHelper(); myClearColor[0] = 0.f; myClearColor[1] = 0.f; myClearColor[2] = 0.f; myClearColor[3] = 0.f; mySceneIndex = 0; }
void BenchCairo::runBlitImageRotate(BenchOutput& output, const BenchParams& params) { cairo_t* cr = cairo_create(screenCairo); configureContext(cr, params); double cx = (double)params.screenSize.w * 0.5; double cy = (double)params.screenSize.h * 0.5; float angle = 0.0f; BenchRandom rPts(app); Fog::SizeI screenSize( params.screenSize.w - params.shapeSize, params.screenSize.h - params.shapeSize); uint32_t spriteIndex = 0; uint32_t spritesLength = (uint32_t)sprites.getLength(); uint32_t i, quantity = params.quantity; for (i = 0; i < quantity; i++, angle += 0.01f) { Fog::PointI pt(rPts.getPointI(screenSize)); cairo_matrix_t matrix; cairo_matrix_init_translate(&matrix, cx, cy); cairo_matrix_rotate(&matrix, angle); cairo_matrix_translate(&matrix, -cx, -cy); cairo_set_matrix(cr, &matrix); cairo_set_source_surface(cr, spritesCairo[spriteIndex], pt.x, pt.y); cairo_rectangle(cr, pt.x, pt.y, params.shapeSize, params.shapeSize); cairo_fill(cr); if (++spriteIndex >= spritesLength) spriteIndex = 0; } cairo_destroy(cr); }
void Draw::DrawBox(const fRect &rect, float rotation, const cColorRGBA &leftTopColor, const cColorRGBA &rightTopColor, const cColorRGBA &leftBottomColor, const cColorRGBA &rightBottomColor) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); fRect rectInProj = rect / screenSize; fPoint rightTop(rect.width, 0.0f); fPoint rightBottom(rect.width, rect.height); fPoint leftBottom(0.0f, rect.height); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(fVector3(rectInProj.xy(), 0.0f)); buffer[0].SetColor(leftTopColor); buffer[0].SetTexcoord(fVector2(0.0f, 0.0f)); buffer[1].SetPosition(fVector3(leftBottom, 0.0f)); buffer[1].SetColor(leftBottomColor); buffer[1].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[2].SetPosition(fVector3(rightTop, 0.0f)); buffer[2].SetColor(rightTopColor); buffer[2].SetTexcoord(fVector2(1.0f, 0.0f)); buffer[3].SetPosition(fVector3(leftBottom, 0.0f)); buffer[3].SetColor(leftBottomColor); buffer[3].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[4].SetPosition(fVector3(rightBottom, 0.0f)); buffer[4].SetColor(rightBottomColor); buffer[4].SetTexcoord(fVector2(1.0f, 1.0f)); buffer[5].SetPosition(fVector3(rightTop, 0.0f)); buffer[5].SetColor(rightTopColor); buffer[5].SetTexcoord(fVector2(1.0f, 0.0f)); DrawCommand::BindTexture(0, 0); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST); }
qreal AsemanDevices::keyboardHeight() const { #ifdef Q_OS_UBUNTUTOUCH return screenSize().height()*0.5; #else const QSize & scr_size = screenSize(); bool portrait = scr_size.width()<scr_size.height(); if( portrait ) { if( isMobile() ) return screenSize().height()*0.6; else return screenSize().height()*0.4; } else { if( isMobile() ) return screenSize().height()*0.7; else return screenSize().height()*0.5; } #endif }