@@ -55,28 +55,44 @@ void CGame::Render()
5555 // render the map if active
5656 if (MapObj && MapObj->isActive ())
5757 {
58- if (auto * mapSurf = MapObj->getSurface ())
59- {
60- std::array<char , 100 > textBuffer;
61- std::snprintf (textBuffer.data (), textBuffer.size (), " %d %d" , MapObj->getVertexX (), MapObj->getVertexY ());
62- CFont::writeText (mapSurf, textBuffer.data (), 20 , 20 );
63- std::snprintf (textBuffer.data (), textBuffer.size (),
64- " min. height: %#04x/0x3C max. height: %#04x/0x3C NormalNull: 0x0A" ,
65- MapObj->getMinReduceHeight (), MapObj->getMaxRaiseHeight ());
66- CFont::writeText (mapSurf, textBuffer.data (), 100 , 20 );
67- if (MapObj->isHorizontalMovementLocked () && MapObj->isVerticalMovementLocked ())
68- CFont::writeText (mapSurf, " Movement locked (F9 or F10 to unlock)" , 20 , 40 , FontSize::Large,
69- FontColor::Orange);
70- else if (MapObj->isHorizontalMovementLocked ())
71- CFont::writeText (mapSurf, " Horizontal movement locked (F9 to unlock)" , 20 , 40 , FontSize::Large,
72- FontColor::Orange);
73- else if (MapObj->isVerticalMovementLocked ())
74- CFont::writeText (mapSurf, " Vertical movement locked (F10 to unlock)" , 20 , 40 , FontSize::Large,
75- FontColor::Orange);
76-
77- mapTex_.load (mapSurf);
78- mapTex_.draw (Rect (0 , 0 , GameResolution.x , GameResolution.y ));
79- }
58+ // Set up map-space projection: (displayRect.left, top) maps to (0,0) screen
59+ auto viewRect = MapObj->getDisplayRect ();
60+ glMatrixMode (GL_PROJECTION );
61+ glPushMatrix ();
62+ glLoadIdentity ();
63+ glOrtho (static_cast <GLdouble>(viewRect.left ), static_cast <GLdouble>(viewRect.left + GameResolution.x ),
64+ static_cast <GLdouble>(viewRect.top + GameResolution.y ), static_cast <GLdouble>(viewRect.top ), -1 , 1 );
65+ glMatrixMode (GL_MODELVIEW );
66+ glPushMatrix ();
67+ glLoadIdentity ();
68+
69+ MapObj->render ();
70+
71+ // Restore screen-space projection
72+ glMatrixMode (GL_PROJECTION );
73+ glPopMatrix ();
74+ glMatrixMode (GL_MODELVIEW );
75+ glPopMatrix ();
76+
77+ // HUD text overlays drawn directly via OpenGL
78+ std::array<char , 100 > textBuffer;
79+ // text for x and y of vertex (shown in upper left corner)
80+ std::snprintf (textBuffer.data (), textBuffer.size (), " %d %d" , MapObj->getVertexX (), MapObj->getVertexY ());
81+ CFont::draw (textBuffer.data (), Position (20 , 20 ), FontSize::Medium);
82+ // text for MinReduceHeight and MaxRaiseHeight
83+ std::snprintf (textBuffer.data (), textBuffer.size (),
84+ " min. height: %#04x/0x3C max. height: %#04x/0x3C NormalNull: 0x0A" ,
85+ MapObj->getMinReduceHeight (), MapObj->getMaxRaiseHeight ());
86+ CFont::draw (textBuffer.data (), Position (100 , 20 ), FontSize::Medium);
87+ // text for MovementLocked
88+ if (MapObj->isHorizontalMovementLocked () && MapObj->isVerticalMovementLocked ())
89+ CFont::draw (" Movement locked (F9 or F10 to unlock)" , Position (20 , 40 ), FontSize::Large, FontColor::Orange);
90+ else if (MapObj->isHorizontalMovementLocked ())
91+ CFont::draw (" Horizontal movement locked (F9 to unlock)" , Position (20 , 40 ), FontSize::Large,
92+ FontColor::Orange);
93+ else if (MapObj->isVerticalMovementLocked ())
94+ CFont::draw (" Vertical movement locked (F10 to unlock)" , Position (20 , 40 ), FontSize::Large,
95+ FontColor::Orange);
8096 }
8197
8298 // render active menus
0 commit comments