mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 13:03:27 +02:00
introduce startup options
* startup options with -help and -version * many startup options for graphics
This commit is contained in:
@@ -115,10 +115,15 @@ void Application::init(const std::vector<std::string>& args, int appFlags)
|
||||
|
||||
if(m_appFlags & Fw::AppEnableModules)
|
||||
g_modules.discoverModulesPath();
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
void Application::terminate()
|
||||
{
|
||||
if(!m_initialized)
|
||||
return;
|
||||
|
||||
g_lua.callGlobalField("g_app", "onTerminate");
|
||||
|
||||
// hide the window because there is no render anymore
|
||||
@@ -162,6 +167,9 @@ void Application::terminate()
|
||||
|
||||
void Application::run()
|
||||
{
|
||||
if(!m_initialized)
|
||||
return;
|
||||
|
||||
ticks_t lastPollTicks = g_clock.updateTicks();
|
||||
m_stopping = false;
|
||||
m_running = true;
|
||||
|
@@ -65,6 +65,7 @@ protected:
|
||||
std::string m_appBuildDate;
|
||||
int m_appFlags;
|
||||
int m_pollCycleDelay;
|
||||
Boolean<false> m_initialized;
|
||||
Boolean<false> m_running;
|
||||
Boolean<false> m_stopping;
|
||||
};
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -168,7 +168,7 @@ void UIWidget::drawImage(const Rect& screenCoords)
|
||||
m_imageTexture->setSmooth(m_imageSmooth);
|
||||
|
||||
// this will increase fps when rendering larger images, like the background, and improve image quality
|
||||
if(m_imageSmooth && g_graphics.canGenerateMipmaps() && !m_imageTexture->hasMipmaps())
|
||||
if(m_imageSmooth && !m_imageTexture->hasMipmaps() && g_graphics.canGenerateMipmaps())
|
||||
m_imageTexture->generateMipmaps();
|
||||
|
||||
g_painter.setColor(m_imageColor);
|
||||
|
Reference in New Issue
Block a user