summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-21 23:58:06 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:15 +0300
commitbb0281c87995e11dc1cac95009a5253356d94d1a (patch)
treee8b0a1f0f1560dd5d4308f9f7a2d48264ac0ea45
parente5521effc043cdf9d781816c0d72bd17830e34f8 (diff)
downloadmanaplus-bb0281c87995e11dc1cac95009a5253356d94d1a.tar.gz
manaplus-bb0281c87995e11dc1cac95009a5253356d94d1a.tar.bz2
manaplus-bb0281c87995e11dc1cac95009a5253356d94d1a.tar.xz
manaplus-bb0281c87995e11dc1cac95009a5253356d94d1a.zip
some SDL2 complilation fixes.
-rw-r--r--src/compoundsprite.cpp6
-rw-r--r--src/graphics.cpp36
-rw-r--r--src/graphics.h1
-rw-r--r--src/graphicsmanager.cpp5
-rw-r--r--src/resources/atlasmanager.cpp6
-rw-r--r--src/sdlshared.h10
6 files changed, 45 insertions, 19 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index bb9b88159..b65d238d4 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -313,6 +313,11 @@ unsigned int CompoundSprite::getFrameCount(unsigned int layer)
void CompoundSprite::redraw() const
{
+#ifdef USE_SDL2
+ // +++ need impliment after
+ return;
+#else
+
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int rmask = 0xff000000;
const int gmask = 0x00ff0000;
@@ -386,6 +391,7 @@ void CompoundSprite::redraw() const
{
mAlphaImage = nullptr;
}
+#endif
}
void CompoundSprite::setAlpha(float alpha)
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 387566013..28d5e09fb 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -106,12 +106,14 @@ void Graphics::setMainFlags(const int w, const int h, const int bpp,
int Graphics::getOpenGLFlags() const
{
#ifdef USE_OPENGL
+
#ifdef USE_SDL2
- int displayFlags = SDL_WINDOW_OPENGL;
+ int displayFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_OPENGL;
if (mFullscreen)
displayFlags |= SDL_WINDOW_FULLSCREEN;
#else
int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
+#endif // USE_SDL2
if (mFullscreen)
{
@@ -131,10 +133,12 @@ int Graphics::getOpenGLFlags() const
displayFlags |= SDL_NOFRAME;
return displayFlags;
-#endif
-#else
+
+#else // USE_OPENGL
+
return 0;
-#endif
+#endif // USE_OPENGL
+
}
bool Graphics::setOpenGLMode()
@@ -203,26 +207,23 @@ bool Graphics::setOpenGLMode()
int Graphics::getSoftwareFlags() const
{
#ifdef USE_SDL2
- int displayFlags = 0;
-
- if (mFullscreen)
- displayFlags |= SDL_FULLSCREEN;
+ int displayFlags = SDL_WINDOW_SHOWN;
#else
int displayFlags = SDL_ANYFORMAT;
- if (mFullscreen)
- displayFlags |= SDL_FULLSCREEN;
- else if (mEnableResize)
- displayFlags |= SDL_RESIZABLE;
-
if (mHWAccel)
displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
else
displayFlags |= SDL_SWSURFACE;
+#endif
+
+ if (mFullscreen)
+ displayFlags |= SDL_FULLSCREEN;
+ else if (mEnableResize)
+ displayFlags |= SDL_RESIZABLE;
if (mNoFrame)
displayFlags |= SDL_NOFRAME;
-#endif
return displayFlags;
}
@@ -261,16 +262,19 @@ int Graphics::getMemoryUsage() const
bool Graphics::videoInfo()
{
- char videoDriverName[65];
logger->log("SDL video info");
+#ifdef USE_SDL2
+ logger->log("Using video driver: %s", SDL_GetCurrentVideoDriver());
+#else
+ char videoDriverName[65];
if (SDL_VideoDriverName(videoDriverName, 64))
logger->log("Using video driver: %s", videoDriverName);
else
logger->log1("Using video driver: unknown");
-
mDoubleBuffer = ((mWindow->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no");
+#endif
imageHelper->dumpSurfaceFormat(mWindow);
diff --git a/src/graphics.h b/src/graphics.h
index c269dc540..cdd5b2e71 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -38,6 +38,7 @@ class ImageVertexes;
class MapLayer;
struct SDL_Surface;
+struct SDL_Window;
static const int defaultScreenWidth = 800;
static const int defaultScreenHeight = 600;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 0d66dc3a7..15eb25af3 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -382,7 +382,12 @@ bool GraphicsManager::getAllVideoModes(StringVect &modeList)
SDL_Window *GraphicsManager::createWindow(const int w, const int h,
const int bpp, const int flags)
{
+#ifdef USE_SDL2
+ return SDL_CreateWindow("ManaPlus", SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED, w, h, flags);
+#else
return SDL_SetVideoMode(w, h, bpp, flags);
+#endif
}
#ifdef USE_OPENGL
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index dd1f7aef3..f6cd23de4 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -200,6 +200,10 @@ void AtlasManager::simpleSort(const std::string &name,
SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
{
+#ifdef USE_SDL2
+ // +++ should be enabled after
+ return nullptr;
+#else
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int rmask = 0xff000000;
const int gmask = 0x00ff0000;
@@ -223,7 +227,6 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
// temp SDL surface for atlas
SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
atlas->width, atlas->height, 32, rmask, gmask, bmask, amask);
-
if (!surface)
return nullptr;
@@ -251,6 +254,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
delete graphics;
atlas->surface = surface;
return surface;
+#endif
}
void AtlasManager::convertAtlas(TextureAtlas *const atlas)
diff --git a/src/sdlshared.h b/src/sdlshared.h
index 70798d441..840283688 100644
--- a/src/sdlshared.h
+++ b/src/sdlshared.h
@@ -23,11 +23,17 @@
#ifdef USE_SDL2
-#define SDLKey SDL_Keycode
#define SDL_GetKeyState SDL_GetKeyboardState
-#define SDL_HWSURFACE 0
+#define SDLKey SDL_Keycode
#define SDL_keysym SDL_Keysym
+#define SDL_ANYFORMAT 0
+#define SDL_HWSURFACE 0
+#define SDL_NOFRAME SDL_WINDOW_BORDERLESS
+#define SDL_RESIZABLE SDL_WINDOW_RESIZABLE
+#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
+#define SDL_OPENGL SDL_WINDOW_OPENGL
+
#define KMOD_META KMOD_GUI
#define SDLK_RMETA SDLK_RGUI
#define SDLK_LMETA SDLK_LGUI