summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-11 01:52:35 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-13 22:17:00 +0300
commit7ad6bc89291c198122f087a11fd9ab585ea87034 (patch)
tree5b88547634c99dfd549b50fe3491e56a71f48304
parent4e12e0514a3ade4f693c49353c369028481999d1 (diff)
downloadmv-7ad6bc89291c198122f087a11fd9ab585ea87034.tar.gz
mv-7ad6bc89291c198122f087a11fd9ab585ea87034.tar.bz2
mv-7ad6bc89291c198122f087a11fd9ab585ea87034.tar.xz
mv-7ad6bc89291c198122f087a11fd9ab585ea87034.zip
Some changes in screenshot code.
-rw-r--r--src/actionmanager.cpp2
-rw-r--r--src/game.cpp9
-rw-r--r--src/game.h4
-rw-r--r--src/graphicsmanager.cpp34
-rw-r--r--src/graphicsmanager.h2
5 files changed, 39 insertions, 12 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index a1303773a..45d0fd0ac 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -853,7 +853,7 @@ impHandler0(changeTrade)
impHandler0(screenshot)
{
- Game::saveScreenshot();
+ Game::createScreenshot();
return true;
}
diff --git a/src/game.cpp b/src/game.cpp
index 2314940d8..f0cf1e290 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -469,9 +469,8 @@ Game::~Game()
DepricatedEvent(EVENT_DESTRUCTED));
}
-bool Game::saveScreenshot()
+bool Game::createScreenshot()
{
- static unsigned int screenshotCount = 0;
SDL_Surface *screenshot = nullptr;
if (!config.getBoolValue("showip"))
@@ -490,6 +489,12 @@ bool Game::saveScreenshot()
if (!screenshot)
return false;
+ return saveScreenshot(screenshot);
+}
+
+bool Game::saveScreenshot(SDL_Surface *screenshot)
+{
+ static unsigned int screenshotCount = 0;
// Search for an unused screenshot name
std::stringstream filenameSuffix;
std::stringstream filename;
diff --git a/src/game.h b/src/game.h
index ec49fafe1..e0c752f46 100644
--- a/src/game.h
+++ b/src/game.h
@@ -111,7 +111,9 @@ class Game
bool getValidSpeed()
{ return mValidSpeed; }
- static bool saveScreenshot();
+ static bool createScreenshot();
+
+ static bool saveScreenshot(SDL_Surface *screenshot);
private:
void updateHistory(SDL_Event &event);
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index b14ec1688..14ea31447 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -196,6 +196,24 @@ void GraphicsManager::initGraphics(bool noOpenGL)
#endif
}
+Graphics *GraphicsManager::createGraphics()
+{
+#ifdef USE_OPENGL
+ switch (config.getIntValue("opengl"))
+ {
+ case 0:
+ return new Graphics;
+ case 1:
+ default:
+ return new NormalOpenGLGraphics;
+ case 2:
+ return new SafeOpenGLGraphics;
+ };
+#else
+ return new Graphics;
+#endif
+}
+
void GraphicsManager::updateExtensions(const char *extensions)
{
mExtensions.clear();
@@ -355,14 +373,14 @@ void GraphicsManager::createFBO(int width, int height, FBOInfo *fbo)
// create a texture object
glGenTextures(1, &fbo->textureId);
- glBindTexture(GL_TEXTURE_2D, fbo->textureId);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0,
+ glBindTexture(OpenGLImageHelper::mTextureType, fbo->textureId);
+ glTexParameterf(OpenGLImageHelper::mTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(OpenGLImageHelper::mTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(OpenGLImageHelper::mTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(OpenGLImageHelper::mTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexImage2D(OpenGLImageHelper::mTextureType, 0, GL_RGBA8, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
- glBindTexture(GL_TEXTURE_2D, 0);
+ glBindTexture(OpenGLImageHelper::mTextureType, 0);
// create a renderbuffer object to store depth info
mglGenRenderbuffers(1, &fbo->rboId);
@@ -377,7 +395,7 @@ void GraphicsManager::createFBO(int width, int height, FBOInfo *fbo)
// attach the texture to FBO color attachment point
mglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, fbo->textureId, 0);
+ OpenGLImageHelper::mTextureType, fbo->textureId, 0);
// attach the renderbuffer to depth attachment point
mglFramebufferRenderbuffer(GL_FRAMEBUFFER,
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 9b7a40a29..c7e8ead6a 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -63,6 +63,8 @@ class GraphicsManager
void initOpenGLFunctions();
+ Graphics *createGraphics();
+
private:
std::set<std::string> mExtensions;