From: numzero Date: Sat, 25 Mar 2023 07:42:11 +0000 (+0300) Subject: Resolve conflicts with master X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=d97d1708d68a98c039db8a06c4110bfc961d3fb1;hp=-c;p=irrlicht.git Resolve conflicts with master --- d97d1708d68a98c039db8a06c4110bfc961d3fb1 diff --combined examples/AutomatedTest/main.cpp index 6e9d646,5df7a29..96cbc73 --- a/examples/AutomatedTest/main.cpp +++ b/examples/AutomatedTest/main.cpp @@@ -20,8 -20,6 +20,8 @@@ static video::E_DRIVER_TYPE chooseDrive return video::EDT_OGLES2; if (arg_ == "opengl") return video::EDT_OPENGL; + if (arg_ == "opengl3") + return video::EDT_OPENGL3; std::cerr << "Unknown driver type: " << arg_.c_str() << ". Trying OpenGL." << std::endl; return video::EDT_OPENGL; } @@@ -87,8 -85,12 +87,12 @@@ int main(int argc, char *argv[] const io::path mediaPath = getExampleMediaPath(); - scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "coolguy_opt.x"); + auto mesh_file = device->getFileSystem()->createAndOpenFile(mediaPath + "coolguy_opt.x"); + check(mesh_file, "mesh file loading"); + scene::IAnimatedMesh* mesh = smgr->getMesh(mesh_file); check(mesh, "mesh loading"); + if (mesh_file) + mesh_file->drop(); if (mesh) { video::ITexture* tex = driver->getTexture(mediaPath + "cooltexture.png"); diff --combined include/IVideoDriver.h index 9bf7afd,2fcb0ab..f93d761 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@@ -717,6 -717,23 +717,6 @@@ namespace vide virtual void draw3DLine(const core::vector3df& start, const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0; - //! Draws a 3d triangle. - /** This method calls drawVertexPrimitiveList for some triangles. - This method works with all drivers because it simply calls - drawVertexPrimitiveList, but it is hence not very fast. - Note that the triangle is drawn using the current - transformation matrix and material. So if you need to draw it - independently of the current transformation, use - \code - driver->setMaterial(someMaterial); - driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); - \endcode - for some properly set up material before drawing the triangle. - \param triangle The triangle to draw. - \param color Color of the line. */ - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)) =0; - //! Draws a 3d axis aligned box. /** This method simply calls draw3DLine for the edges of the box. Note that the box is drawn using the current transformation @@@ -747,7 -764,7 +747,7 @@@ \param texture Texture to be drawn. \param destPos Upper left 2d destination position where the image will be drawn. - \param sourceRect Source rectangle in the image. + \param sourceRect Source rectangle in the texture (based on it's OriginalSize) \param clipRect Pointer to rectangle on the screen where the image is clipped to. If this pointer is NULL the image is not clipped. @@@ -761,6 -778,35 +761,6 @@@ const core::rect& sourceRect, const core::rect* clipRect =0, SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0; - //! Draws a set of 2d images, using a color and the alpha channel of the texture. - /** The images are drawn beginning at pos and concatenated in - one line. All drawings are clipped against clipRect (if != 0). - The subtextures are defined by the array of sourceRects and are - chosen by the indices given. - \param texture Texture to be drawn. - \param pos Upper left 2d destination position where the image - will be drawn. - \param sourceRects Source rectangles of the texture (based on it's OriginalSize) - \param indices List of indices which choose the actual - rectangle used each time. - \param kerningWidth Offset to Position on X - \param clipRect Pointer to rectangle on the screen where the - image is clipped to. - If this pointer is 0 then the image is not clipped. - \param color Color with which the image is drawn. - Note that the alpha component is used. If alpha is other than - 255, the image will be transparent. - \param useAlphaChannelOfTexture: If true, the alpha channel of - the texture is used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - s32 kerningWidth=0, - const core::rect* clipRect=0, - SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false) =0; - //! Draws a set of 2d images, using a color and the alpha channel of the texture. /** All drawings are clipped against clipRect (if != 0). The subtextures are defined by the array of sourceRects and are @@@ -768,7 -814,7 +768,7 @@@ \param texture Texture to be drawn. \param positions Array of upper left 2d destinations where the images will be drawn. - \param sourceRects Source rectangles of the image. + \param sourceRects Source rectangles of the texture (based on it's OriginalSize) \param clipRect Pointer to rectangle on the screen where the images are clipped to. If this pointer is 0 then the image is not clipped. @@@ -788,7 -834,7 +788,7 @@@ /** Suggested and first implemented by zola. \param texture The texture to draw from \param destRect The rectangle to draw into - \param sourceRect The rectangle denoting a part of the texture + \param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize) \param clipRect Clips the destination rectangle (may be 0) \param colors Array of 4 colors denoting the color values of the corners of the destRect @@@ -831,6 -877,13 +831,6 @@@ SColor colorLeftDown, SColor colorRightDown, const core::rect* clip =0) =0; - //! Draws the outline of a 2D rectangle. - /** \param pos Position of the rectangle. - \param color Color of the rectangle to draw. The alpha component - specifies how transparent the rectangle outline will be. */ - virtual void draw2DRectangleOutline(const core::recti& pos, - SColor color=SColor(255,255,255,255)) =0; - //! Draws a 2d line. /** In theory both start and end will be included in coloring. BUG: Currently d3d ignores the last pixel @@@ -844,6 -897,72 +844,6 @@@ const core::position2d& end, SColor color=SColor(255,255,255,255)) =0; - //! Draws a pixel. - /** \param x The x-position of the pixel. - \param y The y-position of the pixel. - \param color Color of the pixel to draw. */ - virtual void drawPixel(u32 x, u32 y, const SColor& color) =0; - - //! Draws a non filled concyclic regular 2d polygon. - /** This method can be used to draw circles, but also - triangles, tetragons, pentagons, hexagons, heptagons, octagons, - enneagons, decagons, hendecagons, dodecagon, triskaidecagons, - etc. I think you'll got it now. And all this by simply - specifying the vertex count. Welcome to the wonders of - geometry. - \param center Position of center of circle (pixels). - \param radius Radius of circle in pixels. - \param color Color of the circle. - \param vertexCount Amount of vertices of the polygon. Specify 2 - to draw a line, 3 to draw a triangle, 4 for tetragons and a lot - (>10) for nearly a circle. */ - virtual void draw2DPolygon(core::position2d center, - f32 radius, - video::SColor color=SColor(100,255,255,255), - s32 vertexCount=10) =0; - - //! Draws a shadow volume into the stencil buffer. - /** To draw a stencil shadow, do this: First, draw all geometry. - Then use this method, to draw the shadow volume. Then, use - IVideoDriver::drawStencilShadow() to visualize the shadow. - Please note that the code for the opengl version of the method - is based on free code sent in by Philipp Dortmann, lots of - thanks go to him! - \param triangles Array of 3d vectors, specifying the shadow - volume. - \param zfail If set to true, zfail method is used, otherwise - zpass. - \param debugDataVisible The debug data that is enabled for this - shadow node - */ - virtual void drawStencilShadowVolume(const core::array& triangles, bool zfail=true, u32 debugDataVisible=0) =0; - - //! Fills the stencil shadow with color. - /** After the shadow volume has been drawn into the stencil - buffer using IVideoDriver::drawStencilShadowVolume(), use this - to draw the color of the shadow. - Please note that the code for the opengl version of the method - is based on free code sent in by Philipp Dortmann, lots of - thanks go to him! - \param clearStencilBuffer Set this to false, if you want to - draw every shadow with the same color, and only want to call - drawStencilShadow() once after all shadow volumes have been - drawn. Set this to true, if you want to paint every shadow with - its own color. - \param leftUpEdge Color of the shadow in the upper left corner - of screen. - \param rightUpEdge Color of the shadow in the upper right - corner of screen. - \param leftDownEdge Color of the shadow in the lower left - corner of screen. - \param rightDownEdge Color of the shadow in the lower right - corner of screen. */ - virtual void drawStencilShadow(bool clearStencilBuffer=false, - video::SColor leftUpEdge = video::SColor(255,0,0,0), - video::SColor rightUpEdge = video::SColor(255,0,0,0), - video::SColor leftDownEdge = video::SColor(255,0,0,0), - video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0; - //! Draws a mesh buffer /** \param mb Buffer to draw */ virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0; @@@ -1160,7 -1279,7 +1160,7 @@@ E_MATERIAL_TYPE enum or a value which was returned by addMaterialRenderer(). \param name: New name of the material renderer. */ - virtual void setMaterialRendererName(s32 idx, const c8* name) =0; + virtual void setMaterialRendererName(u32 idx, const c8* name) =0; //! Swap the material renderers used for certain id's /** Swap the IMaterialRenderers responsible for rendering specific diff --combined include/SIrrCreationParameters.h index 7439604,5c1f8da..1ac150b --- a/include/SIrrCreationParameters.h +++ b/include/SIrrCreationParameters.h @@@ -24,7 -24,7 +24,7 @@@ namespace ir //! Constructs a SIrrlichtCreationParameters structure with default values. SIrrlichtCreationParameters() : DeviceType(EIDT_BEST), - DriverType(video::EDT_BURNINGSVIDEO), + DriverType(video::EDT_OPENGL), WindowSize(core::dimension2d(800, 600)), WindowPosition(core::position2di(-1,-1)), Bits(32), @@@ -235,7 -235,6 +235,6 @@@ /** If this is set to a value other than 0, the Irrlicht Engine will be created in an already existing window. For Windows, set this to the HWND of the window you want. - For iOS, assign UIView to this variable. The windowSize and FullScreen options will be ignored when using the WindowId parameter. Default this is set to 0. To make Irrlicht run inside the custom window, you still will diff --combined source/Irrlicht/CIrrDeviceSDL.cpp index b0c7747,26683a7..c1e7527 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@@ -20,10 -20,15 +20,10 @@@ #include #ifdef _IRR_EMSCRIPTEN_PLATFORM_ -#ifdef _IRR_COMPILE_WITH_OGLES2_ -#include "CEGLManager.h" -#endif #include #endif -#ifdef _IRR_COMPILE_WITH_OPENGL_ #include "CSDLManager.h" -#endif static int SDLDeviceInstances = 0; @@@ -33,42 -38,14 +33,42 @@@ namespace ir { #ifdef _IRR_COMPILE_WITH_OPENGL_ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); + #else + static IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) + { + os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); + return nullptr; + } + #endif + + #ifdef ENABLE_OPENGL3 + IVideoDriver* createOpenGL3Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); + #else + static IVideoDriver* createOpenGL3Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) + { + os::Printer::log("No OpenGL 3 support compiled in.", ELL_ERROR); + return nullptr; + } #endif #ifdef _IRR_COMPILE_WITH_OGLES2_ IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); + #else + static IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) + { + os::Printer::log("No OpenGL ES 2 support compiled in.", ELL_ERROR); + return nullptr; + } #endif #ifdef _IRR_COMPILE_WITH_WEBGL1_ IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); + #else + static IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) + { + os::Printer::log("No WebGL 1 support compiled in.", ELL_ERROR); + return nullptr; + } #endif } // end namespace video @@@ -243,7 -220,7 +243,7 @@@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrr #endif if (SDL_Init(flags) < 0) { - os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); + os::Printer::log("Unable to initialize SDL!", SDL_GetError()); Close = true; } else @@@ -255,6 -232,28 +255,6 @@@ // create keymap createKeyMap(); - if (CreationParams.Fullscreen) { -#ifdef _IRR_EMSCRIPTEN_PLATFORM_ - SDL_Flags |= SDL_WINDOW_FULLSCREEN; -#else - SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; -#endif - } - if (Resizable) - SDL_Flags |= SDL_WINDOW_RESIZABLE; - if (CreationParams.WindowMaximized) - SDL_Flags |= SDL_WINDOW_MAXIMIZED; - - if (CreationParams.DriverType == video::EDT_OPENGL) - { - SDL_Flags |= SDL_WINDOW_OPENGL; - if (!CreationParams.Doublebuffer) - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); - } -#ifdef _IRR_EMSCRIPTEN_PLATFORM_ - SDL_Flags |= SDL_WINDOW_OPENGL; -#endif //_IRR_EMSCRIPTEN_PLATFORM_ - // create window if (CreationParams.DriverType != video::EDT_NULL) { @@@ -344,19 -343,6 +344,19 @@@ void CIrrDeviceSDL::logAttributes( bool CIrrDeviceSDL::createWindow() { + if (CreationParams.Fullscreen) { +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + SDL_Flags |= SDL_WINDOW_FULLSCREEN; +#else + SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; +#endif + } + if (Resizable) + SDL_Flags |= SDL_WINDOW_RESIZABLE; + if (CreationParams.WindowMaximized) + SDL_Flags |= SDL_WINDOW_MAXIMIZED; + SDL_Flags |= SDL_WINDOW_OPENGL; + #ifdef _IRR_EMSCRIPTEN_PLATFORM_ if ( Width != 0 || Height != 0 ) emscripten_set_canvas_size( Width, Height); @@@ -403,73 -389,54 +403,73 @@@ if ( Close ) return false; - if (CreationParams.DriverType == video::EDT_OPENGL) { - if (CreationParams.Bits == 16) { - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4); - SDL_GL_SetAttribute( - SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0); - } else { - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute( - SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0); - } - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); - if (CreationParams.Doublebuffer) - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0); - if (CreationParams.Stereobuffer) - SDL_GL_SetAttribute(SDL_GL_STEREO, 1); - if (CreationParams.AntiAlias > 1) { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + switch (CreationParams.DriverType) { + case video::EDT_OPENGL: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + break; + case video::EDT_OPENGL3: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); + break; + case video::EDT_OGLES1: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + break; + case video::EDT_OGLES2: + case video::EDT_WEBGL1: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + break; + default:; + } + +#ifdef _DEBUG + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG); +#endif + + if (CreationParams.Bits == 16) { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0); + } else { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0); + } + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0); + SDL_GL_SetAttribute(SDL_GL_STEREO, CreationParams.Stereobuffer); + if (CreationParams.AntiAlias > 1) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); + } + if (!Window) + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + if (!Window) { + os::Printer::log("Could not create window...", SDL_GetError(), ELL_WARNING); + } + if (!Window && CreationParams.AntiAlias > 1) { + while (--CreationParams.AntiAlias > 1) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); - } - if (!Window) Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); - if (!Window && CreationParams.AntiAlias > 1) { - while (--CreationParams.AntiAlias > 1) { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); - Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); - if (Window) - break; - } - if (!Window) { - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); - Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); - if (Window) - os::Printer::log("AntiAliasing disabled due to lack of support!"); - } + if (Window) + break; } - - if (Window) - { - Context = SDL_GL_CreateContext(Window); + if (!Window) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + if (Window) + os::Printer::log("AntiAliasing disabled due to lack of support!", ELL_WARNING); } - } else if (!Window) - Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + } if ( !Window && CreationParams.Doublebuffer) { @@@ -480,14 -447,7 +480,14 @@@ } if ( !Window ) { - os::Printer::log("Could not initialize display!" ); + os::Printer::log("Could not initialize display", SDL_GetError(), ELL_ERROR); + return false; + } + + Context = SDL_GL_CreateContext(Window); + if (!Context) { + os::Printer::log("Could not initialize context", SDL_GetError(), ELL_ERROR); + SDL_DestroyWindow(Window); return false; } @@@ -499,22 -459,79 +499,22 @@@ //! create the driver void CIrrDeviceSDL::createDriver() { - switch(CreationParams.DriverType) - { - case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS: - os::Printer::log("DIRECT3D8 Driver is no longer supported in Irrlicht. Try another one.", ELL_ERROR); - break; - - case video::EDT_DIRECT3D9: - #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ - os::Printer::log("SDL device does not support DIRECT3D9 driver. Try another one.", ELL_ERROR); - #else - os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); - #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ - - break; - - case video::EDT_OPENGL: - #ifdef _IRR_COMPILE_WITH_OPENGL_ - ContextManager = new video::CSDLManager(this); - VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); - #else - os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); - #endif - break; - - case video::EDT_OGLES2: -#if defined(_IRR_COMPILE_WITH_OGLES2_) && defined(_IRR_EMSCRIPTEN_PLATFORM_) - { - video::SExposedVideoData data; - - ContextManager = new video::CEGLManager(); - ContextManager->initialize(CreationParams, data); - - VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); - } -#else - os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR); -#endif - break; - - case video::EDT_WEBGL1: -#if defined(_IRR_COMPILE_WITH_WEBGL1_) && defined(_IRR_EMSCRIPTEN_PLATFORM_) - { - video::SExposedVideoData data; - - ContextManager = new video::CEGLManager(); - ContextManager->initialize(CreationParams, data); - - VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager); - } -#else - os::Printer::log("No WebGL1 support compiled in.", ELL_ERROR); -#endif - break; - - case video::EDT_NULL: + if (CreationParams.DriverType == video::EDT_NULL) { VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); - break; - - default: - os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); - break; + return; } - // In case we got the size from the canvas - if ( VideoDriver && CreationParams.WindowSize.Width == 0 && CreationParams.WindowSize.Height == 0 && Width > 0 && Height > 0 ) + ContextManager = new video::CSDLManager(this); + switch(CreationParams.DriverType) { -#ifdef _IRR_EMSCRIPTEN_PLATFORM_ - SDL_CreateWindowAndRenderer(Width, Height, SDL_Flags, &Window, &Renderer); -#else //_IRR_EMSCRIPTEN_PLATFORM_ - Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); -#endif //_IRR_EMSCRIPTEN_PLATFOR - VideoDriver->OnResize(core::dimension2d(Width, Height)); + case video::EDT_OPENGL: VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); break; + case video::EDT_OPENGL3: VideoDriver = video::createOpenGL3Driver(CreationParams, FileSystem, ContextManager); break; + case video::EDT_OGLES2: VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); break; + case video::EDT_WEBGL1: VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager); break; + default:; } + if (!VideoDriver) + os::Printer::log("Could not create video driver", ELL_ERROR); } diff --combined source/Irrlicht/CMakeLists.txt index fa345ca,e993ace..ad11dd4 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@@ -77,28 -77,20 +77,19 @@@ add_definitions if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") set(SOLARIS TRUE) endif() - if(APPLE AND NOT IOS) - set(OSX TRUE) - endif() # Device if(WIN32) add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_) set(DEVICE "WINDOWS") - elseif(IOS) - add_definitions(-D_IRR_IOS_PLATFORM_ -D_IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_) - if(USE_SDL2) - message(SEND_ERROR "SDL2 backend is not supported on iOS") - endif() - set(DEVICE "IOS") - elseif(OSX) + elseif(APPLE) add_definitions(-D_IRR_OSX_PLATFORM_) set(DEVICE "OSX") elseif(ANDROID) add_definitions(-D_IRR_ANDROID_PLATFORM_ -D_IRR_COMPILE_ANDROID_ASSET_READER_) if(USE_SDL2) - message(WARNING "SDL2 backend is not supported on Android") - set(USE_SDL2 FALSE) + message(SEND_ERROR "SDL2 backend is not supported on Android") endif() set(DEVICE "Android") elseif(EMSCRIPTEN) @@@ -148,28 -140,26 +139,28 @@@ endif( # OpenGL +option(ENABLE_OPENGL3 "Enable OpenGL 3+" FALSE) + - if(IOS OR ANDROID OR EMSCRIPTEN) + if(ANDROID OR EMSCRIPTEN) set(ENABLE_OPENGL FALSE) else() option(ENABLE_OPENGL "Enable OpenGL" TRUE) endif() - if(EMSCRIPTEN OR OSX) + if(EMSCRIPTEN OR APPLE) set(ENABLE_GLES1 FALSE) else() - if(ANDROID OR IOS) + if(ANDROID) set(DEFAULT_GLES1 TRUE) endif() option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1}) endif() - if(OSX) + if(APPLE) set(ENABLE_GLES2 FALSE) set(ENABLE_WEBGL1 FALSE) else() - if(ANDROID OR IOS OR EMSCRIPTEN) + if(ANDROID OR EMSCRIPTEN) set(DEFAULT_GLES2 TRUE) endif() if(EMSCRIPTEN) @@@ -195,23 -185,10 +186,21 @@@ if(ENABLE_OPENGL endif() endif() +if(ENABLE_OPENGL3) + if (NOT USE_SDL2) + message(SEND_ERROR "OpenGL3 support requires SDL2") + endif() + set(USE_SDLGL ON) + set(USE_SDLGL3 ON) +endif() + if(ENABLE_GLES1) + if (USE_SDL2) + message(SEND_ERROR "OpenGL ES 1 is not supported with SDL2") + endif() add_definitions(-D_IRR_COMPILE_WITH_OGLES1_) if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$") add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_) - elseif(DEVICE STREQUAL "IOS") - add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_) endif() endif() @@@ -219,11 -196,6 +208,9 @@@ if(ENABLE_GLES2 add_definitions(-D_IRR_COMPILE_WITH_OGLES2_) if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN) add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_) - elseif(DEVICE STREQUAL "IOS") - add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_) + elseif(DEVICE STREQUAL "SDL") + set(USE_SDLGL ON) + set(USE_SDLGLES2 ON) endif() endif() @@@ -243,7 -215,6 +230,7 @@@ endif( message(STATUS "Device: ${DEVICE}") message(STATUS "OpenGL: ${ENABLE_OPENGL}") +message(STATUS "OpenGL 3: ${ENABLE_OPENGL3}") message(STATUS "OpenGL ES: ${ENABLE_GLES1}") message(STATUS "OpenGL ES 2: ${ENABLE_GLES2}") message(STATUS "WebGL: ${ENABLE_WEBGL1}") @@@ -365,6 -336,12 +352,6 @@@ set(IRRDRVROB COpenGLExtensionHandler.cpp COGLESDriver.cpp COGLESExtensionHandler.cpp - COGLES2Driver.cpp - COGLES2ExtensionHandler.cpp - COGLES2FixedPipelineRenderer.cpp - COGLES2MaterialRenderer.cpp - COGLES2Renderer2D.cpp - CWebGL1Driver.cpp CGLXManager.cpp CWGLManager.cpp CEGLManager.cpp @@@ -389,37 -366,6 +376,37 @@@ add_library(IRRVIDEOOBJ OBJEC ${IRRIMAGEOBJ} ) +if(USE_SDLGL) + target_sources(IRRVIDEOOBJ PUBLIC + OpenGL/Driver.cpp + OpenGL/ExtensionHandler.cpp + OpenGL/FixedPipelineRenderer.cpp + OpenGL/MaterialRenderer.cpp + OpenGL/Renderer2D.cpp + ) +endif() + +if(USE_SDLGL3) + target_sources(IRRVIDEOOBJ PUBLIC + OpenGL3/Driver.cpp + ) +endif() + +if(USE_SDLGLES2) + target_sources(IRRVIDEOOBJ PUBLIC + OpenGLES2/Driver.cpp + ) +else() + target_sources(IRRVIDEOOBJ PUBLIC + COGLES2Driver.cpp + COGLES2ExtensionHandler.cpp + COGLES2FixedPipelineRenderer.cpp + COGLES2MaterialRenderer.cpp + COGLES2Renderer2D.cpp + CWebGL1Driver.cpp + ) +endif() + add_library(IRRIOOBJ OBJECT CFileList.cpp CFileSystem.cpp @@@ -442,10 -388,6 +429,10 @@@ add_library(IRROTHEROBJ OBJEC os.cpp ) +if(ENABLE_OPENGL3) + target_compile_definitions(IRROTHEROBJ PRIVATE ENABLE_OPENGL3) +endif() + if(ANDROID) target_sources(IRROTHEROBJ PRIVATE Android/CIrrDeviceAndroid.cpp diff --combined source/Irrlicht/CNullDriver.cpp index a76dbec,21e143a..a02431c --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@@ -719,6 -719,27 +719,6 @@@ void CNullDriver::draw3DLine(const core } -//! Draws a 3d triangle. -void CNullDriver::draw3DTriangle(const core::triangle3df& triangle, SColor color) -{ - S3DVertex vertices[3]; - vertices[0].Pos=triangle.pointA; - vertices[0].Color=color; - vertices[0].Normal=triangle.getNormal().normalize(); - vertices[0].TCoords.set(0.f,0.f); - vertices[1].Pos=triangle.pointB; - vertices[1].Color=color; - vertices[1].Normal=vertices[0].Normal; - vertices[1].TCoords.set(0.5f,1.f); - vertices[2].Pos=triangle.pointC; - vertices[2].Color=color; - vertices[2].Normal=vertices[0].Normal; - vertices[2].TCoords.set(1.f,0.f); - const u16 indexList[] = {0,1,2}; - drawVertexPrimitiveList(vertices, 3, indexList, 1, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); -} - - //! Draws a 3d axis aligned box. void CNullDriver::draw3DBox(const core::aabbox3d& box, SColor color) { @@@ -758,6 -779,31 +758,6 @@@ void CNullDriver::draw2DImage(const vid } - -//! draws a set of 2d images, using a color and the alpha channel of the -//! texture if desired. The images are drawn beginning at pos and concatenated -//! in one line. All drawings are clipped against clipRect (if != 0). -//! The subtextures are defined by the array of sourceRects and are chosen -//! by the indices given. -void CNullDriver::draw2DImageBatch(const video::ITexture* texture, - const core::position2d& pos, - const core::array >& sourceRects, - const core::array& indices, - s32 kerningWidth, - const core::rect* clipRect, SColor color, - bool useAlphaChannelOfTexture) -{ - core::position2d target(pos); - - for (u32 i=0; i& pos, const core::rect* clip) { @@@ -821,6 -877,38 +821,6 @@@ void CNullDriver::draw2DLine(const core { } -//! Draws a pixel -void CNullDriver::drawPixel(u32 x, u32 y, const SColor & color) -{ -} - - -//! Draws a non filled concyclic regular 2d polygon. -void CNullDriver::draw2DPolygon(core::position2d center, - f32 radius, video::SColor color, s32 count) -{ - if (count < 2) - return; - - core::position2d first; - core::position2d a,b; - - for (s32 j=0; j((s32)(sin(p)*radius), (s32)(cos(p)*radius)); - - if (j==0) - first = a; - else - draw2DLine(a, b, color); - } - - draw2DLine(a, first, color); -} - //! returns color format ECOLOR_FORMAT CNullDriver::getColorFormat() const @@@ -891,6 -979,25 +891,6 @@@ const wchar_t* CNullDriver::getName() c } - -//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: First, draw all geometry. Then use this method, to draw the shadow -//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. -void CNullDriver::drawStencilShadowVolume(const core::array& triangles, bool zfail, u32 debugDataVisible) -{ -} - - -//! Fills the stencil shadow with color. After the shadow volume has been drawn -//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this -//! to draw the color of the shadow. -void CNullDriver::drawStencilShadow(bool clearStencilBuffer, - video::SColor leftUpEdge, video::SColor rightUpEdge, - video::SColor leftDownEdge, video::SColor rightDownEdge) -{ -} - - //! Creates a boolean alpha channel of the texture based of an color key. void CNullDriver::makeColorKeyTexture(video::ITexture* texture, video::SColor color, @@@ -1717,10 -1824,10 +1717,10 @@@ s32 CNullDriver::addMaterialRenderer(IM //! Sets the name of a material renderer. - void CNullDriver::setMaterialRendererName(s32 idx, const char* name) + void CNullDriver::setMaterialRendererName(u32 idx, const char* name) { - if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 || - idx >= (s32)MaterialRenderers.size()) + if (idx < (sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 || + idx >= MaterialRenderers.size()) return; MaterialRenderers[idx].Name = name; diff --combined source/Irrlicht/CNullDriver.h index 3362045,625ff1a..e6b27d8 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@@ -126,8 -126,9 +126,8 @@@ namespace vide virtual void draw3DLine(const core::vector3df& start, const core::vector3df& end, SColor color = SColor(255,255,255,255)) override; - //! Draws a 3d triangle. - virtual void draw3DTriangle(const core::triangle3df& triangle, - SColor color = SColor(255,255,255,255)) override; + [[deprecated]] virtual void draw3DTriangle(const core::triangle3df& triangle, + SColor color = SColor(255,255,255,255)) {} //! Draws a 3d axis aligned box. virtual void draw3DBox(const core::aabbox3d& box, @@@ -153,14 -154,14 +153,14 @@@ Note that the alpha component is used: If alpha is other than 255, the image will be transparent. \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is used to draw the image. */ - virtual void draw2DImageBatch(const video::ITexture* texture, + [[deprecated]] virtual void draw2DImageBatch(const video::ITexture* texture, const core::position2d& pos, const core::array >& sourceRects, const core::array& indices, s32 kerningWidth = 0, const core::rect* clipRect = 0, SColor color=SColor(255,255,255,255), - bool useAlphaChannelOfTexture=false) override; + bool useAlphaChannelOfTexture=false) {} //! Draws a set of 2d images, using a color and the alpha channel of the texture. /** All drawings are clipped against clipRect (if != 0). @@@ -204,7 -205,7 +204,7 @@@ const core::rect* clip = 0) override; //! Draws the outline of a 2d rectangle - void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)) override; + [[deprecated]] virtual void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)) {} //! Draws a 2d line. virtual void draw2DLine(const core::position2d& start, @@@ -212,11 -213,11 +212,11 @@@ SColor color=SColor(255,255,255,255)) override; //! Draws a pixel - void drawPixel(u32 x, u32 y, const SColor & color) override; + [[deprecated]] virtual void drawPixel(u32 x, u32 y, const SColor & color) {} //! Draws a non filled concyclic reqular 2d polygon. - virtual void draw2DPolygon(core::position2d center, - f32 radius, video::SColor Color, s32 vertexCount) override; + [[deprecated]] virtual void draw2DPolygon(core::position2d center, + f32 radius, video::SColor Color, s32 vertexCount) {} virtual void setFog(SColor color=SColor(0,255,255,255), E_FOG_TYPE fogType=EFT_FOG_LINEAR, @@@ -267,17 -268,17 +267,17 @@@ //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do //! this: First, draw all geometry. Then use this method, to draw the shadow //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. - virtual void drawStencilShadowVolume(const core::array& triangles, - bool zfail=true, u32 debugDataVisible=0) override; + [[deprecated]] virtual void drawStencilShadowVolume(const core::array& triangles, + bool zfail=true, u32 debugDataVisible=0) {} //! Fills the stencil shadow with color. After the shadow volume has been drawn //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this //! to draw the color of the shadow. - virtual void drawStencilShadow(bool clearStencilBuffer=false, + [[deprecated]] virtual void drawStencilShadow(bool clearStencilBuffer=false, video::SColor leftUpEdge = video::SColor(0,0,0,0), video::SColor rightUpEdge = video::SColor(0,0,0,0), video::SColor leftDownEdge = video::SColor(0,0,0,0), - video::SColor rightDownEdge = video::SColor(0,0,0,0)) override; + video::SColor rightDownEdge = video::SColor(0,0,0,0)) {} //! Removes a texture from the texture cache and deletes it, freeing lot of @@@ -584,7 -585,7 +584,7 @@@ bool writeImageToFile(IImage* image, io::IWriteFile * file, u32 param = 0) override; //! Sets the name of a material renderer. - void setMaterialRendererName(s32 idx, const char* name) override; + void setMaterialRendererName(u32 idx, const char* name) override; //! Swap the material renderers used for certain id's void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) override; diff --combined source/Irrlicht/Irrlicht.cpp index ed6b082,e598ec3..d1d2678 --- a/source/Irrlicht/Irrlicht.cpp +++ b/source/Irrlicht/Irrlicht.cpp @@@ -29,10 -29,6 +29,6 @@@ static const char* const copyright = "I #include "CIrrDeviceSDL.h" #endif - #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ - #include "CIrrDeviceiOS.h" - #endif - #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ #include "Android/CIrrDeviceAndroid.h" #endif @@@ -78,11 -74,6 +74,6 @@@ namespace ir if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceLinux(params); #endif - - #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ - if (params.DeviceType == EIDT_IOS || (!dev && params.DeviceType == EIDT_BEST)) - dev = new CIrrDeviceiOS(params); - #endif #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST)) @@@ -118,9 -109,6 +109,9 @@@ namespace vide { switch (driver) { case EDT_NULL: return true; +#ifdef ENABLE_OPENGL3 + case EDT_OPENGL3: return true; +#endif #ifdef _IRR_COMPILE_WITH_OPENGL_ case EDT_OPENGL: return true; #endif