Skip to content

Commit

Permalink
Added version and device information
Browse files Browse the repository at this point in the history
  • Loading branch information
hidefuku committed Nov 24, 2016
1 parent 8e48ef4 commit 25e3ac9
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/AnimeEffects.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export(copydata.commands)
export(copytools.commands)
QMAKE_EXTRA_TARGETS += first copydata copytools
}
unix {
unix|macx {
copydata.commands = rsync -ru $$shell_path($$PWD/../data) $$shell_path($$OUT_PWD)
copytools.commands = rsync -ru $$shell_path($$PWD/../tools) $$shell_path($$OUT_PWD)
first.depends = $(first) copydata copytools
Expand Down
8 changes: 7 additions & 1 deletion src/common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ HEADERS += \
$$PWD/XC.h \
$$PWD/XCAssert.h

DEFINES += "AE_MAJOR_VERSION=0"
DEFINES += "AE_MINOR_VERSION=8"

DEFINES += "AE_PROJECT_FORMAT_MAJOR_VERSION=0"
DEFINES += "AE_PROJECT_FORMAT_MINOR_VERSION=1"

# OpenGL CoreProfile Option
unix {
unix|macx {
DEFINES += USE_GL_CORE_PROFILE
}
2 changes: 1 addition & 1 deletion src/ctrl/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool Exporter::execute(const CommonParam& aCommon, const VideoParam& aVideo)
mIsCanceled = false;

{
#if defined(_WIN32) || defined(_WIN64)
#if defined(Q_OS_WIN)
const QFileInfo localEncoderInfo("./tools/ffmpeg.exe");
const bool hasLocalEncoder = localEncoderInfo.exists() && localEncoderInfo.isExecutable();
const QString program = hasLocalEncoder ? QString(".\\tools\\ffmpeg") : QString("ffmpeg");
Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/ProjectLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ bool ProjectLoader::readHeader(util::LEStreamReader& aIn)

// major version
const int majorVersion = aIn.readUInt32();
if (majorVersion > 0) return false;
if (majorVersion > AE_PROJECT_FORMAT_MAJOR_VERSION) return false;

// minor version
const int minorVersion = aIn.readUInt32();
if (minorVersion > 1) return false;
if (minorVersion > AE_PROJECT_FORMAT_MINOR_VERSION) return false;

// reserved
if (!aIn.skipZeroArea(16)) return false;
Expand Down
4 changes: 2 additions & 2 deletions src/ctrl/ProjectSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ bool ProjectSaver::writeHeader(util::StreamWriter& aOut)
{
static const std::array<uint8, 6> kSignature{ 'A', 'N', 'I', 'M', 'F', 'X' };
static const std::array<uint8, 2> kEndian{ 0xff, 0x00 };
static const uint32 kMajorVersion = 0;
static const uint32 kMinorVersion = 1;
static const uint32 kMajorVersion = AE_PROJECT_FORMAT_MAJOR_VERSION;
static const uint32 kMinorVersion = AE_PROJECT_FORMAT_MINOR_VERSION;
static const int kReserveSize = 16;

// signature
Expand Down
15 changes: 6 additions & 9 deletions src/ctrl/System.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <QDir>
#include <QFile>
#include "gl/Global.h"
#include "gl/DeviceInfo.h"
#include "ctrl/System.h"
#include "ctrl/ProjectSaver.h"
#include "ctrl/ProjectLoader.h"
Expand All @@ -21,7 +22,6 @@ System::System(const QString& aResourceDir, const QString& aCacheDir)
, mCacheDir(aCacheDir)
, mProjects()
, mAnimator()
, mGLDeviceInfo()
{
}

Expand All @@ -35,11 +35,6 @@ void System::setAnimator(Animator& aAnimator)
mAnimator = &aAnimator;
}

void System::setGLDeviceInfo(const gl::DeviceInfo& aInfo)
{
mGLDeviceInfo = aInfo;
}

core::Project* System::newProject(
const QString& aFileName,
const core::Project::Attribute& aAttr,
Expand All @@ -50,14 +45,16 @@ core::Project* System::newProject(
QScopedPointer<core::Project::Hook> hookScope(aHookGrabbed);

XC_ASSERT(mAnimator);
XC_ASSERT(gl::DeviceInfo::validInstanceExists());

gl::Global::makeCurrent();

QScopedPointer<core::Project> projectScope;
projectScope.reset(new Project(QString(), *mAnimator, hookScope.take()));
projectScope->attribute() = aAttr;
projectScope->resourceHolder().setRootPath(QFileInfo(aFileName).path());

ctrl::ImageFileLoader loader(mGLDeviceInfo);
ctrl::ImageFileLoader loader(gl::DeviceInfo::instance());
loader.setCanvasSize(aAttr.imageSize(), aSpecifiesCanvasSize);

if (loader.load(aFileName, *projectScope, aReporter))
Expand All @@ -78,7 +75,7 @@ core::Project* System::openProject(
QScopedPointer<core::Project::Hook> hookScope(aHookGrabbed);

XC_ASSERT(mAnimator);
XC_ASSERT(mGLDeviceInfo.isValid());
XC_ASSERT(gl::DeviceInfo::validInstanceExists());

gl::Global::makeCurrent();

Expand All @@ -88,7 +85,7 @@ core::Project* System::openProject(
projectScope.reset(new Project(aFileName, *mAnimator, hookScope.take()));

ctrl::ProjectLoader loader;
if (loader.load(aFileName, *projectScope, mGLDeviceInfo, aReporter))
if (loader.load(aFileName, *projectScope, gl::DeviceInfo::instance(), aReporter))
{
mProjects.push_back(projectScope.take());
return mProjects.back();
Expand Down
2 changes: 0 additions & 2 deletions src/ctrl/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class System : private util::NonCopyable
~System();

void setAnimator(core::Animator& aAnimator);
void setGLDeviceInfo(const gl::DeviceInfo& aInfo);

core::Project* newProject(
const QString& aFileName,
Expand Down Expand Up @@ -51,7 +50,6 @@ class System : private util::NonCopyable
const QString mCacheDir;
QVector<core::Project*> mProjects;
core::Animator* mAnimator;
gl::DeviceInfo mGLDeviceInfo;
};

} // namespace ctrl
Expand Down
44 changes: 28 additions & 16 deletions src/gl/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,48 @@

namespace
{
static bool sIsDeviceInfoInitialized = false;
static gl::DeviceInfo sDeviceInfo;
static const gl::DeviceInfo* sDeviceInfoPtr;
} // namespace

namespace gl
{

const DeviceInfo& DeviceInfo::instance()
{
XC_PTR_ASSERT(sIsDeviceInfoInitialized);
return sDeviceInfo;
XC_PTR_ASSERT(sDeviceInfoPtr);
return *sDeviceInfoPtr;
}

void DeviceInfo::createInstance()
void DeviceInfo::setInstance(const DeviceInfo* aInstance)
{
sDeviceInfoPtr = aInstance;
}

bool DeviceInfo::validInstanceExists()
{
return sDeviceInfoPtr && sDeviceInfoPtr->isValid();
}

DeviceInfo::DeviceInfo()
: vender()
, renderer()
, version()
, maxTextureSize(0)
, maxRenderBufferSize(0)
{
}

void DeviceInfo::load()
{
Global::makeCurrent();
auto& ggl = Global::functions();

DeviceInfo info;
ggl.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &info.maxTextureSize);
ggl.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &info.maxRenderBufferSize);
vender = std::string((const char*)ggl.glGetString(GL_VENDOR));
renderer = std::string((const char*)ggl.glGetString(GL_RENDERER));
version = std::string((const char*)ggl.glGetString(GL_VERSION));

sDeviceInfo = info;
sIsDeviceInfoInitialized = true;
ggl.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
ggl.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxRenderBufferSize);

#if 0
GLint val = 0;
Expand Down Expand Up @@ -58,12 +76,6 @@ void DeviceInfo::createInstance()
#endif
}

DeviceInfo::DeviceInfo()
: maxTextureSize(0)
, maxRenderBufferSize(0)
{
}

bool DeviceInfo::isValid() const
{
return maxTextureSize > 0 && maxRenderBufferSize > 0;
Expand Down
8 changes: 7 additions & 1 deletion src/gl/DeviceInfo.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
#ifndef GL_DEVICEINFO_H
#define GL_DEVICEINFO_H

#include <string>
#include <QGL>

namespace gl
{

struct DeviceInfo
{
static void setInstance(const DeviceInfo* aInstance);
static bool validInstanceExists();
static const DeviceInfo& instance();
static void createInstance();

DeviceInfo();
void load();
bool isValid() const;

std::string vender;
std::string renderer;
std::string version;
GLint maxTextureSize;
GLint maxRenderBufferSize;
};
Expand Down
8 changes: 4 additions & 4 deletions src/gui/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ int entryPoint(int argc, char *argv[])

// create qt application
QApplication app(argc, argv);

// unicode argments
const QStringList uniArgs = app.arguments();

Expand All @@ -529,6 +530,7 @@ int entryPoint(int argc, char *argv[])

// language
QString preferFont;
QScopedPointer<QTranslator> translator;
{
QString locAbb;
#if 1
Expand All @@ -541,9 +543,9 @@ int entryPoint(int argc, char *argv[])

if (!locAbb.isEmpty())
{
auto translator = new QTranslator();
translator.reset(new QTranslator());
translator->load("translation_" + locAbb, "data/locale");
app.installTranslator(translator);
app.installTranslator(translator.data());
}

{
Expand Down Expand Up @@ -586,8 +588,6 @@ int entryPoint(int argc, char *argv[])
qDebug() << "show main window";
// show main window
mainWindow->showWithSettings();
// set opengl device info
system->setGLDeviceInfo(gl::DeviceInfo::instance());

#if !defined(QT_NO_DEBUG)
qDebug() << "test new project";
Expand Down
7 changes: 5 additions & 2 deletions src/gui/MainDisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace gui
MainDisplayWidget::MainDisplayWidget(ViaPoint& aViaPoint, QWidget* aParent)
: QOpenGLWidget(aParent)
, mViaPoint(aViaPoint)
, mGLDeviceInfo()
, mProject()
, mGLRoot()
, mGLContextAccessor(this)
Expand Down Expand Up @@ -119,6 +120,7 @@ MainDisplayWidget::~MainDisplayWidget()
mFramebuffer.reset();
mDefaultVAO.reset();

gl::DeviceInfo::setInstance(nullptr);
gl::Global::clearFunctions();
}

Expand Down Expand Up @@ -203,8 +205,9 @@ void MainDisplayWidget::initializeGL()
mGLRoot.setFunctions(*functions);

// initialize opengl device info
gl::DeviceInfo::createInstance();
mViaPoint.setGLDeviceInfo(gl::DeviceInfo::instance());
mGLDeviceInfo.load();
gl::DeviceInfo::setInstance(&mGLDeviceInfo);
mViaPoint.setGLDeviceInfo(mGLDeviceInfo);

#ifdef USE_GL_CORE_PROFILE
// initialize default vao
Expand Down
1 change: 1 addition & 0 deletions src/gui/MainDisplayWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MainDisplayWidget : public QOpenGLWidget
void updatePenInfo(QEvent::Type aType, const QPoint& aPos, float aPressure);

ViaPoint& mViaPoint;
gl::DeviceInfo mGLDeviceInfo;
util::LinkPointer<core::Project> mProject;
gl::Root mGLRoot;
GLContextAccessor mGLContextAccessor;
Expand Down
25 changes: 17 additions & 8 deletions src/gui/MainMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,27 @@ MainMenuBar::MainMenuBar(MainWindow& aMainWindow, ViaPoint& aViaPoint, QWidget*

QMenu* helpMenu = new QMenu(tr("Help"), this);
{
QAction* aboutMe = new QAction("About Anime Effects...", this);
QAction* aboutMe = new QAction("About AnimeEffects...", this);
connect(aboutMe, &QAction::triggered, [=]()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText("Anime Effects (Version 0.9.0)");

QString infoText;
infoText += "Build ABI : " + QSysInfo::buildAbi() + "\n";
//infoText += "Build CPU : " + QSysInfo::buildCpuArchitecture() + "\n";
//infoText += "Current CPU : " + QSysInfo::currentCpuArchitecture() + "\n";
msgBox.setInformativeText(infoText);
auto versionString = QString::number(AE_MAJOR_VERSION) + "." + QString::number(AE_MINOR_VERSION);
auto formatVersionString = QString::number(AE_PROJECT_FORMAT_MAJOR_VERSION) + "." + QString::number(AE_PROJECT_FORMAT_MINOR_VERSION);
auto platform = QSysInfo::productType();
msgBox.setText(QString("AnimeEffects for ") + platform + " version " + versionString);

QString detail;
detail += "Version: " + versionString + "\n";
detail += "Platform: " + platform + " " + QSysInfo::productVersion() + "\n";
detail += "Build ABI: " + QSysInfo::buildAbi() + "\n";
detail += "Build CPU: " + QSysInfo::buildCpuArchitecture() + "\n";
detail += "Current CPU: " + QSysInfo::currentCpuArchitecture() + "\n";
detail += "Current GPU: " + QString(this->mViaPoint.glDeviceInfo().renderer.c_str()) + "\n";
detail += "GPU Vender: " + QString(this->mViaPoint.glDeviceInfo().vender.c_str()) + "\n";
detail += "OpenGL Version: " + QString(this->mViaPoint.glDeviceInfo().version.c_str()) + "\n";
detail += "Format Version: " + formatVersionString + "\n";
msgBox.setDetailedText(detail);

msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
Expand Down

0 comments on commit 25e3ac9

Please sign in to comment.