summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphics.cpp7
-rw-r--r--src/graphics.h3
-rw-r--r--src/graphicsmanager.cpp36
-rw-r--r--src/graphicsmanager.h9
-rw-r--r--src/graphicsvertexes.cpp1
-rw-r--r--src/gui/socialwindow.cpp2
-rw-r--r--src/normalopenglgraphics.cpp44
-rw-r--r--src/normalopenglgraphics.h6
8 files changed, 81 insertions, 27 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 384bc2341..19c53c83a 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -166,11 +166,8 @@ bool Graphics::setOpenGLMode()
logger->log("Using OpenGL %s double buffering.",
(gotDoubleBuffer ? "with" : "without"));
- graphicsManager.setGLVersion();
- graphicsManager.initOpenGLFunctions();
- graphicsManager.updateExtensions();
- graphicsManager.updatePlanformExtensions();
-
+ graphicsManager.initOpenGL();
+ initArrays();
graphicsManager.updateTextureFormat();
updateMemoryInfo();
diff --git a/src/graphics.h b/src/graphics.h
index ce3a6ea2a..51f0a708a 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -305,6 +305,9 @@ class Graphics : public gcn::SDLGraphics
const std::string &getName() const
{ return mName; }
+ virtual void initArrays()
+ { }
+
int mWidth;
int mHeight;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 86814b4be..66502434d 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -54,7 +54,8 @@ GraphicsManager::GraphicsManager() :
mMinor(0),
mMajor(0),
mPlatformMinor(0),
- mPlatformMajor(0)
+ mPlatformMajor(0),
+ mMaxVertices(500)
{
}
@@ -80,10 +81,8 @@ bool GraphicsManager::detectGraphics()
logger->log("enable opengl mode");
SDL_SetVideoMode(100, 100, 0, SDL_ANYFORMAT | SDL_OPENGL);
- setGLVersion();
- initOpenGLFunctions();
- updateExtensions();
- updatePlanformExtensions();
+ initOpenGL();
+
std::string vendor = getGLString(GL_VENDOR);
std::string renderer = getGLString(GL_RENDERER);
logger->log("gl vendor: %s", vendor.c_str());
@@ -598,3 +597,30 @@ void GraphicsManager::initOpenGLFunctions()
#endif
#endif
}
+
+void GraphicsManager::updateLimits()
+{
+#ifdef USE_OPENGL
+ GLint value;
+ glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &value);
+ logger->log("GL_MAX_ELEMENTS_VERTICES: %d", value);
+
+ mMaxVertices = value;
+
+ glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &value);
+ logger->log("GL_MAX_ELEMENTS_INDICES: %d", value);
+ if (value < mMaxVertices)
+ mMaxVertices = value;
+#endif
+}
+
+void GraphicsManager::initOpenGL()
+{
+#ifdef USE_OPENGL
+ setGLVersion();
+ initOpenGLFunctions();
+ updateExtensions();
+ updatePlanformExtensions();
+ updateLimits();
+#endif
+}
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 9abc3bf23..0ee79cb25 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -67,8 +67,15 @@ class GraphicsManager
void updatePlanformExtensions();
+ void initOpenGL();
+
+ void updateLimits();
+
Graphics *createGraphics();
+ int getMaxVertices()
+ { return mMaxVertices; }
+
private:
std::set<std::string> mExtensions;
@@ -83,6 +90,8 @@ class GraphicsManager
int mPlatformMinor;
int mPlatformMajor;
+
+ int mMaxVertices;
};
extern GraphicsManager graphicsManager;
diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp
index 4c144cad0..841873aee 100644
--- a/src/graphicsvertexes.cpp
+++ b/src/graphicsvertexes.cpp
@@ -26,7 +26,6 @@
#ifdef USE_OPENGL
int GraphicsVertexes::mUseOpenGL = 0;
-const unsigned int vertexBufSize = 500;
#endif
SDLGraphicsVertexes::SDLGraphicsVertexes()
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 6a04582b1..bba269144 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -1193,8 +1193,8 @@ private:
};
SocialWindow::SocialWindow() :
- ActionListener(),
Window(_("Social"), false, nullptr, "social.xml"),
+ ActionListener(),
mGuildInvited(0),
mGuildAcceptDialog(nullptr),
mGuildCreateDialog(nullptr),
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index 257fb7171..0538d2da1 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -45,18 +45,19 @@
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
#endif
-const unsigned int vertexBufSize = 500;
-
GLuint NormalOpenGLGraphics::mLastImage = 0;
+unsigned int vertexBufSize = 500;
+
NormalOpenGLGraphics::NormalOpenGLGraphics():
- mFloatTexArray(new GLfloat[vertexBufSize * 4 + 30]),
- mIntTexArray(new GLint[vertexBufSize * 4 + 30]),
- mIntVertArray(new GLint[vertexBufSize * 4 + 30]),
+ mFloatTexArray(nullptr),
+ mIntTexArray(nullptr),
+ mIntVertArray(nullptr),
mAlpha(false),
mTexture(false),
mIsByteColor(false),
mFloatColor(1.0f),
+ mMaxVertices(500),
#ifdef DEBUG_BIND_TEXTURE
mColorAlpha(false),
mOldTextureId(0)
@@ -75,6 +76,21 @@ NormalOpenGLGraphics::~NormalOpenGLGraphics()
delete [] mIntVertArray;
}
+void NormalOpenGLGraphics::initArrays()
+{
+ mMaxVertices = graphicsManager.getMaxVertices();
+ if (mMaxVertices < 500)
+ mMaxVertices = 500;
+ else if (mMaxVertices > 1024)
+ mMaxVertices = 1024;
+
+ // need alocate small size, after if limit reached reallocate to double size
+ vertexBufSize = mMaxVertices;
+ mFloatTexArray = new GLfloat[mMaxVertices * 4 + 30];
+ mIntTexArray = new GLint[mMaxVertices * 4 + 30];
+ mIntVertArray = new GLint[mMaxVertices * 4 + 30];
+}
+
bool NormalOpenGLGraphics::setVideoMode(const int w, const int h,
const int bpp, const bool fs,
const bool hwaccel, const bool resize,
@@ -336,7 +352,7 @@ void NormalOpenGLGraphics::drawImagePattern(const Image *const image,
setTexturingAndBlending(true);
unsigned int vp = 0;
- const unsigned int vLimit = vertexBufSize * 4;
+ const unsigned int vLimit = mMaxVertices * 4;
// Draw a set of textured rectangles
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
{
@@ -468,7 +484,7 @@ void NormalOpenGLGraphics::drawRescaledImagePattern(const Image *const image,
setTexturingAndBlending(true);
unsigned int vp = 0;
- const unsigned int vLimit = vertexBufSize * 4;
+ const unsigned int vLimit = mMaxVertices * 4;
// Draw a set of textured rectangles
if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
@@ -671,7 +687,7 @@ void NormalOpenGLGraphics::calcImagePattern(GraphicsVertexes *const vert,
const float th = static_cast<float>(image->getTextureHeight());
unsigned int vp = 0;
- const unsigned int vLimit = vertexBufSize * 4;
+ const unsigned int vLimit = mMaxVertices * 4;
NormalOpenGLGraphicsVertexes *ogl = vert->getOGL();
ogl->init();
@@ -804,7 +820,7 @@ void NormalOpenGLGraphics::calcTile(ImageVertexes *const vert,
const float tw = static_cast<float>(image->mTexWidth);
const float th = static_cast<float>(image->mTexHeight);
- const unsigned int vLimit = vertexBufSize * 4;
+ const unsigned int vLimit = mMaxVertices * 4;
NormalOpenGLGraphicsVertexes *ogl = vert->ogl;
@@ -817,9 +833,9 @@ void NormalOpenGLGraphics::calcTile(ImageVertexes *const vert,
float texY1 = static_cast<float>(srcY) / th;
if (!ogl->mFloatTexArray)
- ogl->mFloatTexArray = new GLfloat[vertexBufSize * 4 + 30];
+ ogl->mFloatTexArray = new GLfloat[mMaxVertices * 4 + 30];
if (!ogl->mIntVertArray)
- ogl->mIntVertArray = new GLint[vertexBufSize * 4 + 30];
+ ogl->mIntVertArray = new GLint[mMaxVertices * 4 + 30];
GLfloat *floatTexArray = ogl->mFloatTexArray;
GLint *intVertArray = ogl->mIntVertArray;
@@ -862,9 +878,9 @@ void NormalOpenGLGraphics::calcTile(ImageVertexes *const vert,
else
{
if (!ogl->mIntTexArray)
- ogl->mIntTexArray = new GLint[vertexBufSize * 4 + 30];
+ ogl->mIntTexArray = new GLint[mMaxVertices * 4 + 30];
if (!ogl->mIntVertArray)
- ogl->mIntVertArray = new GLint[vertexBufSize * 4 + 30];
+ ogl->mIntVertArray = new GLint[mMaxVertices * 4 + 30];
GLint *intTexArray = ogl->mIntTexArray;
GLint *intVertArray = ogl->mIntVertArray;
@@ -1191,7 +1207,7 @@ bool NormalOpenGLGraphics::drawNet(const int x1, const int y1,
const int width, const int height)
{
unsigned int vp = 0;
- const unsigned int vLimit = vertexBufSize * 4;
+ const unsigned int vLimit = mMaxVertices * 4;
setTexturingAndBlending(false);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
diff --git a/src/normalopenglgraphics.h b/src/normalopenglgraphics.h
index 972656cc4..29ef6a13b 100644
--- a/src/normalopenglgraphics.h
+++ b/src/normalopenglgraphics.h
@@ -130,6 +130,8 @@ class NormalOpenGLGraphics : public Graphics
void drawLineArrayf(int size);
+ void initArrays();
+
static void dumpSettings();
/**
@@ -179,7 +181,7 @@ class NormalOpenGLGraphics : public Graphics
bool mIsByteColor;
gcn::Color mByteColor;
float mFloatColor;
-
+ int mMaxVertices;
bool mColorAlpha;
FBOInfo mFbo;
#ifdef DEBUG_BIND_TEXTURE
@@ -189,4 +191,6 @@ class NormalOpenGLGraphics : public Graphics
};
#endif
+extern unsigned int vertexBufSize;
+
#endif