Permalink
Browse files

Crash fix for wall drawing when OpenGL is enabled.

  • Loading branch information...
simtr committed Jul 17, 2016
1 parent 5b52585 commit 3b106b7c226e138617a0dbff682b1a0b723d98ac
Showing with 16 additions and 17 deletions.
  1. +16 −17 src/graphics/Renderer.cpp
@@ -63,7 +63,6 @@ void Renderer::RenderBegin()
draw_grav();
DrawWalls();
render_parts();
if(display_mode & DISPLAY_PERS)
{
int i,r,g,b;
@@ -751,14 +750,14 @@ void Renderer::DrawWalls()
for (int j = 0; j < CELL; j++)
for (int i =0; i < CELL; i++)
if (i&j&1)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
}
else
{
for (int j = 0; j < CELL; j++)
for (int i = 0; i < CELL; i++)
if (!(i&j&1))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
}
}
else if (wt == WL_WALLELEC)
@@ -767,9 +766,9 @@ void Renderer::DrawWalls()
for (int i = 0; i < CELL; i++)
{
if (!((y*CELL+j)%2) && !((x*CELL+i)%2))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
else
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x808080);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x808080);
}
}
else if (wt == WL_EHOLE)
@@ -778,16 +777,16 @@ void Renderer::DrawWalls()
{
for (int j = 0; j < CELL; j++)
for (int i = 0; i < CELL; i++)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x242424);
for (int j = 0; j < CELL; j += 2)
for (int i = 0; i < CELL; i += 2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x000000);
}
else
{
for (int j = 0; j < CELL; j += 2)
for (int i =0; i < CELL; i += 2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x242424);
}
}
else if (wt == WL_STREAM)
@@ -837,27 +836,27 @@ void Renderer::DrawWalls()
case 1:
for (int j = 0; j < CELL; j += 2)
for (int i = (j>>1)&1; i < CELL; i += 2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
break;
case 2:
for (int j = 0; j < CELL; j += 2)
for (int i = 0; i < CELL; i += 2)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
break;
case 3:
for (int j = 0; j < CELL; j++)
for (int i = 0; i < CELL; i++)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
break;
case 4:
for (int j = 0; j < CELL; j++)
for (int i = 0; i < CELL; i++)
if (i == j)
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = pc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = pc;
else if (i == j+1 || (i == 0 && j == CELL-1))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = gc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = gc;
else
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x202020);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x202020);
break;
}
@@ -905,7 +904,7 @@ void Renderer::DrawWalls()
for (int j = 0; j < CELL; j += 2)
for (int i = 0; i < CELL; i += 2)
// looks bad if drawing black blobs
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x000000);
}
else
{
@@ -936,10 +935,10 @@ void Renderer::DrawWalls()
if (i == j)
drawblob((x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc));
else if (i == j+1 || (i == 0 && j == CELL-1))
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = gc;
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = gc;
else
// looks bad if drawing black blobs
vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x202020);
vid[(y*CELL+j)*(VIDXRES)+(x*CELL+i)] = PIXPACK(0x202020);
break;
}
}

0 comments on commit 3b106b7

Please sign in to comment.