Skip to content

Commit

Permalink
Fix terminal/screenshot related bugs (#336)
Browse files Browse the repository at this point in the history
* Fix #333 - terminal positioning on scale

* Fix #335 - GL scaling of hotkey snapshots
  • Loading branch information
vintagepc authored Oct 28, 2021
1 parent 029cc59 commit 43df58c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions MK404.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@ void displayCB() /* function called whenever redisplay needed */
glLoadIdentity();
glClear(US(GL_COLOR_BUFFER_BIT) | US(GL_DEPTH_BUFFER_BIT));
int iW = glutGet(GLUT_WINDOW_WIDTH);
//int iH = glutGet(GLUT_WINDOW_HEIGHT);
if (m_bTerminal)
{
glPushMatrix();
glTranslatef(0,m_iTermHeight,0);
ScriptHost::Draw();
glTranslatef(0,4.F*(printer->GetWindowSize().second + 2),0);
ScriptHost::Draw();
glPopMatrix();
}
printer->Draw();
Expand Down Expand Up @@ -224,7 +223,7 @@ void ResizeCB(int w, int h)
std::pair<int,int> winSize = printer->GetWindowSize();
if (m_bTerminal)
{
winSize.second+=10;
winSize.second += 14;
}
float fWS = static_cast<float>(w)/static_cast<float>(winSize.first*4);
float fHS = static_cast<float>(h)/static_cast<float>(winSize.second*4);
Expand Down Expand Up @@ -461,7 +460,7 @@ int main(int argc, char *argv[])
int pixsize = 4;
if (m_bTerminal)
{
winSize.second +=10;
winSize.second += 14;
}
iWinW = winSize.first * pixsize;
iWinH = (winSize.second)*pixsize;
Expand Down
7 changes: 6 additions & 1 deletion parts/components/GLHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void GLHelper::OnDraw()
case ActTakeSnapshotArea:
case ActTakeSnapLCD:
{
if (m_iAct.load() == ActTakeSnapLCD) // Account for LCD scaling
{
m_h = static_cast<float>(m_h)*(static_cast<float>(width)/static_cast<float>(m_w));
m_w = width;
}
WritePNG(width, height, (m_iAct == ActTakeSnapshotArea || m_iAct == ActTakeSnapLCD));
std::cout << "Wrote: " << m_strFile << '\n';
if (m_bIsKeySnap) {
Expand Down Expand Up @@ -120,7 +125,7 @@ void GLHelper::OnKeyPress(const Key& key)
{
std::cout << "LCD Snapshot toggled!\n";
m_bIsKeySnap = true;
// GLHelper::SnapRect(tests/snaps/LCD01,0,0,500,164)
// Args are scaled based on window width in the routine.
ProcessAction(ActTakeSnapLCD,{"","0","0","500","164"});
}
break;
Expand Down
3 changes: 1 addition & 2 deletions parts/printers/Prusa_MMU2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ std::pair<int,int> Prusa_MMU2::GetWindowSize()
void Prusa_MMU2::Draw()
{
glScalef(50.F/35.F,4,1);
auto fY = static_cast<float>(glutGet(GLUT_WINDOW_HEIGHT)/4);
MM_Control_01::Draw(fY);
MM_Control_01::Draw(static_cast<float>(GetWindowSize().second));
m_gl.OnDraw();
}

Expand Down

0 comments on commit 43df58c

Please sign in to comment.