← Back

ofxScreenScale

github.com/ffunatsu/ofxScreenScale · @ffunatsu
OF 0.12 Utilities

openFrameworks addon / get screen scale on HiDPI display

1 0 Last commit 2y ago Created 2y ago

README

ofxScreenScale



Usage



#include "ofMain.h"

include "ofApp.h"

include "ofxScreenScale.h"

int main( ){ float scale = ofxScreenScale::getScreenScale(); ofLogNotice("main") << "Screen scale: " << scale; ofGLWindowSettings settings; settings.setSize(1024 scale, 768 scale); // <-- settings.windowMode = OF_WINDOW; auto window = ofCreateWindow(settings); ofRunApp(window, make_shared<ofApp>()); ofRunMainLoop(); }


void ofApp::draw(){
    float scale = ofxScreenScale::getScreenScale();
    ofScale(scale, scale);

    // or just call
    // ofxScreenScale::applyDrawScale();

    // draw something...
}


void ofApp::setup(){
    float scale = ofxScreenScale::getScreenScale();

    // apply scaling to imgui
    ImGuiStyle& style = ImGui::GetStyle();
    style.ScaleAllSizes(scale);

    // apply font scaling to imgui
    auto&& io = ImGui::GetIO();
    io.FontGlobalScale = scale;

    // or just call
    // ofxScreenScale::applyImGuiScale();
}

Get this addon

HTTPS
SSH