mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Replaced all internal matrix data types and functions with the GLM library equivalents.
Also changed some vectors.
This commit is contained in:
parent
ffc9814636
commit
722468129e
|
@ -196,6 +196,10 @@ if(DEFINED libCEC_FOUND)
|
||||||
add_definitions(-DHAVE_LIBCEC)
|
add_definitions(-DHAVE_LIBCEC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# GLM library options.
|
||||||
|
add_definitions(-DGLM_FORCE_CXX14)
|
||||||
|
add_definitions(-DGLM_FORCE_XYZW_ONLY)
|
||||||
|
|
||||||
# For Unix systems, assign the installation prefix. If it's not explicitly set,
|
# For Unix systems, assign the installation prefix. If it's not explicitly set,
|
||||||
# we use /usr on Linux, /usr/pkg on NetBSD and /usr/local on FreeBSD and OpenBSD.
|
# we use /usr on Linux, /usr/pkg on NetBSD and /usr/local on FreeBSD and OpenBSD.
|
||||||
if(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
|
|
|
@ -83,15 +83,15 @@ void MediaViewer::update(int deltaTime)
|
||||||
|
|
||||||
void MediaViewer::render()
|
void MediaViewer::render()
|
||||||
{
|
{
|
||||||
Transform4x4f transform = Transform4x4f::Identity();
|
glm::mat4 trans = Renderer::getIdentity();
|
||||||
Renderer::setMatrix(transform);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
// Render a black background below the game media.
|
// Render a black background below the game media.
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||||
|
|
||||||
if (mVideo && !mDisplayingImage) {
|
if (mVideo && !mDisplayingImage) {
|
||||||
mVideo->render(transform);
|
mVideo->render(trans);
|
||||||
|
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
Renderer::shaderParameters videoParameters;
|
Renderer::shaderParameters videoParameters;
|
||||||
|
@ -122,7 +122,7 @@ void MediaViewer::render()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (mImage && mImage->hasImage() && mImage->getSize() != 0) {
|
else if (mImage && mImage->hasImage() && mImage->getSize() != 0) {
|
||||||
mImage->render(transform);
|
mImage->render(trans);
|
||||||
|
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
if (mCurrentImageIndex == mScreenShotIndex &&
|
if (mCurrentImageIndex == mScreenShotIndex &&
|
||||||
|
|
|
@ -248,19 +248,19 @@ void SystemScreensaver::renderScreensaver()
|
||||||
|
|
||||||
if (mVideoScreensaver && screensaverType == "video") {
|
if (mVideoScreensaver && screensaverType == "video") {
|
||||||
// Render a black background below the video.
|
// Render a black background below the video.
|
||||||
Renderer::setMatrix(Transform4x4f::Identity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||||
|
|
||||||
// Only render the video if the state requires it.
|
// Only render the video if the state requires it.
|
||||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||||
Transform4x4f transform = Transform4x4f::Identity();
|
glm::mat4 trans = Renderer::getIdentity();
|
||||||
mVideoScreensaver->render(transform);
|
mVideoScreensaver->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mImageScreensaver && screensaverType == "slideshow") {
|
else if (mImageScreensaver && screensaverType == "slideshow") {
|
||||||
// Render a black background below the image.
|
// Render a black background below the image.
|
||||||
Renderer::setMatrix(Transform4x4f::Identity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||||
|
|
||||||
|
@ -268,15 +268,14 @@ void SystemScreensaver::renderScreensaver()
|
||||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||||
if (mImageScreensaver->hasImage()) {
|
if (mImageScreensaver->hasImage()) {
|
||||||
mImageScreensaver->setOpacity(255 - static_cast<unsigned char>(mOpacity * 255));
|
mImageScreensaver->setOpacity(255 - static_cast<unsigned char>(mOpacity * 255));
|
||||||
|
glm::mat4 trans = Renderer::getIdentity();
|
||||||
Transform4x4f transform = Transform4x4f::Identity();
|
mImageScreensaver->render(trans);
|
||||||
mImageScreensaver->render(transform);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isScreensaverActive()) {
|
if (isScreensaverActive()) {
|
||||||
Renderer::setMatrix(Transform4x4f::Identity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
if (Settings::getInstance()->getString("ScreensaverType") == "slideshow") {
|
if (Settings::getInstance()->getString("ScreensaverType") == "slideshow") {
|
||||||
if (mHasMediaFiles) {
|
if (mHasMediaFiles) {
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
|
|
|
@ -10,14 +10,15 @@
|
||||||
#define ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
|
#define ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
|
||||||
|
|
||||||
#include "animations/Animation.h"
|
#include "animations/Animation.h"
|
||||||
|
#include "math/Misc.h"
|
||||||
|
|
||||||
class MoveCameraAnimation : public Animation
|
class MoveCameraAnimation : public Animation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MoveCameraAnimation(Transform4x4f& camera, const Vector3f& target)
|
MoveCameraAnimation(glm::mat4& camera, const glm::vec3& target)
|
||||||
: mCameraStart(camera)
|
: mCameraStart(camera)
|
||||||
, mTarget(target)
|
, mTarget(target)
|
||||||
, cameraOut(camera)
|
, cameraPosition(camera)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,17 +26,16 @@ public:
|
||||||
|
|
||||||
void apply(float t) override
|
void apply(float t) override
|
||||||
{
|
{
|
||||||
// Cubic ease out.
|
|
||||||
t -= 1;
|
t -= 1;
|
||||||
cameraOut.translation() =
|
cameraPosition[3].x = -Math::lerp(-mCameraStart[3].x, mTarget.x, t * t * t + 1);
|
||||||
-Vector3f().lerp(-mCameraStart.translation(), mTarget, t * t * t + 1);
|
cameraPosition[3].y = -Math::lerp(-mCameraStart[3].y, mTarget.y, t * t * t + 1);
|
||||||
|
cameraPosition[3].z = -Math::lerp(-mCameraStart[3].z, mTarget.z, t * t * t + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Transform4x4f mCameraStart;
|
glm::mat4 mCameraStart;
|
||||||
Vector3f mTarget;
|
glm::mat4& cameraPosition;
|
||||||
|
glm::vec3 mTarget;
|
||||||
Transform4x4f& cameraOut;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
|
#endif // ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
|
||||||
|
|
|
@ -115,7 +115,7 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
||||||
|
|
||||||
void GuiGameScraper::onSizeChanged()
|
void GuiGameScraper::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBox.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBox.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
mGrid.setRowHeightPerc(0, 0.04f, false);
|
mGrid.setRowHeightPerc(0, 0.04f, false);
|
||||||
mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y(),
|
mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y(),
|
||||||
|
|
|
@ -54,7 +54,7 @@ GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration)
|
||||||
setPosition(posX, posY, 0);
|
setPosition(posX, posY, 0);
|
||||||
|
|
||||||
mFrame->setImagePath(":/graphics/frame.svg");
|
mFrame->setImagePath(":/graphics/frame.svg");
|
||||||
mFrame->fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mFrame->fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
addChild(mFrame);
|
addChild(mFrame);
|
||||||
|
|
||||||
// We only initialize the actual time when we first start to render.
|
// We only initialize the actual time when we first start to render.
|
||||||
|
@ -72,10 +72,10 @@ GuiInfoPopup::~GuiInfoPopup()
|
||||||
delete mFrame;
|
delete mFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiInfoPopup::render(const Transform4x4f& /*parentTrans*/)
|
void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/)
|
||||||
{
|
{
|
||||||
// We use Identity() as we want to render on a specific window position, not on the view.
|
// We use getIdentity() as we want to render on a specific window position, not on the view.
|
||||||
Transform4x4f trans = getTransform() * Transform4x4f::Identity();
|
glm::mat4 trans = getTransform() * Renderer::getIdentity();
|
||||||
if (mRunning && updateState()) {
|
if (mRunning && updateState()) {
|
||||||
// If we're still supposed to be rendering it.
|
// If we're still supposed to be rendering it.
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
GuiInfoPopup(Window* window, std::string message, int duration);
|
GuiInfoPopup(Window* window, std::string message, int duration);
|
||||||
~GuiInfoPopup();
|
~GuiInfoPopup();
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void stop() override { mRunning = false; }
|
void stop() override { mRunning = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -169,12 +169,12 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
mGrid->getRowHeight(3));
|
mGrid->getRowHeight(3));
|
||||||
|
|
||||||
mMarquee->setOrigin(0.5f, 0.5f);
|
mMarquee->setOrigin(0.5f, 0.5f);
|
||||||
Vector3f currentPos = mMarquee->getPosition();
|
glm::vec3 currentPos = mMarquee->getPosition();
|
||||||
Vector2f currentSize = mMarquee->getSize();
|
Vector2f currentSize = mMarquee->getSize();
|
||||||
|
|
||||||
// Position the image in the middle of row four.
|
// Position the image in the middle of row four.
|
||||||
currentPos.x() = mSize.x() / 2.0f;
|
currentPos.x = mSize.x() / 2.0f;
|
||||||
currentPos.y() = mGrid->getRowHeight(0) + mGrid->getRowHeight(1) + mGrid->getRowHeight(2) +
|
currentPos.y = mGrid->getRowHeight(0) + mGrid->getRowHeight(1) + mGrid->getRowHeight(2) +
|
||||||
mGrid->getRowHeight(3) / 2.0f;
|
mGrid->getRowHeight(3) / 2.0f;
|
||||||
mMarquee->setPosition(currentPos);
|
mMarquee->setPosition(currentPos);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
setPosition(static_cast<float>(Renderer::getScreenWidth()) / 2.0f,
|
setPosition(static_cast<float>(Renderer::getScreenWidth()) / 2.0f,
|
||||||
static_cast<float>(Renderer::getScreenHeight()) / 2.25f);
|
static_cast<float>(Renderer::getScreenHeight()) / 2.25f);
|
||||||
|
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
mBackground.setEdgeColor(0xEEEEEEFF);
|
mBackground.setEdgeColor(0xEEEEEEFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ void GuiLaunchScreen::render()
|
||||||
if (mScaleUp < 1.0f)
|
if (mScaleUp < 1.0f)
|
||||||
setScale(mScaleUp);
|
setScale(mScaleUp);
|
||||||
|
|
||||||
Transform4x4f trans = Transform4x4f::Identity() * getTransform();
|
glm::mat4 trans = Renderer::getIdentity() * getTransform();
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
|
@ -388,11 +388,11 @@ void GuiMetaDataEd::onSizeChanged()
|
||||||
mList->setSize(mList->getSize().x(), listHeight);
|
mList->setSize(mList->getSize().x(), listHeight);
|
||||||
Vector2f newWindowSize = mSize;
|
Vector2f newWindowSize = mSize;
|
||||||
newWindowSize.y() -= heightAdjustment;
|
newWindowSize.y() -= heightAdjustment;
|
||||||
mBackground.fitTo(newWindowSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(newWindowSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
// Move the buttons up as well to make the layout align correctly after the resize.
|
// Move the buttons up as well to make the layout align correctly after the resize.
|
||||||
Vector3f newButtonPos = mButtons->getPosition();
|
glm::vec3 newButtonPos = mButtons->getPosition();
|
||||||
newButtonPos.y() -= heightAdjustment;
|
newButtonPos.y -= heightAdjustment;
|
||||||
mButtons->setPosition(newButtonPos);
|
mButtons->setPosition(newButtonPos);
|
||||||
|
|
||||||
mHeaderGrid->setRowHeightPerc(1, titleHeight / mHeaderGrid->getSize().y());
|
mHeaderGrid->setRowHeightPerc(1, titleHeight / mHeaderGrid->getSize().y());
|
||||||
|
|
|
@ -203,7 +203,7 @@ GuiOfflineGenerator::~GuiOfflineGenerator()
|
||||||
|
|
||||||
void GuiOfflineGenerator::onSizeChanged()
|
void GuiOfflineGenerator::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
// Set row heights.
|
// Set row heights.
|
||||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false);
|
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false);
|
||||||
|
|
|
@ -130,7 +130,7 @@ GuiScraperMulti::~GuiScraperMulti()
|
||||||
|
|
||||||
void GuiScraperMulti::onSizeChanged()
|
void GuiScraperMulti::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false);
|
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false);
|
||||||
mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2.0f) / mSize.y(), false);
|
mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2.0f) / mSize.y(), false);
|
||||||
|
|
|
@ -565,9 +565,9 @@ bool GuiScraperSearch::input(InputConfig* config, Input input)
|
||||||
return GuiComponent::input(config, input);
|
return GuiComponent::input(config, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScraperSearch::render(const Transform4x4f& parentTrans)
|
void GuiScraperSearch::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000009, 0x00000009);
|
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000009, 0x00000009);
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
HelpStyle getHelpStyle() override;
|
HelpStyle getHelpStyle() override;
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
|
@ -396,12 +396,12 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
|
||||||
setAnimation(anim, 0, nullptr, false, 0);
|
setAnimation(anim, 0, nullptr, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemView::render(const Transform4x4f& parentTrans)
|
void SystemView::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return; // Nothing to render.
|
return; // Nothing to render.
|
||||||
|
|
||||||
Transform4x4f trans = getTransform() * parentTrans;
|
glm::mat4 trans = getTransform() * parentTrans;
|
||||||
|
|
||||||
renderExtras(trans, INT16_MIN, INT16_MAX);
|
renderExtras(trans, INT16_MIN, INT16_MAX);
|
||||||
|
|
||||||
|
@ -449,7 +449,6 @@ void SystemView::onThemeChanged(const std::shared_ptr<ThemeData>& /*theme*/)
|
||||||
populate();
|
populate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the ThemeElements that make up the SystemView.
|
|
||||||
void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
||||||
{
|
{
|
||||||
LOG(LogDebug) << "SystemView::getViewElements()";
|
LOG(LogDebug) << "SystemView::getViewElements()";
|
||||||
|
@ -473,18 +472,20 @@ void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
||||||
mViewNeedsReload = false;
|
mViewNeedsReload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render system carousel.
|
void SystemView::renderCarousel(const glm::mat4& trans)
|
||||||
void SystemView::renderCarousel(const Transform4x4f& trans)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// Background box behind logos.
|
// Background box behind logos.
|
||||||
Transform4x4f carouselTrans = trans;
|
glm::mat4 carouselTrans = trans;
|
||||||
carouselTrans.translate(Vector3f(mCarousel.pos.x(), mCarousel.pos.y(), 0.0));
|
carouselTrans =
|
||||||
carouselTrans.translate(Vector3f(mCarousel.origin.x() * mCarousel.size.x() * -1.0f,
|
glm::translate(carouselTrans, glm::vec3(mCarousel.pos.x(), mCarousel.pos.y(), 0.0f));
|
||||||
|
carouselTrans = glm::translate(
|
||||||
|
carouselTrans, glm::vec3(mCarousel.origin.x() * mCarousel.size.x() * -1.0f,
|
||||||
mCarousel.origin.y() * mCarousel.size.y() * -1.0f, 0.0f));
|
mCarousel.origin.y() * mCarousel.size.y() * -1.0f, 0.0f));
|
||||||
|
|
||||||
Vector2f clipPos(carouselTrans.translation().x(), carouselTrans.translation().y());
|
glm::vec2 clipPos(carouselTrans[3].x, carouselTrans[3].y);
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
Vector2i(static_cast<int>(clipPos.x()), static_cast<int>(clipPos.y())),
|
Vector2i(static_cast<int>(clipPos.x), static_cast<int>(clipPos.y)),
|
||||||
Vector2i(static_cast<int>(mCarousel.size.x()), static_cast<int>(mCarousel.size.y())));
|
Vector2i(static_cast<int>(mCarousel.size.x()), static_cast<int>(mCarousel.size.y())));
|
||||||
|
|
||||||
Renderer::setMatrix(carouselTrans);
|
Renderer::setMatrix(carouselTrans);
|
||||||
|
@ -575,8 +576,9 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
|
||||||
while (index >= static_cast<int>(mEntries.size()))
|
while (index >= static_cast<int>(mEntries.size()))
|
||||||
index -= static_cast<int>(mEntries.size());
|
index -= static_cast<int>(mEntries.size());
|
||||||
|
|
||||||
Transform4x4f logoTrans = carouselTrans;
|
glm::mat4 logoTrans = carouselTrans;
|
||||||
logoTrans.translate(Vector3f(i * logoSpacing[0] + xOff, i * logoSpacing[1] + yOff, 0));
|
logoTrans = glm::translate(
|
||||||
|
logoTrans, glm::vec3(i * logoSpacing[0] + xOff, i * logoSpacing[1] + yOff, 0.0f));
|
||||||
|
|
||||||
float distance = i - mCamOffset;
|
float distance = i - mCamOffset;
|
||||||
|
|
||||||
|
@ -600,8 +602,7 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
|
||||||
Renderer::popClipRect();
|
Renderer::popClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw background extras.
|
void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper)
|
||||||
void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upper)
|
|
||||||
{
|
{
|
||||||
int extrasCenter = static_cast<int>(mExtrasCamOffset);
|
int extrasCenter = static_cast<int>(mExtrasCamOffset);
|
||||||
|
|
||||||
|
@ -621,15 +622,16 @@ void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upp
|
||||||
|
|
||||||
// Only render selected system when not showing.
|
// Only render selected system when not showing.
|
||||||
if (mShowing || index == mCursor) {
|
if (mShowing || index == mCursor) {
|
||||||
Transform4x4f extrasTrans = trans;
|
glm::mat4 extrasTrans = trans;
|
||||||
if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL)
|
if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL)
|
||||||
extrasTrans.translate(Vector3f((i - mExtrasCamOffset) * mSize.x(), 0, 0));
|
extrasTrans = glm::translate(
|
||||||
|
extrasTrans, glm::vec3((i - mExtrasCamOffset) * mSize.x(), 0.0f, 0.0f));
|
||||||
else
|
else
|
||||||
extrasTrans.translate(Vector3f(0, (i - mExtrasCamOffset) * mSize.y(), 0));
|
extrasTrans = glm::translate(
|
||||||
|
extrasTrans, glm::vec3(0.0f, (i - mExtrasCamOffset) * mSize.y(), 0.0f));
|
||||||
|
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
Vector2i(static_cast<int>(extrasTrans.translation()[0]),
|
Vector2i(static_cast<int>(extrasTrans[3].x), static_cast<int>(extrasTrans[3].y)),
|
||||||
static_cast<int>(extrasTrans.translation()[1])),
|
|
||||||
Vector2i(static_cast<int>(mSize.x()), static_cast<int>(mSize.y())));
|
Vector2i(static_cast<int>(mSize.x()), static_cast<int>(mSize.y())));
|
||||||
SystemViewData data = mEntries.at(index).data;
|
SystemViewData data = mEntries.at(index).data;
|
||||||
for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) {
|
for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) {
|
||||||
|
@ -644,14 +646,13 @@ void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upp
|
||||||
Renderer::popClipRect();
|
Renderer::popClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemView::renderFade(const Transform4x4f& trans)
|
void SystemView::renderFade(const glm::mat4& trans)
|
||||||
{
|
{
|
||||||
unsigned int fadeColor = 0x00000000 | static_cast<unsigned char>(mExtrasFadeOpacity * 255.0f);
|
unsigned int fadeColor = 0x00000000 | static_cast<unsigned char>(mExtrasFadeOpacity * 255.0f);
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), fadeColor, fadeColor);
|
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), fadeColor, fadeColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the system carousel with the legacy values.
|
|
||||||
void SystemView::getDefaultElements(void)
|
void SystemView::getDefaultElements(void)
|
||||||
{
|
{
|
||||||
// Carousel.
|
// Carousel.
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void onThemeChanged(const std::shared_ptr<ThemeData>& theme);
|
void onThemeChanged(const std::shared_ptr<ThemeData>& theme);
|
||||||
|
|
||||||
|
@ -81,13 +81,17 @@ protected:
|
||||||
private:
|
private:
|
||||||
void populate();
|
void populate();
|
||||||
void updateGameCount();
|
void updateGameCount();
|
||||||
|
// Get the ThemeElements that make up the SystemView.
|
||||||
void getViewElements(const std::shared_ptr<ThemeData>& theme);
|
void getViewElements(const std::shared_ptr<ThemeData>& theme);
|
||||||
|
// Populate the system carousel with the legacy values.
|
||||||
void getDefaultElements(void);
|
void getDefaultElements(void);
|
||||||
void getCarouselFromTheme(const ThemeData::ThemeElement* elem);
|
void getCarouselFromTheme(const ThemeData::ThemeElement* elem);
|
||||||
|
|
||||||
void renderCarousel(const Transform4x4f& parentTrans);
|
// Render system carousel.
|
||||||
void renderExtras(const Transform4x4f& parentTrans, float lower, float upper);
|
void renderCarousel(const glm::mat4& parentTrans);
|
||||||
void renderFade(const Transform4x4f& trans);
|
// Draw background extras.
|
||||||
|
void renderExtras(const glm::mat4& parentTrans, float lower, float upper);
|
||||||
|
void renderFade(const glm::mat4& trans);
|
||||||
|
|
||||||
SystemViewCarousel mCarousel;
|
SystemViewCarousel mCarousel;
|
||||||
TextComponent mSystemInfo;
|
TextComponent mSystemInfo;
|
||||||
|
|
|
@ -66,7 +66,7 @@ ViewController::ViewController(Window* window)
|
||||||
, mCurrentView(nullptr)
|
, mCurrentView(nullptr)
|
||||||
, mPreviousView(nullptr)
|
, mPreviousView(nullptr)
|
||||||
, mSkipView(nullptr)
|
, mSkipView(nullptr)
|
||||||
, mCamera(Transform4x4f::Identity())
|
, mCamera(Renderer::getIdentity())
|
||||||
, mSystemViewTransition(false)
|
, mSystemViewTransition(false)
|
||||||
, mWrappedViews(false)
|
, mWrappedViews(false)
|
||||||
, mFadeOpacity(0)
|
, mFadeOpacity(0)
|
||||||
|
@ -234,8 +234,8 @@ void ViewController::ReloadAndGoToStart()
|
||||||
bool ViewController::isCameraMoving()
|
bool ViewController::isCameraMoving()
|
||||||
{
|
{
|
||||||
if (mCurrentView) {
|
if (mCurrentView) {
|
||||||
if (mCamera.r3().x() - -mCurrentView->getPosition().x() != 0 ||
|
if (mCamera[3].x - -mCurrentView->getPosition().x != 0.0f ||
|
||||||
mCamera.r3().y() - -mCurrentView->getPosition().y() != 0)
|
mCamera[3].y - -mCurrentView->getPosition().y != 0.0f)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -245,8 +245,8 @@ void ViewController::cancelViewTransitions()
|
||||||
{
|
{
|
||||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
||||||
if (isCameraMoving()) {
|
if (isCameraMoving()) {
|
||||||
mCamera.r3().x() = -mCurrentView->getPosition().x();
|
mCamera[3].x = -mCurrentView->getPosition().x;
|
||||||
mCamera.r3().y() = -mCurrentView->getPosition().y();
|
mCamera[3].y = -mCurrentView->getPosition().y;
|
||||||
stopAllAnimations();
|
stopAllAnimations();
|
||||||
}
|
}
|
||||||
// mSkipView is used when skipping through the gamelists in quick succession.
|
// mSkipView is used when skipping through the gamelists in quick succession.
|
||||||
|
@ -285,8 +285,8 @@ int ViewController::getSystemId(SystemData* system)
|
||||||
void ViewController::restoreViewPosition()
|
void ViewController::restoreViewPosition()
|
||||||
{
|
{
|
||||||
if (mPreviousView) {
|
if (mPreviousView) {
|
||||||
Vector3f restorePosition = mPreviousView->getPosition();
|
glm::vec3 restorePosition = mPreviousView->getPosition();
|
||||||
restorePosition.x() = mWrapPreviousPositionX;
|
restorePosition.x = mWrapPreviousPositionX;
|
||||||
mPreviousView->setPosition(restorePosition);
|
mPreviousView->setPosition(restorePosition);
|
||||||
mWrapPreviousPositionX = 0;
|
mWrapPreviousPositionX = 0;
|
||||||
mWrappedViews = false;
|
mWrappedViews = false;
|
||||||
|
@ -320,7 +320,7 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
||||||
|
|
||||||
auto systemList = getSystemListView();
|
auto systemList = getSystemListView();
|
||||||
systemList->setPosition(getSystemId(system) * static_cast<float>(Renderer::getScreenWidth()),
|
systemList->setPosition(getSystemId(system) * static_cast<float>(Renderer::getScreenWidth()),
|
||||||
systemList->getPosition().y());
|
systemList->getPosition().y);
|
||||||
|
|
||||||
systemList->goToSystem(system, false);
|
systemList->goToSystem(system, false);
|
||||||
mCurrentView = systemList;
|
mCurrentView = systemList;
|
||||||
|
@ -328,21 +328,21 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
|
||||||
|
|
||||||
// Application startup animation.
|
// Application startup animation.
|
||||||
if (applicationStartup) {
|
if (applicationStartup) {
|
||||||
mCamera.translation() = -mCurrentView->getPosition();
|
mCamera = glm::translate(mCamera, -mCurrentView->getPosition());
|
||||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
||||||
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
||||||
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
||||||
mCamera.translation().y() += Renderer::getScreenHeight();
|
mCamera[3].y += static_cast<float>(Renderer::getScreenHeight());
|
||||||
else
|
else
|
||||||
mCamera.translation().x() -= Renderer::getScreenWidth();
|
mCamera[3].x -= static_cast<float>(Renderer::getScreenWidth());
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
}
|
}
|
||||||
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
||||||
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
if (getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL ||
|
||||||
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
getSystemListView()->getCarouselType() == CarouselType::HORIZONTAL_WHEEL)
|
||||||
mCamera.translation().y() += Renderer::getScreenHeight();
|
mCamera[3].y += static_cast<float>(Renderer::getScreenHeight());
|
||||||
else
|
else
|
||||||
mCamera.translation().x() += Renderer::getScreenWidth();
|
mCamera[3].x += static_cast<float>(Renderer::getScreenWidth());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
|
@ -444,13 +444,13 @@ void ViewController::goToGameList(SystemData* system)
|
||||||
if (mState.viewing == SYSTEM_SELECT) {
|
if (mState.viewing == SYSTEM_SELECT) {
|
||||||
// Move the system list.
|
// Move the system list.
|
||||||
auto sysList = getSystemListView();
|
auto sysList = getSystemListView();
|
||||||
float offsetX = sysList->getPosition().x();
|
float offsetX = sysList->getPosition().x;
|
||||||
int sysId = getSystemId(system);
|
int sysId = getSystemId(system);
|
||||||
|
|
||||||
sysList->setPosition(sysId * static_cast<float>(Renderer::getScreenWidth()),
|
sysList->setPosition(sysId * static_cast<float>(Renderer::getScreenWidth()),
|
||||||
sysList->getPosition().y());
|
sysList->getPosition().y);
|
||||||
offsetX = sysList->getPosition().x() - offsetX;
|
offsetX = sysList->getPosition().x - offsetX;
|
||||||
mCamera.translation().x() -= offsetX;
|
mCamera[3].x -= offsetX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are wrapping around, either from the first to last system, or the other way
|
// If we are wrapping around, either from the first to last system, or the other way
|
||||||
|
@ -458,30 +458,30 @@ void ViewController::goToGameList(SystemData* system)
|
||||||
// movements will be correct. This is accomplished by simply offsetting the X position
|
// movements will be correct. This is accomplished by simply offsetting the X position
|
||||||
// with the position of the first or last system plus the screen width.
|
// with the position of the first or last system plus the screen width.
|
||||||
if (wrapFirstToLast) {
|
if (wrapFirstToLast) {
|
||||||
Vector3f currentPosition = mCurrentView->getPosition();
|
glm::vec3 currentPosition = mCurrentView->getPosition();
|
||||||
mWrapPreviousPositionX = currentPosition.x();
|
mWrapPreviousPositionX = currentPosition.x;
|
||||||
float offsetX = getGameListView(system)->getPosition().x();
|
float offsetX = getGameListView(system)->getPosition().x;
|
||||||
// This is needed to move the camera in the correct direction if there are only two systems.
|
// This is needed to move the camera in the correct direction if there are only two systems.
|
||||||
if (SystemData::sSystemVector.size() == 2 && mNextSystem)
|
if (SystemData::sSystemVector.size() == 2 && mNextSystem)
|
||||||
offsetX -= Renderer::getScreenWidth();
|
offsetX -= Renderer::getScreenWidth();
|
||||||
else
|
else
|
||||||
offsetX += Renderer::getScreenWidth();
|
offsetX += Renderer::getScreenWidth();
|
||||||
currentPosition.x() = offsetX;
|
currentPosition.x = offsetX;
|
||||||
mCurrentView->setPosition(currentPosition);
|
mCurrentView->setPosition(currentPosition);
|
||||||
mCamera.translation().x() -= offsetX;
|
mCamera[3].x -= offsetX;
|
||||||
mWrappedViews = true;
|
mWrappedViews = true;
|
||||||
}
|
}
|
||||||
else if (wrapLastToFirst) {
|
else if (wrapLastToFirst) {
|
||||||
Vector3f currentPosition = mCurrentView->getPosition();
|
glm::vec3 currentPosition = mCurrentView->getPosition();
|
||||||
mWrapPreviousPositionX = currentPosition.x();
|
mWrapPreviousPositionX = currentPosition.x;
|
||||||
float offsetX = getGameListView(system)->getPosition().x();
|
float offsetX = getGameListView(system)->getPosition().x;
|
||||||
if (SystemData::sSystemVector.size() == 2 && !mNextSystem)
|
if (SystemData::sSystemVector.size() == 2 && !mNextSystem)
|
||||||
offsetX += Renderer::getScreenWidth();
|
offsetX += Renderer::getScreenWidth();
|
||||||
else
|
else
|
||||||
offsetX -= Renderer::getScreenWidth();
|
offsetX -= Renderer::getScreenWidth();
|
||||||
currentPosition.x() = offsetX;
|
currentPosition.x = offsetX;
|
||||||
mCurrentView->setPosition(currentPosition);
|
mCurrentView->setPosition(currentPosition);
|
||||||
mCamera.translation().x() = -offsetX;
|
mCamera[3].x = -offsetX;
|
||||||
mWrappedViews = true;
|
mWrappedViews = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,13 +489,13 @@ void ViewController::goToGameList(SystemData* system)
|
||||||
|
|
||||||
// Application startup animation, if starting in a gamelist rather than in the system view.
|
// Application startup animation, if starting in a gamelist rather than in the system view.
|
||||||
if (mState.viewing == NOTHING) {
|
if (mState.viewing == NOTHING) {
|
||||||
mCamera.translation() = -mCurrentView->getPosition();
|
mCamera = glm::translate(mCamera, -mCurrentView->getPosition());
|
||||||
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
|
||||||
mCamera.translation().y() -= Renderer::getScreenHeight();
|
mCamera[3].y -= static_cast<float>(Renderer::getScreenHeight());
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
}
|
}
|
||||||
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
else if (Settings::getInstance()->getString("TransitionStyle") == "fade") {
|
||||||
mCamera.translation().y() += Renderer::getScreenHeight() * 2;
|
mCamera[3].y += static_cast<float>(Renderer::getScreenHeight() * 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
|
@ -528,13 +528,13 @@ void ViewController::playViewTransition(bool instant)
|
||||||
{
|
{
|
||||||
mCancelledTransition = false;
|
mCancelledTransition = false;
|
||||||
|
|
||||||
Vector3f target(Vector3f::Zero());
|
glm::vec3 target {};
|
||||||
if (mCurrentView)
|
if (mCurrentView)
|
||||||
target = mCurrentView->getPosition();
|
target = mCurrentView->getPosition();
|
||||||
|
|
||||||
// No need to animate, we're not going anywhere (probably due to goToNextGamelist()
|
// No need to animate, we're not going anywhere (probably due to goToNextGamelist()
|
||||||
// or goToPrevGamelist() being called when there's only 1 system).
|
// or goToPrevGamelist() being called when there's only 1 system).
|
||||||
if (target == -mCamera.translation() && !isAnimationPlaying(0))
|
if (target == static_cast<glm::vec3>(-mCamera[3]) && !isAnimationPlaying(0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
||||||
|
@ -542,7 +542,9 @@ void ViewController::playViewTransition(bool instant)
|
||||||
if (instant || transition_style == "instant") {
|
if (instant || transition_style == "instant") {
|
||||||
setAnimation(new LambdaAnimation(
|
setAnimation(new LambdaAnimation(
|
||||||
[this, target](float /*t*/) {
|
[this, target](float /*t*/) {
|
||||||
this->mCamera.translation() = -target;
|
this->mCamera[3].x = -target.x;
|
||||||
|
this->mCamera[3].y = -target.y;
|
||||||
|
this->mCamera[3].z = -target.z;
|
||||||
if (mPreviousView)
|
if (mPreviousView)
|
||||||
mPreviousView->onHide();
|
mPreviousView->onHide();
|
||||||
},
|
},
|
||||||
|
@ -571,14 +573,16 @@ void ViewController::playViewTransition(bool instant)
|
||||||
const static int FADE_WAIT = 200; // Time to wait between in/out.
|
const static int FADE_WAIT = 200; // Time to wait between in/out.
|
||||||
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), 0,
|
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), 0,
|
||||||
[this, fadeFunc, fadeCallback, target] {
|
[this, fadeFunc, fadeCallback, target] {
|
||||||
this->mCamera.translation() = -target;
|
this->mCamera[3].x = -target.x;
|
||||||
|
this->mCamera[3].y = -target.y;
|
||||||
|
this->mCamera[3].z = -target.z;
|
||||||
updateHelpPrompts();
|
updateHelpPrompts();
|
||||||
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), FADE_WAIT,
|
setAnimation(new LambdaAnimation(fadeFunc, FADE_DURATION), FADE_WAIT,
|
||||||
fadeCallback, true);
|
fadeCallback, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fast-forward animation if we're partway faded.
|
// Fast-forward animation if we're partway faded.
|
||||||
if (target == -mCamera.translation()) {
|
if (target == static_cast<glm::vec3>(-mCamera[3])) {
|
||||||
// Not changing screens, so cancel the first half entirely.
|
// Not changing screens, so cancel the first half entirely.
|
||||||
advanceAnimation(0, FADE_DURATION);
|
advanceAnimation(0, FADE_DURATION);
|
||||||
advanceAnimation(0, FADE_WAIT);
|
advanceAnimation(0, FADE_WAIT);
|
||||||
|
@ -848,16 +852,17 @@ void ViewController::update(int deltaTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::render(const Transform4x4f& parentTrans)
|
void ViewController::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = mCamera * parentTrans;
|
glm::mat4 trans = mCamera * parentTrans;
|
||||||
Transform4x4f transInverse;
|
glm::mat4 transInverse;
|
||||||
transInverse.invert(trans);
|
transInverse = glm::inverse(trans);
|
||||||
|
|
||||||
// Camera position, position + size.
|
// Camera position, position + size.
|
||||||
Vector3f viewStart = transInverse.translation();
|
glm::vec3 viewStart = transInverse[3];
|
||||||
Vector3f viewEnd = transInverse * Vector3f(static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec3 viewEnd = { std::fabs(trans[3].x) + static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight(), 0));
|
std::fabs(trans[3].y) + static_cast<float>(Renderer::getScreenHeight()),
|
||||||
|
0.0f };
|
||||||
|
|
||||||
// Keep track of UI mode changes.
|
// Keep track of UI mode changes.
|
||||||
UIModeController::getInstance()->monitorUIMode();
|
UIModeController::getInstance()->monitorUIMode();
|
||||||
|
@ -872,12 +877,13 @@ void ViewController::render(const Transform4x4f& parentTrans)
|
||||||
// Same thing as for the system view, limit the rendering only to what needs to be drawn.
|
// Same thing as for the system view, limit the rendering only to what needs to be drawn.
|
||||||
if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
|
if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
|
||||||
// Clipping.
|
// Clipping.
|
||||||
Vector3f guiStart = it->second->getPosition();
|
glm::vec3 guiStart = it->second->getPosition();
|
||||||
Vector3f guiEnd = it->second->getPosition() +
|
glm::vec3 guiEnd =
|
||||||
Vector3f(it->second->getSize().x(), it->second->getSize().y(), 0);
|
it->second->getPosition() +
|
||||||
|
glm::vec3(it->second->getSize().x(), it->second->getSize().y(), 0.0f);
|
||||||
|
|
||||||
if (guiEnd.x() >= viewStart.x() && guiEnd.y() >= viewStart.y() &&
|
if (guiEnd.x >= viewStart.x && guiEnd.y >= viewStart.y && guiStart.x <= viewEnd.x &&
|
||||||
guiStart.x() <= viewEnd.x() && guiStart.y() <= viewEnd.y())
|
guiStart.y <= viewEnd.y)
|
||||||
it->second->render(trans);
|
it->second->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1006,7 @@ void ViewController::reloadAll()
|
||||||
SystemData* system = mState.getSystem();
|
SystemData* system = mState.getSystem();
|
||||||
mSystemListView->goToSystem(system, false);
|
mSystemListView->goToSystem(system, false);
|
||||||
mCurrentView = mSystemListView;
|
mCurrentView = mSystemListView;
|
||||||
mCamera.r3().x() = 0;
|
mCamera[3].x = 0.0f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
goToSystemView(SystemData::sSystemVector.front(), false);
|
goToSystemView(SystemData::sSystemVector.front(), false);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
NOTHING, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
NOTHING, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
||||||
|
@ -152,7 +152,7 @@ private:
|
||||||
FileData* mGameToLaunch;
|
FileData* mGameToLaunch;
|
||||||
State mState;
|
State mState;
|
||||||
|
|
||||||
Transform4x4f mCamera;
|
glm::mat4 mCamera;
|
||||||
bool mSystemViewTransition;
|
bool mSystemViewTransition;
|
||||||
bool mWrappedViews;
|
bool mWrappedViews;
|
||||||
float mWrapPreviousPositionX;
|
float mWrapPreviousPositionX;
|
||||||
|
|
|
@ -45,7 +45,7 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root)
|
||||||
{
|
{
|
||||||
const float padding = 0.01f;
|
const float padding = 0.01f;
|
||||||
|
|
||||||
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y());
|
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y);
|
||||||
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());
|
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());
|
||||||
mList.setAlignment(TextListComponent<FileData*>::ALIGN_LEFT);
|
mList.setAlignment(TextListComponent<FileData*>::ALIGN_LEFT);
|
||||||
mList.setCursorChangedCallback([&](const CursorState& /*state*/) { updateInfoPanel(); });
|
mList.setCursorChangedCallback([&](const CursorState& /*state*/) { updateInfoPanel(); });
|
||||||
|
@ -69,7 +69,7 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root)
|
||||||
|
|
||||||
// Image.
|
// Image.
|
||||||
mImage.setOrigin(0.5f, 0.5f);
|
mImage.setOrigin(0.5f, 0.5f);
|
||||||
mImage.setPosition(mSize.x() * 0.25f, mList.getPosition().y() + mSize.y() * 0.2125f);
|
mImage.setPosition(mSize.x() * 0.25f, mList.getPosition().y + mSize.y() * 0.2125f);
|
||||||
mImage.setMaxSize(mSize.x() * (0.50f - 2 * padding), mSize.y() * 0.4f);
|
mImage.setMaxSize(mSize.x() * (0.50f - 2 * padding), mSize.y() * 0.4f);
|
||||||
mImage.setDefaultZIndex(30);
|
mImage.setDefaultZIndex(30);
|
||||||
addChild(&mImage);
|
addChild(&mImage);
|
||||||
|
@ -110,7 +110,7 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root)
|
||||||
|
|
||||||
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
||||||
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
mDescContainer.setAutoScroll(true);
|
mDescContainer.setAutoScroll(true);
|
||||||
mDescContainer.setDefaultZIndex(40);
|
mDescContainer.setDefaultZIndex(40);
|
||||||
addChild(&mDescContainer);
|
addChild(&mDescContainer);
|
||||||
|
@ -172,7 +172,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == 0)
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -187,21 +187,21 @@ void DetailedGameListView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
glm::vec3 start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
||||||
|
|
||||||
const float colSize = (mSize.x() * 0.48f) / colCount;
|
const float colSize = (mSize.x() * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y();
|
const float rowPadding = 0.01f * mSize.y();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); i++) {
|
for (unsigned int i = 0; i < components.size(); i++) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
Vector3f pos(0.0f, 0.0f, 0.0f);
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + Vector3f(colSize * (i / rowCount), 0, 0);
|
pos = start + glm::vec3(colSize * (i / rowCount), 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + Vector3f(0, lc->getSize().y() + rowPadding, 0);
|
pos = lc->getPosition() + glm::vec3(0.0f, lc->getSize().y() + rowPadding, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -231,19 +231,19 @@ void DetailedGameListView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); i++) {
|
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||||
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
Vector3f(labels[i]->getSize().x(), heightDiff, 0));
|
glm::vec3(labels[i]->getSize().x(), heightDiff, 0.0f));
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
||||||
values[i]->setDefaultZIndex(40.0f);
|
values[i]->setDefaultZIndex(40.0f);
|
||||||
|
|
||||||
float testBot = values[i]->getPosition().y() + values[i]->getSize().y();
|
float testBot = values[i]->getPosition().y + values[i]->getSize().y();
|
||||||
|
|
||||||
if (testBot > bottom)
|
if (testBot > bottom)
|
||||||
bottom = testBot;
|
bottom = testBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDescContainer.setPosition(mDescContainer.getPosition().x(), bottom + mSize.y() * 0.01f);
|
mDescContainer.setPosition(mDescContainer.getPosition().x, bottom + mSize.y() * 0.01f);
|
||||||
mDescContainer.setSize(mDescContainer.getSize().x(),
|
mDescContainer.setSize(mDescContainer.getSize().x(),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetailedGameListView::updateInfoPanel()
|
void DetailedGameListView::updateInfoPanel()
|
||||||
|
|
|
@ -90,7 +90,7 @@ GridGameListView::GridGameListView(Window* window, FileData* root)
|
||||||
|
|
||||||
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
||||||
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
mDescContainer.setAutoScroll(true);
|
mDescContainer.setAutoScroll(true);
|
||||||
mDescContainer.setDefaultZIndex(40);
|
mDescContainer.setDefaultZIndex(40);
|
||||||
addChild(&mDescContainer);
|
addChild(&mDescContainer);
|
||||||
|
@ -277,7 +277,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == 0)
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -298,21 +298,21 @@ void GridGameListView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
glm::vec3 start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
||||||
|
|
||||||
const float colSize = (mSize.x() * 0.48f) / colCount;
|
const float colSize = (mSize.x() * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y();
|
const float rowPadding = 0.01f * mSize.y();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); i++) {
|
for (unsigned int i = 0; i < components.size(); i++) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
Vector3f pos(0.0f, 0.0f, 0.0f);
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + Vector3f(colSize * (i / rowCount), 0, 0);
|
pos = start + glm::vec3(colSize * (i / rowCount), 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + Vector3f(0, lc->getSize().y() + rowPadding, 0);
|
pos = lc->getPosition() + glm::vec3(0.0f, lc->getSize().y() + rowPadding, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -342,18 +342,18 @@ void GridGameListView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); i++) {
|
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||||
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
Vector3f(labels[i]->getSize().x(), heightDiff, 0));
|
glm::vec3(labels[i]->getSize().x(), heightDiff, 0.0f));
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
||||||
values[i]->setDefaultZIndex(40);
|
values[i]->setDefaultZIndex(40);
|
||||||
|
|
||||||
float testBot = values[i]->getPosition().y() + values[i]->getSize().y();
|
float testBot = values[i]->getPosition().y + values[i]->getSize().y();
|
||||||
if (testBot > bottom)
|
if (testBot > bottom)
|
||||||
bottom = testBot;
|
bottom = testBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDescContainer.setPosition(mDescContainer.getPosition().x(), bottom + mSize.y() * 0.01f);
|
mDescContainer.setPosition(mDescContainer.getPosition().x, bottom + mSize.y() * 0.01f);
|
||||||
mDescContainer.setSize(mDescContainer.getSize().x(),
|
mDescContainer.setSize(mDescContainer.getSize().x(),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridGameListView::updateInfoPanel()
|
void GridGameListView::updateInfoPanel()
|
||||||
|
|
|
@ -60,15 +60,15 @@ HelpStyle IGameListView::getHelpStyle()
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGameListView::render(const Transform4x4f& parentTrans)
|
void IGameListView::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
float scaleX = trans.r0().x();
|
float scaleX = trans[0].x;
|
||||||
float scaleY = trans.r1().y();
|
float scaleY = trans[1].y;
|
||||||
|
|
||||||
Vector2i pos(static_cast<int>(std::round(trans.translation()[0])),
|
Vector2i pos(static_cast<int>(std::round(trans[3].x)),
|
||||||
static_cast<int>(std::round(trans.translation()[1])));
|
static_cast<int>(std::round(trans[3].y)));
|
||||||
Vector2i size(static_cast<int>(std::round(mSize.x() * scaleX)),
|
Vector2i size(static_cast<int>(std::round(mSize.x() * scaleX)),
|
||||||
static_cast<int>(std::round(mSize.y() * scaleY)));
|
static_cast<int>(std::round(mSize.y() * scaleY)));
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
virtual HelpStyle getHelpStyle() override;
|
virtual HelpStyle getHelpStyle() override;
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileData* mRoot;
|
FileData* mRoot;
|
||||||
|
|
|
@ -64,7 +64,7 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root)
|
||||||
mVideo = new VideoFFmpegComponent(window);
|
mVideo = new VideoFFmpegComponent(window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y());
|
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y);
|
||||||
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());
|
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());
|
||||||
mList.setAlignment(TextListComponent<FileData*>::ALIGN_LEFT);
|
mList.setAlignment(TextListComponent<FileData*>::ALIGN_LEFT);
|
||||||
mList.setCursorChangedCallback([&](const CursorState& /*state*/) { updateInfoPanel(); });
|
mList.setCursorChangedCallback([&](const CursorState& /*state*/) { updateInfoPanel(); });
|
||||||
|
@ -127,7 +127,7 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root)
|
||||||
|
|
||||||
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
mDescContainer.setPosition(mSize.x() * padding, mSize.y() * 0.65f);
|
||||||
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
mDescContainer.setSize(mSize.x() * (0.50f - 2.0f * padding),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
mDescContainer.setAutoScroll(true);
|
mDescContainer.setAutoScroll(true);
|
||||||
mDescContainer.setDefaultZIndex(40);
|
mDescContainer.setDefaultZIndex(40);
|
||||||
addChild(&mDescContainer);
|
addChild(&mDescContainer);
|
||||||
|
@ -194,7 +194,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == 0)
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -209,21 +209,21 @@ void VideoGameListView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
glm::vec3 start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
||||||
|
|
||||||
const float colSize = (mSize.x() * 0.48f) / colCount;
|
const float colSize = (mSize.x() * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y();
|
const float rowPadding = 0.01f * mSize.y();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); i++) {
|
for (unsigned int i = 0; i < components.size(); i++) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
Vector3f pos(0.0f, 0.0f, 0.0f);
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + Vector3f(colSize * (i / rowCount), 0, 0);
|
pos = start + glm::vec3(colSize * (i / rowCount), 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + Vector3f(0, lc->getSize().y() + rowPadding, 0);
|
pos = lc->getPosition() + glm::vec3(0.0f, lc->getSize().y() + rowPadding, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -253,19 +253,19 @@ void VideoGameListView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); i++) {
|
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||||
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
Vector3f(labels[i]->getSize().x(), heightDiff, 0));
|
glm::vec3(labels[i]->getSize().x(), heightDiff, 0.0f));
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y());
|
||||||
values[i]->setDefaultZIndex(40);
|
values[i]->setDefaultZIndex(40);
|
||||||
|
|
||||||
float testBot = values[i]->getPosition().y() + values[i]->getSize().y();
|
float testBot = values[i]->getPosition().y + values[i]->getSize().y();
|
||||||
|
|
||||||
if (testBot > bottom)
|
if (testBot > bottom)
|
||||||
bottom = testBot;
|
bottom = testBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDescContainer.setPosition(mDescContainer.getPosition().x(), bottom + mSize.y() * 0.01f);
|
mDescContainer.setPosition(mDescContainer.getPosition().x, bottom + mSize.y() * 0.01f);
|
||||||
mDescContainer.setSize(mDescContainer.getSize().x(),
|
mDescContainer.setSize(mDescContainer.getSize().x(),
|
||||||
mSize.y() - mDescContainer.getPosition().y());
|
mSize.y() - mDescContainer.getPosition().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoGameListView::updateInfoPanel()
|
void VideoGameListView::updateInfoPanel()
|
||||||
|
|
|
@ -24,11 +24,11 @@ GuiComponent::GuiComponent(Window* window)
|
||||||
, mColorShiftEnd(0)
|
, mColorShiftEnd(0)
|
||||||
, mOpacity(255)
|
, mOpacity(255)
|
||||||
, mSaturation(1.0f)
|
, mSaturation(1.0f)
|
||||||
, mPosition(Vector3f::Zero())
|
, mPosition({})
|
||||||
, mOrigin(Vector2f::Zero())
|
, mOrigin(Vector2f::Zero())
|
||||||
, mRotationOrigin(0.5f, 0.5f)
|
, mRotationOrigin(0.5f, 0.5f)
|
||||||
, mSize(Vector2f::Zero())
|
, mSize(Vector2f::Zero())
|
||||||
, mTransform(Transform4x4f::Identity())
|
, mTransform(Renderer::getIdentity())
|
||||||
, mIsProcessing(false)
|
, mIsProcessing(false)
|
||||||
, mVisible(true)
|
, mVisible(true)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
|
@ -78,16 +78,16 @@ void GuiComponent::update(int deltaTime)
|
||||||
updateChildren(deltaTime);
|
updateChildren(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::render(const Transform4x4f& parentTrans)
|
void GuiComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::renderChildren(const Transform4x4f& transform) const
|
void GuiComponent::renderChildren(const glm::mat4& transform) const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); i++)
|
||||||
getChild(i)->render(transform);
|
getChild(i)->render(transform);
|
||||||
|
@ -95,7 +95,7 @@ void GuiComponent::renderChildren(const Transform4x4f& transform) const
|
||||||
|
|
||||||
void GuiComponent::setPosition(float x, float y, float z)
|
void GuiComponent::setPosition(float x, float y, float z)
|
||||||
{
|
{
|
||||||
mPosition = Vector3f(x, y, z);
|
mPosition = glm::vec3(x, y, z);
|
||||||
onPositionChanged();
|
onPositionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ void GuiComponent::setSize(float w, float h)
|
||||||
|
|
||||||
Vector2f GuiComponent::getCenter() const
|
Vector2f GuiComponent::getCenter() const
|
||||||
{
|
{
|
||||||
return Vector2f(mPosition.x() - (getSize().x() * mOrigin.x()) + getSize().x() / 2.0f,
|
return Vector2f(mPosition.x - (getSize().x() * mOrigin.x()) + getSize().x() / 2.0f,
|
||||||
mPosition.y() - (getSize().y() * mOrigin.y()) + getSize().y() / 2.0f);
|
mPosition.y - (getSize().y() * mOrigin.y()) + getSize().y() / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::addChild(GuiComponent* cmp)
|
void GuiComponent::addChild(GuiComponent* cmp)
|
||||||
|
@ -171,13 +171,13 @@ void GuiComponent::setOpacity(unsigned char opacity)
|
||||||
(*it)->setOpacity(opacity);
|
(*it)->setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Transform4x4f& GuiComponent::getTransform()
|
const glm::mat4& GuiComponent::getTransform()
|
||||||
{
|
{
|
||||||
mTransform = Transform4x4f::Identity();
|
mTransform = Renderer::getIdentity();
|
||||||
mTransform.translate(mPosition);
|
mTransform = glm::translate(mTransform, mPosition);
|
||||||
|
|
||||||
if (mScale != 1.0f)
|
if (mScale != 1.0f)
|
||||||
mTransform.scale(mScale);
|
mTransform = glm::scale(mTransform, glm::vec3(mScale));
|
||||||
|
|
||||||
if (mRotation != 0.0f) {
|
if (mRotation != 0.0f) {
|
||||||
// Calculate offset as difference between origin and rotation origin.
|
// Calculate offset as difference between origin and rotation origin.
|
||||||
|
@ -187,17 +187,18 @@ const Transform4x4f& GuiComponent::getTransform()
|
||||||
|
|
||||||
// Transform to offset point.
|
// Transform to offset point.
|
||||||
if (xOff != 0.0f || yOff != 0.0f)
|
if (xOff != 0.0f || yOff != 0.0f)
|
||||||
mTransform.translate(Vector3f(xOff * -1.0f, yOff * -1.0f, 0.0f));
|
mTransform = glm::translate(mTransform, glm::vec3(xOff * -1.0f, yOff * -1.0f, 0.0f));
|
||||||
|
|
||||||
// Apply rotation transform.
|
// Apply rotation transform.
|
||||||
mTransform.rotateZ(mRotation);
|
mTransform = glm::rotate(mTransform, mRotation, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
// Transform back to original point.
|
// Transform back to original point.
|
||||||
if (xOff != 0.0f || yOff != 0.0f)
|
if (xOff != 0.0f || yOff != 0.0f)
|
||||||
mTransform.translate(Vector3f(xOff, yOff, 0.0f));
|
mTransform = glm::translate(mTransform, glm::vec3(xOff, yOff, 0.0f));
|
||||||
}
|
}
|
||||||
mTransform.translate(
|
mTransform = glm::translate(mTransform, glm::vec3(mOrigin.x() * mSize.x() * -1.0f,
|
||||||
Vector3f(mOrigin.x() * mSize.x() * -1.0f, mOrigin.y() * mSize.y() * -1.0f, 0.0f));
|
mOrigin.y() * mSize.y() * -1.0f, 0.0f));
|
||||||
|
|
||||||
return mTransform;
|
return mTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +313,7 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
if (properties & POSITION && elem->has("pos")) {
|
if (properties & POSITION && elem->has("pos")) {
|
||||||
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;
|
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;
|
||||||
setPosition(Vector3f(denormalized.x(), denormalized.y(), 0));
|
setPosition(glm::vec3(denormalized.x(), denormalized.y(), 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "InputConfig.h"
|
#include "InputConfig.h"
|
||||||
#include "animations/AnimationController.h"
|
#include "animations/AnimationController.h"
|
||||||
#include "math/Misc.h"
|
#include "math/Misc.h"
|
||||||
#include "math/Transform4x4f.h"
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -45,8 +44,8 @@ public:
|
||||||
virtual void textInput(const std::string& text);
|
virtual void textInput(const std::string& text);
|
||||||
|
|
||||||
// Called when input is received.
|
// Called when input is received.
|
||||||
// Return true if the input is consumed, false if
|
// Return true if the input is consumed, false if it should continue to be passed
|
||||||
// it should continue to be passed to other children.
|
// to other children.
|
||||||
virtual bool input(InputConfig* config, Input input);
|
virtual bool input(InputConfig* config, Input input);
|
||||||
|
|
||||||
// Called when time passes.
|
// Called when time passes.
|
||||||
|
@ -56,18 +55,19 @@ public:
|
||||||
virtual void update(int deltaTime);
|
virtual void update(int deltaTime);
|
||||||
|
|
||||||
// Called when it's time to render.
|
// Called when it's time to render.
|
||||||
// By default, just calls renderChildren(parentTrans * getTransform()).
|
// By default, just calls renderChildren(parentTrans * getTransform())
|
||||||
// You probably want to override this like so:
|
// Normally the following steps are required:
|
||||||
// 1. Calculate the new transform that your control will draw at with
|
// 1. Calculate the new transform that your component will draw at
|
||||||
// Transform4x4f t = parentTrans * getTransform().
|
// glm::mat4 trans = parentTrans * getTransform();
|
||||||
// 2. Set the renderer to use that new transform as the model matrix
|
// 2. Set the renderer to use that new transform as the model matrix
|
||||||
// Renderer::setMatrix(t);
|
// Renderer::setMatrix(trans);
|
||||||
// 3. Draw your component.
|
// 3. Draw your component
|
||||||
// 4. Tell your children to render, based on your component's transform - renderChildren(t).
|
// 4. Tell your children to render, based on your component's transform
|
||||||
virtual void render(const Transform4x4f& parentTrans);
|
// renderChildren(trans);
|
||||||
|
virtual void render(const glm::mat4& parentTrans);
|
||||||
|
|
||||||
Vector3f getPosition() const { return mPosition; }
|
glm::vec3 getPosition() const { return mPosition; }
|
||||||
void setPosition(const Vector3f& offset) { setPosition(offset.x(), offset.y(), offset.z()); }
|
void setPosition(const glm::vec3& offset) { setPosition(offset.x, offset.y, offset.z); }
|
||||||
void setPosition(float x, float y, float z = 0.0f);
|
void setPosition(float x, float y, float z = 0.0f);
|
||||||
virtual void onPositionChanged() {}
|
virtual void onPositionChanged() {}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
void setRotation(float rotation) { mRotation = rotation; }
|
void setRotation(float rotation) { mRotation = rotation; }
|
||||||
void setRotationDegrees(float rotation)
|
void setRotationDegrees(float rotation)
|
||||||
{
|
{
|
||||||
setRotation(static_cast<float>(ES_DEG_TO_RAD(rotation)));
|
setRotation(static_cast<float>(glm::radians(rotation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float getScale() const { return mScale; }
|
float getScale() const { return mScale; }
|
||||||
|
@ -183,7 +183,7 @@ public:
|
||||||
|
|
||||||
virtual std::shared_ptr<Font> getFont() const { return nullptr; }
|
virtual std::shared_ptr<Font> getFont() const { return nullptr; }
|
||||||
|
|
||||||
const Transform4x4f& getTransform();
|
const glm::mat4& getTransform();
|
||||||
|
|
||||||
virtual std::string getValue() const { return ""; }
|
virtual std::string getValue() const { return ""; }
|
||||||
virtual void setValue(const std::string& value) {}
|
virtual void setValue(const std::string& value) {}
|
||||||
|
@ -231,7 +231,7 @@ public:
|
||||||
const static unsigned char MAX_ANIMATIONS = 4;
|
const static unsigned char MAX_ANIMATIONS = 4;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void renderChildren(const Transform4x4f& transform) const;
|
void renderChildren(const glm::mat4& transform) const;
|
||||||
void updateSelf(int deltaTime); // Updates animations.
|
void updateSelf(int deltaTime); // Updates animations.
|
||||||
void updateChildren(int deltaTime); // Updates animations.
|
void updateChildren(int deltaTime); // Updates animations.
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ protected:
|
||||||
GuiComponent* mParent;
|
GuiComponent* mParent;
|
||||||
std::vector<GuiComponent*> mChildren;
|
std::vector<GuiComponent*> mChildren;
|
||||||
|
|
||||||
Vector3f mPosition;
|
glm::vec3 mPosition;
|
||||||
Vector2f mOrigin;
|
Vector2f mOrigin;
|
||||||
Vector2f mRotationOrigin;
|
Vector2f mRotationOrigin;
|
||||||
Vector2f mSize;
|
Vector2f mSize;
|
||||||
|
@ -265,8 +265,8 @@ protected:
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Don't access this directly! Use getTransform()!
|
// Don't access this directly, instead use getTransform().
|
||||||
Transform4x4f mTransform;
|
glm::mat4 mTransform;
|
||||||
AnimationController* mAnimationMap[MAX_ANIMATIONS];
|
AnimationController* mAnimationMap[MAX_ANIMATIONS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
#include "math/Misc.h"
|
||||||
#include "resources/Font.h"
|
#include "resources/Font.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -348,7 +349,7 @@ void Window::update(int deltaTime)
|
||||||
|
|
||||||
void Window::render()
|
void Window::render()
|
||||||
{
|
{
|
||||||
Transform4x4f transform = Transform4x4f::Identity();
|
glm::mat4 trans = Renderer::getIdentity();
|
||||||
|
|
||||||
mRenderedHelpPrompts = false;
|
mRenderedHelpPrompts = false;
|
||||||
|
|
||||||
|
@ -378,7 +379,7 @@ void Window::render()
|
||||||
renderBottom = false;
|
renderBottom = false;
|
||||||
|
|
||||||
if (renderBottom)
|
if (renderBottom)
|
||||||
bottom->render(transform);
|
bottom->render(trans);
|
||||||
|
|
||||||
if (bottom != top || mRenderLaunchScreen) {
|
if (bottom != top || mRenderLaunchScreen) {
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
|
@ -468,7 +469,7 @@ void Window::render()
|
||||||
}
|
}
|
||||||
#endif // USE_OPENGL_21
|
#endif // USE_OPENGL_21
|
||||||
|
|
||||||
mBackgroundOverlay->render(transform);
|
mBackgroundOverlay->render(trans);
|
||||||
|
|
||||||
// Scale-up menu opening effect.
|
// Scale-up menu opening effect.
|
||||||
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
||||||
|
@ -482,7 +483,7 @@ void Window::render()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mRenderLaunchScreen)
|
if (!mRenderLaunchScreen)
|
||||||
top->render(transform);
|
top->render(trans);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mCachedBackground = false;
|
mCachedBackground = false;
|
||||||
|
@ -493,7 +494,7 @@ void Window::render()
|
||||||
|
|
||||||
// Render the quick list scrolling overlay, which is triggered in IList.
|
// Render the quick list scrolling overlay, which is triggered in IList.
|
||||||
if (mListScrollOpacity != 0) {
|
if (mListScrollOpacity != 0) {
|
||||||
Renderer::setMatrix(Transform4x4f::Identity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()),
|
static_cast<float>(Renderer::getScreenHeight()),
|
||||||
0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity);
|
0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity);
|
||||||
|
@ -509,7 +510,7 @@ void Window::render()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mRenderedHelpPrompts)
|
if (!mRenderedHelpPrompts)
|
||||||
mHelp->render(transform);
|
mHelp->render(trans);
|
||||||
|
|
||||||
unsigned int screensaverTimer =
|
unsigned int screensaverTimer =
|
||||||
static_cast<unsigned int>(Settings::getInstance()->getInt("ScreensaverTimer"));
|
static_cast<unsigned int>(Settings::getInstance()->getInt("ScreensaverTimer"));
|
||||||
|
@ -531,7 +532,7 @@ void Window::render()
|
||||||
renderScreensaver();
|
renderScreensaver();
|
||||||
|
|
||||||
if (!mRenderScreensaver && mInfoPopup)
|
if (!mRenderScreensaver && mInfoPopup)
|
||||||
mInfoPopup->render(transform);
|
mInfoPopup->render(trans);
|
||||||
|
|
||||||
if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
|
if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
|
||||||
if (!isProcessing() && mAllowSleep && (!mScreensaver)) {
|
if (!isProcessing() && mAllowSleep && (!mScreensaver)) {
|
||||||
|
@ -550,14 +551,14 @@ void Window::render()
|
||||||
mLaunchScreen->render();
|
mLaunchScreen->render();
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DisplayGPUStatistics") && mFrameDataText) {
|
if (Settings::getInstance()->getBool("DisplayGPUStatistics") && mFrameDataText) {
|
||||||
Renderer::setMatrix(Transform4x4f::Identity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
mDefaultFonts.at(1)->renderTextCache(mFrameDataText.get());
|
mDefaultFonts.at(1)->renderTextCache(mFrameDataText.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::renderLoadingScreen(std::string text)
|
void Window::renderLoadingScreen(std::string text)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = Transform4x4f::Identity();
|
glm::mat4 trans = Renderer::getIdentity();
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||||
|
@ -574,7 +575,7 @@ void Window::renderLoadingScreen(std::string text)
|
||||||
|
|
||||||
float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x()) / 2.0f);
|
float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x()) / 2.0f);
|
||||||
float y = std::round(Renderer::getScreenHeight() * 0.835f);
|
float y = std::round(Renderer::getScreenHeight() * 0.835f);
|
||||||
trans = trans.translate(Vector3f(x, y, 0.0f));
|
trans = glm::translate(trans, glm::vec3(x, y, 0.0f));
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
font->renderTextCache(cache);
|
font->renderTextCache(cache);
|
||||||
delete cache;
|
delete cache;
|
||||||
|
@ -590,7 +591,7 @@ void Window::renderListScrollOverlay(unsigned char opacity, const std::string& t
|
||||||
|
|
||||||
void Window::renderHelpPromptsEarly()
|
void Window::renderHelpPromptsEarly()
|
||||||
{
|
{
|
||||||
mHelp->render(Transform4x4f::Identity());
|
mHelp->render(Renderer::getIdentity());
|
||||||
mRenderedHelpPrompts = true;
|
mRenderedHelpPrompts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ class HelpComponent;
|
||||||
class ImageComponent;
|
class ImageComponent;
|
||||||
class InputConfig;
|
class InputConfig;
|
||||||
class TextCache;
|
class TextCache;
|
||||||
class Transform4x4f;
|
|
||||||
struct HelpStyle;
|
struct HelpStyle;
|
||||||
|
|
||||||
class Window
|
class Window
|
||||||
|
@ -77,7 +76,7 @@ public:
|
||||||
class InfoPopup
|
class InfoPopup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void render(const Transform4x4f& parentTrans) = 0;
|
virtual void render(const glm::mat4& parentTrans) = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual ~InfoPopup() {}
|
virtual ~InfoPopup() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ void AnimatedImageComponent::update(int deltaTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimatedImageComponent::render(const Transform4x4f& trans)
|
void AnimatedImageComponent::render(const glm::mat4& trans)
|
||||||
{
|
{
|
||||||
if (mFrames.size())
|
if (mFrames.size())
|
||||||
mFrames.at(mCurrentFrame).first->render(getTransform() * trans);
|
mFrames.at(mCurrentFrame).first->render(getTransform() * trans);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
void reset(); // Set to frame 0.
|
void reset(); // Set to frame 0.
|
||||||
|
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& trans) override;
|
void render(const glm::mat4& trans) override;
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ ButtonComponent::ButtonComponent(Window* window,
|
||||||
void ButtonComponent::onSizeChanged()
|
void ButtonComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
// Fit to mBox.
|
// Fit to mBox.
|
||||||
mBox.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBox.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ButtonComponent::input(InputConfig* config, Input input)
|
bool ButtonComponent::input(InputConfig* config, Input input)
|
||||||
|
@ -93,21 +93,21 @@ void ButtonComponent::updateImage()
|
||||||
mBox.setImagePath(mFocused ? ":/graphics/button_filled.svg" : ":/graphics/button.svg");
|
mBox.setImagePath(mFocused ? ":/graphics/button_filled.svg" : ":/graphics/button.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonComponent::render(const Transform4x4f& parentTrans)
|
void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
mBox.render(trans);
|
mBox.render(trans);
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
Vector3f centerOffset((mSize.x() - mTextCache->metrics.size.x()) / 2.0f,
|
glm::vec3 centerOffset((mSize.x() - mTextCache->metrics.size.x()) / 2.0f,
|
||||||
(mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0);
|
(mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f);
|
||||||
trans = trans.translate(centerOffset);
|
trans = glm::translate(trans, centerOffset);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
Renderer::drawRect(centerOffset.x(), 0.0f, mTextCache->metrics.size.x(), mSize.y(),
|
Renderer::drawRect(centerOffset.x, 0.0f, mTextCache->metrics.size.x(), mSize.y(),
|
||||||
0x00000033, 0x00000033);
|
0x00000033, 0x00000033);
|
||||||
Renderer::drawRect(mBox.getPosition().x(), 0.0f, mBox.getSize().x(), mSize.y(),
|
Renderer::drawRect(mBox.getPosition().x, 0.0f, mBox.getSize().x(), mSize.y(),
|
||||||
0x0000FF33, 0x0000FF33);
|
0x0000FF33, 0x0000FF33);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void ButtonComponent::render(const Transform4x4f& parentTrans)
|
||||||
|
|
||||||
mTextCache->setColor(getCurTextColor());
|
mTextCache->setColor(getCurTextColor());
|
||||||
mFont->renderTextCache(mTextCache.get());
|
mFont->renderTextCache(mTextCache.get());
|
||||||
trans = trans.translate(-centerOffset);
|
trans = glm::translate(trans, -centerOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
void setEnabled(bool state) override;
|
void setEnabled(bool state) override;
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void setText(const std::string& text, const std::string& helpText);
|
void setText(const std::string& text, const std::string& helpText);
|
||||||
|
|
||||||
|
|
|
@ -141,17 +141,16 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
||||||
if (cell.resize)
|
if (cell.resize)
|
||||||
cell.component->setSize(size);
|
cell.component->setSize(size);
|
||||||
|
|
||||||
// Position.
|
|
||||||
// Find top left corner.
|
// Find top left corner.
|
||||||
Vector3f pos(0, 0, 0);
|
glm::vec3 pos {};
|
||||||
for (int x = 0; x < cell.pos.x(); x++)
|
for (int x = 0; x < cell.pos.x(); x++)
|
||||||
pos[0] += getColWidth(x);
|
pos[0] += getColWidth(x);
|
||||||
for (int y = 0; y < cell.pos.y(); y++)
|
for (int y = 0; y < cell.pos.y(); y++)
|
||||||
pos[1] += getRowHeight(y);
|
pos[1] += getRowHeight(y);
|
||||||
|
|
||||||
// Center component.
|
// Center component.
|
||||||
pos[0] = pos.x() + (size.x() - cell.component->getSize().x()) / 2;
|
pos[0] = pos.x + (size.x() - cell.component->getSize().x()) / 2.0f;
|
||||||
pos[1] = pos.y() + (size.y() - cell.component->getSize().y()) / 2;
|
pos[1] = pos.y + (size.y() - cell.component->getSize().y()) / 2.0f;
|
||||||
|
|
||||||
cell.component->setPosition(pos);
|
cell.component->setPosition(pos);
|
||||||
}
|
}
|
||||||
|
@ -360,9 +359,9 @@ void ComponentGrid::update(int deltaTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentGrid::render(const Transform4x4f& parentTrans)
|
void ComponentGrid::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void textInput(const std::string& text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
void resetCursor();
|
void resetCursor();
|
||||||
|
|
|
@ -167,23 +167,25 @@ void ComponentList::updateCameraOffset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentList::render(const Transform4x4f& parentTrans)
|
void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!size())
|
if (!size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
// Clip everything to be inside our bounds.
|
// Clip everything to be inside our bounds.
|
||||||
Vector3f dim(mSize.x(), mSize.y(), 0.0f);
|
glm::vec3 dim(mSize.x(), mSize.y(), 0.0f);
|
||||||
dim = trans * dim - trans.translation();
|
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
||||||
|
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||||
|
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
Vector2i(static_cast<int>(std::round(trans.translation().x())),
|
Vector2i(static_cast<int>(std::round(trans[3].x)),
|
||||||
static_cast<int>(std::round(trans.translation().y()))),
|
static_cast<int>(std::round(trans[3].y))),
|
||||||
Vector2i(static_cast<int>(std::round(dim.x())), static_cast<int>(std::round(dim.y()))));
|
Vector2i(static_cast<int>(std::round(dim.x)), static_cast<int>(std::round(dim.y))));
|
||||||
|
|
||||||
// Scroll the camera.
|
// Scroll the camera.
|
||||||
trans.translate(Vector3f(0.0f, -std::round(mCameraOffset), 0.0f));
|
trans = glm::translate(trans, glm::vec3(0.0f, -std::round(mCameraOffset), 0.0f));
|
||||||
|
|
||||||
// Draw our entries.
|
// Draw our entries.
|
||||||
std::vector<GuiComponent*> drawAfterCursor;
|
std::vector<GuiComponent*> drawAfterCursor;
|
||||||
|
@ -243,11 +245,6 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
||||||
|
|
||||||
// Draw selector bar.
|
// Draw selector bar.
|
||||||
if (mFocused) {
|
if (mFocused) {
|
||||||
// Inversion: src * (1 - dst) + dst * 0 = where src = 1
|
|
||||||
// Need a function that goes roughly 0x777777 -> 0xFFFFFF
|
|
||||||
// and 0xFFFFFF -> 0x777777
|
|
||||||
// (1 - dst) + 0x77
|
|
||||||
|
|
||||||
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
|
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
|
||||||
|
|
||||||
if (opacity == 1) {
|
if (opacity == 1) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void textInput(const std::string& text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
|
@ -101,8 +101,9 @@ std::string DateTimeComponent::getDisplayString() const
|
||||||
return Utils::Time::timeToString(mTime.getTime(), mFormat);
|
return Utils::Time::timeToString(mTime.getTime(), mFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTimeComponent::render(const Transform4x4f& parentTrans)
|
void DateTimeComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
|
// Render the component.
|
||||||
TextComponent::render(parentTrans);
|
TextComponent::render(parentTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
Vector2f size = Vector2f::Zero(),
|
Vector2f size = Vector2f::Zero(),
|
||||||
unsigned int bgcolor = 0x00000000);
|
unsigned int bgcolor = 0x00000000);
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void setValue(const std::string& val) override;
|
void setValue(const std::string& val) override;
|
||||||
std::string getValue() const override;
|
std::string getValue() const override;
|
||||||
|
|
|
@ -154,9 +154,9 @@ void DateTimeEditComponent::update(int deltaTime)
|
||||||
GuiComponent::update(deltaTime);
|
GuiComponent::update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
std::shared_ptr<Font> font = getFont();
|
std::shared_ptr<Font> font = getFont();
|
||||||
|
@ -170,18 +170,18 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertically center.
|
// Vertically center.
|
||||||
Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f);
|
glm::vec3 off(0.0f, (mSize.y() - mTextCache->metrics.size.y()) / 2.0f, 0.0f);
|
||||||
|
|
||||||
if (mAlignRight)
|
if (mAlignRight)
|
||||||
off.x() += referenceSize - mTextCache->metrics.size.x();
|
off.x += referenceSize - mTextCache->metrics.size.x();
|
||||||
trans.translate(off);
|
trans = glm::translate(trans, off);
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
if (mTextCache->metrics.size.x() > 0) {
|
if (mTextCache->metrics.size.x() > 0) {
|
||||||
Renderer::drawRect(0.0f, 0.0f - off.y(), mSize.x() - off.x(), mSize.y(), 0x0000FF33,
|
Renderer::drawRect(0.0f, 0.0f - off.y, mSize.x() - off.x, mSize.y(), 0x0000FF33,
|
||||||
0x0000FF33);
|
0x0000FF33);
|
||||||
}
|
}
|
||||||
Renderer::drawRect(0.0f, 0.0f, mTextCache->metrics.size.x(),
|
Renderer::drawRect(0.0f, 0.0f, mTextCache->metrics.size.x(),
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
unsigned int getColor() const override { return mColor; }
|
unsigned int getColor() const override { return mColor; }
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
// Set how the point in time will be displayed:
|
// Set how the point in time will be displayed:
|
||||||
|
|
|
@ -50,9 +50,9 @@ GridTileComponent::GridTileComponent(Window* window)
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridTileComponent::render(const Transform4x4f& parentTrans)
|
void GridTileComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = getTransform() * parentTrans;
|
glm::mat4 trans = getTransform() * parentTrans;
|
||||||
|
|
||||||
if (mVisible)
|
if (mVisible)
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
@ -171,7 +171,7 @@ void GridTileComponent::setImage(const std::shared_ptr<TextureResource>& texture
|
||||||
|
|
||||||
void GridTileComponent::setSelected(bool selected,
|
void GridTileComponent::setSelected(bool selected,
|
||||||
bool allowAnimation,
|
bool allowAnimation,
|
||||||
Vector3f* pPosition,
|
glm::vec3* pPosition,
|
||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
if (mSelected == selected && !force)
|
if (mSelected == selected && !force)
|
||||||
|
@ -189,7 +189,7 @@ void GridTileComponent::setSelected(bool selected,
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mAnimPosition = Vector3f(pPosition->x(), pPosition->y(), pPosition->z());
|
mAnimPosition = Vector3f(pPosition->x, pPosition->y, pPosition->z);
|
||||||
|
|
||||||
auto func = [this](float t) {
|
auto func = [this](float t) {
|
||||||
t -= 1; // Cubic ease out.
|
t -= 1; // Cubic ease out.
|
||||||
|
@ -307,7 +307,7 @@ void GridTileComponent::calcCurrentProperties()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f GridTileComponent::getBackgroundPosition()
|
glm::vec3 GridTileComponent::getBackgroundPosition()
|
||||||
{
|
{
|
||||||
return mBackground.getPosition() + mPosition;
|
return mBackground.getPosition() + mPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class GridTileComponent : public GuiComponent
|
||||||
public:
|
public:
|
||||||
GridTileComponent(Window* window);
|
GridTileComponent(Window* window);
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
|
@ -45,13 +45,13 @@ public:
|
||||||
void setImage(const std::shared_ptr<TextureResource>& texture);
|
void setImage(const std::shared_ptr<TextureResource>& texture);
|
||||||
void setSelected(bool selected,
|
void setSelected(bool selected,
|
||||||
bool allowAnimation = true,
|
bool allowAnimation = true,
|
||||||
Vector3f* pPosition = nullptr,
|
glm::vec3* pPosition = nullptr,
|
||||||
bool force = false);
|
bool force = false);
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
|
||||||
void forceSize(Vector2f size, float selectedZoom);
|
void forceSize(Vector2f size, float selectedZoom);
|
||||||
|
|
||||||
Vector3f getBackgroundPosition();
|
glm::vec3 getBackgroundPosition();
|
||||||
|
|
||||||
virtual void update(int deltaTime) override;
|
virtual void update(int deltaTime) override;
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ void HelpComponent::updateGrid()
|
||||||
mGrid->setEntry(labels.at(i), Vector2i(col + 2, 0), false, false);
|
mGrid->setEntry(labels.at(i), Vector2i(col + 2, 0), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid->setPosition(Vector3f(mStyle.position.x(), mStyle.position.y(), 0.0f));
|
mGrid->setPosition({ mStyle.position.x(), mStyle.position.y(), 0.0f });
|
||||||
mGrid->setOrigin(mStyle.origin);
|
mGrid->setOrigin(mStyle.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +187,9 @@ void HelpComponent::setOpacity(unsigned char opacity)
|
||||||
mGrid->getChild(i)->setOpacity(opacity);
|
mGrid->getChild(i)->setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpComponent::render(const Transform4x4f& parentTrans)
|
void HelpComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
if (mGrid)
|
if (mGrid)
|
||||||
mGrid->render(trans);
|
mGrid->render(trans);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
void clearPrompts();
|
void clearPrompts();
|
||||||
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
||||||
|
|
||||||
void render(const Transform4x4f& parent) override;
|
void render(const glm::mat4& parent) override;
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(unsigned char opacity) override;
|
||||||
|
|
||||||
void setStyle(const HelpStyle& style);
|
void setStyle(const HelpStyle& style);
|
||||||
|
|
|
@ -282,7 +282,7 @@ protected:
|
||||||
scroll(mScrollVelocity);
|
scroll(mScrollVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void listRenderTitleOverlay(const Transform4x4f& /*trans*/)
|
void listRenderTitleOverlay(const glm::mat4& /*trans*/)
|
||||||
{
|
{
|
||||||
if (!Settings::getInstance()->getBool("ListScrollOverlay"))
|
if (!Settings::getInstance()->getBool("ListScrollOverlay"))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -387,12 +387,12 @@ void ImageComponent::updateColors()
|
||||||
mVertices[3].col = colorEnd;
|
mVertices[3].col = colorEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageComponent::render(const Transform4x4f& parentTrans)
|
void ImageComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mTexture && mOpacity > 0) {
|
if (mTexture && mOpacity > 0) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
bool hasImage() { return static_cast<bool>(mTexture); }
|
bool hasImage() { return static_cast<bool>(mTexture); }
|
||||||
std::shared_ptr<TextureResource> getTexture() { return mTexture; }
|
std::shared_ptr<TextureResource> getTexture() { return mTexture; }
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
|
@ -208,17 +208,17 @@ template <typename T> void ImageGridComponent<T>::update(int deltaTime)
|
||||||
(*it)->update(deltaTime);
|
(*it)->update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void ImageGridComponent<T>::render(const Transform4x4f& parentTrans)
|
template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = getTransform() * parentTrans;
|
glm::mat4 trans = getTransform() * parentTrans;
|
||||||
Transform4x4f tileTrans = trans;
|
glm::mat4 tileTrans = trans;
|
||||||
|
|
||||||
float offsetX =
|
float offsetX =
|
||||||
isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x() + mMargin.x());
|
isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x() + mMargin.x());
|
||||||
float offsetY =
|
float offsetY =
|
||||||
isVertical() ? mCamera * mCameraDirection * (mTileSize.y() + mMargin.y()) : 0.0f;
|
isVertical() ? mCamera * mCameraDirection * (mTileSize.y() + mMargin.y()) : 0.0f;
|
||||||
|
|
||||||
tileTrans.translate(Vector3f(offsetX, offsetY, 0.0));
|
tileTrans = glm::translate(tileTrans, glm::vec3(offsetX, offsetY, 0.0f));
|
||||||
|
|
||||||
if (mEntriesDirty) {
|
if (mEntriesDirty) {
|
||||||
updateTiles();
|
updateTiles();
|
||||||
|
@ -226,11 +226,11 @@ template <typename T> void ImageGridComponent<T>::render(const Transform4x4f& pa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a clipRect to hide tiles used to buffer texture loading.
|
// Create a clipRect to hide tiles used to buffer texture loading.
|
||||||
float scaleX = trans.r0().x();
|
float scaleX = trans[0].x;
|
||||||
float scaleY = trans.r1().y();
|
float scaleY = trans[1].y;
|
||||||
|
|
||||||
Vector2i pos(static_cast<int>(std::round(trans.translation()[0])),
|
Vector2i pos(static_cast<int>(std::round(trans[3].x)),
|
||||||
static_cast<int>(std::round(trans.translation()[1])));
|
static_cast<int>(std::round(trans[3].y)));
|
||||||
Vector2i size(static_cast<int>(std::round(mSize.x() * scaleX)),
|
Vector2i size(static_cast<int>(std::round(mSize.x() * scaleX)),
|
||||||
static_cast<int>(std::round(mSize.y() * scaleY)));
|
static_cast<int>(std::round(mSize.y() * scaleY)));
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f oldPos = Vector3f::Zero();
|
glm::vec3 oldPos {};
|
||||||
|
|
||||||
if (oldTile != nullptr && oldTile != newTile) {
|
if (oldTile != nullptr && oldTile != newTile) {
|
||||||
oldPos = oldTile->getBackgroundPosition();
|
oldPos = oldTile->getBackgroundPosition();
|
||||||
|
@ -457,7 +457,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTile != nullptr)
|
if (newTile != nullptr)
|
||||||
newTile->setSelected(true, true, oldPos == Vector3f::Zero() ? nullptr : &oldPos, true);
|
newTile->setSelected(true, true, oldPos == glm::vec3 {} ? nullptr : &oldPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstVisibleCol = mStartPosition / dimOpposite;
|
int firstVisibleCol = mStartPosition / dimOpposite;
|
||||||
|
@ -677,7 +677,7 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos,
|
||||||
if (idx < 0 || idx >= mTiles.size())
|
if (idx < 0 || idx >= mTiles.size())
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
|
||||||
Vector3f pos = mTiles.at(idx)->getBackgroundPosition();
|
glm::vec3 pos = mTiles.at(idx)->getBackgroundPosition();
|
||||||
tile->setSelected(true, allowAnimation, &pos);
|
tile->setSelected(true, allowAnimation, &pos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -106,7 +106,7 @@ void MenuComponent::updateSize()
|
||||||
|
|
||||||
void MenuComponent::onSizeChanged()
|
void MenuComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
// Update grid row/column sizes.
|
// Update grid row/column sizes.
|
||||||
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y());
|
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y());
|
||||||
|
|
|
@ -118,12 +118,12 @@ void NinePatchComponent::buildVertices()
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NinePatchComponent::render(const Transform4x4f& parentTrans)
|
void NinePatchComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
if (mTexture && mVertices != nullptr) {
|
if (mTexture && mVertices != nullptr) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
@ -146,15 +146,15 @@ void NinePatchComponent::render(const Transform4x4f& parentTrans)
|
||||||
|
|
||||||
void NinePatchComponent::onSizeChanged() { buildVertices(); }
|
void NinePatchComponent::onSizeChanged() { buildVertices(); }
|
||||||
|
|
||||||
void NinePatchComponent::fitTo(Vector2f size, Vector3f position, Vector2f padding)
|
void NinePatchComponent::fitTo(Vector2f size, glm::vec3 position, Vector2f padding)
|
||||||
{
|
{
|
||||||
size += padding;
|
size += padding;
|
||||||
position[0] -= padding.x() / 2.0f;
|
position[0] -= padding.x() / 2.0f;
|
||||||
position[1] -= padding.y() / 2.0f;
|
position[1] -= padding.y() / 2.0f;
|
||||||
|
|
||||||
setSize(size + mCornerSize * 2.0f);
|
setSize(size + mCornerSize * 2.0f);
|
||||||
setPosition(position.x() + Math::lerp(-mCornerSize.x(), mCornerSize.x(), mOrigin.x()),
|
setPosition(position.x + Math::lerp(-mCornerSize.x(), mCornerSize.x(), mOrigin.x()),
|
||||||
position.y() + Math::lerp(-mCornerSize.y(), mCornerSize.y(), mOrigin.y()));
|
position.y + Math::lerp(-mCornerSize.y(), mCornerSize.y(), mOrigin.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NinePatchComponent::setImagePath(const std::string& path)
|
void NinePatchComponent::setImagePath(const std::string& path)
|
||||||
|
|
|
@ -35,13 +35,11 @@ public:
|
||||||
unsigned int centerColor = 0xFFFFFFFF);
|
unsigned int centerColor = 0xFFFFFFFF);
|
||||||
virtual ~NinePatchComponent();
|
virtual ~NinePatchComponent();
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
void fitTo(Vector2f size,
|
void fitTo(Vector2f size, glm::vec3 position = {}, Vector2f padding = Vector2f::Zero());
|
||||||
Vector3f position = Vector3f::Zero(),
|
|
||||||
Vector2f padding = Vector2f::Zero());
|
|
||||||
|
|
||||||
void setImagePath(const std::string& path);
|
void setImagePath(const std::string& path);
|
||||||
// Apply a color shift to the "edge" parts of the ninepatch.
|
// Apply a color shift to the "edge" parts of the ninepatch.
|
||||||
|
|
|
@ -75,11 +75,11 @@ public:
|
||||||
mText.getFont()->getHeight());
|
mText.getFont()->getHeight());
|
||||||
|
|
||||||
// Position.
|
// Position.
|
||||||
mLeftArrow.setPosition(0, (mSize.y() - mLeftArrow.getSize().y()) / 2);
|
mLeftArrow.setPosition(0.0f, (mSize.y() - mLeftArrow.getSize().y()) / 2.0f);
|
||||||
mText.setPosition(mLeftArrow.getPosition().x() + mLeftArrow.getSize().x(),
|
mText.setPosition(mLeftArrow.getPosition().x + mLeftArrow.getSize().x(),
|
||||||
(mSize.y() - mText.getSize().y()) / 2);
|
(mSize.y() - mText.getSize().y()) / 2.0f);
|
||||||
mRightArrow.setPosition(mText.getPosition().x() + mText.getSize().x(),
|
mRightArrow.setPosition(mText.getPosition().x + mText.getSize().x(),
|
||||||
(mSize.y() - mRightArrow.getSize().y()) / 2);
|
(mSize.y() - mRightArrow.getSize().y()) / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override
|
bool input(InputConfig* config, Input input) override
|
||||||
|
|
|
@ -141,12 +141,12 @@ void RatingComponent::updateColors()
|
||||||
mVertices[i].col = color;
|
mVertices[i].col = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::render(const Transform4x4f& parentTrans)
|
void RatingComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
void setValue(const std::string& value) override;
|
void setValue(const std::string& value) override;
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
|
|
|
@ -148,23 +148,26 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
GuiComponent::update(deltaTime);
|
GuiComponent::update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollableContainer::render(const Transform4x4f& parentTrans)
|
void ScrollableContainer::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
Vector2i clipPos(static_cast<int>(trans.translation().x()),
|
Vector2i clipPos(static_cast<int>(trans[3].x), static_cast<int>(trans[3].y));
|
||||||
static_cast<int>(trans.translation().y()));
|
|
||||||
|
|
||||||
Vector3f dimScaled = trans * Vector3f(mSize.x(), mSize.y(), 0);
|
glm::vec3 dimScaled {};
|
||||||
Vector2i clipDim(static_cast<int>((dimScaled.x()) - trans.translation().x()),
|
|
||||||
static_cast<int>((dimScaled.y()) - trans.translation().y()));
|
dimScaled.x = std::fabs(trans[3].x + mSize.x());
|
||||||
|
dimScaled.y = std::fabs(trans[3].y + mSize.y());
|
||||||
|
|
||||||
|
Vector2i clipDim(static_cast<int>(dimScaled.x - trans[3].x),
|
||||||
|
static_cast<int>(dimScaled.y - trans[3].y));
|
||||||
|
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
trans.translate(-Vector3f(mScrollPos.x(), mScrollPos.y(), 0));
|
trans = glm::translate(trans, -glm::vec3(mScrollPos.x(), mScrollPos.y(), 0.0f));
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector2f getContentSize();
|
Vector2f getContentSize();
|
||||||
|
|
|
@ -74,9 +74,9 @@ void SliderComponent::update(int deltaTime)
|
||||||
GuiComponent::update(deltaTime);
|
GuiComponent::update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderComponent::render(const Transform4x4f& parentTrans)
|
void SliderComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
// Render suffix.
|
// Render suffix.
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ bool SwitchComponent::input(InputConfig* config, Input input)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwitchComponent::render(const Transform4x4f& parentTrans)
|
void SwitchComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
mImage.render(trans);
|
mImage.render(trans);
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
SwitchComponent(Window* window, bool state = false);
|
SwitchComponent(Window* window, bool state = false);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void onSizeChanged() override { mImage.setSize(mSize); }
|
void onSizeChanged() override { mImage.setSize(mSize); }
|
||||||
|
|
||||||
void setResize(float width, float height) override { mImage.setResize(width, height); }
|
void setResize(float width, float height) override { mImage.setResize(width, height); }
|
||||||
|
|
|
@ -54,7 +54,11 @@ TextComponent::TextComponent(Window* window,
|
||||||
setColor(color);
|
setColor(color);
|
||||||
setBackgroundColor(bgcolor);
|
setBackgroundColor(bgcolor);
|
||||||
setText(text);
|
setText(text);
|
||||||
setPosition(pos);
|
|
||||||
|
// TEMPORARY
|
||||||
|
glm::vec3 tempvec = { pos.x(), pos.y(), pos.z() };
|
||||||
|
|
||||||
|
setPosition(tempvec);
|
||||||
setSize(size);
|
setSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,12 +119,12 @@ void TextComponent::setUppercase(bool uppercase)
|
||||||
onTextChanged();
|
onTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextComponent::render(const Transform4x4f& parentTrans)
|
void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
|
|
||||||
if (mRenderBackground) {
|
if (mRenderBackground) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
@ -147,7 +151,7 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector3f off(0, yOff, 0);
|
glm::vec3 off(0.0f, yOff, 0.0f);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
// Draw the "textbox" area, what we are aligned within.
|
// Draw the "textbox" area, what we are aligned within.
|
||||||
|
@ -155,7 +159,7 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x0000FF33, 0x0000FF33);
|
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x0000FF33, 0x0000FF33);
|
||||||
}
|
}
|
||||||
|
|
||||||
trans.translate(off);
|
trans = glm::translate(trans, off);
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
// Draw the text area, where the text actually is located.
|
// Draw the text area, where the text actually is located.
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
void setBackgroundColor(unsigned int color);
|
void setBackgroundColor(unsigned int color);
|
||||||
void setRenderBackground(bool render) { mRenderBackground = render; }
|
void setRenderBackground(bool render) { mRenderBackground = render; }
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
std::string getValue() const override { return mText; }
|
std::string getValue() const override { return mText; }
|
||||||
void setValue(const std::string& value) override { setText(value); }
|
void setValue(const std::string& value) override { setText(value); }
|
||||||
|
|
|
@ -46,7 +46,7 @@ void TextEditComponent::onFocusLost()
|
||||||
|
|
||||||
void TextEditComponent::onSizeChanged()
|
void TextEditComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBox.fitTo(mSize, Vector3f::Zero(),
|
mBox.fitTo(mSize, {},
|
||||||
Vector2f(-34 + mResolutionAdjustment,
|
Vector2f(-34 + mResolutionAdjustment,
|
||||||
-32 - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())));
|
-32 - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())));
|
||||||
onTextChanged(); // Wrap point probably changed.
|
onTextChanged(); // Wrap point probably changed.
|
||||||
|
@ -271,24 +271,26 @@ void TextEditComponent::onCursorChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditComponent::render(const Transform4x4f& parentTrans)
|
void TextEditComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
Transform4x4f trans = getTransform() * parentTrans;
|
glm::mat4 trans = getTransform() * parentTrans;
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
// Text + cursor rendering.
|
// Text + cursor rendering.
|
||||||
// Offset into our "text area" (padding).
|
// Offset into our "text area" (padding).
|
||||||
trans.translation() += Vector3f(getTextAreaPos().x(), getTextAreaPos().y(), 0);
|
trans = glm::translate(trans, glm::vec3(getTextAreaPos().x(), getTextAreaPos().y(), 0.0f));
|
||||||
|
|
||||||
Vector2i clipPos(static_cast<int>(trans.translation().x()),
|
Vector2i clipPos(static_cast<int>(trans[3].x), static_cast<int>(trans[3].y));
|
||||||
static_cast<int>(trans.translation().y()));
|
|
||||||
// Use "text area" size for clipping.
|
// Use "text area" size for clipping.
|
||||||
Vector3f dimScaled = trans * Vector3f(getTextAreaSize().x(), getTextAreaSize().y(), 0);
|
glm::vec3 dimScaled {};
|
||||||
Vector2i clipDim(static_cast<int>((dimScaled.x()) - trans.translation().x()),
|
dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x());
|
||||||
static_cast<int>((dimScaled.y()) - trans.translation().y()));
|
dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y());
|
||||||
|
|
||||||
|
Vector2i clipDim(static_cast<int>(dimScaled.x - trans[3].x),
|
||||||
|
static_cast<int>(dimScaled.y - trans[3].y));
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
trans.translate(Vector3f(-mScrollOffset.x(), -mScrollOffset.y(), 0));
|
trans = glm::translate(trans, glm::vec3(-mScrollOffset.x(), -mScrollOffset.y(), 0.0f));
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mTextCache)
|
if (mTextCache)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
void textInput(const std::string& text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
void onFocusGained() override;
|
void onFocusGained() override;
|
||||||
void onFocusLost() override;
|
void onFocusLost() override;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
|
@ -155,12 +155,12 @@ TextListComponent<T>::TextListComponent(Window* window)
|
||||||
mColors[1] = 0x00FF00FF;
|
mColors[1] = 0x00FF00FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void TextListComponent<T>::render(const Transform4x4f& parentTrans)
|
template <typename T> void TextListComponent<T>::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
std::shared_ptr<Font>& font = mFont;
|
std::shared_ptr<Font>& font = mFont;
|
||||||
|
|
||||||
int startEntry = 0;
|
int startEntry = 0;
|
||||||
|
@ -206,12 +206,13 @@ template <typename T> void TextListComponent<T>::render(const Transform4x4f& par
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clip to inside margins.
|
// Clip to inside margins.
|
||||||
Vector3f dim(mSize.x(), mSize.y(), 0.0f);
|
glm::vec3 dim(mSize.x(), mSize.y(), 0.0f);
|
||||||
dim = trans * dim - trans.translation();
|
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
||||||
|
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||||
|
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
Vector2i(static_cast<int>(trans.translation().x() + mHorizontalMargin),
|
Vector2i(static_cast<int>(trans[3].x + mHorizontalMargin), static_cast<int>(trans[3].y)),
|
||||||
static_cast<int>(trans.translation().y())),
|
Vector2i(static_cast<int>(dim.x - mHorizontalMargin * 2.0f), static_cast<int>(dim.y)));
|
||||||
Vector2i(static_cast<int>(dim.x() - mHorizontalMargin * 2.0f), static_cast<int>(dim.y())));
|
|
||||||
|
|
||||||
for (int i = startEntry; i < listCutoff; i++) {
|
for (int i = startEntry; i < listCutoff; i++) {
|
||||||
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
||||||
|
@ -235,34 +236,35 @@ template <typename T> void TextListComponent<T>::render(const Transform4x4f& par
|
||||||
else
|
else
|
||||||
entry.data.textCache->setColor(color);
|
entry.data.textCache->setColor(color);
|
||||||
|
|
||||||
Vector3f offset(0.0f, y, 0.0f);
|
glm::vec3 offset(0.0f, y, 0.0f);
|
||||||
|
|
||||||
switch (mAlignment) {
|
switch (mAlignment) {
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFT:
|
||||||
offset[0] = mHorizontalMargin;
|
offset.x = mHorizontalMargin;
|
||||||
break;
|
break;
|
||||||
case ALIGN_CENTER:
|
case ALIGN_CENTER:
|
||||||
offset[0] =
|
offset.x =
|
||||||
static_cast<float>((mSize.x() - entry.data.textCache->metrics.size.x()) / 2.0f);
|
static_cast<float>((mSize.x() - entry.data.textCache->metrics.size.x()) / 2.0f);
|
||||||
if (offset[0] < mHorizontalMargin)
|
if (offset.x < mHorizontalMargin)
|
||||||
offset[0] = mHorizontalMargin;
|
offset.x = mHorizontalMargin;
|
||||||
break;
|
break;
|
||||||
case ALIGN_RIGHT:
|
case ALIGN_RIGHT:
|
||||||
offset[0] = (mSize.x() - entry.data.textCache->metrics.size.x());
|
offset.x = (mSize.x() - entry.data.textCache->metrics.size.x());
|
||||||
offset[0] -= mHorizontalMargin;
|
offset.x -= mHorizontalMargin;
|
||||||
if (offset[0] < mHorizontalMargin)
|
if (offset.x < mHorizontalMargin)
|
||||||
offset[0] = mHorizontalMargin;
|
offset.x = mHorizontalMargin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render text.
|
// Render text.
|
||||||
Transform4x4f drawTrans = trans;
|
glm::mat4 drawTrans = trans;
|
||||||
|
|
||||||
// Currently selected item text might be scrolling.
|
// Currently selected item text might be scrolling.
|
||||||
if (mCursor == i && mMarqueeOffset > 0)
|
if (mCursor == i && mMarqueeOffset > 0)
|
||||||
drawTrans.translate(offset - Vector3f(static_cast<float>(mMarqueeOffset), 0.0f, 0.0f));
|
drawTrans = glm::translate(
|
||||||
|
drawTrans, offset - glm::vec3(static_cast<float>(mMarqueeOffset), 0.0f, 0.0f));
|
||||||
else
|
else
|
||||||
drawTrans.translate(offset);
|
drawTrans = glm::translate(drawTrans, offset);
|
||||||
|
|
||||||
// Needed to avoid flickering when returning to the start position.
|
// Needed to avoid flickering when returning to the start position.
|
||||||
if (mMarqueeOffset == 0 && mMarqueeOffset2 == 0)
|
if (mMarqueeOffset == 0 && mMarqueeOffset2 == 0)
|
||||||
|
@ -275,13 +277,13 @@ template <typename T> void TextListComponent<T>::render(const Transform4x4f& par
|
||||||
if ((mCursor == i && mMarqueeOffset2 < 0) || (mCursor == i && mMarqueeScroll)) {
|
if ((mCursor == i && mMarqueeOffset2 < 0) || (mCursor == i && mMarqueeScroll)) {
|
||||||
mMarqueeScroll = true;
|
mMarqueeScroll = true;
|
||||||
drawTrans = trans;
|
drawTrans = trans;
|
||||||
drawTrans.translate(offset - Vector3f(static_cast<float>(mMarqueeOffset2), 0.0f, 0.0f));
|
drawTrans = glm::translate(
|
||||||
|
drawTrans, offset - glm::vec3(static_cast<float>(mMarqueeOffset2), 0.0f, 0.0f));
|
||||||
Renderer::setMatrix(drawTrans);
|
Renderer::setMatrix(drawTrans);
|
||||||
font->renderTextCache(entry.data.textCache.get());
|
font->renderTextCache(entry.data.textCache.get());
|
||||||
}
|
}
|
||||||
y += entrySize;
|
y += entrySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::popClipRect();
|
Renderer::popClipRect();
|
||||||
listRenderTitleOverlay(trans);
|
listRenderTitleOverlay(trans);
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
|
@ -171,12 +171,12 @@ void VideoComponent::topWindow(bool isTop)
|
||||||
manageState();
|
manageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoComponent::render(const Transform4x4f& parentTrans)
|
void VideoComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
@ -191,7 +191,7 @@ void VideoComponent::render(const Transform4x4f& parentTrans)
|
||||||
pauseVideo();
|
pauseVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoComponent::renderSnapshot(const Transform4x4f& parentTrans)
|
void VideoComponent::renderSnapshot(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
// This function is called when the video is not currently being played. We need to
|
// This function is called when the video is not currently being played. We need to
|
||||||
// work out if we should display a static image. If the menu is open, then always render
|
// work out if we should display a static image. If the menu is open, then always render
|
||||||
|
|
|
@ -61,8 +61,8 @@ public:
|
||||||
void onPositionChanged() override { mStaticImage.setPosition(mPosition); }
|
void onPositionChanged() override { mStaticImage.setPosition(mPosition); }
|
||||||
void onSizeChanged() override { mStaticImage.onSizeChanged(); }
|
void onSizeChanged() override { mStaticImage.onSizeChanged(); }
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void renderSnapshot(const Transform4x4f& parentTrans);
|
void renderSnapshot(const glm::mat4& parentTrans);
|
||||||
|
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
|
|
|
@ -119,10 +119,10 @@ void VideoFFmpegComponent::resize()
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoFFmpegComponent::render(const Transform4x4f& parentTrans)
|
void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
VideoComponent::render(parentTrans);
|
VideoComponent::render(parentTrans);
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
||||||
if (mIsPlaying && mFormatContext) {
|
if (mIsPlaying && mFormatContext) {
|
||||||
|
@ -839,8 +839,8 @@ void VideoFFmpegComponent::calculateBlackRectangle()
|
||||||
// If the option to display pillarboxes is disabled, then make the rectangle equivalent
|
// If the option to display pillarboxes is disabled, then make the rectangle equivalent
|
||||||
// to the size of the video.
|
// to the size of the video.
|
||||||
else {
|
else {
|
||||||
mVideoRectangleCoords.push_back(std::round(mPosition.x() - mSize.x() * mOrigin.x()));
|
mVideoRectangleCoords.push_back(std::round(mPosition.x - mSize.x() * mOrigin.x()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mPosition.y() - mSize.y() * mOrigin.y()));
|
mVideoRectangleCoords.push_back(std::round(mPosition.y - mSize.y() * mOrigin.y()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mSize.x()));
|
mVideoRectangleCoords.push_back(std::round(mSize.x()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mSize.y()));
|
mVideoRectangleCoords.push_back(std::round(mSize.y()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
// Used internally whenever the resizing parameters or texture change.
|
// Used internally whenever the resizing parameters or texture change.
|
||||||
void resize();
|
void resize();
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
virtual void updatePlayer() override;
|
virtual void updatePlayer() override;
|
||||||
|
|
||||||
// This will run the frame processing in a separate thread.
|
// This will run the frame processing in a separate thread.
|
||||||
|
|
|
@ -168,7 +168,7 @@ void VideoVlcComponent::resize()
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoVlcComponent::render(const Transform4x4f& parentTrans)
|
void VideoVlcComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
// Set the audio volume. As libVLC is very unreliable we need to make an additional
|
// Set the audio volume. As libVLC is very unreliable we need to make an additional
|
||||||
// attempt here in the render loop in addition to the initialization in startVideo().
|
// attempt here in the render loop in addition to the initialization in startVideo().
|
||||||
|
@ -179,7 +179,7 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans)
|
||||||
setAudioVolume();
|
setAudioVolume();
|
||||||
|
|
||||||
VideoComponent::render(parentTrans);
|
VideoComponent::render(parentTrans);
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
glm::mat4 trans = parentTrans * getTransform();
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
||||||
// Check the actual VLC state, i.e. if the video is really playing rather than
|
// Check the actual VLC state, i.e. if the video is really playing rather than
|
||||||
|
@ -296,8 +296,8 @@ void VideoVlcComponent::calculateBlackRectangle()
|
||||||
// If the option to display pillarboxes is disabled, then make the rectangle equivalent
|
// If the option to display pillarboxes is disabled, then make the rectangle equivalent
|
||||||
// to the size of the video.
|
// to the size of the video.
|
||||||
else {
|
else {
|
||||||
mVideoRectangleCoords.push_back(std::round(mPosition.x() - mSize.x() * mOrigin.x()));
|
mVideoRectangleCoords.push_back(std::round(mPosition.x - mSize.x() * mOrigin.x()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mPosition.y() - mSize.y() * mOrigin.y()));
|
mVideoRectangleCoords.push_back(std::round(mPosition.y - mSize.y() * mOrigin.y()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mSize.x()));
|
mVideoRectangleCoords.push_back(std::round(mSize.x()));
|
||||||
mVideoRectangleCoords.push_back(std::round(mSize.y()));
|
mVideoRectangleCoords.push_back(std::round(mSize.y()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
// Used internally whenever the resizing parameters or texture change.
|
// Used internally whenever the resizing parameters or texture change.
|
||||||
void resize();
|
void resize();
|
||||||
|
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
void calculateBlackRectangle();
|
void calculateBlackRectangle();
|
||||||
void setAudioVolume();
|
void setAudioVolume();
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
|
||||||
|
|
||||||
void GuiComplexTextEditPopup::onSizeChanged()
|
void GuiComplexTextEditPopup::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
mText->setSize(mSize.x() - 40.0f, mText->getSize().y());
|
mText->setSize(mSize.x() - 40.0f, mText->getSize().y());
|
||||||
|
|
||||||
// Update grid.
|
// Update grid.
|
||||||
|
|
|
@ -93,7 +93,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
|
|
||||||
void GuiDetectDevice::onSizeChanged()
|
void GuiDetectDevice::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
// Grid.
|
// Grid.
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
|
|
|
@ -293,7 +293,7 @@ void GuiInputConfig::update(int deltaTime)
|
||||||
|
|
||||||
void GuiInputConfig::onSizeChanged()
|
void GuiInputConfig::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
// Update grid.
|
// Update grid.
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
|
|
|
@ -160,7 +160,7 @@ void GuiMsgBox::onSizeChanged()
|
||||||
mGrid.getRowHeight(0));
|
mGrid.getRowHeight(0));
|
||||||
mGrid.onSizeChanged();
|
mGrid.onSizeChanged();
|
||||||
|
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiMsgBox::deleteMeAndCall(const std::function<void()>& func)
|
void GuiMsgBox::deleteMeAndCall(const std::function<void()>& func)
|
||||||
|
|
|
@ -78,7 +78,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
||||||
|
|
||||||
void GuiTextEditPopup::onSizeChanged()
|
void GuiTextEditPopup::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32.0f, -32.0f));
|
mBackground.fitTo(mSize, {}, Vector2f(-32.0f, -32.0f));
|
||||||
|
|
||||||
mText->setSize(mSize.x() - 40, mText->getSize().y());
|
mText->setSize(mSize.x() - 40, mText->getSize().y());
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
#define ES_CORE_MATH_MISC_H
|
#define ES_CORE_MATH_MISC_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
|
#include <glm/trigonometric.hpp>
|
||||||
|
|
||||||
#define ES_PI (3.1415926535897932384626433832795028841971693993751058209749445923)
|
#include <glm/gtc/round.hpp>
|
||||||
#define ES_RAD_TO_DEG(_x) ((_x) * (180.0 / ES_PI))
|
|
||||||
#define ES_DEG_TO_RAD(_x) ((_x) * (ES_PI / 180.0))
|
|
||||||
|
|
||||||
namespace Math
|
namespace Math
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Shader_GL21.h"
|
#include "Shader_GL21.h"
|
||||||
#include "math/Transform4x4f.h"
|
|
||||||
#include "math/Vector2i.h"
|
#include "math/Vector2i.h"
|
||||||
#include "resources/ResourceManager.h"
|
#include "resources/ResourceManager.h"
|
||||||
|
|
||||||
|
@ -326,28 +325,19 @@ namespace Renderer
|
||||||
if (!createWindow())
|
if (!createWindow())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Transform4x4f projection = Transform4x4f::Identity();
|
glm::mat4 projection = getIdentity();
|
||||||
Rect viewport = Rect(0, 0, 0, 0);
|
Rect viewport = Rect(0, 0, 0, 0);
|
||||||
|
|
||||||
switch (screenRotate) {
|
switch (screenRotate) {
|
||||||
case 0: {
|
|
||||||
viewport.x = screenOffsetX;
|
|
||||||
viewport.y = screenOffsetY;
|
|
||||||
viewport.w = screenWidth;
|
|
||||||
viewport.h = screenHeight;
|
|
||||||
projection.orthoProjection(0.0f, static_cast<float>(screenWidth),
|
|
||||||
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {
|
case 1: {
|
||||||
viewport.x = windowWidth - screenOffsetY - screenHeight;
|
viewport.x = windowWidth - screenOffsetY - screenHeight;
|
||||||
viewport.y = screenOffsetX;
|
viewport.y = screenOffsetX;
|
||||||
viewport.w = screenHeight;
|
viewport.w = screenHeight;
|
||||||
viewport.h = screenWidth;
|
viewport.h = screenWidth;
|
||||||
projection.orthoProjection(0.0f, static_cast<float>(screenHeight),
|
projection = glm::ortho(0.0f, static_cast<float>(screenHeight),
|
||||||
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
|
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
|
||||||
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(90)), { 0, 0, 1 });
|
projection = glm::rotate(projection, glm::radians(90.0f), { 0.0f, 0.0f, 1.0f });
|
||||||
projection.translate({ 0, screenHeight * -1.0f, 0 });
|
projection = glm::translate(projection, { 0.0f, screenHeight * -1.0f, 0.0f });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
|
@ -355,10 +345,11 @@ namespace Renderer
|
||||||
viewport.y = windowHeight - screenOffsetY - screenHeight;
|
viewport.y = windowHeight - screenOffsetY - screenHeight;
|
||||||
viewport.w = screenWidth;
|
viewport.w = screenWidth;
|
||||||
viewport.h = screenHeight;
|
viewport.h = screenHeight;
|
||||||
projection.orthoProjection(0.0f, static_cast<float>(screenWidth),
|
projection = glm::ortho(0.0f, static_cast<float>(screenWidth),
|
||||||
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
|
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
|
||||||
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(180)), { 0, 0, 1 });
|
projection = glm::rotate(projection, glm::radians(180.0f), { 0.0f, 0.0f, 1.0f });
|
||||||
projection.translate({ screenWidth * -1.0f, screenHeight * -1.0f, 0 });
|
projection =
|
||||||
|
glm::translate(projection, { screenWidth * -1.0f, screenHeight * -1.0f, 0.0f });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
|
@ -366,10 +357,19 @@ namespace Renderer
|
||||||
viewport.y = windowHeight - screenOffsetX - screenWidth;
|
viewport.y = windowHeight - screenOffsetX - screenWidth;
|
||||||
viewport.w = screenHeight;
|
viewport.w = screenHeight;
|
||||||
viewport.h = screenWidth;
|
viewport.h = screenWidth;
|
||||||
projection.orthoProjection(0.0f, static_cast<float>(screenHeight),
|
projection = glm::ortho(0.0f, static_cast<float>(screenHeight),
|
||||||
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
|
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
|
||||||
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(270)), { 0, 0, 1 });
|
projection = glm::rotate(projection, glm::radians(270.0f), { 0.0f, 0.0f, 1.0f });
|
||||||
projection.translate({ screenWidth * -1.0f, 0, 0 });
|
projection = glm::translate(projection, { screenWidth * -1.0f, 0.0f, 0.0f });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
viewport.x = screenOffsetX;
|
||||||
|
viewport.y = screenOffsetY;
|
||||||
|
viewport.w = screenWidth;
|
||||||
|
viewport.h = screenHeight;
|
||||||
|
projection = glm::ortho(0.0f, static_cast<float>(screenWidth),
|
||||||
|
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ namespace Renderer
|
||||||
const unsigned int _colorEnd,
|
const unsigned int _colorEnd,
|
||||||
bool horizontalGradient,
|
bool horizontalGradient,
|
||||||
const float _opacity,
|
const float _opacity,
|
||||||
const Transform4x4f& _trans,
|
const glm::mat4& _trans,
|
||||||
const Blend::Factor _srcBlendFactor,
|
const Blend::Factor _srcBlendFactor,
|
||||||
const Blend::Factor _dstBlendFactor)
|
const Blend::Factor _dstBlendFactor)
|
||||||
{
|
{
|
||||||
|
@ -542,7 +542,7 @@ namespace Renderer
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Transform4x4f getProjectionMatrix() { return mProjectionMatrix; }
|
const glm::mat4 getProjectionMatrix() { return mProjectionMatrix; }
|
||||||
SDL_Window* getSDLWindow() { return sdlWindow; }
|
SDL_Window* getSDLWindow() { return sdlWindow; }
|
||||||
int getWindowWidth() { return windowWidth; }
|
int getWindowWidth() { return windowWidth; }
|
||||||
int getWindowHeight() { return windowHeight; }
|
int getWindowHeight() { return windowHeight; }
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Shader_GL21.h"
|
#include "Shader_GL21.h"
|
||||||
#include "math/Transform4x4f.h"
|
#include "math/Misc.h"
|
||||||
#include "math/Vector2f.h"
|
#include "math/Vector2f.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
|
||||||
class Transform4x4f;
|
|
||||||
class Vector2i;
|
class Vector2i;
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
|
@ -52,7 +51,8 @@ namespace Renderer
|
||||||
|
|
||||||
static std::vector<Shader*> sShaderProgramVector;
|
static std::vector<Shader*> sShaderProgramVector;
|
||||||
static GLuint shaderFBO;
|
static GLuint shaderFBO;
|
||||||
static Transform4x4f mProjectionMatrix;
|
static glm::mat4 mProjectionMatrix;
|
||||||
|
static constexpr glm::mat4 getIdentity() { return glm::mat4(1.0f); }
|
||||||
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
||||||
|
@ -141,7 +141,7 @@ namespace Renderer
|
||||||
const unsigned int _colorEnd,
|
const unsigned int _colorEnd,
|
||||||
bool horizontalGradient = false,
|
bool horizontalGradient = false,
|
||||||
const float _opacity = 1.0,
|
const float _opacity = 1.0,
|
||||||
const Transform4x4f& _trans = Transform4x4f::Identity(),
|
const glm::mat4& _trans = getIdentity(),
|
||||||
const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA,
|
const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA,
|
||||||
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||||
SDL_Window* getSDLWindow();
|
SDL_Window* getSDLWindow();
|
||||||
|
@ -160,7 +160,7 @@ namespace Renderer
|
||||||
unsigned int convertABGRToRGBA(unsigned int color);
|
unsigned int convertABGRToRGBA(unsigned int color);
|
||||||
|
|
||||||
Shader* getShaderProgram(unsigned int shaderID);
|
Shader* getShaderProgram(unsigned int shaderID);
|
||||||
const Transform4x4f getProjectionMatrix();
|
const glm::mat4 getProjectionMatrix();
|
||||||
void shaderPostprocessing(unsigned int shaders,
|
void shaderPostprocessing(unsigned int shaders,
|
||||||
const Renderer::shaderParameters& parameters = shaderParameters(),
|
const Renderer::shaderParameters& parameters = shaderParameters(),
|
||||||
unsigned char* textureRGBA = nullptr);
|
unsigned char* textureRGBA = nullptr);
|
||||||
|
@ -191,12 +191,12 @@ namespace Renderer
|
||||||
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||||
void drawTriangleStrips(const Vertex* _vertices,
|
void drawTriangleStrips(const Vertex* _vertices,
|
||||||
const unsigned int _numVertices,
|
const unsigned int _numVertices,
|
||||||
const Transform4x4f& _trans = Transform4x4f::Identity(),
|
const glm::mat4& _trans = getIdentity(),
|
||||||
const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA,
|
const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA,
|
||||||
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA,
|
const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA,
|
||||||
const shaderParameters& _parameters = shaderParameters());
|
const shaderParameters& _parameters = shaderParameters());
|
||||||
void setProjection(const Transform4x4f& _projection);
|
void setProjection(const glm::mat4& _projection);
|
||||||
void setMatrix(const Transform4x4f& _matrix);
|
void setMatrix(const glm::mat4& _matrix);
|
||||||
void setViewport(const Rect& _viewport);
|
void setViewport(const Rect& _viewport);
|
||||||
void setScissor(const Rect& _scissor);
|
void setScissor(const Rect& _scissor);
|
||||||
void setSwapInterval();
|
void setSwapInterval();
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Shader_GL21.h"
|
#include "Shader_GL21.h"
|
||||||
#include "math/Transform4x4f.h"
|
|
||||||
#include "renderers/Renderer.h"
|
#include "renderers/Renderer.h"
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
|
@ -239,7 +238,7 @@ namespace Renderer
|
||||||
|
|
||||||
void drawTriangleStrips(const Vertex* _vertices,
|
void drawTriangleStrips(const Vertex* _vertices,
|
||||||
const unsigned int _numVertices,
|
const unsigned int _numVertices,
|
||||||
const Transform4x4f& _trans,
|
const glm::mat4& _trans,
|
||||||
const Blend::Factor _srcBlendFactor,
|
const Blend::Factor _srcBlendFactor,
|
||||||
const Blend::Factor _dstBlendFactor,
|
const Blend::Factor _dstBlendFactor,
|
||||||
const shaderParameters& _parameters)
|
const shaderParameters& _parameters)
|
||||||
|
@ -353,16 +352,16 @@ namespace Renderer
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setProjection(const Transform4x4f& _projection)
|
void setProjection(const glm::mat4& _projection)
|
||||||
{
|
{
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&_projection)));
|
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&_projection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrix(const Transform4x4f& _matrix)
|
void setMatrix(const glm::mat4& _matrix)
|
||||||
{
|
{
|
||||||
Transform4x4f matrix = _matrix;
|
glm::mat4 matrix = _matrix;
|
||||||
matrix.round();
|
matrix[3] = glm::round(matrix[3]);
|
||||||
|
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&matrix)));
|
GL_CHECK_ERROR(glLoadMatrixf(reinterpret_cast<const GLfloat*>(&matrix)));
|
||||||
|
@ -448,7 +447,7 @@ namespace Renderer
|
||||||
if (parameters.fragmentSaturation < 1.0)
|
if (parameters.fragmentSaturation < 1.0)
|
||||||
vertices[0].saturation = parameters.fragmentSaturation;
|
vertices[0].saturation = parameters.fragmentSaturation;
|
||||||
|
|
||||||
setMatrix(Transform4x4f::Identity());
|
setMatrix(getIdentity());
|
||||||
GLuint screenTexture = createTexture(Texture::RGBA, false, false, width, height, nullptr);
|
GLuint screenTexture = createTexture(Texture::RGBA, false, false, width, height, nullptr);
|
||||||
|
|
||||||
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0));
|
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0));
|
||||||
|
@ -475,7 +474,7 @@ namespace Renderer
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST));
|
GL_COLOR_BUFFER_BIT, GL_NEAREST));
|
||||||
|
|
||||||
// Apply/render the shaders.
|
// Apply/render the shaders.
|
||||||
drawTriangleStrips(vertices, 4, Transform4x4f::Identity(), Blend::SRC_ALPHA,
|
drawTriangleStrips(vertices, 4, getIdentity(), Blend::SRC_ALPHA,
|
||||||
Blend::ONE_MINUS_SRC_ALPHA, parameters);
|
Blend::ONE_MINUS_SRC_ALPHA, parameters);
|
||||||
|
|
||||||
// If textureRGBA has an address, it means that the output should go to this
|
// If textureRGBA has an address, it means that the output should go to this
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "math/Transform4x4f.h"
|
|
||||||
#include "renderers/Renderer.h"
|
#include "renderers/Renderer.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
@ -185,7 +184,7 @@ namespace Renderer
|
||||||
|
|
||||||
void drawTriangleStrips(const Vertex* _vertices,
|
void drawTriangleStrips(const Vertex* _vertices,
|
||||||
const unsigned int _numVertices,
|
const unsigned int _numVertices,
|
||||||
const Transform4x4f& _trans,
|
const glm::mat4& _trans,
|
||||||
const Blend::Factor _srcBlendFactor,
|
const Blend::Factor _srcBlendFactor,
|
||||||
const Blend::Factor _dstBlendFactor,
|
const Blend::Factor _dstBlendFactor,
|
||||||
const shaderParameters& _parameters)
|
const shaderParameters& _parameters)
|
||||||
|
@ -200,16 +199,16 @@ namespace Renderer
|
||||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, _numVertices));
|
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, _numVertices));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setProjection(const Transform4x4f& _projection)
|
void setProjection(const glm::mat4& _projection)
|
||||||
{
|
{
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
GL_CHECK_ERROR(glMatrixMode(GL_PROJECTION));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&_projection));
|
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&_projection));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrix(const Transform4x4f& _matrix)
|
void setMatrix(const glm::mat4& _matrix)
|
||||||
{
|
{
|
||||||
Transform4x4f matrix = _matrix;
|
glm::mat4 matrix = _matrix;
|
||||||
matrix.round();
|
matrix[3] = glm::round(matrix[3]);
|
||||||
|
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||||
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&matrix));
|
GL_CHECK_ERROR(glLoadMatrixf((GLfloat*)&matrix));
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace Renderer
|
||||||
shaderDimValue = glGetUniformLocation(mProgramID, "dimValue");
|
shaderDimValue = glGetUniformLocation(mProgramID, "dimValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Shader::setModelViewProjectionMatrix(Transform4x4f mvpMatrix)
|
void Renderer::Shader::setModelViewProjectionMatrix(glm::mat4 mvpMatrix)
|
||||||
{
|
{
|
||||||
if (shaderMVPMatrix != -1)
|
if (shaderMVPMatrix != -1)
|
||||||
GL_CHECK_ERROR(glUniformMatrix4fv(shaderMVPMatrix, 1, GL_FALSE,
|
GL_CHECK_ERROR(glUniformMatrix4fv(shaderMVPMatrix, 1, GL_FALSE,
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
|
||||||
#include "math/Transform4x4f.h"
|
#include "math/Misc.h"
|
||||||
|
#include "math/Vector3f.h"
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
@ -45,7 +46,8 @@ namespace Renderer
|
||||||
// Get references to the variables inside the compiled shaders.
|
// Get references to the variables inside the compiled shaders.
|
||||||
void getVariableLocations(GLuint programID);
|
void getVariableLocations(GLuint programID);
|
||||||
// One-way communication with the compiled shaders.
|
// One-way communication with the compiled shaders.
|
||||||
void setModelViewProjectionMatrix(Transform4x4f mvpMatrix);
|
void setModelViewProjectionMatrix(glm::mat4 mvpMatrix);
|
||||||
|
|
||||||
void setTextureSize(std::array<GLfloat, 2> shaderVec2);
|
void setTextureSize(std::array<GLfloat, 2> shaderVec2);
|
||||||
void setTextureCoordinates(std::array<GLfloat, 4> shaderVec4);
|
void setTextureCoordinates(std::array<GLfloat, 4> shaderVec4);
|
||||||
void setColor(std::array<GLfloat, 4> shaderVec4);
|
void setColor(std::array<GLfloat, 4> shaderVec4);
|
||||||
|
|
Loading…
Reference in a new issue