VideoMode VideoModeImpl::getDesktopMode() { // Get the activity states priv::ActivityStates* states = priv::getActivity(NULL); Lock lock(states->mutex); return VideoMode(states->screenSize.x, states->screenSize.y); }
//////////////////////////////////////////////////////////// /// Get current desktop video mode //////////////////////////////////////////////////////////// VideoMode VideoModeSupport::GetDesktopVideoMode() { DEVMODE Win32Mode; Win32Mode.dmSize = sizeof(DEVMODE); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &Win32Mode); return VideoMode(Win32Mode.dmPelsWidth, Win32Mode.dmPelsHeight, Win32Mode.dmBitsPerPel); }
Application::Application() : m_window( VideoMode( 800, 600 ), "Informatik Projekt" ), m_gui( m_window ) { m_window.setVerticalSyncEnabled( true ); m_gui.setFont( "Data/DejaVuSans.ttf" ); }
void App::initSFML() { // stwórz okno window.create(VideoMode(windowWidth, windowHeight), "OpenGL", Style::Fullscreen, ContextSettings(32)); window.setFramerateLimit(60); window.setKeyRepeatEnabled(false); window.setMouseCursorVisible(false); Mouse::setPosition(getWindowCenter(), window); }
VideoModeList getListOfVideoModes() { VideoModeList list; for (int i=0; i < int(NUMBER_OF_VIDEOMODE); i++) { list.push_back(VideoMode(i)); } return list; }
int main() { RenderWindow window(VideoMode(1300,702),"Find the fish"); window.setPosition(Vector2i(0,0)); menu(window); mainLevel(window); //MiniGame_Books(); return 0; }
void createWindow(Window* app) { app->contextSettings = ContextSettings(24,8,0,3,3); app->contextVideoMode = VideoMode(WIDTH,HEIGHT,32); app->contextWindow = new sf::Window(app->contextVideoMode,"Midori - NG4 Logo identify tool", Style::Close,app->contextSettings); app->contextWindow->SetActive(); app->contextWindow->ShowMouseCursor(true); app->contextWindow->SetCursorPosition(WIDTH/2,HEIGHT/2); }
VideoMode VideoModeImpl::getDesktopMode() { DEVMODE win32Mode; win32Mode.dmSize = sizeof(win32Mode); win32Mode.dmDriverExtra = 0; EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &win32Mode); return VideoMode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel); }
Game::Game(int ww, int hh) : win(VideoMode(ww, hh), "Samolocik"), map(ww, hh), w(ww), h(hh) { win.setFramerateLimit(FPS_LIMIT); win.setVerticalSyncEnabled(VSYNC); // ³adowanie Load(); }
void AVForm::updateVideoModes(int curIndex) { if (curIndex < 0 || curIndex >= videoDeviceList.size()) { qWarning() << "Invalid index:" << curIndex; return; } QString devName = videoDeviceList[curIndex].first; QVector<VideoMode> allVideoModes = CameraDevice::getVideoModes(devName); qDebug("available Modes:"); bool isScreen = CameraDevice::isScreen(devName); if (isScreen) { // Add extra video mode to region selection allVideoModes.push_back(VideoMode()); videoModes = allVideoModes; fillScreenModesComboBox(); } else { selectBestModes(allVideoModes); videoModes = allVideoModes; fillCameraModesComboBox(); } int preferedIndex = searchPreferredIndex(); if (preferedIndex != -1) { Settings::getInstance().setScreenGrabbed(false); videoModescomboBox->blockSignals(true); videoModescomboBox->setCurrentIndex(preferedIndex); videoModescomboBox->blockSignals(false); open(devName, videoModes[preferedIndex]); return; } if (isScreen) { QRect rect = Settings::getInstance().getScreenRegion(); VideoMode mode(rect); Settings::getInstance().setScreenGrabbed(true); videoModescomboBox->setCurrentIndex(videoModes.size() - 1); open(devName, mode); return; } // If the user hasn't set a preferred resolution yet, // we'll pick the resolution in the middle of the list, // and the best FPS for that resolution. // If we picked the lowest resolution, the quality would be awful // but if we picked the largest, FPS would be bad and thus quality bad too. int mid = (videoModes.size() - 1) / 2; videoModescomboBox->setCurrentIndex(mid); }
std::vector<VideoMode> VideoModeImpl::getFullscreenModes() { VideoMode desktop = getDesktopMode(); // Return both portrait and landscape resolutions std::vector<VideoMode> modes; modes.push_back(desktop); modes.push_back(VideoMode(desktop.height, desktop.width, desktop.bitsPerPixel)); return modes; }
Game::Game() { textureManager = new TextureManager("data/imgList"); world = new World("data/Map/world.map"); player = new Player(400,250); window = new RenderWindow(VideoMode(800,500,32),"Game -PRE.ALPHA",!sf::Style::Resize | sf::Style::Close); window->setPosition(sf::Vector2i(100,250)); Renderer::Setup(window,textureManager); Run(); }
VideoMode VideoModeImpl::getDesktopMode() { VideoMode desktopMode; // Open a connection with the X server Display* display = OpenDisplay(); if (display) { // Retrieve the default screen number int screen = DefaultScreen(display); // Check if the XRandR extension is present int version; if (XQueryExtension(display, "RANDR", &version, &version, &version)) { // Get the current configuration XRRScreenConfiguration* config = XRRGetScreenInfo(display, RootWindow(display, screen)); if (config) { // Get the current video mode Rotation currentRotation; int currentMode = XRRConfigCurrentConfiguration(config, ¤tRotation); // Get the available screen sizes int nbSizes; XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes); if (sizes && (nbSizes > 0)) desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(display, screen)); // Free the configuration instance XRRFreeScreenConfigInfo(config); } else { // Failed to get the screen configuration err() << "Failed to retrieve the screen configuration while trying to get the desktop video modes" << std::endl; } } else { // XRandr extension is not supported : we cannot get the video modes err() << "Failed to use the XRandR extension while trying to get the desktop video modes" << std::endl; } // Close the connection with the X server CloseDisplay(display); } else { // We couldn't connect to the X server err() << "Failed to connect to the X server while trying to get the desktop video modes" << std::endl; } return desktopMode; }
int Frigid::init() { //Load stuff //TODO: Change to the refresh rate of the monitor. //mWindow.setFramerateLimit(30); //Get the user folder path. char path[MAX_PATH]; if (SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, path) != S_OK) { _error("Could not get the user path") } mPrefs = Preferences::instance(); mPrefs->setHomeDir(path); mPrefs->setConfigDir(String(path) + "/Documents/_quark"); BindingManager::instance()->setDefaultBindings(); loadConfig(); uint32 w = mPrefs->getStartingWindowWidth(); uint32 h = mPrefs->getStartingWindowHeight(); bool m = mPrefs->getStartMaximized(); if (w == 0 || h == 0) { m = true; w = 1024; h = 600; } mWindow = new RenderWindow(VideoMode(w, h, 32, m), "Quark"); mMainPanel = Panel(); tempHelpText = Text("Press control + ? for help.", *mPrefs->getFont(), 12); getPreferences(); CodeEditor *editor = new CodeEditor(); mMainPanel.setWidget(editor); Input::initInput(); WindowEvent e; e.type = WindowEvent::Resized; e.size.width = mWindow->getWidth(); e.size.height = mWindow->getHeight(); Rectf visibleArea(0, 0, staticCastf(e.size.width), staticCastf(e.size.height)); mWindow->setView(View(visibleArea)); mMainPanel.resizeEvent(e); update(); quit(); return 0; }
void CSysSettingDialog::WriteFile( ) { QString strGroup = "CommonSet"; pSettings->beginGroup( strGroup ); pSettings->setValue( "FeeCalculateSet", ui->rdxCostSelfDef->isChecked( ) ); pSettings->setValue( "WorkMode", ui->rdxWorkMaster->isChecked( ) ); pSettings->setValue( "MonthlyWakeup", ui->spMonthlyDay->value( ) ); pSettings->setValue( "SaveWakeup", ui->spValueSurplus->value( ) ); pSettings->setValue( "EnterComfirm/Monhtly", ui->chxEntranceMonth->isChecked( ) ); pSettings->setValue( "EnterComfirm/Save", ui->chxEntranceValue->isChecked( ) ); pSettings->setValue( "EnterComfirm/Time", ui->chxEntranceTime->isChecked( ) ); pSettings->setValue( "LeaveComfirm/Monhtly", ui->chxLeaveMonth->isChecked( ) ); pSettings->setValue( "LeaveComfirm/Save", ui->chxLeaveValue->isChecked( ) ); pSettings->setValue( "LeaveComfirm/Time", ui->chxLeaveTime->isChecked( ) ); pSettings->setValue( "MonthlyWorkMode", ui->chxMonthlyMode->isChecked( ) ); pSettings->setValue( "ForceOpenGate", ui->chxForceOpenGate->isChecked( ) ); pSettings->setValue( "CardConfirm", ui->chkConfirm->isChecked( ) ); pSettings->endGroup( ); strGroup = "TimeLimit"; pSettings->beginGroup( strGroup ); pSettings->setValue( "Expiration", ui->dateValid->date( ).toString( "yyyy-MM-dd" ) ); pSettings->endGroup( ); strGroup = "VideoMode"; pSettings->beginGroup( strGroup ); int nWay = 2; VideoMode( nWay, true ); pSettings->setValue( "Way", nWay ); pSettings->setValue( "Resolution", ui->lsResolution->currentRow( ) ); pSettings->endGroup( ); strGroup = "CarLicence"; pSettings->beginGroup( strGroup ); pSettings->setValue( "AutoRecognize", ui->chxStartAuto->isChecked( ) ); pSettings->setValue( "Blacklist", ui->chxStartBlacklist->isChecked( ) ); int nPrecision = 0; Precision( nPrecision, true ); pSettings->setValue( "Precision", nPrecision ); pSettings->endGroup( ); strGroup = "SpecialSet"; pSettings->beginGroup( strGroup ); pSettings->setValue( "Space/Monthly", ui->chxSpaceMonth->isChecked( ) ); pSettings->setValue( "Space/Save", ui->chxSpaceValue->isChecked( ) ); pSettings->setValue( "CC/Enter", ui->chxCCEnter->isChecked( ) ); pSettings->setValue( "CC/EnterAddr", ui->spCCEnterAddr->value( ) ); pSettings->setValue( "CC/Leave", ui->chxCCLeave->isChecked( ) ); pSettings->setValue( "CC/LeaveAddr", ui->spCCLeaveAddr->value( ) ); pSettings->setValue( "SyncOffline", ui->chxDataSync->isChecked( ) ); pSettings->setValue( "SaveFee", ui->chxValueCharging->isChecked( ) ); pSettings->endGroup( ); pSettings->sync( ); }
GameBase::GameBase(int ancho, int alto,std::string titulo) { this->alto = alto; this->ancho = ancho; wnd= new RenderWindow(VideoMode(ancho,alto),titulo); wnd->setVisible(true); fps=60; wnd->setFramerateLimit(fps); frameTime=1.0f/fps; EnableDebugPhysics(false); }
LevelGUI::LevelGUI(string LevelName) { Level LevelTest(LevelName); LevelTest.Load(); RenderWindow window(VideoMode(1280, 720), "Platformer:" + LevelName); View view(Vector2f(0, 0), Vector2f(1280, 720)); //These numbers can be scaled to zoom it out Player Player(Player(LevelTest.PlayerSpawn->rect.getPosition(), Vector2f(64, 64), Color::Blue, &LevelTest)); window.setFramerateLimit(60); while (window.isOpen()) { Event event; while (window.pollEvent(event)) //If theres any event that is supposed to close the window, do that and deallocate everything. { if (event.type == Event::Closed) { cout << "Closing...\n"; //LevelTest.Save(); //cout << "Successfully saved level.\n"; window.close(); cout << "Successfully closed window.\n"; goto stop; } else if (event.type == sf::Event::MouseWheelMoved) { if (event.mouseWheel.delta > 0) { view.zoom(0.7f); cout << "Zooming in... \n"; } else if (event.mouseWheel.delta < 0) { view.zoom(1.3f); cout << "Zooming out... \n"; } } } Player.Move(&view); //HOLY SHIT SO MANY ADDRESSES window.clear(Color::White); //Make background white Player.Update(); //Update the coordinates of Player window.setView(view); //Has to be called every frame I read somewhere on the SFML tutorials LevelTest.Draw(&window); //"Draws" all of the blocks on the window window.draw(Player.rect); //Draw player view.setCenter(Vector2f(Player.rect.getPosition().x + ((Player.rect.getSize().x) / 2), Player.rect.getPosition().y + (Player.rect.getSize().y) / 2) ); //Centers camera on player window.display(); } stop: cout << "Successfully exited this levelGUI.\n"; }
std::vector<VideoMode> GetAvailableVideoModes() { std::vector<VideoMode> modes; //querying modes using the current pixel format //note - this has always been sdl_fullscreen, hopefully it does not matter SDL_Rect **sdlmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_FULLSCREEN); if (sdlmodes == 0) OS::Error("Failed to query video modes"); if (sdlmodes == reinterpret_cast<SDL_Rect **>(-1)) { // Modes restricted. Fall back to 800x600 modes.push_back(VideoMode(800, 600)); } else { for (int i=0; sdlmodes[i]; ++i) { modes.push_back(VideoMode(sdlmodes[i]->w, sdlmodes[i]->h)); } } return modes; }
CView::CView(): m_mouseClicked(false), m_pWindow(make_unique<RenderWindow>(VideoMode(DEFAULT_WINDOW_SIZE.x, DEFAULT_WINDOW_SIZE.y), APPLICATION_TITLE)) { m_pFrame->ResetFigure({ OUTSTIDE_WORKSPACE_POS, OUTSTIDE_WORKSPACE_POS }, { OUTSTIDE_WORKSPACE_POS - FRAME_POINT_RADIUS, OUTSTIDE_WORKSPACE_POS - FRAME_POINT_RADIUS }); m_settings.antialiasingLevel = 8; CreatingApplicationWindow(); }
VideoMode dskOptions::getAspectRatio(const VideoMode& vm) { // First some a bit off values where the aspect ratio is defined by convention if(vm == VideoMode(1360, 1024)) return VideoMode(4, 3); else if(vm == VideoMode(1360, 768)) return VideoMode(16, 9); else if(vm == VideoMode(1366, 768)) return VideoMode(16, 9); // Normally Aspect ration is simply width/height as integer numbers (e.g. 4:3) int divisor = helpers::gcd(vm.width, vm.height); VideoMode ratio(vm.width / divisor, vm.height / divisor); // But there are some special cases: if(ratio == VideoMode(8, 5)) return VideoMode(16, 10); else if(ratio == VideoMode(5, 3)) return VideoMode(15, 9); else return ratio; }
int main(int argc, char **argv) { GLContext ctx; if (!ctx.create(VideoMode(720, 480, 24, 0, 4), "12 Framebuffer", true, true)) { APP_LOG << "Failed to open context\n"; return EXIT_FAILURE; } APP_LOG << ctx.getDebugInfo(); Renderer gfx; gfx.init(ctx); try { if (!load()) { gfx.dispose(); ctx.dispose(); APP_LOG << "Failed to load content\n"; return EXIT_FAILURE; } init(gfx, ctx); double dt = 0.0; while (ctx.isOpen()) { double frame_t = ctx.getElapsedTime(); update(gfx, ctx, dt); render(gfx, ctx, dt); ctx.display(); ctx.pollEvents(); if (ctx.isKeyPressed(SDL_SCANCODE_ESCAPE)) ctx.close(); if (checkGLErrors()) ctx.close(); dt = ctx.getElapsedTime() - frame_t; } } catch (std::exception &e) { APP_LOG << "An unexpected error occurred: " << e.what(); } free(); gfx.dispose(); ctx.dispose(); return EXIT_SUCCESS; }
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(uint desktopWidth, uint desktopHeight, SdlEventSource *eventSource) : SdlGraphicsManager(eventSource), _lastVideoModeLoad(0), _hwScreen(nullptr), _lastRequestedWidth(0), _lastRequestedHeight(0), _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0), _desiredFullscreenWidth(0), _desiredFullscreenHeight(0) { // Setup OpenGL attributes for SDL SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // Retrieve a list of working fullscreen modes const SDL_Rect *const *availableModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); if (availableModes != (void *)-1) { for (;*availableModes; ++availableModes) { const SDL_Rect *mode = *availableModes; _fullscreenVideoModes.push_back(VideoMode(mode->w, mode->h)); } // Sort the modes in ascending order. Common::sort(_fullscreenVideoModes.begin(), _fullscreenVideoModes.end()); } // In case SDL is fine with every mode we will force the desktop mode. // TODO? We could also try to add some default resolutions here. if (_fullscreenVideoModes.empty() && desktopWidth && desktopHeight) { _fullscreenVideoModes.push_back(VideoMode(desktopWidth, desktopHeight)); } // Get information about display sizes from the previous runs. if (ConfMan.hasKey("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain)) { _desiredFullscreenWidth = ConfMan.getInt("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain); _desiredFullscreenHeight = ConfMan.getInt("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain); } else { // Use the desktop resolutions when no previous default has been setup. _desiredFullscreenWidth = desktopWidth; _desiredFullscreenHeight = desktopHeight; } }
void Rgame::pre_init(void) { cout << m_title << " is starting." << endl; renderWindow.Create(VideoMode(SCREEN_W, SCREEN_H), m_title,Style::Resize | Style::Close); renderWindow.UseVerticalSync(true); renderWindow.SetFramerateLimit(30); scale = 1; }
//////////////////////////////////////////////////////////// /// Construct a new window //////////////////////////////////////////////////////////// sfWindow* sfWindow_Create(sfVideoMode Mode, const char* Title, unsigned long Style, sfWindowSettings Params) { // Convert video mode sf::VideoMode VideoMode(Mode.Width, Mode.Height, Mode.BitsPerPixel); // Create the window sfWindow* Window = new sfWindow; sf::WindowSettings Settings(Params.DepthBits, Params.StencilBits, Params.AntialiasingLevel); Window->This.Create(VideoMode, Title, Style, Settings); Window->Input.This = &Window->This.GetInput(); return Window; }
Game::Game() { pWnd = new RenderWindow(VideoMode(800, 600), "Testing box2d"); pWnd->setVisible(true); fps = 60; pWnd->setFramerateLimit(fps); frameTime = 1.0f / fps; setZoom(); initPhysics(); ragdoll = new Ragdoll(phyWorld, pWnd, 30, 10); }
GameBase::GameBase(int ancho, int alto,std::string titulo) { srand((unsigned int)time(NULL)); this->alto = alto; this->ancho = ancho; wnd= new RenderWindow(VideoMode(ancho,alto),titulo); wnd->setVisible(true); fps=FPS; wnd->setFramerateLimit(fps); frameTime=1.0f/fps; EnableDebugPhysics(false); ImageManager::Instance()->addResourceDirectory("Recursos/imagenes/"); }
void RenderContextImplGLX::EnumVideoModes(VideoModeList& videoModes) { // check for xrandr support videoModes.clear(); bool fallback = false; if ((xrandrSupported = IsXRandrSupported())) { XRRScreenSize* screenSize; int nsizes = 0; Trace("XRANDR is enabled"); screenSize = XRRSizes(display, screenIndex, &nsizes); if (!nsizes) fallback = true; videoModes.reserve((size_t) nsizes); for (int i = 0; i < nsizes; ++i) { VideoMode vmode; vmode.width = uint16(screenSize[i].width); vmode.height = uint16(screenSize[i].height); int nrates; short* rates = XRRRates(display, screenIndex, i, &nrates); for (int j = 0; j < nrates; ++j) { vmode.refreshRate = uint16(rates[j]); videoModes.push_back(vmode); } } Window root = RootWindow(display, screenIndex); Rotation rotation; XRRScreenConfiguration *conf = XRRGetScreenInfo(display, root); int currsize = XRRConfigCurrentConfiguration(conf, &rotation); VideoMode current = VideoMode(screenSize[currsize].width, screenSize[currsize].height, XRRConfigCurrentRate(conf)); std::sort(videoModes.begin(), videoModes.end()); auto it = std::find(videoModes.begin(), videoModes.end(), current); if (it != videoModes.end()) baseContext->SetOriginalVideoMode((uint32)(it - videoModes.begin())); else { videoModes.push_back(current); baseContext->SetOriginalVideoMode((uint32)videoModes.size() - 1); } XRRFreeScreenConfigInfo(conf); } /* check vid modes*/ if (fallback || !videoModes.size()) { VideoMode vmode; vmode.width = DisplayWidth(display, screenIndex); vmode.height = DisplayHeight(display, screenIndex); vmode.refreshRate = 0; videoModes.push_back(vmode); baseContext->SetOriginalVideoMode((uint32)videoModes.size() - 1); Error("Viewmode set in fallback mode!"); } }
VideoMode VideoModeImpl::getDesktopMode() { static bool initialized=false; if (!initialized) { bcm_host_init(); initialized=true; } uint32_t width( 0 ), height( 0 ); graphics_get_display_size( 0 /* LCD */, &width, &height ); return VideoMode(width, height); }
CameraSource::CameraSource() : deviceName{"none"} , device{nullptr} , mode(VideoMode()) , cctx{nullptr} , cctxOrig{nullptr} , videoStreamIndex{-1} , _isOpen{false} , streamBlocker{false} , subscriptions{0} { subscriptions = 0; av_register_all(); avdevice_register_all(); }
void Game::start(void) { if(_gameState != Uninitialized) return; _mainWindow.create(VideoMode(640, 480, 32), "Breakout"); _gameState = Game::Playing; while(!isExiting()) gameLoop(); _mainWindow.close(); }