Skip to content

Commit

Permalink
Fixed|libgui|GLSandbox: Fixed minor regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent fd4be70 commit 1296dc7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
11 changes: 11 additions & 0 deletions doomsday/libs/gui/include/de/graphics/glwindow.h
Expand Up @@ -127,6 +127,17 @@ class LIBGUI_PUBLIC GLWindow : public Asset
duint pixelWidth() const;
duint pixelHeight() const;

inline Vec2f pointSizef() const
{
const auto n = pointSize();
return {float(n.x), float(n.y)};
}
inline Vec2f pixelSizef() const
{
const auto p = pixelSize();
return {float(p.x), float(p.y)};
}

double pixelRatio() const;

inline Rectanglei geometry() const { return {x(), y(), pointSize().x, pointSize().y }; }
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/gui/src/graphics/atlas.cpp
Expand Up @@ -178,7 +178,7 @@ DE_PIMPL(Atlas)
}
backing.draw(image, noBorders.topLeft);

//backing.save(Stringf("backing-%p.png", this));
//backing.save(NativePath::homePath() / Stringf("backing-%p.png", this));

markAsChanged(rect);
}
Expand Down
10 changes: 9 additions & 1 deletion doomsday/tests/test_glsandbox/CMakeLists.txt
Expand Up @@ -18,7 +18,15 @@ deng_link_libraries (test_glsandbox PRIVATE DengGui)

if (APPLE)
set_property (TARGET test_glsandbox PROPERTY OUTPUT_NAME test_glsandbox)
find_package (the_Foundation REQUIRED)
find_package (glbinding REQUIRED)
deng_install_bundle_deps (test_glsandbox
Deng::libcore Deng::libgui Deng::libshell
Deng::libcore
Deng::libgui
Deng::libcomms
the_Foundation::the_Foundation
glbinding::glbinding
)
endif ()

deng_deploy_target (test_glsandbox)
22 changes: 13 additions & 9 deletions doomsday/tests/test_glsandbox/testwindow.cpp
Expand Up @@ -326,25 +326,28 @@ DE_PIMPL(TestWindow)

void updateProjection()
{
const auto pointSize = self().pointSizef();
switch (mode)
{
case TestRenderToTexture:
// 3D projection.
projMatrix = Mat4f::perspective(40, float(self().pixelWidth())/float(self().pixelHeight())) *
projMatrix = Mat4f::perspective(75, pointSize.x / pointSize.y) *
Mat4f::lookAt(Vec3f(), Vec3f(0, 0, -5), Vec3f(0, -1, 0));
break;

case TestDynamicAtlas:
// 2D projection.
projMatrix = Mat4f::ortho(-self().pointWidth()/2, self().pointWidth()/2,
-self().pointHeight()/2, self().pointHeight()/2) *
Mat4f::scale(self().pointHeight()/150.f) *
projMatrix = Mat4f::ortho(-pointSize.x / 2,
+pointSize.x / 2,
-pointSize.y / 2,
+pointSize.y / 2) *
Mat4f::scale(pointSize.y / 150.f) *
Mat4f::translate(Vec2f(-50, -50));
break;

case TestModel:
// 3D projection.
projMatrix = Mat4f::perspective(40, float(self().pixelWidth())/float(self().pixelHeight())) *
projMatrix = Mat4f::perspective(75, pointSize.x / pointSize.y) *
Mat4f::lookAt(Vec3f(), Vec3f(0, -3, 0), Vec3f(0, 0, 1));
break;
}
Expand Down Expand Up @@ -412,7 +415,7 @@ DE_PIMPL(TestWindow)
// The right cube.
uTex = frameTex;
uMvpMatrix = projMatrix *
Mat4f::translate(Vec3f(1.5f, 0, 0)) *
Mat4f::translate(Vec3f(+1.5f, 0, 0)) *
modelMatrix;
ob.draw();
}
Expand Down Expand Up @@ -500,18 +503,19 @@ DE_PIMPL(TestWindow)
Id chosen = ids[rand() % ids.size()];
atlas->release(chosen);

LOG_DEBUG("Removed ") << chosen;
LOG_MSG("Removed ") << chosen;
}
#endif

// Generate a random image.
Image::Size imgSize(10 + rand() % 40, 10 + 10 * (rand() % 2));
Image img(imgSize, Image::RGBA_8888);
img.fill(Image::makeColor(rand() % 256, rand() % 256, rand() % 256));
img.drawRect(img.rect() /*.adjusted(0, 0, -1, -1)*/, Image::Color(255, 255, 255, 255));
img.drawRect(img.rect(), Image::Color(255, 255, 255, 255));

Id id = atlas->alloc(img);
LOG_DEBUG("Allocated ") << id;

LOG_MSG("Allocated ") << id;
if (id.isNone())
{
lastAtlasAdditionAt = Time() + 5.0;
Expand Down

0 comments on commit 1296dc7

Please sign in to comment.