summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-22 14:47:53 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:15 +0300
commit5e4fcb8a6036746ec1b500297fa55989a80094b4 (patch)
tree915d788dcaf3bc39bed6985236fb879c3c93f6cb
parent2480ea4cc668ff99007dd6fb8b44911eea5d5287 (diff)
downloadplus-5e4fcb8a6036746ec1b500297fa55989a80094b4.tar.gz
plus-5e4fcb8a6036746ec1b500297fa55989a80094b4.tar.bz2
plus-5e4fcb8a6036746ec1b500297fa55989a80094b4.tar.xz
plus-5e4fcb8a6036746ec1b500297fa55989a80094b4.zip
final SDL2 compilation fixes.
now it can be compiled, but still not works.
-rwxr-xr-xconfigure.ac9
-rw-r--r--src/client.cpp3
-rw-r--r--src/graphics.cpp13
-rw-r--r--src/graphics.h5
-rw-r--r--src/graphicsmanager.cpp9
-rw-r--r--src/graphicsmanager.h6
-rw-r--r--src/sdl2graphics.cpp72
-rw-r--r--src/soundmanager.cpp6
8 files changed, 88 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac
index 8abb9d82a..756160ce8 100755
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,9 @@ if test "x$with_sdl2" == "xyes"; then
# using embedded sdl2gfx
CPPFLAGS="$CPPFLAGS -I./sdl2gfx"
+ AC_CHECK_LIB(SDL2_net, SDLNet_Init, ,
+ AC_MSG_ERROR([ *** Unable to find SDL2_net library]))
+
with_sdl2=yes
else
AC_PATH_PROG(SDL_CONFIG, sdl-config)
@@ -87,6 +90,9 @@ else
AC_MSG_ERROR([ *** Unable to find SDL_gfx library (http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx)]))
AC_CHECK_HEADERS(SDL_rotozoom.h, ,)
+ AC_CHECK_LIB(SDL_net, SDLNet_Init, ,
+ AC_MSG_ERROR([ *** Unable to find SDL_net library]))
+
with_sdl2=no
fi
@@ -239,9 +245,6 @@ fi
AM_CONDITIONAL(USE_MUMBLE, test x$with_mumble = xyes)
-AC_CHECK_LIB(SDL_net, SDLNet_Init, ,
-AC_MSG_ERROR([ *** Unable to find SDL_net library]))
-
AC_ARG_WITH(librt,[ --without-librt don't link to librt ] )
if test "x$with_librt" == "xno"; then
without_librt=yes
diff --git a/src/client.cpp b/src/client.cpp
index 7c04e807e..aeee05c1f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2906,7 +2906,8 @@ void Client::applyGamma()
{
const float val = config.getFloatValue("gamma");
#ifdef USE_SDL2
- SDL_SetWindowBrightness(mWindow, val);
+ if (mainGraphics)
+ SDL_SetWindowBrightness(mainGraphics->getWindow(), val);
#else
SDL_SetGamma(val, val, val);
#endif
diff --git a/src/graphics.cpp b/src/graphics.cpp
index d1d5a9590..e08304b24 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -53,6 +53,9 @@ Graphics::Graphics() :
mWidth(0),
mHeight(0),
mWindow(nullptr),
+#ifdef USE_SDL2
+ mRenderer(nullptr),
+#endif
mBpp(0),
mAlpha(false),
mFullscreen(false),
@@ -153,8 +156,18 @@ bool Graphics::setOpenGLMode()
return false;
}
+#ifdef USE_SDL2
+ int w1 = 0;
+ int h1 = 0;
+ SDL_GetWindowSize(mWindow, &w1, &h1);
+ mRect.w = w1;
+ mRect.h = h1;
+
+ mRenderer = graphicsManager.createRenderer(mWindow, 0);
+#else
mRect.w = static_cast<uint16_t>(mWindow->w);
mRect.h = static_cast<uint16_t>(mWindow->h);
+#endif
#ifdef __APPLE__
if (mSync)
diff --git a/src/graphics.h b/src/graphics.h
index 04234d415..a90e1d0e7 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -392,7 +392,10 @@ class Graphics : public gcn::Graphics
bool videoInfo();
- SDL_Window* mWindow;
+ SDL_Window *mWindow;
+#ifdef USE_SDL2
+ SDL_Renderer *mRenderer;
+#endif
int mBpp;
bool mAlpha;
bool mFullscreen;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 25131957f..0e0ac4fa3 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -360,6 +360,15 @@ SDL_Window *GraphicsManager::createWindow(const int w, const int h,
#endif
}
+#ifdef USE_SDL2
+SDL_Renderer *GraphicsManager::createRenderer(SDL_Window *const window,
+ const int flags)
+{
+ // +++ need use different drivers and different flags
+ return SDL_CreateRenderer(window, -1, flags);
+}
+#endif
+
#ifdef USE_OPENGL
void GraphicsManager::updateExtensions()
{
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 40e323c60..cca1e5898 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -52,6 +52,7 @@ class Graphics;
class TestMain;
struct FBOInfo;
+struct SDL_Renderer;
struct SDL_Window;
enum ScreenDensity
@@ -81,6 +82,11 @@ class GraphicsManager final
SDL_Window *createWindow(const int w, const int h,
const int bpp, const int flags);
+#ifdef USE_SDL2
+ SDL_Renderer *createRenderer(SDL_Window *const window,
+ const int flags);
+#endif
+
bool getAllVideoModes(StringVect &modeList);
void detectPixelSize();
diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp
index a2fc010f6..09b52470b 100644
--- a/src/sdl2graphics.cpp
+++ b/src/sdl2graphics.cpp
@@ -35,14 +35,17 @@
#include <guichan/sdl/sdlpixel.hpp>
-#include <SDL_gfxBlitFunc.h>
+#include <SDL.h>
+
+//#include <SDL_gfxBlitFunc.h>
#include "debug.h"
int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
- return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect);
+ return 0;
+// return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect);
}
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
@@ -100,8 +103,9 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, int srcX, int srcY
srcRect.w = static_cast<uint16_t>(width);
srcRect.h = static_cast<uint16_t>(height);
- const bool returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface,
- &srcRect, mWindow, &dstRect) < 0);
+ const bool returnValue(true);
+// const bool returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface,
+// &srcRect, mWindow, &dstRect) < 0);
delete tmpImage;
@@ -132,6 +136,8 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY,
srcRect.w = static_cast<uint16_t>(width);
srcRect.h = static_cast<uint16_t>(height);
+ return true;
+/*
if (mBlitMode == BLIT_NORMAL)
{
return !(SDL_BlitSurface(image->mSDLSurface, &srcRect,
@@ -142,6 +148,7 @@ bool SDLGraphics::drawImage2(const Image *const image, int srcX, int srcY,
return !(SDL_gfxBlitRGBA(image->mSDLSurface, &srcRect,
mWindow, &dstRect) < 0);
}
+*/
}
void SDLGraphics::drawImagePattern(const Image *const image,
@@ -182,7 +189,7 @@ void SDLGraphics::drawImagePattern(const Image *const image,
srcRect.w = static_cast<uint16_t>(dw);
srcRect.h = static_cast<uint16_t>(dh);
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
+// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
}
}
}
@@ -234,8 +241,8 @@ void SDLGraphics::drawRescaledImagePattern(const Image *const image,
srcRect.w = static_cast<uint16_t>(dw);
srcRect.h = static_cast<uint16_t>(dh);
- SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
- mWindow, &dstRect);
+// SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
+// mWindow, &dstRect);
}
}
@@ -279,12 +286,14 @@ void SDLGraphics::calcImagePattern(ImageVertexes* const vert,
srcRect.w = static_cast<uint16_t>(dw);
srcRect.h = static_cast<uint16_t>(dh);
+/*
if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect,
mWindow, &dstRect) == 1)
{
vert->sdl.push_back(r);
}
else
+*/
{
delete r;
}
@@ -341,12 +350,14 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const
rect->src.y = static_cast<int16_t>(image->mBounds.y);
rect->src.w = static_cast<uint16_t>(image->mBounds.w);
rect->src.h = static_cast<uint16_t>(image->mBounds.h);
+/*
if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src,
mWindow, &rect->dst) == 1)
{
vert->sdl.push_back(rect);
}
else
+*/
{
delete rect;
}
@@ -384,8 +395,8 @@ void SDLGraphics::drawTile(const ImageCollection *const vertCol)
const DoubleRects::const_iterator it2_end = rects->end();
while (it2 != it2_end)
{
- SDL_LowerBlit(img->mSDLSurface, &(*it2)->src,
- mWindow, &(*it2)->dst);
+// SDL_LowerBlit(img->mSDLSurface, &(*it2)->src,
+// mWindow, &(*it2)->dst);
++ it2;
}
}
@@ -400,7 +411,7 @@ void SDLGraphics::drawTile(const ImageVertexes *const vert)
const DoubleRects::const_iterator it_end = rects->end();
while (it != it_end)
{
- SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mWindow, &(*it)->dst);
+// SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mWindow, &(*it)->dst);
++ it;
}
}
@@ -408,15 +419,7 @@ void SDLGraphics::drawTile(const ImageVertexes *const vert)
void SDLGraphics::updateScreen()
{
BLOCK_START("Graphics::updateScreen")
- if (mDoubleBuffer)
- {
- SDL_Flip(mWindow);
- }
- else
- {
- SDL_UpdateRects(mWindow, 1, &mRect);
-// SDL_UpdateRect(mWindow, 0, 0, 0, 0);
- }
+ SDL_RenderPresent(mRenderer);
BLOCK_END("Graphics::updateScreen")
}
@@ -436,8 +439,8 @@ SDL_Surface *SDLGraphics::getScreenshot()
SDL_Surface *const screenshot = SDL_CreateRGBSurface(SDL_SWSURFACE,
mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
- if (screenshot)
- SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
+// if (screenshot)
+// SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
return screenshot;
}
@@ -482,9 +485,9 @@ bool SDLGraphics::calcWindow(ImageCollection *const vertCol,
}
int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
- SDL_Rect *const srcrect,
- const SDL_Surface *const dst,
- SDL_Rect *dstrect) const
+ SDL_Rect *const srcrect,
+ const SDL_Surface *const dst,
+ SDL_Rect *dstrect) const
{
SDL_Rect fulldst;
int srcx, srcy, w, h;
@@ -578,7 +581,6 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
dstrect->h = static_cast<int16_t>(h);
return 1;
-// return SDL_LowerBlit(src, &sr, dst, dstrect);
}
dstrect->w = dstrect->h = 0;
return 0;
@@ -586,6 +588,7 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src,
void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
{
+/*
FUNC_BLOCK("Graphics::fillRectangle", 1)
if (mClipStack.empty())
return;
@@ -778,6 +781,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
static_cast<int8_t>(mColor.a));
SDL_FillRect(mWindow, &rect, color);
}
+*/
}
void SDLGraphics::_beginDraw()
@@ -800,7 +804,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area)
rect.y = static_cast<int16_t>(carea.y);
rect.w = static_cast<int16_t>(carea.width);
rect.h = static_cast<int16_t>(carea.height);
- SDL_SetClipRect(mWindow, &rect);
+// SDL_SetClipRect(mWindow, &rect);
return result;
}
@@ -819,7 +823,7 @@ void SDLGraphics::popClipArea()
rect.w = static_cast<int16_t>(carea.width);
rect.h = static_cast<int16_t>(carea.height);
- SDL_SetClipRect(mWindow, &rect);
+// SDL_SetClipRect(mWindow, &rect);
}
void SDLGraphics::drawPoint(int x, int y)
@@ -835,14 +839,17 @@ void SDLGraphics::drawPoint(int x, int y)
if (!top.isPointInRect(x, y))
return;
+/*
if (mAlpha)
SDLputPixelAlpha(mWindow, x, y, mColor);
else
SDLputPixel(mWindow, x, y, mColor);
+*/
}
void SDLGraphics::drawHLine(int x1, int y, int x2)
{
+/*
if (mClipStack.empty())
return;
@@ -965,10 +972,12 @@ void SDLGraphics::drawHLine(int x1, int y, int x2)
} // end switch
SDL_UnlockSurface(mWindow);
+*/
}
void SDLGraphics::drawVLine(int x, int y1, int y2)
{
+/*
if (mClipStack.empty())
return;
@@ -1100,6 +1109,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2)
} // end switch
SDL_UnlockSurface(mWindow);
+*/
}
void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle)
@@ -1146,9 +1156,13 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
return false;
}
- mRect.w = static_cast<uint16_t>(mWindow->w);
- mRect.h = static_cast<uint16_t>(mWindow->h);
+ int w1 = 0;
+ int h1 = 0;
+ SDL_GetWindowSize(mWindow, &w1, &h1);
+ mRect.w = w1;
+ mRect.h = h1;
+ mRenderer = graphicsManager.createRenderer(mWindow, 0);
return videoInfo();
}
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 72a7d26c2..8575edd2b 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -165,7 +165,6 @@ void SoundManager::init()
void SoundManager::info() const
{
SDL_version compiledVersion;
- char driver[40] = "Unknown";
const char *format = "Unknown";
int rate = 0;
uint16_t audioFormat = 0;
@@ -174,7 +173,12 @@ void SoundManager::info() const
MIX_VERSION(&compiledVersion);
const SDL_version *const linkedVersion = Mix_Linked_Version();
+#ifdef USE_SDL2
+ const char *driver = SDL_GetCurrentAudioDriver();
+#else
+ char driver[40] = "Unknown";
SDL_AudioDriverName(driver, 40);
+#endif
Mix_QuerySpec(&rate, &audioFormat, &channels);
switch (audioFormat)