introduce startup options
* startup options with -help and -version * many startup options for graphics
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 548 B After Width: | Height: | Size: 548 B |
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
Before Width: | Height: | Size: 928 B After Width: | Height: | Size: 928 B |
|
@ -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);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "otclient.h"
|
||||
#include <framework/core/modulemanager.h>
|
||||
#include <framework/core/resourcemanager.h>
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include "core/game.h"
|
||||
#include "core/map.h"
|
||||
|
||||
|
@ -33,11 +34,49 @@ OTClient::OTClient() : Application(Otc::AppCompactName)
|
|||
|
||||
void OTClient::init(const std::vector<std::string>& args)
|
||||
{
|
||||
std::string startupOptions;
|
||||
for(uint i=1;i<args.size();++i) {
|
||||
const std::string& arg = args[i];
|
||||
startupOptions += " ";
|
||||
startupOptions += arg;
|
||||
|
||||
if(g_graphics.parseOption(arg))
|
||||
continue;
|
||||
|
||||
if(arg == "-version" || arg == "--version" || arg == "-v") {
|
||||
Fw::print(Otc::AppName, " ", Otc::AppVersion, "\n"
|
||||
"Buitt on: ", BUILD_DATE, "\n",
|
||||
"Revision: ", BUILD_REVISION, "\n",
|
||||
"Compiled by: ", BUILD_COMPILER, "\n",
|
||||
"Build type: ", BUILD_TYPE, "\n");
|
||||
return;
|
||||
} else if(arg == "-help" || arg == "--help" || arg == "-h") {
|
||||
Fw::print("Usage: ", args[0], " [options]\n"
|
||||
"Options:\n"
|
||||
" -help Display this information and exit\n"
|
||||
" -version Display version and exit\n"
|
||||
"\n"
|
||||
" -no-fbos Disable usage of opengl framebuffer objects\n"
|
||||
" -no-mipmapping Disable texture mipmaping\n"
|
||||
" -no-smoothing Disable texture smoothing (bilinear filter)\n"
|
||||
" -no-hardware-buffering Disable buffering vertex arrays in hardware\n"
|
||||
" -realtime-mipmapping Improve framebuffer smoothing quality by\n"
|
||||
" generating mipmaps in realtime when hardware\n"
|
||||
" mipmap generation implementation is available\n");
|
||||
return;
|
||||
} else {
|
||||
Fw::println("Unrecognized option '", arg, "', please see -help for available options list");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logInfo(Fw::formatString("%s %s (rev %s) built on %s",
|
||||
Otc::AppName,
|
||||
Otc::AppVersion,
|
||||
BUILD_REVISION,
|
||||
BUILD_DATE));
|
||||
if(startupOptions.length() > 0)
|
||||
logInfo("Startup options:", startupOptions);
|
||||
|
||||
g_logger.setLogFile(Fw::formatString("%s.txt", Otc::AppCompactName));
|
||||
Application::init(args, Fw::AppEnableAll);
|
||||
|
|