aboutsummaryrefslogtreecommitdiff
path: root/src/mapblock_mesh.cpp
Commit message (Collapse)AuthorAge
* Fix remnants of s32 enable_shadersKahrl2013-09-04
|
* Dont crash if facedir > 23PilzAdam2013-08-10
|
* Fix crack overlay for animated texturesKahrl2013-08-05
|
* Fix light issue in 6d facedir.RealBadAngel2013-07-21
|
* Clean up bumpmap code a bitkwolekr2013-07-12
|
* Fix many formspec menu bugssapier2013-07-07
|
* Add texture bumpmapping feature.RealBadAngel2013-07-04
|
* Remove texture atlas / AtlasPointer, rename getTextureRaw to getTextureKahrl2013-07-02
|
* Remove useless recalculation of bounding box (mapblock_mesh)Esteban I. Ruiz Moreno2013-06-18
|
* Removed a redundant step which degraded performancesweetbomber2013-06-15
|
* Remove 'Meshbuffer ran out of indices' limitationKahrl2013-05-06
|
* Add option to use texture alpha channelkwolekr2013-04-23
|
* 6d facedirRealBadAngel2013-03-23
|
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
|
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Try to add a bit of topside brightness when not using shadersPerttu Ahola2012-12-02
|
* Handle day-night transition in shader and make light sources brighter when ↵Perttu Ahola2012-12-02
| | | | shaders are used
* Fix tile MaterialType to make sense and make lava surface be shader'd lower ↵Perttu Ahola2012-12-02
| | | | like water
* Implement a global shader parameter passing system and useful shadersPerttu Ahola2012-12-02
|
* ShaderSource and silly example shadersKahrl2012-12-02
|
* Fix mesh glitches on MapBlock boundariesPerttu Ahola2012-11-27
|
* Rotate facedir-rotated top and bottom textures too, and re-implement nodebox ↵Perttu Ahola2012-07-21
| | | | side rotation
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
|
* Add desynchronize_mapblock_texture_animation setting and improve ↵Perttu Ahola2012-06-16
| | | | minetest.conf.example a bit
* Node texture animationPerttu Ahola2012-06-16
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* Fix MSVC build (pow type overload stuff)Perttu Ahola2012-05-31
|
* Tune smooth lighting a bitPerttu Ahola2012-05-20
|
* Make lava brighter by showing light sources at their full emitted light levelPerttu Ahola2012-04-08
|
* MapBlockMesh, mesh animation system, urgent mesh updates, athmospheric ↵Kahrl2012-03-15
| | | | light, removed footprints
* Node placement / mineral / serialization / iron freq / node_dig callbackKahrl2012-01-22
| | | | | | | | - Node placement code moved to Lua - Mineral system removed (added default:stone_with_coal and default:stone_with_iron). - MapBlock and MapNode serialization updated. - Mapgen: Frequency of iron increased. - node_dig callback and related changes.
* The huge item definition and item namespace unification patch (itemdef), see ↵Kahrl2012-01-12
| | | | http://c55.me/minetest/wiki/doku.php?id=changes:itemdef
* Clean mapnode.h and fix other files accordinglyPerttu Ahola2011-11-29
|
* GameDef compilesPerttu Ahola2011-11-29
|
* Create framework for getting rid of global definitions of ↵Perttu Ahola2011-11-29
| | | | node/tool/item/whatever types
* Move ContentFeatures to mapnode_contentfeatures.{h,cpp} and clean stuffPerttu Ahola2011-11-29
|
* Fix water-glass and water-lava surfacesPerttu Ahola2011-11-08
|
* Improve rendering and fix tiling in mesh generationPerttu Ahola2011-10-18
|
* Fix some "Conditional jump or move depends on uninitialised value(s)" ↵Perttu Ahola2011-10-15
| | | | valgrind detections
* Header file tweaking; mainly for speedPerttu Ahola2011-10-12
|
* made shadows less bluePerttu Ahola2011-07-24
|
* merged jungle and bluish shadowsPerttu Ahola2011-07-23
|\
| * Made dark places tint slightly in bluePerttu Ahola2011-07-23
| |
* | extended content-type rangePerttu Ahola2011-07-23
|/
* more reorganizing of map codePerttu Ahola2011-06-26
|
* mapgen stuffPerttu Ahola2011-06-25
|
* Moved stuff from mapblock{h,cpp} to mapblock_mesh.{h,cpp} and ↵Perttu Ahola2011-06-17
content_mapblock.{h,cpp}
>get("3d_mode") == "pageflip"; // Determine driver video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; const std::string &driverstring = g_settings->get("video_driver"); std::vector<video::E_DRIVER_TYPE> drivers = RenderingEngine::getSupportedVideoDrivers(); u32 i; for (i = 0; i != drivers.size(); i++) { if (!strcasecmp(driverstring.c_str(), RenderingEngine::getVideoDriverName(drivers[i]))) { driverType = drivers[i]; break; } } if (i == drivers.size()) { errorstream << "Invalid video_driver specified; " "defaulting to opengl" << std::endl; } SIrrlichtCreationParameters params = SIrrlichtCreationParameters(); params.DriverType = driverType; params.WindowSize = core::dimension2d<u32>(screen_w, screen_h); params.Bits = bits; params.AntiAlias = fsaa; params.Fullscreen = fullscreen; params.Stencilbuffer = false; params.Stereobuffer = stereo_buffer; params.Vsync = vsync; params.EventReceiver = receiver; params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu"); params.ZBufferBits = 24; #ifdef __ANDROID__ // clang-format off params.PrivateData = porting::app_global; params.OGLES2ShaderPath = std::string(porting::path_user + DIR_DELIM + "media" + DIR_DELIM + "Shaders" + DIR_DELIM).c_str(); // clang-format on #endif m_device = createDeviceEx(params); driver = m_device->getVideoDriver(); s_singleton = this; } RenderingEngine::~RenderingEngine() { core.reset(); m_device->drop(); s_singleton = nullptr; } v2u32 RenderingEngine::getWindowSize() const { if (core) return core->getVirtualSize(); return m_device->getVideoDriver()->getScreenSize(); } void RenderingEngine::setResizable(bool resize) { m_device->setResizable(resize); } bool RenderingEngine::print_video_modes() { IrrlichtDevice *nulldevice; bool vsync = g_settings->getBool("vsync"); u16 fsaa = g_settings->getU16("fsaa"); MyEventReceiver *receiver = new MyEventReceiver(); SIrrlichtCreationParameters params = SIrrlichtCreationParameters(); params.DriverType = video::EDT_NULL; params.WindowSize = core::dimension2d<u32>(640, 480); params.Bits = 24; params.AntiAlias = fsaa; params.Fullscreen = false; params.Stencilbuffer = false; params.Vsync = vsync; params.EventReceiver = receiver; params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu"); nulldevice = createDeviceEx(params); if (!nulldevice) { delete receiver; return false; } std::cout << _("Available video modes (WxHxD):") << std::endl; video::IVideoModeList *videomode_list = nulldevice->getVideoModeList(); if (videomode_list != NULL) { s32 videomode_count = videomode_list->getVideoModeCount(); core::dimension2d<u32> videomode_res; s32 videomode_depth; for (s32 i = 0; i < videomode_count; ++i) { videomode_res = videomode_list->getVideoModeResolution(i); videomode_depth = videomode_list->getVideoModeDepth(i); std::cout << videomode_res.Width << "x" << videomode_res.Height << "x" << videomode_depth << std::endl; } std::cout << _("Active video mode (WxHxD):") << std::endl; videomode_res = videomode_list->getDesktopResolution(); videomode_depth = videomode_list->getDesktopDepth(); std::cout << videomode_res.Width << "x" << videomode_res.Height << "x" << videomode_depth << std::endl; } nulldevice->drop(); delete receiver; return videomode_list != NULL; } void RenderingEngine::setXorgClassHint( const video::SExposedVideoData &video_data, const std::string &name) { #ifdef XORG_USED if (video_data.OpenGLLinux.X11Display == NULL) return; XClassHint *classhint = XAllocClassHint(); classhint->res_name = (char *)name.c_str(); classhint->res_class = (char *)name.c_str(); XSetClassHint((Display *)video_data.OpenGLLinux.X11Display, video_data.OpenGLLinux.X11Window, classhint); XFree(classhint); #endif } bool RenderingEngine::setWindowIcon() { #if defined(XORG_USED) #if RUN_IN_PLACE return setXorgWindowIconFromPath( porting::path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); #else // We have semi-support for reading in-place data if we are // compiled with RUN_IN_PLACE. Don't break with this and // also try the path_share location. return setXorgWindowIconFromPath( ICON_DIR "/hicolor/128x128/apps/" PROJECT_NAME ".png") || setXorgWindowIconFromPath(porting::path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); #endif #elif defined(_WIN32) const video::SExposedVideoData exposedData = driver->getExposedVideoData(); HWND hWnd; // Window handle switch (driver->getDriverType()) { case video::EDT_DIRECT3D8: hWnd = reinterpret_cast<HWND>(exposedData.D3D8.HWnd); break; case video::EDT_DIRECT3D9: hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd); break; case video::EDT_OPENGL: hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd); break; default: return false; } // Load the ICON from resource file const HICON hicon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(130) // The ID of the ICON defined in // winresource.rc ); if (hicon) { SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hicon)); SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hicon)); return true; } return false; #else return false; #endif } bool RenderingEngine::setXorgWindowIconFromPath(const std::string &icon_file) { #ifdef XORG_USED video::IImageLoader *image_loader = NULL; u32 cnt = driver->getImageLoaderCount(); for (u32 i = 0; i < cnt; i++) { if (driver->getImageLoader(i)->isALoadableFileExtension( icon_file.c_str())) { image_loader = driver->getImageLoader(i); break; } } if (!image_loader) { warningstream << "Could not find image loader for file '" << icon_file << "'" << std::endl; return false; } io::IReadFile *icon_f = m_device->getFileSystem()->createAndOpenFile(icon_file.c_str()); if (!icon_f) { warningstream << "Could not load icon file '" << icon_file << "'" << std::endl; return false; } video::IImage *img = image_loader->loadImage(icon_f); if (!img) { warningstream << "Could not load icon file '" << icon_file << "'" << std::endl; icon_f->drop(); return false; } u32 height = img->getDimension().Height; u32 width = img->getDimension().Width; size_t icon_buffer_len = 2 + height * width; long *icon_buffer = new long[icon_buffer_len]; icon_buffer[0] = width; icon_buffer[1] = height; for (u32 x = 0; x < width; x++) { for (u32 y = 0; y < height; y++) { video::SColor col = img->getPixel(x, y); long pixel_val = 0; pixel_val |= (u8)col.getAlpha() << 24; pixel_val |= (u8)col.getRed() << 16; pixel_val |= (u8)col.getGreen() << 8; pixel_val |= (u8)col.getBlue(); icon_buffer[2 + x + y * width] = pixel_val; } } img->drop(); icon_f->drop(); const video::SExposedVideoData &video_data = driver->getExposedVideoData(); Display *x11_dpl = (Display *)video_data.OpenGLLinux.X11Display; if (x11_dpl == NULL) { warningstream << "Could not find x11 display for setting its icon." << std::endl; delete[] icon_buffer; return false; } Window x11_win = (Window)video_data.OpenGLLinux.X11Window; Atom net_wm_icon = XInternAtom(x11_dpl, "_NET_WM_ICON", False); Atom cardinal = XInternAtom(x11_dpl, "CARDINAL", False); XChangeProperty(x11_dpl, x11_win, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char *)icon_buffer, icon_buffer_len); delete[] icon_buffer; #endif return true; } /* Draws a screen with a single text on it. Text will be removed when the screen is drawn the next time. Additionally, a progressbar can be drawn when percent is set between 0 and 100. */ void RenderingEngine::_draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime, int percent, bool clouds) { v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight()); v2s32 center(screensize.X / 2, screensize.Y / 2); core::rect<s32> textrect(center - textsize / 2, center + textsize / 2); gui::IGUIStaticText *guitext = guienv->addStaticText(text.c_str(), textrect, false, false); guitext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds"); if (cloud_menu_background) { g_menuclouds->step(dtime * 3); g_menuclouds->render(); get_video_driver()->beginScene( true, true, video::SColor(255, 140, 186, 250)); g_menucloudsmgr->drawAll(); } else get_video_driver()->beginScene(true, true, video::SColor(255, 0, 0, 0)); // draw progress bar if ((percent >= 0) && (percent <= 100)) { video::ITexture *progress_img = tsrc->getTexture("progress_bar.png"); video::ITexture *progress_img_bg = tsrc->getTexture("progress_bar_bg.png"); if (progress_img && progress_img_bg) { #ifndef __ANDROID__ const core::dimension2d<u32> &img_size = progress_img_bg->getSize(); u32 imgW = rangelim(img_size.Width, 200, 600); u32 imgH = rangelim(img_size.Height, 24, 72); #else const core::dimension2d<u32> img_size(256, 48); float imgRatio = (float)img_size.Height / img_size.Width; u32 imgW = screensize.X / 2.2f; u32 imgH = floor(imgW * imgRatio); #endif v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2); draw2DImageFilterScaled(get_video_driver(), progress_img_bg, core::rect<s32>(img_pos.X, img_pos.Y, img_pos.X + imgW, img_pos.Y + imgH), core::rect<s32>(0, 0, img_size.Width, img_size.Height), 0, 0, true); draw2DImageFilterScaled(get_video_driver(), progress_img, core::rect<s32>(img_pos.X, img_pos.Y, img_pos.X + (percent * imgW) / 100, img_pos.Y + imgH), core::rect<s32>(0, 0, (percent * img_size.Width) / 100, img_size.Height), 0, 0, true); } } guienv->drawAll(); get_video_driver()->endScene(); guitext->remove(); } std::vector<core::vector3d<u32>> RenderingEngine::getSupportedVideoModes() { IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL); sanity_check(nulldevice); std::vector<core::vector3d<u32>> mlist; video::IVideoModeList *modelist = nulldevice->getVideoModeList(); s32 num_modes = modelist->getVideoModeCount(); for (s32 i = 0; i != num_modes; i++) { core::dimension2d<u32> mode_res = modelist->getVideoModeResolution(i); u32 mode_depth = (u32)modelist->getVideoModeDepth(i); mlist.emplace_back(mode_res.Width, mode_res.Height, mode_depth); } nulldevice->drop(); return mlist; } std::vector<irr::video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers() { std::vector<irr::video::E_DRIVER_TYPE> drivers; for (int i = 0; i != irr::video::EDT_COUNT; i++) { if (irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE)i)) drivers.push_back((irr::video::E_DRIVER_TYPE)i); } return drivers; } void RenderingEngine::_initialize(Client *client, Hud *hud) { const std::string &draw_mode = g_settings->get("3d_mode"); core.reset(createRenderingCore(draw_mode, m_device, client, hud)); core->initialize(); } void RenderingEngine::_finalize() { core.reset(); } void RenderingEngine::_draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap, bool draw_wield_tool, bool draw_crosshair) { core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair); } const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type) { static const char *driver_ids[] = { "null", "software", "burningsvideo", "direct3d8", "direct3d9", "opengl", "ogles1", "ogles2", }; return driver_ids[type]; } const char *RenderingEngine::getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type) { static const char *driver_names[] = { "NULL Driver", "Software Renderer", "Burning's Video", "Direct3D 8", "Direct3D 9", "OpenGL", "OpenGL ES1", "OpenGL ES2", }; return driver_names[type]; } #ifndef __ANDROID__ #ifdef XORG_USED static float calcDisplayDensity() { const char *current_display = getenv("DISPLAY"); if (current_display != NULL) { Display *x11display = XOpenDisplay(current_display); if (x11display != NULL) { /* try x direct */ float dpi_height = floor( DisplayHeight(x11display, 0) / (DisplayHeightMM(x11display, 0) * 0.039370) + 0.5); float dpi_width = floor( DisplayWidth(x11display, 0) / (DisplayWidthMM(x11display, 0) * 0.039370) + 0.5); XCloseDisplay(x11display); return std::max(dpi_height, dpi_width) / 96.0; } } /* return manually specified dpi */ return g_settings->getFloat("screen_dpi") / 96.0; } float RenderingEngine::getDisplayDensity() { static float cached_display_density = calcDisplayDensity(); return cached_display_density; } #else // XORG_USED float RenderingEngine::getDisplayDensity() { return g_settings->getFloat("screen_dpi") / 96.0; } #endif // XORG_USED v2u32 RenderingEngine::getDisplaySize() { IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL); core::dimension2d<u32> deskres = nulldevice->getVideoModeList()->getDesktopResolution(); nulldevice->drop(); return deskres; } #endif // __ANDROID__