introduce startup options

* startup options with -help and -version
* many startup options for graphics
This commit is contained in:
Eduardo Bart
2012-03-22 13:07:23 -03:00
parent 3ad97c9eab
commit 159eb98df2
57 changed files with 77 additions and 2 deletions

View File

@@ -21,6 +21,7 @@
*/
#include "coordsbuffer.h"
#include "graphics.h"
CoordsBuffer::CoordsBuffer()
{
@@ -86,6 +87,9 @@ void CoordsBuffer::addRepeatedRects(const Rect& dest, const Rect& src)
void CoordsBuffer::enableHardwareCaching(HardwareBuffer::UsagePattern usagePattern)
{
if(!g_graphics.canUseHardwareBuffers())
return;
#ifndef OPENGL_ES2
if(!GL_ARB_vertex_buffer_object)
return;

View File

@@ -62,6 +62,23 @@ void Graphics::terminate()
m_emptyTexture.reset();
}
bool Graphics::parseOption(const std::string& option)
{
if(option == "-no-fbos")
m_useFBO = false;
else if(option == "-no-mipmapping")
m_generateMipmaps = false;
else if(option == "-no-smoothing")
m_useBilinearFiltering = false;
else if(option == "-realtime-mipmapping")
m_generateRealtimeMipmaps = true;
else if(option == "-no-hardware-buffering")
m_useHardwareBuffers = false;
else
return false;
return true;
}
void Graphics::resize(const Size& size)
{
setViewportSize(size);

View File

@@ -31,9 +31,11 @@ class Graphics
public:
void init();
void terminate();
bool parseOption(const std::string& option);
bool canUseFBO() { return m_useFBO; }
bool canUseBilinearFiltering() { return m_useBilinearFiltering; }
bool canUseHardwareBuffers() { return m_useHardwareBuffers; }
bool canGenerateMipmaps() { return m_generateMipmaps; }
bool canGenerateHardwareMipmaps() { return m_generateHardwareMipmaps; }
bool canGenerateRealtimeMipmaps() { return m_generateRealtimeMipmaps; }
@@ -53,6 +55,7 @@ private:
TexturePtr m_emptyTexture;
Boolean<true> m_useFBO;
Boolean<true> m_useHardwareBuffers;
Boolean<true> m_useBilinearFiltering;
Boolean<true> m_generateMipmaps;
Boolean<true> m_generateHardwareMipmaps;

View File

@@ -103,7 +103,9 @@ void Texture::generateMipmaps()
generateHardwareMipmaps();
else {
// fallback to software mipmaps generation, this can be slow
generateSoftwareMipmaps(getPixels());
//FIXME: disable because mipmaps size needs to be in base of 2,
// and the current algorithmn does not support that
//generateSoftwareMipmaps(getPixels());
}
}
@@ -169,6 +171,7 @@ void Texture::generateSoftwareMipmaps(std::vector<uint8> inPixels)
Size outSize = inSize / 2;
std::vector<uint8> outPixels(outSize.area()*4);
dump << "yeah";
int mipmap = 1;
while(true) {
// this is a simple bilinear filtering algorithm, it combines every 4 pixels in one pixel