Skip to content

Commit b5984cd

Browse files
committed
Wrap glScissor with glPushAttrib/glPopAttrib to fix game/display capture.
1 parent 070d498 commit b5984cd

7 files changed

+25
-32
lines changed

include/SceneRenderer.h

-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ class SceneRenderer : public Singleton<SceneRenderer>
103103

104104
void setExposed();
105105

106-
void clearRadar(float opacity);
107-
108106
void getGroundUV(const float p[2], float uv[2]) const;
109107

110108
bool getBlank() const;

src/bzflag/ControlPanel.cxx

+2
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ void ControlPanel::render(SceneRenderer& _renderer)
336336
glMatrixMode(GL_MODELVIEW);
337337
glPushMatrix();
338338
glLoadIdentity();
339+
glPushAttrib(GL_SCISSOR_BIT);
339340
OpenGLGState::resetState();
340341

341342
FontManager &fm = FontManager::instance();
@@ -646,6 +647,7 @@ void ControlPanel::render(SceneRenderer& _renderer)
646647

647648
glColor4f(teamColor[0], teamColor[1], teamColor[2],1.0f );
648649

650+
glPopAttrib();
649651
glPopMatrix();
650652

651653
fm.setOpacity(1.0f);

src/bzflag/HUDRenderer.cxx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ void HUDRenderer::renderBox(SceneRenderer&)
14511451
if (true /* always draw heading strip */)
14521452
{
14531453
// first clip to area
1454+
glPushAttrib(GL_SCISSOR_BIT);
14541455
glScissor(ox + centerx - maxMotionSize, oy + height - viewHeight + centery + maxMotionSize - 5,
14551456
2 * maxMotionSize, 25 + (int)(headingFontSize + 0.5f));
14561457

@@ -1570,12 +1571,14 @@ void HUDRenderer::renderBox(SceneRenderer&)
15701571
}
15711572
markers.clear();
15721573
glPopMatrix();
1574+
glPopAttrib();
15731575
}
15741576

15751577
// draw altitude strip
15761578
if (altitudeTape)
15771579
{
15781580
// clip to area
1581+
glPushAttrib(GL_SCISSOR_BIT);
15791582
glScissor(ox + centerx + maxMotionSize - 5, oy + height - viewHeight + centery - maxMotionSize,
15801583
(int)altitudeLabelMaxWidth + 15, 2 * maxMotionSize);
15811584

@@ -1652,6 +1655,8 @@ void HUDRenderer::renderBox(SceneRenderer&)
16521655
y += altitudeMarkSpacing;
16531656
}
16541657
}
1658+
1659+
glPopAttrib();
16551660
}
16561661
}
16571662

@@ -1705,7 +1710,6 @@ void HUDRenderer::setOneToOnePrj()
17051710
const int oy = window.getOriginY();
17061711

17071712
// use one-to-one pixel projection
1708-
glScissor(ox, oy + height - viewHeight, width, viewHeight);
17091713
glMatrixMode(GL_PROJECTION);
17101714
window.setProjectionHUD();
17111715
glMatrixMode(GL_MODELVIEW);

src/bzflag/RadarRenderer.cxx

+7-4
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,15 @@ void RadarRenderer::render(SceneRenderer& renderer, bool blank, bool observer)
380380
return;
381381
}
382382

383+
glPushAttrib(GL_SCISSOR_BIT);
384+
383385
// render the frame
384386
renderFrame(renderer);
385387

386-
if (blank)
387-
return;
388-
389-
if (!world)
388+
if (blank || !world) {
389+
glPopAttrib();
390390
return;
391+
}
391392

392393
smooth = BZDBCache::smooth;
393394
const bool fastRadar = ((BZDBCache::radarStyle == 1) ||
@@ -782,6 +783,8 @@ void RadarRenderer::render(SceneRenderer& renderer, bool blank, bool observer)
782783
}
783784

784785
triangleCount = RenderNode::getTriangleCount();
786+
787+
glPopAttrib();
785788
}
786789

787790

src/bzflag/RadarRenderer.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ class RadarRenderer
4747

4848
void render(SceneRenderer&, bool blank, bool observer);
4949

50-
void renderFrame(SceneRenderer&);
51-
52-
void renderObstacles(bool fastRadar, float range);
53-
void renderWalls();
54-
void renderBoxPyrMesh();
55-
void renderBoxPyrMeshFast(float range);
56-
void renderBasesAndTeles();
57-
5850
int getFrameTriangleCount() const;
5951

6052
private:
@@ -73,6 +65,15 @@ class RadarRenderer
7365
static float colorScale(const float z, const float h);
7466
static float transScale(const float z, const float h);
7567

68+
void renderFrame(SceneRenderer&);
69+
70+
void renderObstacles(bool fastRadar, float range);
71+
void renderWalls();
72+
void renderBoxPyrMesh();
73+
void renderBoxPyrMeshFast(float range);
74+
void renderBasesAndTeles();
75+
76+
7677
private:
7778
World* world;
7879
int x, y;

src/bzflag/SceneRenderer.cxx

+2-10
Original file line numberDiff line numberDiff line change
@@ -468,16 +468,6 @@ void SceneRenderer::setExposed()
468468
}
469469

470470

471-
void SceneRenderer::clearRadar(float opacity)
472-
{
473-
int size = window->getHeight() - window->getViewHeight();
474-
float op = (opacity > 1.0f) ? 1.0f : (opacity < 0.0f) ? 0.0f : opacity;
475-
glScissor(window->getOriginX(), 0, size, size);
476-
glClearColor(0.0f, 0.0f, 0.0f, op);
477-
glClear(GL_COLOR_BUFFER_BIT);
478-
}
479-
480-
481471
void SceneRenderer::setSceneDatabase(SceneDatabase* db)
482472
{
483473
// update the styles
@@ -893,6 +883,7 @@ void SceneRenderer::renderScene(bool UNUSED(_lastFrame), bool UNUSED(_sameFrame)
893883
}
894884

895885
// set scissor
886+
glPushAttrib(GL_SCISSOR_BIT);
896887
glScissor(window->getOriginX(), window->getOriginY() + window->getHeight() - window->getViewHeight(),
897888
window->getWidth(), window->getViewHeight());
898889

@@ -1054,6 +1045,7 @@ void SceneRenderer::renderScene(bool UNUSED(_lastFrame), bool UNUSED(_sameFrame)
10541045
// do depth complexity
10551046
if (useDepthComplexityOn)
10561047
renderDepthComplexity();
1048+
glPopAttrib();
10571049

10581050
return;
10591051
}

src/bzflag/playing.cxx

-7
Original file line numberDiff line numberDiff line change
@@ -5650,11 +5650,6 @@ static void renderDialog()
56505650
{
56515651
if (HUDDialogStack::get()->isActive())
56525652
{
5653-
const int width = mainWindow->getWidth();
5654-
const int height = mainWindow->getHeight();
5655-
const int ox = mainWindow->getOriginX();
5656-
const int oy = mainWindow->getOriginY();
5657-
glScissor(ox, oy, width, height);
56585653
glMatrixMode(GL_PROJECTION);
56595654
mainWindow->setProjectionPlay();
56605655
glMatrixMode(GL_MODELVIEW);
@@ -5698,7 +5693,6 @@ static void renderRoamMouse()
56985693

56995694
glPushAttrib(GL_ALL_ATTRIB_BITS);
57005695

5701-
glScissor(ox, oy, sx, sy);
57025696
glMatrixMode(GL_PROJECTION);
57035697
glPushMatrix();
57045698
mainWindow->setProjectionPlay();
@@ -6546,7 +6540,6 @@ void drawFrame(const float dt)
65466540
mainWindow->getWindow()->getMouse(mx, my);
65476541
my = height - my - 1;
65486542

6549-
glScissor(ox, oy, width, height);
65506543
glMatrixMode(GL_PROJECTION);
65516544
mainWindow->setProjectionPlay();
65526545
glMatrixMode(GL_MODELVIEW);

0 commit comments

Comments
 (0)