/** * This method will expand the graphics panel already openned to the maximun of the display area scaled by the scale value supplied. * * @param scale Porcentage (0-100) of the display width to use. */ void resizemax(float scale) { Display *disp; float ax, ay; int X, Y; /* Xlib code */ disp = XOpenDisplay(NULL); if (disp == NULL) { fprintf(stderr, "No Display.\n"); exit(-1); } else { Y = XDisplayHeightMM(disp, 0); X = XDisplayWidthMM(disp, 0) / (0.9); } XCloseDisplay(disp); /* End of Xlib code */ ay = (double) Y / (double) X; ax = X / 25.4 * scale; cpgpap(ax, ay); cpgpage(); BASIC_ASPECT = ay; }
/* Returns the physical display size as reported by X11: */ void PsychGetDisplaySize(int screenNumber, int *width, int *height) { if(screenNumber>=numDisplays) PsychErrorExitMsg(PsychError_internal, "screenNumber passed to PsychGetDisplaySize() is out of range"); *width = (int) XDisplayWidthMM(displayCGIDs[screenNumber], PsychGetXScreenIdForScreen(screenNumber)); *height = (int) XDisplayHeightMM(displayCGIDs[screenNumber], PsychGetXScreenIdForScreen(screenNumber)); }
std::pair<int, int> getDPI() { Display * dpy = XOpenDisplay(nullptr); int screen = 0; //TODO: find a way to get the current screen int horizontalDPI = ((((double) XDisplayWidth(dpy, screen)) * 25.4) / ((double) XDisplayWidthMM(dpy, screen))); int verticalDPI = ((((double) XDisplayHeight(dpy, screen)) * 25.4) / ((double) XDisplayHeightMM(dpy, screen))); return std::pair<int, int>(horizontalDPI, verticalDPI); }
// INPUT display, screen n° // OUTPUT int * int (size in mm) CAMLprim value caml_xscreen_sizemm(value disp, value screen) { CAMLparam2(disp, screen); int w = XDisplayWidthMM ((Display*) disp, Int_val(screen)); int h = XDisplayHeightMM ((Display*) disp, Int_val(screen)); CAMLreturn(Int_pair(w,h)); }
int main(int argc, char* argv[]) { (void)argc; (void)argv; Display *dpy = _getXdis (); XVisualInfo *vis = _getXvis (dpy, _attr); Window win = _setXwin (dpy, vis); GLXContext ctx = _getGLXctx(dpy, vis); // bind the rendering context to the window Bool ret = glXMakeCurrent(dpy, win, ctx); if (False == ret) { printf("ERROR: glXMakeCurrent() fail\n"); exit(0); } { // init S52 lib (Screen No 0) #ifdef SET_SCREEN_SIZE int w = 1280; int h = 1024; int wmm = 376; int hmm = 307; #else int h = XDisplayHeight (dpy, 0); int hmm = XDisplayHeightMM(dpy, 0); int w = XDisplayWidth (dpy, 0); int wmm = XDisplayWidthMM (dpy, 0); #endif S52_init(w, h, wmm, hmm, NULL); } // differ from w/h S52_setViewPort(0, 0, WIDTH, HEIGHT); /* debug - use for timing rendering S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_SY); //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LS); S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LC); S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AC); S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AP); S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_TX); //*/ // load cell from s52.cfg S52_loadCell(NULL, NULL); { // main loop XEvent event; while (True) { do { XNextEvent(dpy, &event); switch (event.type) { case ConfigureNotify: break; //case GraphicsExpose: // S52_setViewPort(0, 0, event.xconfigure.width, event.xconfigure.height); break; //case ... case KeyPress: case KeyRelease: { unsigned int keycode = ((XKeyEvent *)&event)->keycode; unsigned int keysym = XkbKeycodeToKeysym(dpy, keycode, 0, 1); // ESC - quit if (XK_Escape == keysym) { goto exit; } } } } while (XPending(dpy)); S52_draw(); S52_drawLast(); // nothing to do glXSwapBuffers(dpy, win); } } exit: XKillClient(dpy, win); S52_done(); return True; }