summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
committerReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
commit490862919d79369112c75955a9c36ff8a081efd3 (patch)
tree6fe89466b9c53ba811f298174e6d787bbae71e09 /src/graphics.cpp
parentdff814619d63496acd3c4e8730b828b5d4d931fb (diff)
parentd873da3e8e57480016596f714845c1bc7e712e68 (diff)
downloadmv-490862919d79369112c75955a9c36ff8a081efd3.tar.gz
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.bz2
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.xz
mv-490862919d79369112c75955a9c36ff8a081efd3.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index e98b1a283..e6841fa5c 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -112,7 +112,7 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs,
if (mTarget->format)
{
logger->log("Bits per pixel: %d", mTarget->format->BytesPerPixel);
- bpp = mTarget->format->BytesPerPixel;
+// bpp = mTarget->format->BytesPerPixel;
}
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
@@ -845,7 +845,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
case 1:
for (y = y1; y < y2; y++)
{
- Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
+ Uint8 *p = static_cast<Uint8 *>(mTarget->pixels)
+ + y * mTarget->pitch;
for (x = x1; x < x2; x++)
*(p + x) = pixel;
}
@@ -853,12 +854,14 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
case 2:
for (y = y1; y < y2; y++)
{
- Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
+ Uint8 *p0 = static_cast<Uint8 *>(mTarget->pixels)
+ + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
Uint8 *p = p0 + x * 2;
- *(Uint16 *)p = gcn::SDLAlpha16(
- pixel, *(Uint32 *)p, mColor.a, mTarget->format);
+ *reinterpret_cast<Uint16 *>(p) = gcn::SDLAlpha16(
+ pixel, *reinterpret_cast<Uint32 *>(p),
+ mColor.a, mTarget->format);
}
}
break;
@@ -871,7 +874,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
for (y = y1; y < y2; y++)
{
- Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
+ Uint8 *p0 = static_cast<Uint8 *>(mTarget->pixels)
+ + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
Uint8 *p = p0 + x * 3;
@@ -896,18 +900,19 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
const unsigned a1 = (255 - mColor.a);
for (y = y1; y < y2; y++)
{
- Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
+ Uint8 *p0 = static_cast<Uint8 *>(mTarget->pixels)
+ + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
Uint8 *p = p0 + x * 4;
- Uint32 dst = *(Uint32 *)p;
+ Uint32 dst = *reinterpret_cast<Uint32 *>(p);
const unsigned int b = (pb + (dst & 0xff) * a1) >> 8;
const unsigned int g = (pg + (dst & 0xff00) * a1) >> 8;
const unsigned int r = (pr
+ (dst & 0xff0000) * a1) >> 8;
- *(Uint32 *)p = ((b & 0xff) | (g & 0xff00)
- | (r & 0xff0000));
+ *reinterpret_cast<Uint32 *>(p) = ((b & 0xff)
+ | (g & 0xff00) | (r & 0xff0000));
}
}
break;