From 8fe9c1d9f046aa6d746ab075b3056d75898d1f2c Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 7 Sep 2011 23:09:28 -0700 Subject: Changes need to build without OpenGL --- src/CMakeLists.txt | 1 + src/openglgraphics.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 35af94fb..7b64d404 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -649,6 +649,7 @@ TARGET_LINK_LIBRARIES(mana ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} ${GUICHAN_LIBRARIES} + ${X11_LIBRARIES} ${OPENGL_LIBRARIES} ${LIBINTL_LIBRARIES} ${EXTRA_LIBRARIES}) diff --git a/src/openglgraphics.h b/src/openglgraphics.h index ee96e19c..73adbdc1 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -30,7 +30,6 @@ #define NO_SDL_GLEXT #include -#endif class OpenGLGraphics : public Graphics { @@ -129,5 +128,6 @@ class OpenGLGraphics : public Graphics bool mColorAlpha; bool mSync; }; +#endif //USE_OPENGL #endif -- cgit v1.2.3-70-g09d2 From 248a274ec6c6e4b5e1f1eb76cf4c6f8b43ac02d3 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 11 Sep 2011 11:17:00 +0200 Subject: Bumped version to 0.5.3 and updated the NEWS file --- CMakeLists.txt | 2 +- NEWS | 5 +++++ README | 2 +- data/help/changes.txt | 13 +++++-------- data/help/header.txt | 4 ++-- src/main.h | 2 +- src/winver.h | 4 ++-- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a139d66..ba1f306a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ CMAKE_POLICY(VERSION 2.6) PROJECT(MANA) IF (NOT VERSION) - SET(VERSION 0.5.2) + SET(VERSION 0.5.3) ENDIF() STRING(REPLACE "." " " _VERSION ${VERSION}) diff --git a/NEWS b/NEWS index cca5d461..cabbbd44 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +0.5.3 (11 September 2011) +- Fixed endless loop when a sprite definition promises too many images +- Fixed crash when selecting a character that has a Dark Talisman equipped +- Fixed building without OpenGL + 0.5.2 (17 April 2011) - Removed NPC "Thanks for buying/selling" messages from the chat - Added a few missing authentication failure reasons diff --git a/README b/README index 6e62d537..a3b0258f 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ THE MANA CLIENT =============== - Version: 0.5.2 Date: 2011-04-17 + Version: 0.5.3 Date: 2011-09-11 Development team: - See AUTHORS file for a list diff --git a/data/help/changes.txt b/data/help/changes.txt index 2453a608..33fb2845 100644 --- a/data/help/changes.txt +++ b/data/help/changes.txt @@ -3,6 +3,11 @@ ##3 === RECENT CHANGES === + 0.5.3 (11 September 2011) + - Fixed endless loop when a sprite definition promises too many images + - Fixed crash when selecting a character that has a Dark Talisman equipped + - Fixed building without OpenGL + 0.5.2 (17 April 2011) - Removed NPC "Thanks for buying/selling" messages from the chat - Added a few missing authentication failure reasons @@ -142,11 +147,3 @@ - Fixed inability to chat while talking to NPCs - Updated Swedish translation - 0.0.28 (25 January 2009) - - Added support for animated map tiles - - Added support for internationalization, plus many translations - - Added support for TrueType fonts - - Trade window is now resizable - - Obscure precise home directory name when making screenshots - - Fixed follow-parent of nested and being-following particle emitters - diff --git a/data/help/header.txt b/data/help/header.txt index 505ae25c..52ecedae 100644 --- a/data/help/header.txt +++ b/data/help/header.txt @@ -1,8 +1,8 @@ -##1 M A N A S O U R C E +##1 M A N A C L I E N T ##1 ========================================== - ##2Version:##6 0.5.2 ##2Date:##3 17 April 2011 + ##2Version:##6 0.5.3 ##2Date:##3 11 September 2011 ##2 Website: http://manasource.org diff --git a/src/main.h b/src/main.h index b1db3258..681fd9c8 100644 --- a/src/main.h +++ b/src/main.h @@ -55,7 +55,7 @@ #elif defined WIN32 #include "winver.h" #elif defined __APPLE__ -#define PACKAGE_VERSION "0.5.2" +#define PACKAGE_VERSION "0.5.3" #endif #ifdef PACKAGE_VERSION diff --git a/src/winver.h b/src/winver.h index 89b7004f..7f9d3f8d 100644 --- a/src/winver.h +++ b/src/winver.h @@ -1,6 +1,6 @@ /* VERSION DEFINITIONS */ #define VER_MAJOR 0 #define VER_MINOR 5 -#define VER_RELEASE 2 +#define VER_RELEASE 3 #define VER_BUILD 0 -#define PACKAGE_VERSION "0.5.2.0" +#define PACKAGE_VERSION "0.5.3.0" -- cgit v1.2.3-70-g09d2 From 6ed5449ea0b8e7356304dd4f6705dcc0ac11647e Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 11 Sep 2011 11:58:50 +0200 Subject: Fixed drawing glitch with overwide tiles The layer rendering code was not prepared to handle tiles that were wider than the tile width of the map. This commit also fixes the initialization of the maximum tile height, which was based on the map height rather than the tile height. This could slightly reduce overdraw for some maps. Reviewed-by: Stefan Beller --- NEWS | 1 + src/map.cpp | 13 +++++++++---- src/map.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index cabbbd44..97478837 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 0.5.3 (11 September 2011) - Fixed endless loop when a sprite definition promises too many images - Fixed crash when selecting a character that has a Dark Talisman equipped +- Fixed drawing glitch with overwide tiles - Fixed building without OpenGL 0.5.2 (17 April 2011) diff --git a/src/map.cpp b/src/map.cpp index f845f2ff..9e6d865d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -120,8 +120,10 @@ Image* MapLayer::getTile(int x, int y) const return mTiles[x + y * mWidth]; } -void MapLayer::draw(Graphics *graphics, int startX, int startY, - int endX, int endY, int scrollX, int scrollY, +void MapLayer::draw(Graphics *graphics, + int startX, int startY, + int endX, int endY, + int scrollX, int scrollY, const MapSprites &sprites, int debugFlags) const { startX -= mX; @@ -178,7 +180,8 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY, Map::Map(int width, int height, int tileWidth, int tileHeight): mWidth(width), mHeight(height), mTileWidth(tileWidth), mTileHeight(tileHeight), - mMaxTileHeight(height), + mMaxTileHeight(tileHeight), + mMaxTileWidth(tileWidth), mDebugFlags(MAP_NORMAL), mOnClosedList(1), mOnOpenList(2), mLastScrollX(0.0f), mLastScrollY(0.0f) @@ -281,6 +284,8 @@ void Map::addTileset(Tileset *tileset) if (tileset->getHeight() > mMaxTileHeight) mMaxTileHeight = tileset->getHeight(); + if (tileset->getWidth() > mMaxTileWidth) + mMaxTileWidth = tileset->getWidth(); } bool spriteCompare(const Sprite *a, const Sprite *b) @@ -304,7 +309,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) // Calculate range of tiles which are on-screen int endPixelY = graphics->getHeight() + scrollY + mTileHeight - 1; endPixelY += mMaxTileHeight - mTileHeight; - int startX = scrollX / mTileWidth; + int startX = (scrollX - mMaxTileWidth + mTileWidth) / mTileWidth; int startY = scrollY / mTileHeight; int endX = (graphics->getWidth() + scrollX + mTileWidth - 1) / mTileWidth; int endY = endPixelY / mTileHeight; diff --git a/src/map.h b/src/map.h index 9fc32232..2e0eb614 100644 --- a/src/map.h +++ b/src/map.h @@ -360,7 +360,7 @@ class Map : public Properties int mWidth, mHeight; int mTileWidth, mTileHeight; - int mMaxTileHeight; + int mMaxTileHeight, mMaxTileWidth; MetaTile *mMetaTiles; Layers mLayers; Tilesets mTilesets; -- cgit v1.2.3-70-g09d2 From 965cad21750b45206ceea4523d94b7ec92bb8ac6 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 11 Sep 2011 14:25:36 +0200 Subject: Fixed OpenGLGraphics::drawRescaledImagePattern This fixes overlay effects that are meant to scale with screen resolution. The problem was that the texture coordinates were not calculated correctly. They were adjusted to the scaled size of the image, and when scaling both the vertex and the texture coordinates, the image will simply not appear scaled at all. Now the texture coordinates are calculated based on the visible part of the original texture. There was also a problem with the vertex coordinates, which were not taking into account the visible part of the image. TMW-Mantis-issue: 1047 Reviewed-by: Andrei Karas --- NEWS | 1 + src/openglgraphics.cpp | 77 +++++++++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 97478837..a6ebfce8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ - Fixed endless loop when a sprite definition promises too many images - Fixed crash when selecting a character that has a Dark Talisman equipped - Fixed drawing glitch with overwide tiles +- Fixed scaling of overlays in OpenGL mode - Fixed building without OpenGL 0.5.2 (17 April 2011) diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 7818e9d2..33346b47 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -480,24 +480,26 @@ void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h) static_cast(mColor.a)); } -void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y, - int w, int h, int scaledWidth, +void OpenGLGraphics::drawRescaledImagePattern(Image *image, + int x, int y, + int w, int h, + int scaledWidth, int scaledHeight) { if (!image) return; + if (scaledWidth == 0 || scaledHeight == 0) + return; + const int srcX = image->mBounds.x; const int srcY = image->mBounds.y; - const int iw = scaledWidth; - const int ih = scaledHeight; + const int iw = image->getWidth(); + const int ih = image->getHeight(); if (iw == 0 || ih == 0) return; - const float tw = static_cast(image->getTextureWidth()); - const float th = static_cast(image->getTextureHeight()); - glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha); bindTexture(Image::mTextureType, image->mGLImage); @@ -507,23 +509,31 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y, unsigned int vp = 0; const unsigned int vLimit = vertexBufSize * 4; - float texX1 = static_cast(srcX) / tw; - float texY1 = static_cast(srcY) / th; - // Draw a set of textured rectangles if (image->getTextureType() == GL_TEXTURE_2D) { - for (int py = 0; py < h; py += ih) + const float tw = static_cast(image->getTextureWidth()); + const float th = static_cast(image->getTextureHeight()); + + const float texX1 = static_cast(srcX) / tw; + const float texY1 = static_cast(srcY) / th; + + const float tFractionW = iw / tw; + const float tFractionH = ih / th; + + for (int py = 0; py < h; py += scaledHeight) { - const int height = (py + ih >= h) ? h - py : ih; + const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; const int dstY = y + py; - for (int px = 0; px < w; px += iw) + for (int px = 0; px < w; px += scaledWidth) { - int width = (px + iw >= w) ? w - px : iw; + int width = (px + scaledWidth >= w) ? w - px : scaledWidth; int dstX = x + px; + const float visibleFractionW = (float) width / scaledWidth; + const float visibleFractionH = (float) height / scaledHeight; - float texX2 = static_cast(srcX + width) / tw; - float texY2 = static_cast(srcY + height) / th; + const float texX2 = texX1 + tFractionW * visibleFractionW; + const float texY2 = texY1 + tFractionH * visibleFractionH; mFloatTexArray[vp + 0] = texX1; mFloatTexArray[vp + 1] = texY1; @@ -540,14 +550,14 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y, mIntVertArray[vp + 0] = dstX; mIntVertArray[vp + 1] = dstY; - mIntVertArray[vp + 2] = dstX + scaledWidth; + mIntVertArray[vp + 2] = dstX + width; mIntVertArray[vp + 3] = dstY; - mIntVertArray[vp + 4] = dstX + scaledWidth; - mIntVertArray[vp + 5] = dstY + scaledHeight; + mIntVertArray[vp + 4] = dstX + width; + mIntVertArray[vp + 5] = dstY + height; mIntVertArray[vp + 6] = dstX; - mIntVertArray[vp + 7] = dstY + scaledHeight; + mIntVertArray[vp + 7] = dstY + height; vp += 8; if (vp >= vLimit) @@ -562,38 +572,41 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, int x, int y, } else { - for (int py = 0; py < h; py += ih) + const float scaleFactorW = (float) scaledWidth / iw; + const float scaleFactorH = (float) scaledHeight / ih; + + for (int py = 0; py < h; py += scaledHeight) { - const int height = (py + ih >= h) ? h - py : ih; + const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; const int dstY = y + py; - for (int px = 0; px < w; px += iw) + for (int px = 0; px < w; px += scaledWidth) { - int width = (px + iw >= w) ? w - px : iw; + int width = (px + scaledWidth >= w) ? w - px : scaledWidth; int dstX = x + px; mIntTexArray[vp + 0] = srcX; mIntTexArray[vp + 1] = srcY; - mIntTexArray[vp + 2] = srcX + width; + mIntTexArray[vp + 2] = srcX + width / scaleFactorW; mIntTexArray[vp + 3] = srcY; - mIntTexArray[vp + 4] = srcX + width; - mIntTexArray[vp + 5] = srcY + height; + mIntTexArray[vp + 4] = srcX + width / scaleFactorW; + mIntTexArray[vp + 5] = srcY + height / scaleFactorH; mIntTexArray[vp + 6] = srcX; - mIntTexArray[vp + 7] = srcY + height; + mIntTexArray[vp + 7] = srcY + height / scaleFactorH; mIntVertArray[vp + 0] = dstX; mIntVertArray[vp + 1] = dstY; - mIntVertArray[vp + 2] = dstX + scaledWidth; + mIntVertArray[vp + 2] = dstX + width; mIntVertArray[vp + 3] = dstY; - mIntVertArray[vp + 4] = dstX + scaledWidth; - mIntVertArray[vp + 5] = dstY + scaledHeight; + mIntVertArray[vp + 4] = dstX + width; + mIntVertArray[vp + 5] = dstY + height; mIntVertArray[vp + 6] = dstX; - mIntVertArray[vp + 7] = dstY + scaledHeight; + mIntVertArray[vp + 7] = dstY + height; vp += 8; if (vp >= vLimit) -- cgit v1.2.3-70-g09d2