Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix problems with radar drawing.

  • Loading branch information...
commit 6b274b1a7f3d734d3aa5638594bb3c9e3a27dcc7 1 parent 433942e
@perim perim authored
Showing with 10 additions and 26 deletions.
  1. +4 −16 lib/ivis_opengl/pieblitfunc.cpp
  2. +6 −10 src/radar.cpp
View
20 lib/ivis_opengl/pieblitfunc.cpp
@@ -94,8 +94,8 @@ void GFX::makeTexture(int width, int height, GLenum filter, GLenum format, const
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
mWidth = width;
mHeight = height;
mFormat = format;
@@ -433,20 +433,8 @@ bool pie_ShutdownRadar(void)
void pie_SetRadar(GLfloat x, GLfloat y, GLfloat width, GLfloat height, int twidth, int theight, bool filter)
{
- int w = 1, h = 1;
- char *black;
-
- /* Find power of two size */
- while (twidth > (w *= 2)) {}
- while (theight > (h *= 2)) {}
-
- black = (char *)calloc(1, w * h * 4);
- radarGfx->makeTexture(twidth, theight, filter ? GL_LINEAR : GL_NEAREST, GL_RGBA, black);
- free(black);
-
- GLfloat radarTexX = ((GLfloat)twidth / (GLfloat)w);
- GLfloat radarTexY = ((GLfloat)theight / (GLfloat)h);
- GLfloat texcoords[] = { 0.0f, 0.0f, radarTexX, 0.0f, 0.0f, radarTexY, radarTexX, radarTexY };
+ radarGfx->makeTexture(twidth, theight, filter ? GL_LINEAR : GL_NEAREST);
+ GLfloat texcoords[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f };
GLfloat vertices[] = { x, y, x + width, y, x, y + height, x + width, y + height };
radarGfx->buffers(4, vertices, texcoords);
}
View
16 src/radar.cpp
@@ -261,11 +261,7 @@ void drawRadar(void)
{
float pixSizeH, pixSizeV;
- ASSERT(radarBuffer, "No radar buffer allocated");
- if (!radarBuffer)
- {
- return;
- }
+ ASSERT_OR_RETURN(, radarBuffer, "No radar buffer allocated");
CalcRadarPixelSize(&pixSizeH, &pixSizeV);
@@ -286,11 +282,6 @@ void drawRadar(void)
pie_MatRotZ(player.r.y);
DrawNorth();
}
- // draw the box at the dimensions of the map
- iV_TransBoxFill(-radarWidth/2.0 - 1,
- -radarHeight/2.0 - 1,
- radarWidth/2.0,
- radarHeight/2.0);
pie_RenderRadar();
pie_MatBegin();
pie_TRANSLATE(-radarWidth/2 - 1, -radarHeight/2 - 1, 0);
@@ -407,6 +398,11 @@ static void DrawRadarTiles(void)
size_t pos = radarTexWidth * (y - scrollMinY) + (x - scrollMinX);
ASSERT(pos * sizeof(*radarBuffer) < radarBufferSize, "Buffer overrun");
+ if (y == scrollMinY || x == scrollMinX || y == scrollMaxY - 1 || x == scrollMaxX - 1)
+ {
+ radarBuffer[pos] = WZCOL_BLACK.rgba;
+ continue;
+ }
radarBuffer[pos] = appliedRadarColour(radarDrawMode, psTile).rgba;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.