Skip to content
Snippets Groups Projects
Commit b9772e1a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fixes for high resolution (retina) display

parent 83af2d19
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,6 @@ static void navigator_handler(void *data) ...@@ -42,7 +42,6 @@ static void navigator_handler(void *data)
} }
} }
static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &click2) static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &click2)
{ {
if(click1.win[0] == click2.win[0] || click1.win[1] == click2.win[1]) return; if(click1.win[0] == click2.win[0] || click1.win[1] == click2.win[1]) return;
...@@ -66,7 +65,8 @@ openglWindow::openglWindow(int x, int y, int w, int h) ...@@ -66,7 +65,8 @@ openglWindow::openglWindow(int x, int y, int w, int h)
: Fl_Gl_Window(x, y, w, h, "gl"), _lock(false), _drawn(false), : Fl_Gl_Window(x, y, w, h, "gl"), _lock(false), _drawn(false),
_selection(ENT_NONE), _trySelection(0), Nautilus(0) _selection(ENT_NONE), _trySelection(0), Nautilus(0)
{ {
_ctx = new drawContext(); _ctx = new drawContext(this);
for(int i = 0; i < 3; i++) _point[i] = 0.; for(int i = 0; i < 3; i++) _point[i] = 0.;
for(int i = 0; i < 4; i++) _trySelectionXYWH[i] = 0; for(int i = 0; i < 4; i++) _trySelectionXYWH[i] = 0;
_lassoXY[0] = _lassoXY[1] = 0; _lassoXY[0] = _lassoXY[1] = 0;
...@@ -689,11 +689,6 @@ int openglWindow::pixel_h() ...@@ -689,11 +689,6 @@ int openglWindow::pixel_h()
#endif #endif
} }
bool openglWindow::retina()
{
return pixel_w() > w();
}
bool openglWindow::_select(int type, bool multiple, bool mesh, bool openglWindow::_select(int type, bool multiple, bool mesh,
int x, int y, int w, int h, int x, int y, int w, int h,
std::vector<GVertex*> &vertices, std::vector<GVertex*> &vertices,
......
...@@ -42,7 +42,6 @@ class openglWindow : public Fl_Gl_Window { ...@@ -42,7 +42,6 @@ class openglWindow : public Fl_Gl_Window {
public: public:
int pixel_w(); int pixel_w();
int pixel_h(); int pixel_h();
bool retina();
time_t rawtime, prev_rawtime; time_t rawtime, prev_rawtime;
double response_frequency; double response_frequency;
bool addPointMode, lassoMode, selectionMode; bool addPointMode, lassoMode, selectionMode;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <FL/Fl_JPEG_Image.H> #include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_PNG_Image.H> #include <FL/Fl_PNG_Image.H>
#include <FL/gl.h> #include <FL/gl.h>
#include "openglWindow.h"
#endif #endif
#if defined(HAVE_POPPLER) #if defined(HAVE_POPPLER)
...@@ -34,8 +35,8 @@ drawContextGlobal *drawContext::_global = 0; ...@@ -34,8 +35,8 @@ drawContextGlobal *drawContext::_global = 0;
extern SPoint2 getGraph2dDataPointForTag(unsigned int); extern SPoint2 getGraph2dDataPointForTag(unsigned int);
drawContext::drawContext(drawTransform *transform) drawContext::drawContext(openglWindow *window, drawTransform *transform)
: _transform(transform) : _transform(transform), _openglWindow(window)
{ {
// initialize from temp values in global context // initialize from temp values in global context
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
...@@ -65,6 +66,17 @@ drawContext::~drawContext() ...@@ -65,6 +66,17 @@ drawContext::~drawContext()
invalidateQuadricsAndDisplayLists(); invalidateQuadricsAndDisplayLists();
} }
bool drawContext::isHighResolution()
{
// this must be dynamic: the high resolution can change when a window is moved
// across displays
#if defined(HAVE_FLTK)
return _openglWindow->pixel_w() > _openglWindow->w();
#else
return false;
#endif
}
drawContextGlobal *drawContext::global() drawContextGlobal *drawContext::global()
{ {
if(!_global) _global = new drawContextGlobal(); // create dummy default if(!_global) _global = new drawContextGlobal(); // create dummy default
...@@ -299,6 +311,7 @@ void drawContext::draw2d() ...@@ -299,6 +311,7 @@ void drawContext::draw2d()
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho((double)viewport[0], (double)viewport[2], glOrtho((double)viewport[0], (double)viewport[2],
(double)viewport[1], (double)viewport[3], (double)viewport[1], (double)viewport[3],
-100., 100.); // in pixels, so we can draw some 3D glyphs -100., 100.); // in pixels, so we can draw some 3D glyphs
......
...@@ -34,6 +34,7 @@ class GEdge; ...@@ -34,6 +34,7 @@ class GEdge;
class GFace; class GFace;
class GRegion; class GRegion;
class MElement; class MElement;
class openglWindow;
class drawTransform { class drawTransform {
public: public:
...@@ -112,6 +113,7 @@ class drawContext { ...@@ -112,6 +113,7 @@ class drawContext {
std::set<GModel*> _hiddenModels; std::set<GModel*> _hiddenModels;
std::set<PView*> _hiddenViews; std::set<PView*> _hiddenViews;
GLuint _bgImageTexture, _bgImageW, _bgImageH; GLuint _bgImageTexture, _bgImageW, _bgImageH;
openglWindow *_openglWindow;
public: public:
Camera camera; Camera camera;
double r[3]; // current Euler angles (in degrees!) double r[3]; // current Euler angles (in degrees!)
...@@ -127,8 +129,9 @@ class drawContext { ...@@ -127,8 +129,9 @@ class drawContext {
enum RenderMode {GMSH_RENDER=1, GMSH_SELECT=2, GMSH_FEEDBACK=3}; enum RenderMode {GMSH_RENDER=1, GMSH_SELECT=2, GMSH_FEEDBACK=3};
int render_mode; // current rendering mode int render_mode; // current rendering mode
public: public:
drawContext(drawTransform *transform=0); drawContext(openglWindow *window, drawTransform *transform=0);
~drawContext(); ~drawContext();
bool isHighResolution();
void copyViewAttributes(drawContext *other) void copyViewAttributes(drawContext *other)
{ {
camera = other->camera; camera = other->camera;
......
...@@ -31,6 +31,12 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, ...@@ -31,6 +31,12 @@ void drawContext::drawString(const std::string &s, const std::string &font_name,
drawContext::global()->setFont(font_enum, font_size); drawContext::global()->setFont(font_enum, font_size);
double width = drawContext::global()->getStringWidth(s.c_str()); double width = drawContext::global()->getStringWidth(s.c_str());
double height = drawContext::global()->getStringHeight(); double height = drawContext::global()->getStringHeight();
// width and height must here be computed in true pixel coordinates, because
// viewport2world uses the actual, pixel-sized (not FLTK-sized) viewport
if(isHighResolution()){
width *= 2;
height *= 2;
}
switch(align){ switch(align){
case 1: w[0] -= width/2.; break; // bottom center case 1: w[0] -= width/2.; break; // bottom center
case 2: w[0] -= width; break; // bottom right case 2: w[0] -= width; break; // bottom right
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment