#endif
}
-void draw_plain(Camera &camera, bool show_hud, Hud &hud,
- video::IVideoDriver *driver, bool draw_wield_tool,
- Client &client, gui::IGUIEnvironment *guienv)
+// returns (size / coef), rounded upwards
+inline int scaledown(int coef, int size)
{
+ return (size + coef - 1) / coef;
+}
+
+void draw_plain(Camera &camera, bool show_hud,
+ Hud &hud, video::IVideoDriver *driver,
+ scene::ISceneManager *smgr, const v2u32 &screensize,
+ bool draw_wield_tool, Client &client, gui::IGUIEnvironment *guienv,
+ video::SColor skycolor)
+{
+ // Undersampling-specific stuff
+ static video::ITexture *image = NULL;
+ static v2u32 last_pixelated_size = v2u32(0, 0);
+ int undersampling = g_settings->getU16("undersampling");
+ v2u32 pixelated_size;
+ v2u32 dest_size;
+ if (undersampling > 0) {
+ pixelated_size = v2u32(scaledown(undersampling, screensize.X),
+ scaledown(undersampling, screensize.Y));
+ dest_size = v2u32(undersampling * pixelated_size.X, undersampling * pixelated_size.Y);
+ if (pixelated_size != last_pixelated_size) {
+ init_texture(driver, pixelated_size, &image, "mt_drawimage_img1");
+ last_pixelated_size = pixelated_size;
+ }
+ driver->setRenderTarget(image, true, true, skycolor);
+ }
+
+ // Render
+ smgr->drawAll();
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (show_hud) {
hud.drawSelectionMesh();
camera.drawWieldedTool();
}
}
+
+ // Upscale lowres render
+ if (undersampling > 0) {
+ driver->setRenderTarget(0, true, true);
+ driver->draw2DImage(image,
+ irr::core::rect<s32>(0, 0, dest_size.X, dest_size.Y),
+ irr::core::rect<s32>(0, 0, pixelated_size.X, pixelated_size.Y));
+ }
}
void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
- Camera &camera, Client& client, LocalPlayer *player, Hud &hud,
+ Camera &camera, Client &client, LocalPlayer *player, Hud &hud,
Minimap &mapper, gui::IGUIEnvironment *guienv,
const v2u32 &screensize, const video::SColor &skycolor,
bool show_hud, bool show_minimap)
const std::string &draw_mode = g_settings->get("3d_mode");
- smgr->drawAll();
-
if (draw_mode == "anaglyph")
{
draw_anaglyph_3d_mode(camera, show_hud, hud, driver,
}
else {
draw_plain(camera, show_hud, hud, driver,
- draw_wield_tool, client, guienv);
+ smgr, screensize, draw_wield_tool, client, guienv, skycolor);
}
/*