Skip to content

Commit

Permalink
Attempt at fixing spheric mirror effect on retina
Browse files Browse the repository at this point in the history
This commit will at least make the rendering work, as long
as we don't resize the window!  It mostly makes sure that
the effect buffer size is using the actual screen pixel size
and not the logical size.

It's not good.  The code it quite complex and we have to jungle
with the screen scale (pixelsPerPixel) in a few places where it
shouldn't matter.

The input handling is also broken.

Need to keep working on that.
  • Loading branch information
guillaumechereau committed Dec 22, 2017
1 parent 9212d9b commit d95be5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ void StelApp::quit()
void StelApp::setDevicePixelsPerPixel(float dppp)
{
// Check that the device-independent pixel size didn't change
if (devicePixelsPerPixel!=dppp)
if (!viewportEffect && devicePixelsPerPixel!=dppp)
{
devicePixelsPerPixel = dppp;
StelProjector::StelProjectorParams params = core->getCurrentStelProjectorParams();
Expand Down
19 changes: 6 additions & 13 deletions src/core/StelViewportEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,22 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
core->getMovementMgr()->setMaxFov(distorter_max_fov);

// width of the not yet distorted image
newProjectorParams.viewportXywh[2] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[2]idth", originalProjectorParams.viewportXywh[2]).toInt();
newProjectorParams.devicePixelsPerPixel = 1;
newProjectorParams.viewportXywh[2] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[2]idth", originalProjectorParams.viewportXywh[2] * params.devicePixelsPerPixel).toInt();
if (newProjectorParams.viewportXywh[2] <= 0)
{
newProjectorParams.viewportXywh[2] = originalProjectorParams.viewportXywh[2];
newProjectorParams.viewportXywh[2] = originalProjectorParams.viewportXywh[2] * params.devicePixelsPerPixel;
}
else if (newProjectorParams.viewportXywh[2] > screen_w)
{
newProjectorParams.viewportXywh[2] = screen_w;
}

// height of the not yet distorted image
newProjectorParams.viewportXywh[3] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[3]eight", originalProjectorParams.viewportXywh[3]).toInt();
newProjectorParams.viewportXywh[3] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[3]eight", originalProjectorParams.viewportXywh[3] * params.devicePixelsPerPixel).toInt();
if (newProjectorParams.viewportXywh[3] <= 0)
{
newProjectorParams.viewportXywh[3] = originalProjectorParams.viewportXywh[3];
newProjectorParams.viewportXywh[3] = originalProjectorParams.viewportXywh[3] * params.devicePixelsPerPixel;
}
else if (newProjectorParams.viewportXywh[3] > screen_h)
{
Expand All @@ -106,8 +107,6 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
newProjectorParams.viewportXywh[0] = (screen_w-newProjectorParams.viewportXywh[2]) >> 1;
newProjectorParams.viewportXywh[1] = (screen_h-newProjectorParams.viewportXywh[3]) >> 1;

newProjectorParams.viewportXywh[2] *= originalProjectorParams.devicePixelsPerPixel;
newProjectorParams.viewportXywh[3] *= originalProjectorParams.devicePixelsPerPixel;
StelApp::getInstance().getCore()->setCurrentStelProjectorParams(newProjectorParams);

// init transformation
Expand Down Expand Up @@ -248,13 +247,7 @@ StelViewportDistorterFisheyeToSphericMirror::~StelViewportDistorterFisheyeToSphe
{
if (texture_point_array)
delete[] texture_point_array;

// TODO repair
// prj->setMaxFov(original_max_fov);
// prj->setViewport(original_viewport[0],original_viewport[1],
// original_viewport[2],original_viewport[3],
// original_viewportCenter[0],original_viewportCenter[1],
// original_viewportFovDiameter);
StelApp::getInstance().getCore()->setCurrentStelProjectorParams(originalProjectorParams);
}


Expand Down

0 comments on commit d95be5b

Please sign in to comment.