Merge branch 'master' into feat/gltf-loader
This commit is contained in:
		| @@ -2,7 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef   _IRR_COMPILE_ANDROID_ASSET_READER_ | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #define __C_ANDROID_ASSET_FILE_ARCHIVE_H_INCLUDED__ | ||||
|  | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef  _IRR_COMPILE_ANDROID_ASSET_READER_ | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef   _IRR_COMPILE_ANDROID_ASSET_READER_ | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #define __C_ANDROID_ASSET_READER_H_INCLUDED__ | ||||
|  | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef  _IRR_COMPILE_ANDROID_ASSET_READER_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_IRR_DEVICE_ANDROID_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_ANDROID_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,6 @@ | ||||
| #ifndef __C_IRR_KEY_EVENT_WRAPPER_H_INCLUDED__ | ||||
| #define __C_IRR_KEY_EVENT_WRAPPER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ | ||||
|  | ||||
|   | ||||
| @@ -5,8 +5,6 @@ | ||||
| #ifndef __BUILD_IN_FONT_H_INCLUDED__ | ||||
| #define __BUILD_IN_FONT_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| // header file generated by Bin2H, copyright 2002 by N.Gebhardt. | ||||
| // Bin2H is Freeware. Download it freely from www.code3d.com. | ||||
| @@ -16,7 +14,6 @@ namespace irr | ||||
| { | ||||
| namespace gui | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_BMP_LOADER_ | ||||
| const u8 BuiltInFontData[] = | ||||
| { | ||||
| 	0x42, 0x4d, 0x4a, 0x20, 0x00, 0x00, 0x00, 0x00, | ||||
| @@ -1056,20 +1053,7 @@ const u8 BuiltInFontData[] = | ||||
| }; | ||||
|  | ||||
| 	const u32 BuiltInFontDataSize = sizeof(BuiltInFontData); | ||||
|  | ||||
| #else // !defined(_IRR_COMPILE_WITH_BMP_LOADER_) | ||||
|  | ||||
| 	// built-in font cannot be loaded if there is no BMP loader | ||||
|  | ||||
| 	const u8 * const BuiltInFontData=0; | ||||
|  | ||||
| 	const u32 BuiltInFontDataSize = 0; | ||||
|  | ||||
| #endif | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,9 @@ | ||||
| #include "ISceneManager.h" | ||||
| #include "S3DVertex.h" | ||||
| #include "os.h" | ||||
| #ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ | ||||
| #include "CSkinnedMesh.h" | ||||
| #endif | ||||
| #include "IDummyTransformationSceneNode.h" | ||||
| #include "IBoneSceneNode.h" | ||||
| #include "IMaterialRenderer.h" | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_ATTRIBUTES_H_INCLUDED__ | ||||
| #define __C_ATTRIBUTES_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "IAttributes.h" | ||||
| #include "IAttribute.h" | ||||
|   | ||||
| @@ -6,9 +6,6 @@ | ||||
| // File format designed by Mark Sibly for the Blitz3D engine and has been | ||||
| // declared public domain | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_B3D_LOADER_ | ||||
|  | ||||
| #include "CB3DMeshFileLoader.h" | ||||
|  | ||||
| #include "IVideoDriver.h" | ||||
| @@ -1055,7 +1052,3 @@ void CB3DMeshFileLoader::readFloats(f32* vec, u32 count) | ||||
|  | ||||
| } // end namespace scene | ||||
| } // end namespace irr | ||||
|  | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_B3D_LOADER_ | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| // File format designed by Mark Sibly for the Blitz3D engine and has been | ||||
| // declared public domain | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifndef __C_B3D_MESH_LOADER_H_INCLUDED__ | ||||
| #define __C_B3D_MESH_LOADER_H_INCLUDED__ | ||||
|   | ||||
| @@ -4,9 +4,6 @@ | ||||
|  | ||||
| // TODO: replace printf's by logging messages | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_B3D_WRITER_ | ||||
|  | ||||
| #include "CB3DMeshWriter.h" | ||||
| #include "os.h" | ||||
| @@ -97,7 +94,7 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag | ||||
|     u32 numTexture = texs.size(); | ||||
|     for (u32 i = 0; i < numTexture; i++) | ||||
| 	{ | ||||
|         file->write(texs[i].TextureName.c_str(), texs[i].TextureName.size() + 1); | ||||
|         file->write(texs[i].TextureName.c_str(), (size_t)texs[i].TextureName.size() + 1); | ||||
|         file->write(&texs[i].Flags, 7*4); | ||||
|     } | ||||
|  | ||||
| @@ -479,7 +476,7 @@ core::array<ISkinnedMesh::SJoint*> CB3DMeshWriter::getRootJoints(const ISkinnedM | ||||
|     return roots; | ||||
| } | ||||
|  | ||||
| u32 CB3DMeshWriter::getUVlayerCount(IMesh* mesh) | ||||
| u32 CB3DMeshWriter::getUVlayerCount(const IMesh* mesh) | ||||
| { | ||||
|     const u32 numBeshBuffers = mesh->getMeshBufferCount(); | ||||
|     for (u32 i = 0; i < numBeshBuffers; i++) | ||||
| @@ -531,6 +528,3 @@ void CB3DMeshWriter::writeSizeFrom(io::IWriteFile* file, const u32 from, const u | ||||
|  | ||||
| } // end namespace | ||||
| } // end namespace | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_B3D_WRITER_ | ||||
|  | ||||
|   | ||||
| @@ -37,7 +37,7 @@ private: | ||||
|     u32 getJointChunkSize(const ISkinnedMesh* mesh, ISkinnedMesh::SJoint* joint); | ||||
|     core::array<ISkinnedMesh::SJoint*> getRootJoints(const ISkinnedMesh* mesh); | ||||
|  | ||||
|     u32 getUVlayerCount(IMesh *mesh); | ||||
|     u32 getUVlayerCount(const IMesh *mesh); | ||||
|     ISkinnedMesh* getSkinned (IMesh *mesh); | ||||
|  | ||||
|     inline void writeVector2(io::IWriteFile* file, const core::vector2df& vec); | ||||
|   | ||||
| @@ -2,8 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ | ||||
| #include "CBillboardSceneNode.h" | ||||
| #include "IVideoDriver.h" | ||||
| #include "ISceneManager.h" | ||||
| @@ -143,7 +141,7 @@ void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode* camera) | ||||
| //! returns the axis aligned bounding box of this node | ||||
| const core::aabbox3d<f32>& CBillboardSceneNode::getBoundingBox() const | ||||
| { | ||||
| 	// Really wrong when scaled. | ||||
| 	// Really wrong when scaled (as the node does not scale it's vertices - maybe it should?) | ||||
| 	return BBoxSafe; | ||||
| } | ||||
|  | ||||
| @@ -164,9 +162,9 @@ void CBillboardSceneNode::setSize(const core::dimension2d<f32>& size) | ||||
| 	if (core::equals(Size.Height, 0.0f)) | ||||
| 		Size.Height = 1.0f; | ||||
|  | ||||
| 	const f32 avg = (Size.Width + Size.Height)/6; | ||||
| 	BBoxSafe.MinEdge.set(-avg,-avg,-avg); | ||||
| 	BBoxSafe.MaxEdge.set(avg,avg,avg); | ||||
| 	const f32 extent = 0.5f*sqrtf(Size.Width*Size.Width + Size.Height*Size.Height); | ||||
| 	BBoxSafe.MinEdge.set(-extent,-extent,-extent); | ||||
| 	BBoxSafe.MaxEdge.set(extent,extent,extent); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -184,9 +182,9 @@ void CBillboardSceneNode::setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWi | ||||
| 		TopEdgeWidth = 1.0f; | ||||
| 	} | ||||
|  | ||||
| 	const f32 avg = (core::max_(Size.Width,TopEdgeWidth) + Size.Height)/6; | ||||
| 	BBoxSafe.MinEdge.set(-avg,-avg,-avg); | ||||
| 	BBoxSafe.MaxEdge.set(avg,avg,avg); | ||||
| 	const f32 extent = 0.5f*sqrtf(Size.Width*Size.Width + Size.Height*Size.Height); | ||||
| 	BBoxSafe.MinEdge.set(-extent,-extent,-extent); | ||||
| 	BBoxSafe.MaxEdge.set(extent,extent,extent); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -281,5 +279,3 @@ ISceneNode* CBillboardSceneNode::clone(ISceneNode* newParent, ISceneManager* new | ||||
|  | ||||
| } // end namespace scene | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ | ||||
|   | ||||
| @@ -2,9 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ | ||||
|  | ||||
| #include "CBoneSceneNode.h" | ||||
|  | ||||
| namespace irr | ||||
| @@ -98,6 +95,3 @@ void CBoneSceneNode::updateAbsolutePositionOfAllChildren() | ||||
|  | ||||
| } // namespace scene | ||||
| } // namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -28,16 +28,16 @@ CCameraSceneNode::CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 i | ||||
|  | ||||
| 	// set default projection | ||||
| 	Fovy = core::PI / 2.5f;	// Field of view, in radians. | ||||
| 	Aspect = 4.0f / 3.0f;	// Aspect ratio. | ||||
|  | ||||
| 	const video::IVideoDriver* const d = mgr?mgr->getVideoDriver():0; | ||||
| 	if (d) | ||||
| 	{ | ||||
| 		Aspect = (f32)d->getCurrentRenderTargetSize().Width / | ||||
| 			(f32)d->getCurrentRenderTargetSize().Height; | ||||
| 		if ( d->getCurrentRenderTargetSize().Height ) | ||||
| 			Aspect = (f32)d->getCurrentRenderTargetSize().Width / | ||||
| 				(f32)d->getCurrentRenderTargetSize().Height; | ||||
| 		HasD3DStyleProjectionMatrix = d->getDriverType() != video::EDT_OPENGL; | ||||
| 	} | ||||
| 	else | ||||
| 		Aspect = 4.0f / 3.0f;	// Aspect ratio. | ||||
|  | ||||
| 	ViewArea.setFarNearDistance(ZFar - ZNear); | ||||
| 	recalculateProjectionMatrix(); | ||||
|   | ||||
| @@ -1,87 +0,0 @@ | ||||
| // Copyright (C) 2015 Patryk Nadrowski | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in Irrlicht.h | ||||
|  | ||||
| #ifndef __C_EAGL_MANAGER_H_INCLUDED__ | ||||
| #define __C_EAGL_MANAGER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_EAGL_MANAGER_ | ||||
|  | ||||
| #include "SIrrCreationParameters.h" | ||||
| #include "SExposedVideoData.h" | ||||
| #include "IContextManager.h" | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| namespace video | ||||
| { | ||||
| 	// EAGL manager. | ||||
| 	class CEAGLManager : public IContextManager | ||||
| 	{ | ||||
| 	public: | ||||
| 		//! Constructor. | ||||
| 		CEAGLManager(); | ||||
|  | ||||
| 		//! Destructor. | ||||
| 		virtual ~CEAGLManager(); | ||||
|  | ||||
| 		// Initialize EAGL. | ||||
| 		/* This method checks if a view has CAEAGLLayer and grabs it if it does, anyway surface and context | ||||
| 		aren't create. */ | ||||
| 		bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data); | ||||
|  | ||||
| 		// Terminate EAGL. | ||||
| 		/* Terminate EAGL context. This method break both existed surface and context. */ | ||||
| 		void terminate(); | ||||
|  | ||||
| 		// Create EAGL surface. | ||||
| 		/* This method configure CAEAGLLayer. */ | ||||
| 		bool generateSurface(); | ||||
|  | ||||
| 		// Destroy EAGL surface. | ||||
| 		/* This method reset CAEAGLLayer states. */ | ||||
| 		void destroySurface(); | ||||
|  | ||||
| 		// Create EAGL context. | ||||
| 		/* This method create and activate EAGL context. */ | ||||
| 		bool generateContext(); | ||||
|  | ||||
| 		// Destroy EAGL context. | ||||
| 		/* This method destroy EAGL context. */ | ||||
| 		void destroyContext(); | ||||
|  | ||||
| 		const SExposedVideoData& getContext() const; | ||||
|  | ||||
| 		bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero); | ||||
|  | ||||
| 		// Swap buffers. | ||||
| 		bool swapBuffers(); | ||||
|  | ||||
| 	private: | ||||
| 		SIrrlichtCreationParameters Params; | ||||
| 		SExposedVideoData Data; | ||||
|  | ||||
| 		bool Configured; | ||||
|  | ||||
|         void* DataStorage; | ||||
|  | ||||
| 		struct SFrameBuffer | ||||
| 		{ | ||||
| 			SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0) | ||||
| 			{ | ||||
| 			} | ||||
|  | ||||
| 			u32 BufferID; | ||||
| 			u32 ColorBuffer; | ||||
| 			u32 DepthBuffer; | ||||
| 		}; | ||||
|  | ||||
| 		SFrameBuffer FrameBuffer; | ||||
| 	}; | ||||
| } | ||||
| } | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
| @@ -1,273 +0,0 @@ | ||||
| // Copyright (C) 2015 Patryk Nadrowski | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in Irrlicht.h | ||||
|  | ||||
| #include "CEAGLManager.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_EAGL_MANAGER_ | ||||
|  | ||||
| #include "irrString.h" | ||||
| #include "os.h" | ||||
|  | ||||
| #import <UIKit/UIKit.h> | ||||
| #import <OpenGLES/EAGL.h> | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_OGLES1_) | ||||
| #include <OpenGLES/ES1/gl.h> | ||||
| #include <OpenGLES/ES1/glext.h> | ||||
| #elif defined(_IRR_COMPILE_WITH_OGLES2_) | ||||
| #include <OpenGLES/ES2/gl.h> | ||||
| #include <OpenGLES/ES2/glext.h> | ||||
| #endif | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| namespace video | ||||
| { | ||||
|  | ||||
| struct SEAGLManagerDataStorage | ||||
| { | ||||
|     SEAGLManagerDataStorage() : Layer(0), Context(0) | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	CAEAGLLayer* Layer; | ||||
|     EAGLContext* Context; | ||||
| }; | ||||
|  | ||||
| CEAGLManager::CEAGLManager() : IContextManager(), Configured(false), DataStorage(0) | ||||
| { | ||||
| #ifdef _DEBUG | ||||
| 	setDebugName("CEAGLManager"); | ||||
| #endif | ||||
|  | ||||
| 	DataStorage = new SEAGLManagerDataStorage(); | ||||
| } | ||||
|  | ||||
| CEAGLManager::~CEAGLManager() | ||||
| { | ||||
|     destroyContext(); | ||||
|     destroySurface(); | ||||
|     terminate(); | ||||
|  | ||||
| 	delete static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
| } | ||||
|  | ||||
| bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
|  | ||||
| 	if (dataStorage->Layer != nil) | ||||
|         return true; | ||||
|  | ||||
| 	Params = params; | ||||
| 	Data = data; | ||||
|  | ||||
| 	UIView* view = (__bridge UIView*)data.OpenGLiOS.View; | ||||
|  | ||||
| 	if (view == nil || ![[view layer] isKindOfClass:[CAEAGLLayer class]]) | ||||
| 	{ | ||||
| 		os::Printer::log("Could not get EAGL display."); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	dataStorage->Layer = (CAEAGLLayer*)[view layer]; | ||||
|  | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| void CEAGLManager::terminate() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
|  | ||||
| 	[EAGLContext setCurrentContext:0]; | ||||
|  | ||||
| 	destroySurface(); | ||||
|  | ||||
|     if (dataStorage->Layer != nil) | ||||
|         dataStorage->Layer = 0; | ||||
| } | ||||
|  | ||||
| bool CEAGLManager::generateSurface() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
| 	CAEAGLLayer* layer = dataStorage->Layer; | ||||
|  | ||||
|     if (layer == nil) | ||||
|         return false; | ||||
|  | ||||
| 	if (Configured) | ||||
| 		return true; | ||||
|  | ||||
| 	NSDictionary* attribs = [NSDictionary dictionaryWithObjectsAndKeys: | ||||
| 		[NSNumber numberWithBool:NO], | ||||
| 		kEAGLDrawablePropertyRetainedBacking, | ||||
| 		(Params.Bits > 16) ? kEAGLColorFormatRGBA8 : kEAGLColorFormatRGB565, | ||||
| 		kEAGLDrawablePropertyColorFormat, | ||||
| 		nil]; | ||||
|  | ||||
| 	[layer setOpaque:(Params.WithAlphaChannel) ? YES : NO]; | ||||
| 	[layer setDrawableProperties:attribs]; | ||||
|  | ||||
| 	Configured = true; | ||||
|  | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| void CEAGLManager::destroySurface() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
| 	CAEAGLLayer* layer = dataStorage->Layer; | ||||
|  | ||||
| 	if (layer == nil) | ||||
| 		return; | ||||
|  | ||||
| 	[layer setOpaque:NO]; | ||||
| 	[layer setDrawableProperties:nil]; | ||||
|  | ||||
| 	Configured = false; | ||||
| } | ||||
|  | ||||
| bool CEAGLManager::generateContext() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
|  | ||||
|     if (dataStorage->Context != nil || !Configured) | ||||
|         return false; | ||||
|  | ||||
| 	EAGLRenderingAPI OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; | ||||
|  | ||||
| 	switch (Params.DriverType) | ||||
| 	{ | ||||
| 	case EDT_OGLES1: | ||||
| 		OpenGLESVersion = kEAGLRenderingAPIOpenGLES1; | ||||
| 		break; | ||||
| 	case EDT_OGLES2: | ||||
| 		OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
|     dataStorage->Context = [[EAGLContext alloc] initWithAPI:OpenGLESVersion]; | ||||
|  | ||||
| 	if (dataStorage->Context == nil) | ||||
| 	{ | ||||
| 		os::Printer::log("Could not create EAGL context.", ELL_ERROR); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	Data.OpenGLiOS.Context = (__bridge void*)dataStorage->Context; | ||||
|  | ||||
| 	os::Printer::log("EAGL context created with OpenGLESVersion: ", core::stringc(static_cast<int>(OpenGLESVersion)), ELL_DEBUG); | ||||
|  | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| void CEAGLManager::destroyContext() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
|  | ||||
| 	[dataStorage->Context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil]; | ||||
|  | ||||
| 	if (FrameBuffer.BufferID != 0) | ||||
| 	{ | ||||
| 		glDeleteFramebuffersOES(1, &FrameBuffer.BufferID); | ||||
| 		FrameBuffer.BufferID = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (FrameBuffer.ColorBuffer != 0) | ||||
| 	{ | ||||
| 		glDeleteRenderbuffersOES(1, &FrameBuffer.ColorBuffer); | ||||
| 		FrameBuffer.ColorBuffer = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (FrameBuffer.DepthBuffer != 0) | ||||
| 	{ | ||||
| 		glDeleteRenderbuffersOES(1, &FrameBuffer.DepthBuffer); | ||||
| 		FrameBuffer.DepthBuffer = 0; | ||||
| 	} | ||||
|  | ||||
| 	[EAGLContext setCurrentContext:0]; | ||||
|  | ||||
|     if (dataStorage->Context != nil) | ||||
|         dataStorage->Context = 0; | ||||
|  | ||||
| 	Data.OpenGLiOS.Context = 0; | ||||
| } | ||||
|  | ||||
| bool CEAGLManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero) | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
| 	EAGLContext* context = dataStorage->Context; | ||||
|  | ||||
| 	bool status = false; | ||||
|  | ||||
| 	if (context != nil) | ||||
| 	{ | ||||
| 		status = ([EAGLContext currentContext] == context || [EAGLContext setCurrentContext:context]); | ||||
| 	} | ||||
|  | ||||
| 	if (status) | ||||
| 	{ | ||||
| 		if (FrameBuffer.ColorBuffer == 0) | ||||
| 		{ | ||||
| 			glGenRenderbuffersOES(1, &FrameBuffer.ColorBuffer); | ||||
| 			glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); | ||||
| 			[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:dataStorage->Layer]; | ||||
| 		} | ||||
|  | ||||
| 		if (FrameBuffer.DepthBuffer == 0) | ||||
| 		{ | ||||
| 			GLenum depth = (Params.ZBufferBits >= 24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16_OES; | ||||
|  | ||||
| 			glGenRenderbuffersOES(1, &FrameBuffer.DepthBuffer); | ||||
| 			glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer); | ||||
| 			glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depth, Params.WindowSize.Width, Params.WindowSize.Height); | ||||
| 		} | ||||
|  | ||||
| 		if (FrameBuffer.BufferID == 0) | ||||
| 		{ | ||||
| 			glGenFramebuffersOES(1, &FrameBuffer.BufferID); | ||||
| 			glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID); | ||||
| 			glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); | ||||
| 			glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer); | ||||
| 		} | ||||
|  | ||||
| 		glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		os::Printer::log("Could not make EGL context current."); | ||||
| 	} | ||||
|  | ||||
| 	return status; | ||||
| } | ||||
|  | ||||
| const SExposedVideoData& CEAGLManager::getContext() const | ||||
| { | ||||
| 	return Data; | ||||
| } | ||||
|  | ||||
| bool CEAGLManager::swapBuffers() | ||||
| { | ||||
| 	SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage); | ||||
| 	EAGLContext* context = dataStorage->Context; | ||||
|  | ||||
| 	bool status = false; | ||||
|  | ||||
| 	if (context != nil && context == [EAGLContext currentContext]) | ||||
| 	{ | ||||
| 		glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); | ||||
| 		[context presentRenderbuffer:GL_RENDERBUFFER_OES]; | ||||
|  | ||||
| 		status = true; | ||||
| 	} | ||||
|  | ||||
|     return status; | ||||
| } | ||||
|  | ||||
| } | ||||
| } | ||||
|  | ||||
| #endif | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_EGL_MANAGER_H_INCLUDED__ | ||||
| #define __C_EGL_MANAGER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_EGL_MANAGER_ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CFileList.h" | ||||
| #include "IrrCompileConfig.h" | ||||
| #include "irrArray.h" | ||||
| #include "coreutil.h" | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "CFileSystem.h" | ||||
| #include "IReadFile.h" | ||||
| @@ -25,7 +24,7 @@ | ||||
| 	#include <direct.h> // for _chdir | ||||
| 	#include <io.h> // for _access | ||||
| 	#include <tchar.h> | ||||
| #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_)) | ||||
| #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_)) | ||||
| 		#include <stdio.h> | ||||
| 		#include <stdlib.h> | ||||
| 		#include <string.h> | ||||
| @@ -54,9 +53,7 @@ CFileSystem::CFileSystem() | ||||
| 	//! reset current working directory | ||||
| 	getWorkingDirectory(); | ||||
|  | ||||
| #ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ | ||||
| 	ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); | ||||
| #endif | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -799,7 +796,7 @@ IFileList* CFileSystem::createFileList() | ||||
| 					size = buf.st_size; | ||||
| 					isDirectory = S_ISDIR(buf.st_mode); | ||||
| 				} | ||||
| 				#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) | ||||
| 				#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) && !defined(__HAIKU__) | ||||
| 				// only available on some systems | ||||
| 				else | ||||
| 				{ | ||||
|   | ||||
| @@ -52,6 +52,7 @@ public: | ||||
| private: | ||||
| 	const std::vector<unsigned char>& m_buf; | ||||
| 	std::size_t m_offset; | ||||
|         int m_filesize; | ||||
| }; | ||||
|  | ||||
| // A helper function to disable tinygltf embedded image loading | ||||
| @@ -232,7 +233,7 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file) | ||||
| { | ||||
| 	tinygltf::Model model{}; | ||||
|  | ||||
| 	if (file->getSize() == 0 || !tryParseGLTF(file, model)) { | ||||
| 	if (file->getSize() <= 0 || !tryParseGLTF(file, model)) { | ||||
| 		return nullptr; | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_GLX_MANAGER_H_INCLUDED__ | ||||
| #define __C_GLX_MANAGER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_GLX_MANAGER_ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIButton.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -558,6 +557,3 @@ bool CGUIButton::isDrawingBorder() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_BUTTON_H_INCLUDED__ | ||||
| #define __C_GUI_BUTTON_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIButton.h" | ||||
| #include "IGUISpriteBank.h" | ||||
| #include "ITexture.h" | ||||
| @@ -244,7 +241,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_BUTTON_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -4,8 +4,6 @@ | ||||
|  | ||||
| #include "CGUICheckBox.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "IVideoDriver.h" | ||||
| @@ -227,6 +225,3 @@ bool CGUICheckBox::isDrawBorderEnabled() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_CHECKBOX_H_INCLUDED__ | ||||
| #define __C_GUI_CHECKBOX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUICheckBox.h" | ||||
|  | ||||
| namespace irr | ||||
| @@ -61,5 +58,3 @@ namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // __C_GUI_CHECKBOX_H_INCLUDED__ | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIComboBox.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "IVideoDriver.h" | ||||
| @@ -321,6 +320,10 @@ bool CGUIComboBox::OnEvent(const SEvent& event) | ||||
| 				} | ||||
| 			case EMIE_MOUSE_WHEEL: | ||||
| 				{ | ||||
| 					// Try scrolling parent first | ||||
| 					if (IGUIElement::OnEvent(event)) | ||||
| 						return true; | ||||
|  | ||||
| 					s32 oldSelected = Selected; | ||||
| 					setSelected( Selected + ((event.MouseInput.Wheel < 0) ? 1 : -1)); | ||||
|  | ||||
| @@ -330,11 +333,12 @@ bool CGUIComboBox::OnEvent(const SEvent& event) | ||||
| 					if (Selected >= (s32)Items.size()) | ||||
| 						setSelected((s32)Items.size() -1); | ||||
|  | ||||
| 					if (Selected != oldSelected) | ||||
| 					{ | ||||
| 					if (Selected != oldSelected) { | ||||
| 						sendSelectionChangedEvent(); | ||||
| 						return true; | ||||
| 					} | ||||
|  | ||||
| 					return false; | ||||
| 				} | ||||
| 			default: | ||||
| 				break; | ||||
| @@ -488,7 +492,3 @@ void CGUIComboBox::openCloseMenu() | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_COMBO_BOX_H_INCLUDED__ | ||||
| #define __C_GUI_COMBO_BOX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIComboBox.h" | ||||
| #include "IGUIStaticText.h" | ||||
| #include "irrString.h" | ||||
| @@ -107,7 +104,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_COMBO_BOX_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIEditBox.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -1136,6 +1135,34 @@ bool CGUIEditBox::processMouse(const SEvent& event) | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 	case EMIE_MMOUSE_PRESSED_DOWN: { | ||||
| 		if (!AbsoluteClippingRect.isPointInside(core::position2d<s32>( | ||||
| 					event.MouseInput.X, event.MouseInput.Y))) | ||||
| 			return false; | ||||
|  | ||||
| 		if (!Environment->hasFocus(this)) { | ||||
| 			BlinkStartTime = os::Timer::getTime(); | ||||
| 		} | ||||
|  | ||||
| 		// move cursor and disable marking | ||||
| 		CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); | ||||
| 		MouseMarking = false; | ||||
| 		setTextMarkers(CursorPos, CursorPos); | ||||
|  | ||||
| 		// paste from the primary selection | ||||
| 		inputString([&] { | ||||
| 			irr::core::stringw inserted_text; | ||||
| 			if (!Operator) | ||||
| 				return inserted_text; | ||||
| 			const c8 *inserted_text_utf8 = Operator->getTextFromPrimarySelection(); | ||||
| 			if (!inserted_text_utf8) | ||||
| 				return inserted_text; | ||||
| 			core::multibyteToWString(inserted_text, inserted_text_utf8); | ||||
| 			return inserted_text; | ||||
| 		}()); | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| @@ -1625,6 +1652,17 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end) | ||||
| 	{ | ||||
| 		MarkBegin = begin; | ||||
| 		MarkEnd = end; | ||||
|  | ||||
| 		if (!PasswordBox && Operator && MarkBegin != MarkEnd) { | ||||
| 			// copy to primary selection | ||||
| 			const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; | ||||
| 			const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; | ||||
|  | ||||
| 			core::stringc s; | ||||
| 			wStringToMultibyte(s, Text.subString(realmbgn, realmend - realmbgn)); | ||||
| 			Operator->copyToPrimarySelection(s.c_str()); | ||||
| 		} | ||||
|  | ||||
| 		sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED); | ||||
| 	} | ||||
| } | ||||
| @@ -1652,6 +1690,3 @@ bool CGUIEditBox::acceptsIME() | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_EDIT_BOX_H_INCLUDED__ | ||||
| #define __C_GUI_EDIT_BOX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIEditBox.h" | ||||
| #include "irrArray.h" | ||||
| #include "IOSOperator.h" | ||||
| @@ -201,6 +198,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
| #endif // __C_GUI_EDIT_BOX_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -5,8 +5,6 @@ | ||||
|  | ||||
| #include "CGUIEnvironment.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IVideoDriver.h" | ||||
|  | ||||
| #include "CGUISkin.h" | ||||
| @@ -25,8 +23,9 @@ | ||||
| #include "CGUIComboBox.h" | ||||
|  | ||||
| #include "IWriteFile.h" | ||||
|  | ||||
| #ifdef IRR_ENABLE_BUILTIN_FONT | ||||
| #include "BuiltInFont.h" | ||||
| #endif | ||||
| #include "os.h" | ||||
|  | ||||
| namespace irr | ||||
| @@ -143,6 +142,7 @@ CGUIEnvironment::~CGUIEnvironment() | ||||
|  | ||||
| void CGUIEnvironment::loadBuiltInFont() | ||||
| { | ||||
| #ifdef IRR_ENABLE_BUILTIN_FONT | ||||
| 	io::IReadFile* file = FileSystem->createMemoryReadFile(BuiltInFontData, | ||||
| 				BuiltInFontDataSize, DefaultFontName, false); | ||||
|  | ||||
| @@ -161,6 +161,7 @@ void CGUIEnvironment::loadBuiltInFont() | ||||
| 	Fonts.push_back(f); | ||||
|  | ||||
| 	file->drop(); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1107,6 +1108,3 @@ IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__ | ||||
| #define __C_GUI_ENVIRONMENT_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "IGUIElement.h" | ||||
| #include "irrArray.h" | ||||
| @@ -231,8 +228,4 @@ private: | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_ENVIRONMENT_H_INCLUDED__ | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIFileOpenDialog.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -411,5 +410,3 @@ void CGUIFileOpenDialog::sendCancelEvent() | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ | ||||
| #define __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIFileOpenDialog.h" | ||||
| #include "IGUIButton.h" | ||||
| #include "IGUIListBox.h" | ||||
| @@ -90,7 +87,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_FILE_OPEN_DIALOG_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIFont.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "os.h" | ||||
| #include "coreutil.h" | ||||
| @@ -594,6 +593,3 @@ IGUISpriteBank* CGUIFont::getSpriteBank() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_FONT_H_INCLUDED__ | ||||
| #define __C_GUI_FONT_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIFontBitmap.h" | ||||
| #include "irrString.h" | ||||
| #include "IReadFile.h" | ||||
| @@ -111,7 +108,4 @@ private: | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_FONT_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIImage.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -177,7 +176,3 @@ core::rect<f32> CGUIImage::getDrawBounds() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_IMAGE_H_INCLUDED__ | ||||
| #define __C_GUI_IMAGE_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIImage.h" | ||||
|  | ||||
| namespace irr | ||||
| @@ -102,6 +99,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_IMAGE_H_INCLUDED__ | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIListBox.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "CGUIListBox.h" | ||||
| #include "IGUISkin.h" | ||||
| @@ -841,6 +840,3 @@ IGUIScrollBar* CGUIListBox::getVerticalScrollBar() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_LIST_BOX_H_INCLUDED__ | ||||
| #define __C_GUI_LIST_BOX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIListBox.h" | ||||
| #include "irrArray.h" | ||||
|  | ||||
| @@ -178,6 +175,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIScrollBar.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -534,6 +533,3 @@ void CGUIScrollBar::refreshControls() | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__ | ||||
| #define __C_GUI_SCROLL_BAR_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIScrollBar.h" | ||||
| #include "IGUIButton.h" | ||||
|  | ||||
| @@ -101,7 +98,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUISkin.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIFont.h" | ||||
| #include "IGUISpriteBank.h" | ||||
| @@ -973,6 +972,3 @@ void CGUISkin::draw2DRectangle(IGUIElement* element, | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_SKIN_H_INCLUDED__ | ||||
| #define __C_GUI_SKIN_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "irrString.h" | ||||
|  | ||||
| @@ -234,8 +231,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUISpriteBank.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "IVideoDriver.h" | ||||
| @@ -32,10 +31,7 @@ CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) : | ||||
|  | ||||
| CGUISpriteBank::~CGUISpriteBank() | ||||
| { | ||||
| 	// drop textures | ||||
| 	for (u32 i=0; i<Textures.size(); ++i) | ||||
| 		if (Textures[i]) | ||||
| 			Textures[i]->drop(); | ||||
| 	clear(); | ||||
|  | ||||
| 	// drop video driver | ||||
| 	if (Driver) | ||||
| @@ -133,15 +129,38 @@ s32 CGUISpriteBank::addTextureAsSprite(video::ITexture* texture) | ||||
| 	return Sprites.size() - 1; | ||||
| } | ||||
|  | ||||
| // get FrameNr for time. return true on exisiting frame | ||||
| inline bool CGUISpriteBank::getFrameNr(u32& frame,u32 index, u32 time, bool loop) const | ||||
| { | ||||
| 	frame = 0; | ||||
| 	if (index >= Sprites.size()) | ||||
| 		return false; | ||||
|  | ||||
| 	const SGUISprite& sprite = Sprites[index]; | ||||
| 	const u32 frameSize = sprite.Frames.size(); | ||||
| 	if (frameSize < 1) | ||||
| 		return false; | ||||
|  | ||||
| 	if (sprite.frameTime) | ||||
| 	{ | ||||
| 		u32 f = (time / sprite.frameTime); | ||||
| 		if (loop) | ||||
| 			frame = f % frameSize; | ||||
| 		else | ||||
| 			frame = (f >= frameSize) ? frameSize - 1 : f; | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| //! draws a sprite in 2d with scale and color | ||||
| void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, | ||||
| 		const core::rect<s32>* clip, const video::SColor& color, | ||||
| 		u32 starttime, u32 currenttime, bool loop, bool center) | ||||
| { | ||||
| 	if (index >= Sprites.size() || Sprites[index].Frames.empty() ) | ||||
| 	u32 frame = 0; | ||||
| 	if (!getFrameNr(frame, index, currenttime - starttime, loop)) | ||||
| 		return; | ||||
|  | ||||
| 	u32 frame = getFrameNr(index, currenttime - starttime, loop); | ||||
| 	const video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber); | ||||
| 	if (!tex) | ||||
| 		return; | ||||
| @@ -163,10 +182,10 @@ void CGUISpriteBank::draw2DSprite(u32 index, const core::rect<s32>& destRect, | ||||
| 		const core::rect<s32>* clip, const video::SColor * const colors, | ||||
| 		u32 timeTicks, bool loop) | ||||
| { | ||||
| 	if (index >= Sprites.size() || Sprites[index].Frames.empty() ) | ||||
| 	u32 frame = 0; | ||||
| 	if (!getFrameNr(frame,index, timeTicks, loop)) | ||||
| 		return; | ||||
|  | ||||
| 	u32 frame = getFrameNr(index, timeTicks, loop); | ||||
| 	const video::ITexture* tex = getTexture(Sprites[index].Frames[frame].textureNumber); | ||||
| 	if (!tex) | ||||
| 		return; | ||||
| @@ -201,21 +220,16 @@ void CGUISpriteBank::draw2DSpriteBatch(	const core::array<u32>& indices, | ||||
| 	{ | ||||
| 		const u32 index = indices[i]; | ||||
|  | ||||
| 		if (index >= Sprites.size() || Sprites[index].Frames.empty() ) | ||||
| 			continue; | ||||
|  | ||||
| 		// work out frame number | ||||
| 		u32 frame = 0; | ||||
| 		if (Sprites[index].frameTime) | ||||
| 		{ | ||||
| 			u32 f = ((currenttime - starttime) / Sprites[index].frameTime); | ||||
| 			if (loop) | ||||
| 				frame = f % Sprites[index].Frames.size(); | ||||
| 			else | ||||
| 				frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f; | ||||
| 		} | ||||
| 		if (!getFrameNr(frame, index, currenttime - starttime, loop)) | ||||
| 			return; | ||||
|  | ||||
| 		const u32 texNum = Sprites[index].Frames[frame].textureNumber; | ||||
| 		if (texNum >= drawBatches.size()) | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
| 		SDrawBatch& currentBatch = drawBatches[texNum]; | ||||
|  | ||||
| 		const u32 rn = Sprites[index].Frames[frame].rectNumber; | ||||
| @@ -249,5 +263,3 @@ void CGUISpriteBank::draw2DSpriteBatch(	const core::array<u32>& indices, | ||||
|  | ||||
| } // namespace gui | ||||
| } // namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__ | ||||
| #define __C_GUI_SPRITE_BANK_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISpriteBank.h" | ||||
|  | ||||
| namespace irr | ||||
| @@ -67,19 +64,7 @@ public: | ||||
|  | ||||
| protected: | ||||
|  | ||||
| 	inline u32 getFrameNr(u32 index, u32 time, bool loop) const | ||||
| 	{ | ||||
| 		u32 frame = 0; | ||||
| 		if (Sprites[index].frameTime && Sprites[index].Frames.size() ) | ||||
| 		{ | ||||
| 			u32 f = (time / Sprites[index].frameTime); | ||||
| 			if (loop) | ||||
| 				frame = f % Sprites[index].Frames.size(); | ||||
| 			else | ||||
| 				frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f; | ||||
| 		} | ||||
| 		return frame; | ||||
| 	} | ||||
| 	bool getFrameNr(u32& frameNr, u32 index, u32 time, bool loop) const; | ||||
|  | ||||
| 	struct SDrawBatch | ||||
| 	{ | ||||
| @@ -99,7 +84,4 @@ protected: | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif // __C_GUI_SPRITE_BANK_H_INCLUDED__ | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUIStaticText.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUISkin.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| @@ -592,6 +591,3 @@ s32 CGUIStaticText::getTextWidth() const | ||||
|  | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__ | ||||
| #define __C_GUI_STATIC_TEXT_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUIStaticText.h" | ||||
| #include "irrArray.h" | ||||
|  | ||||
| @@ -136,7 +133,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,6 @@ | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "CGUITabControl.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "CGUIButton.h" | ||||
| #include "IGUISkin.h" | ||||
| @@ -1030,6 +1029,3 @@ void CGUITabControl::updateAbsolutePosition() | ||||
|  | ||||
| } // end namespace irr | ||||
| } // end namespace gui | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__ | ||||
| #define __C_GUI_TAB_CONTROL_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #include "IGUITabControl.h" | ||||
| #include "irrArray.h" | ||||
| #include "IGUISkin.h" | ||||
| @@ -184,7 +181,4 @@ namespace gui | ||||
| } // end namespace gui | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_GUI_ | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -173,6 +173,50 @@ void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, c | ||||
| } | ||||
|  | ||||
|  | ||||
| //! copies this surface into another, if it has the exact same size and format. | ||||
| bool CImage::copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) const | ||||
| { | ||||
| 	if (IImage::isCompressedFormat(Format)) | ||||
| 	{ | ||||
| 		os::Printer::log("IImage::copyToNoScaling method doesn't work with compressed images.", ELL_WARNING); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (!target || !width || !height || !Size.Width || !Size.Height) | ||||
| 		return false; | ||||
|  | ||||
| 	const u32 bpp=getBitsPerPixelFromFormat(format)/8; | ||||
| 	if (0==pitch) | ||||
| 		pitch = width*bpp; | ||||
|  | ||||
| 	if (!(Format==format && Size.Width==width && Size.Height==height)) | ||||
| 		return false; | ||||
|  | ||||
| 	if (pitch==Pitch) | ||||
| 	{ | ||||
| 		memcpy(target, Data, (size_t)height*pitch); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		u8* tgtpos = (u8*) target; | ||||
| 		u8* srcpos = Data; | ||||
| 		const u32 bwidth = width*bpp; | ||||
| 		const u32 rest = pitch-bwidth; | ||||
| 		for (u32 y=0; y<height; ++y) | ||||
| 		{ | ||||
| 			// copy scanline | ||||
| 			memcpy(tgtpos, srcpos, bwidth); | ||||
| 			// clear pitch | ||||
| 			memset(tgtpos+bwidth, 0, rest); | ||||
| 			tgtpos += pitch; | ||||
| 			srcpos += Pitch; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! copies this surface into another, scaling it to the target image size | ||||
| // note: this is very very slow. | ||||
| void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) | ||||
| @@ -190,31 +234,8 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo | ||||
| 	if (0==pitch) | ||||
| 		pitch = width*bpp; | ||||
|  | ||||
| 	if (Format==format && Size.Width==width && Size.Height==height) | ||||
| 	{ | ||||
| 		if (pitch==Pitch) | ||||
| 		{ | ||||
| 			memcpy(target, Data, height*pitch); | ||||
| 			return; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			u8* tgtpos = (u8*) target; | ||||
| 			u8* srcpos = Data; | ||||
| 			const u32 bwidth = width*bpp; | ||||
| 			const u32 rest = pitch-bwidth; | ||||
| 			for (u32 y=0; y<height; ++y) | ||||
| 			{ | ||||
| 				// copy scanline | ||||
| 				memcpy(tgtpos, srcpos, bwidth); | ||||
| 				// clear pitch | ||||
| 				memset(tgtpos+bwidth, 0, rest); | ||||
| 				tgtpos += pitch; | ||||
| 				srcpos += Pitch; | ||||
| 			} | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
| 	if (copyToNoScaling(target, width, height, format, pitch)) | ||||
| 		return; | ||||
|  | ||||
| 	// NOTE: Scaling is coded to keep the border pixels intact. | ||||
| 	// Alternatively we could for example work with first pixel being taken at half step-size. | ||||
|   | ||||
| @@ -42,6 +42,9 @@ public: | ||||
| 	//! sets a pixel | ||||
| 	void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) override; | ||||
|  | ||||
| 	//! copies this surface into another, if it has the exact same size and format. | ||||
| 	bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0) const override; | ||||
|  | ||||
| 	//! copies this surface into another, scaling it to fit. | ||||
| 	void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0) override; | ||||
|  | ||||
|   | ||||
| @@ -4,8 +4,6 @@ | ||||
|  | ||||
| #include "CImageLoaderBMP.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_BMP_LOADER_ | ||||
|  | ||||
| #include "IReadFile.h" | ||||
| #include "SColor.h" | ||||
| #include "CColorConverter.h" | ||||
| @@ -371,6 +369,3 @@ IImageLoader* createImageLoaderBMP() | ||||
|  | ||||
| } // end namespace video | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_IMAGE_LOADER_BMP_H_INCLUDED__ | ||||
| #define __C_IMAGE_LOADER_BMP_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "IImageLoader.h" | ||||
|  | ||||
| @@ -15,9 +14,6 @@ namespace irr | ||||
| namespace video | ||||
| { | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_) | ||||
|  | ||||
|  | ||||
| // byte-align structures | ||||
| #include "irrpack.h" | ||||
|  | ||||
| @@ -59,10 +55,6 @@ namespace video | ||||
| // Default alignment | ||||
| #include "irrunpack.h" | ||||
|  | ||||
| #endif // defined with loader or writer | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_BMP_LOADER_ | ||||
|  | ||||
| /*! | ||||
| 	Surface Loader for Windows bitmaps | ||||
| */ | ||||
| @@ -91,10 +83,7 @@ private: | ||||
| }; | ||||
|  | ||||
|  | ||||
| #endif // compiled with loader | ||||
|  | ||||
| } // end namespace video | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,8 +4,6 @@ | ||||
|  | ||||
| #include "CImageLoaderJPG.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_LOADER_ | ||||
|  | ||||
| #include "IReadFile.h" | ||||
| #include "CImage.h" | ||||
| #include "os.h" | ||||
| @@ -40,21 +38,18 @@ bool CImageLoaderJPG::isALoadableFileExtension(const io::path& filename) const | ||||
| 	return core::hasFileExtension ( filename, "jpg", "jpeg" ); | ||||
| } | ||||
|  | ||||
| // struct for handling jpeg errors | ||||
| struct irr_jpeg_error_mgr | ||||
| { | ||||
| 	// public jpeg error fields | ||||
| 	struct jpeg_error_mgr pub; | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| 	// for longjmp, to return to caller on a fatal error | ||||
| 	jmp_buf setjmp_buffer; | ||||
|  | ||||
|     // struct for handling jpeg errors | ||||
|     struct irr_jpeg_error_mgr | ||||
|     { | ||||
|         // public jpeg error fields | ||||
|         struct jpeg_error_mgr pub; | ||||
|  | ||||
|         // for longjmp, to return to caller on a fatal error | ||||
|         jmp_buf setjmp_buffer; | ||||
|  | ||||
|         // for having access to the filename when printing the error messages | ||||
|         core::stringc* filename; | ||||
|     }; | ||||
| 	// for having access to the filename when printing the error messages | ||||
| 	core::stringc* filename; | ||||
| }; | ||||
|  | ||||
| void CImageLoaderJPG::init_source (j_decompress_ptr cinfo) | ||||
| { | ||||
| @@ -116,31 +111,20 @@ void CImageLoaderJPG::output_message(j_common_ptr cinfo) | ||||
| 	errMsg += *myerr->filename; | ||||
| 	os::Printer::log(errMsg.c_str(),temp1, ELL_ERROR); | ||||
| } | ||||
| #endif // _IRR_COMPILE_WITH_LIBJPEG_ | ||||
|  | ||||
| //! returns true if the file maybe is able to be loaded by this class | ||||
| bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile* file) const | ||||
| { | ||||
| 	#ifndef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| 	return false; | ||||
| 	#else | ||||
|  | ||||
| 	if (!(file && file->seek(0))) | ||||
| 		return false; | ||||
| 	unsigned char header[3]; | ||||
| 	size_t headerLen = file->read(header, sizeof(header)); | ||||
| 	return headerLen >= 3 && !memcmp(header, "\xFF\xD8\xFF", 3); | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
| //! creates a surface from the file | ||||
| IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const | ||||
| { | ||||
| 	#ifndef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| 	os::Printer::log("Can't load as not compiled with _IRR_COMPILE_WITH_LIBJPEG_:", file->getFileName(), ELL_DEBUG); | ||||
| 	return 0; | ||||
| 	#else | ||||
|  | ||||
| 	if (!file) | ||||
| 		return 0; | ||||
|  | ||||
| @@ -288,8 +272,6 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const | ||||
| 	delete [] input; | ||||
|  | ||||
| 	return image; | ||||
|  | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -302,6 +284,3 @@ IImageLoader* createImageLoaderJPG() | ||||
|  | ||||
| } // end namespace video | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,19 +5,12 @@ | ||||
| #ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__ | ||||
| #define __C_IMAGE_LOADER_JPG_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_LOADER_ | ||||
|  | ||||
| #include "IImageLoader.h" | ||||
|  | ||||
| #include <stdio.h> // required for jpeglib.h | ||||
| #ifdef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| extern "C" { | ||||
| 	#include <jpeglib.h> // use system lib | ||||
| 	#include <setjmp.h> | ||||
| } | ||||
| #endif // _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| #include <jpeglib.h> // use system lib | ||||
| #include <setjmp.h> | ||||
|  | ||||
|  | ||||
| namespace irr | ||||
| @@ -48,8 +41,6 @@ public: | ||||
| 	IImage* loadImage(io::IReadFile* file) const override; | ||||
|  | ||||
| private: | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| 	// several methods used via function pointers by jpeglib | ||||
|  | ||||
| 	/* Receives control for a fatal error. Information sufficient to | ||||
| @@ -95,8 +86,6 @@ private: | ||||
| 	/* Terminate source --- called by jpeg_finish_decompress() after all | ||||
| 	data has been read. Often a no-op. */ | ||||
| 	static void term_source (j_decompress_ptr cinfo); | ||||
|  | ||||
| 	#endif // _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| }; | ||||
|  | ||||
|  | ||||
| @@ -105,5 +94,3 @@ private: | ||||
|  | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,11 +4,7 @@ | ||||
|  | ||||
| #include "CImageLoaderPNG.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_LOADER_ | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	#include <png.h> // use system lib png | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
| #include <png.h> // use system lib png | ||||
|  | ||||
| #include "CImage.h" | ||||
| #include "CReadFile.h" | ||||
| @@ -19,7 +15,6 @@ namespace irr | ||||
| namespace video | ||||
| { | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| // PNG function for error handling | ||||
| static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) | ||||
| { | ||||
| @@ -46,25 +41,19 @@ void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t l | ||||
| 	if (check != length) | ||||
| 		png_error(png_ptr, "Read Error"); | ||||
| } | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
|  | ||||
|  | ||||
| //! returns true if the file maybe is able to be loaded by this class | ||||
| //! based on the file extension (e.g. ".tga") | ||||
| bool CImageLoaderPng::isALoadableFileExtension(const io::path& filename) const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	return core::hasFileExtension ( filename, "png" ); | ||||
| #else | ||||
| 	return false; | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns true if the file maybe is able to be loaded by this class | ||||
| bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile* file) const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	if (!file) | ||||
| 		return false; | ||||
|  | ||||
| @@ -75,16 +64,12 @@ bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile* file) const | ||||
|  | ||||
| 	// Check if it really is a PNG file | ||||
| 	return !png_sig_cmp(buffer, 0, 8); | ||||
| #else | ||||
| 	return false; | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
| } | ||||
|  | ||||
|  | ||||
| // load in the image data | ||||
| IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	if (!file) | ||||
| 		return 0; | ||||
|  | ||||
| @@ -95,14 +80,14 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 	// Read the first few bytes of the PNG file | ||||
| 	if( file->read(buffer, 8) != 8 ) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: can't read file (filesize < 8)", file->getFileName(), ELL_ERROR); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	// Check if it really is a PNG file | ||||
| 	if( png_sig_cmp(buffer, 0, 8) ) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: not really a png (wrong signature)", file->getFileName(), ELL_ERROR); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| @@ -111,7 +96,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 		NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn); | ||||
| 	if (!png_ptr) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create read struct failure", file->getFileName(), ELL_ERROR); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| @@ -119,7 +104,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 	png_infop info_ptr = png_create_info_struct(png_ptr); | ||||
| 	if (!info_ptr) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_read_struct(&png_ptr, NULL, NULL); | ||||
| 		return 0; | ||||
| 	} | ||||
| @@ -227,7 +212,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 		image = new CImage(ECF_R8G8B8, core::dimension2d<u32>(Width, Height)); | ||||
| 	if (!image) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create image struct failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_read_struct(&png_ptr, NULL, NULL); | ||||
| 		return 0; | ||||
| 	} | ||||
| @@ -236,7 +221,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 	RowPointers = new png_bytep[Height]; | ||||
| 	if (!RowPointers) | ||||
| 	{ | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("LOAD PNG: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_read_struct(&png_ptr, NULL, NULL); | ||||
| 		delete image; | ||||
| 		return 0; | ||||
| @@ -267,9 +252,6 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const | ||||
| 	png_destroy_read_struct(&png_ptr,&info_ptr, 0); // Clean up memory | ||||
|  | ||||
| 	return image; | ||||
| #else | ||||
| 	return 0; | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -281,6 +263,3 @@ IImageLoader* createImageLoaderPNG() | ||||
|  | ||||
| }// end namespace irr | ||||
| }//end namespace video | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -9,9 +9,6 @@ | ||||
| #ifndef __C_IMAGE_LOADER_PNG_H_INCLUDED__ | ||||
| #define __C_IMAGE_LOADER_PNG_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_LOADER_ | ||||
|  | ||||
| #include "IImageLoader.h" | ||||
|  | ||||
| @@ -41,5 +38,3 @@ public: | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,8 +4,6 @@ | ||||
|  | ||||
| #include "CImageLoaderTGA.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_TGA_LOADER_ | ||||
|  | ||||
| #include "IReadFile.h" | ||||
| #include "os.h" | ||||
| #include "CColorConverter.h" | ||||
| @@ -108,7 +106,7 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const | ||||
|  | ||||
| 	if (!checkImageDimensions(header.ImageWidth, header.ImageHeight)) | ||||
| 	{ | ||||
| 		os::Printer::log("Rejecting TGA with unreasonable size.", ELL_ERROR); | ||||
| 		os::Printer::log("Image dimensions too large in file", file->getFileName(), ELL_ERROR); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| @@ -238,6 +236,3 @@ IImageLoader* createImageLoaderTGA() | ||||
|  | ||||
| } // end namespace video | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__ | ||||
| #define __C_IMAGE_LOADER_TGA_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "IImageLoader.h" | ||||
|  | ||||
| @@ -15,8 +14,6 @@ namespace irr | ||||
| namespace video | ||||
| { | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_) | ||||
|  | ||||
| // byte-align structures | ||||
| #include "irrpack.h" | ||||
|  | ||||
| @@ -46,10 +43,6 @@ namespace video | ||||
| // Default alignment | ||||
| #include "irrunpack.h" | ||||
|  | ||||
| #endif // compiled with loader or reader | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_TGA_LOADER_ | ||||
|  | ||||
| /*! | ||||
| 	Surface Loader for targa images | ||||
| */ | ||||
| @@ -73,10 +66,7 @@ private: | ||||
| 	u8* loadCompressedImage(io::IReadFile *file, const STGAHeader& header) const; | ||||
| }; | ||||
|  | ||||
| #endif // compiled with loader | ||||
|  | ||||
| } // end namespace video | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,15 +4,12 @@ | ||||
|  | ||||
| #include "CImageWriterJPG.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_WRITER_ | ||||
|  | ||||
| #include "CColorConverter.h" | ||||
| #include "IWriteFile.h" | ||||
| #include "CImage.h" | ||||
| #include "irrString.h" | ||||
| #include "os.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| #include <stdio.h> // required for jpeglib.h | ||||
| extern "C" | ||||
| { | ||||
| @@ -181,7 +178,7 @@ static bool writeJPEGFile(io::IWriteFile* file, IImage* image, u32 quality) | ||||
| } // namespace video | ||||
| } // namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_LIBJPEG_ | ||||
|  | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| @@ -209,15 +206,8 @@ bool CImageWriterJPG::isAWriteableFileExtension(const io::path& filename) const | ||||
|  | ||||
| bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *image, u32 quality) const | ||||
| { | ||||
| #ifndef _IRR_COMPILE_WITH_LIBJPEG_ | ||||
| 	return false; | ||||
| #else | ||||
| 	return writeJPEGFile(file, image, quality); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| } // namespace video | ||||
| } // namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef _C_IMAGE_WRITER_JPG_H_INCLUDED__ | ||||
| #define _C_IMAGE_WRITER_JPG_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_WRITER_ | ||||
|  | ||||
| #include "IImageWriter.h" | ||||
|  | ||||
| @@ -33,5 +30,3 @@ public: | ||||
| } | ||||
|  | ||||
| #endif // _C_IMAGE_WRITER_JPG_H_INCLUDED__ | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -4,17 +4,13 @@ | ||||
|  | ||||
| #include "CImageWriterPNG.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_WRITER_ | ||||
|  | ||||
| #include "CImageLoaderPNG.h" | ||||
| #include "CColorConverter.h" | ||||
| #include "IWriteFile.h" | ||||
| #include "irrString.h" | ||||
| #include "os.h" // for logging | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	#include <png.h> // use system lib png | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
| #include <png.h> // use system lib png | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| @@ -26,7 +22,6 @@ IImageWriter* createImageWriterPNG() | ||||
| 	return new CImageWriterPNG; | ||||
| } | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| // PNG function for error handling | ||||
| static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) | ||||
| { | ||||
| @@ -51,7 +46,6 @@ void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t | ||||
| 	if (check != length) | ||||
| 		png_error(png_ptr, "Write Error"); | ||||
| } | ||||
| #endif // _IRR_COMPILE_WITH_LIBPNG_ | ||||
|  | ||||
| CImageWriterPNG::CImageWriterPNG() | ||||
| { | ||||
| @@ -62,16 +56,11 @@ CImageWriterPNG::CImageWriterPNG() | ||||
|  | ||||
| bool CImageWriterPNG::isAWriteableFileExtension(const io::path& filename) const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	return core::hasFileExtension ( filename, "png" ); | ||||
| #else | ||||
| 	return false; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_LIBPNG_ | ||||
| 	if (!file || !image) | ||||
| 		return false; | ||||
|  | ||||
| @@ -80,7 +69,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) | ||||
| 		NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warning); | ||||
| 	if (!png_ptr) | ||||
| 	{ | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create write struct failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create write struct failure", file->getFileName(), ELL_ERROR); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| @@ -88,7 +77,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) | ||||
| 	png_infop info_ptr = png_create_info_struct(png_ptr); | ||||
| 	if (!info_ptr) | ||||
| 	{ | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_write_struct(&png_ptr, NULL); | ||||
| 		return false; | ||||
| 	} | ||||
| @@ -137,7 +126,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) | ||||
| 	u8* tmpImage = new u8[image->getDimension().Height*lineWidth]; | ||||
| 	if (!tmpImage) | ||||
| 	{ | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create image failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create image failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_write_struct(&png_ptr, &info_ptr); | ||||
| 		return false; | ||||
| 	} | ||||
| @@ -171,7 +160,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) | ||||
| 	u8** RowPointers = new png_bytep[image->getDimension().Height]; | ||||
| 	if (!RowPointers) | ||||
| 	{ | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); | ||||
| 		os::Printer::log("PNGWriter: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); | ||||
| 		png_destroy_write_struct(&png_ptr, &info_ptr); | ||||
| 		delete [] tmpImage; | ||||
| 		return false; | ||||
| @@ -206,13 +195,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) | ||||
| 	delete [] tmpImage; | ||||
| 	png_destroy_write_struct(&png_ptr, &info_ptr); | ||||
| 	return true; | ||||
| #else | ||||
| 	return false; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| } // namespace video | ||||
| } // namespace irr | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef _C_IMAGE_WRITER_PNG_H_INCLUDED__ | ||||
| #define _C_IMAGE_WRITER_PNG_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_WRITER_ | ||||
|  | ||||
| #include "IImageWriter.h" | ||||
|  | ||||
| @@ -33,5 +30,3 @@ public: | ||||
| } // namespace irr | ||||
|  | ||||
| #endif // _C_IMAGE_WRITER_PNG_H_INCLUDED__ | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -24,6 +24,8 @@ | ||||
| #include "SIrrCreationParameters.h" | ||||
| #include "SExposedVideoData.h" | ||||
| #include "IGUISpriteBank.h" | ||||
| #include "IImageLoader.h" | ||||
| #include "IFileSystem.h" | ||||
| #include <X11/XKBlib.h> | ||||
| #include <X11/Xatom.h> | ||||
|  | ||||
| @@ -115,7 +117,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param) | ||||
| 	HasNetWM(false), | ||||
| #endif | ||||
| 	Width(param.WindowSize.Width), Height(param.WindowSize.Height), | ||||
| 	WindowHasFocus(false), WindowMinimized(false), | ||||
| 	WindowHasFocus(false), WindowMinimized(false), WindowMaximized(param.WindowMaximized), | ||||
| 	ExternalWindow(false), AutorepeatSupport(0) | ||||
| #if defined(_IRR_LINUX_X11_XINPUT2_) | ||||
| 	, currentTouchedCount(0) | ||||
| @@ -168,6 +170,11 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param) | ||||
| 		return; | ||||
|  | ||||
| 	createGUIAndScene(); | ||||
|  | ||||
| 	if (param.WindowMaximized) | ||||
| 		maximizeWindow(); | ||||
|  | ||||
| 	setupTopLevelXorgWindow(); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -279,31 +286,97 @@ bool CIrrDeviceLinux::switchToFullscreen() | ||||
| } | ||||
|  | ||||
|  | ||||
| void CIrrDeviceLinux::setupTopLevelXorgWindow() | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
| 	if (CreationParams.DriverType == video::EDT_NULL) | ||||
| 		return; // no display and window | ||||
|  | ||||
| 	os::Printer::log("Configuring X11-specific top level window properties", ELL_DEBUG); | ||||
|  | ||||
| 	// Set application name and class hints. For now name and class are the same. | ||||
| 	// Note: SDL uses the executable name here (i.e. "minetest"). | ||||
| 	XClassHint *classhint = XAllocClassHint(); | ||||
| 	classhint->res_name = const_cast<char *>("Minetest"); | ||||
| 	classhint->res_class = const_cast<char *>("Minetest"); | ||||
|  | ||||
| 	XSetClassHint(XDisplay, XWindow, classhint); | ||||
| 	XFree(classhint); | ||||
|  | ||||
| 	// FIXME: In the future WMNormalHints should be set ... e.g see the | ||||
| 	// gtk/gdk code (gdk/x11/gdksurface-x11.c) for the setup_top_level | ||||
| 	// method. But for now (as it would require some significant changes) | ||||
| 	// leave the code as is. | ||||
|  | ||||
| 	// The following is borrowed from the above gdk source for setting top | ||||
| 	// level windows. The source indicates and the Xlib docs suggest that | ||||
| 	// this will set the WM_CLIENT_MACHINE and WM_LOCAL_NAME. This will not | ||||
| 	// set the WM_CLIENT_MACHINE to a Fully Qualified Domain Name (FQDN) which is | ||||
| 	// required by the Extended Window Manager Hints (EWMH) spec when setting | ||||
| 	// the _NET_WM_PID (see further down) but running Minetest in an env | ||||
| 	// where the window manager is on another machine from Minetest (therefore | ||||
| 	// making the PID useless) is not expected to be a problem. Further | ||||
| 	// more, using gtk/gdk as the model it would seem that not using a FQDN is | ||||
| 	// not an issue for modern Xorg window managers. | ||||
|  | ||||
| 	os::Printer::log("Setting Xorg window manager Properties", ELL_DEBUG); | ||||
|  | ||||
| 	XSetWMProperties (XDisplay, XWindow, NULL, NULL, NULL, 0, NULL, NULL, NULL); | ||||
|  | ||||
| 	// Set the _NET_WM_PID window property according to the EWMH spec. _NET_WM_PID | ||||
| 	// (in conjunction with WM_CLIENT_MACHINE) can be used by window managers to | ||||
| 	// force a shutdown of an application if it doesn't respond to the destroy | ||||
| 	// window message. | ||||
|  | ||||
| 	os::Printer::log("Setting Xorg _NET_WM_PID extended window manager property", ELL_DEBUG); | ||||
|  | ||||
| 	Atom NET_WM_PID = XInternAtom(XDisplay, "_NET_WM_PID", false); | ||||
|  | ||||
| 	pid_t pid = getpid(); | ||||
|  | ||||
| 	XChangeProperty(XDisplay, XWindow, NET_WM_PID, | ||||
| 			XA_CARDINAL, 32, PropModeReplace, | ||||
| 			reinterpret_cast<unsigned char *>(&pid),1); | ||||
|  | ||||
| 	// Set the WM_CLIENT_LEADER window property here. Minetest has only one | ||||
| 	// window and that window will always be the leader. | ||||
|  | ||||
| 	os::Printer::log("Setting Xorg WM_CLIENT_LEADER property", ELL_DEBUG); | ||||
|  | ||||
| 	Atom WM_CLIENT_LEADER = XInternAtom(XDisplay, "WM_CLIENT_LEADER", false); | ||||
|  | ||||
| 	XChangeProperty (XDisplay, XWindow, WM_CLIENT_LEADER, | ||||
| 		XA_WINDOW, 32, PropModeReplace, | ||||
| 		reinterpret_cast<unsigned char *>(&XWindow), 1); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| void IrrPrintXGrabError(int grabResult, const c8 * grabCommand ) | ||||
| { | ||||
| 	if ( grabResult == GrabSuccess ) | ||||
| 	{ | ||||
| //		os::Printer::log(grabCommand, ": GrabSuccess", ELL_INFORMATION); | ||||
| //		os::Printer::log(grabCommand, "GrabSuccess", ELL_INFORMATION); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	switch ( grabResult ) | ||||
| 	{ | ||||
| 		case AlreadyGrabbed: | ||||
| 			os::Printer::log(grabCommand, ": AlreadyGrabbed", ELL_WARNING); | ||||
| 			os::Printer::log(grabCommand, "AlreadyGrabbed", ELL_WARNING); | ||||
| 			break; | ||||
| 		case GrabNotViewable: | ||||
| 			os::Printer::log(grabCommand, ": GrabNotViewable", ELL_WARNING); | ||||
| 			os::Printer::log(grabCommand, "GrabNotViewable", ELL_WARNING); | ||||
| 			break; | ||||
| 		case GrabFrozen: | ||||
| 			os::Printer::log(grabCommand, ": GrabFrozen", ELL_WARNING); | ||||
| 			os::Printer::log(grabCommand, "GrabFrozen", ELL_WARNING); | ||||
| 			break; | ||||
| 		case GrabInvalidTime: | ||||
| 			os::Printer::log(grabCommand, ": GrabInvalidTime", ELL_WARNING); | ||||
| 			os::Printer::log(grabCommand, "GrabInvalidTime", ELL_WARNING); | ||||
| 			break; | ||||
| 		default: | ||||
| 			os::Printer::log(grabCommand, ": grab failed with unknown problem", ELL_WARNING); | ||||
| 			os::Printer::log(grabCommand, "grab failed with unknown problem", ELL_WARNING); | ||||
| 			break; | ||||
| 	} | ||||
| } | ||||
| @@ -377,7 +450,7 @@ bool CIrrDeviceLinux::createWindow() | ||||
| 	} | ||||
| #ifdef _DEBUG | ||||
| 	else | ||||
| 		os::Printer::log("Visual chosen: ", core::stringc(static_cast<u32>(VisualInfo->visualid)).c_str(), ELL_DEBUG); | ||||
| 		os::Printer::log("Visual chosen", core::stringc(static_cast<u32>(VisualInfo->visualid)).c_str(), ELL_DEBUG); | ||||
| #endif | ||||
|  | ||||
| 	// create color map | ||||
| @@ -997,12 +1070,15 @@ bool CIrrDeviceLinux::run() | ||||
| 						send_response(req->property); | ||||
| 					}; | ||||
|  | ||||
| 					if (req->selection != X_ATOM_CLIPBOARD || | ||||
| 					if ((req->selection != X_ATOM_CLIPBOARD && | ||||
| 							req->selection != XA_PRIMARY) || | ||||
| 							req->owner != XWindow) { | ||||
| 						// we are not the owner, refuse request | ||||
| 						send_response_refuse(); | ||||
| 						break; | ||||
| 					} | ||||
| 					const core::stringc &text_buffer = req->selection == X_ATOM_CLIPBOARD ? | ||||
| 							Clipboard : PrimarySelection; | ||||
|  | ||||
| 					// for debugging: | ||||
| 					//~ { | ||||
| @@ -1023,8 +1099,8 @@ bool CIrrDeviceLinux::run() | ||||
| 								req->target, X_ATOM_UTF8_STRING, | ||||
| 								8, // format = 8-bit | ||||
| 								PropModeReplace, | ||||
| 								(unsigned char *)Clipboard.c_str(), | ||||
| 								Clipboard.size()); | ||||
| 								(unsigned char *)text_buffer.c_str(), | ||||
| 								text_buffer.size()); | ||||
| 						send_response(req->target); | ||||
| 						break; | ||||
| 					} | ||||
| @@ -1049,8 +1125,8 @@ bool CIrrDeviceLinux::run() | ||||
| 						set_property_and_notify( | ||||
| 								X_ATOM_UTF8_STRING, | ||||
| 								8, | ||||
| 								Clipboard.c_str(), | ||||
| 								Clipboard.size() | ||||
| 								text_buffer.c_str(), | ||||
| 								text_buffer.size() | ||||
| 							); | ||||
|  | ||||
| 					} else { | ||||
| @@ -1172,6 +1248,50 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Sets the window icon. | ||||
| bool CIrrDeviceLinux::setWindowIcon(const video::IImage *img) | ||||
| { | ||||
| 	if (CreationParams.DriverType == video::EDT_NULL) | ||||
| 		return false; // no display and window | ||||
|  | ||||
| 	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; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (XDisplay == NULL) { | ||||
| 		os::Printer::log("Could not find x11 display for setting its icon.", ELL_ERROR); | ||||
| 		delete[] icon_buffer; | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	Atom net_wm_icon = XInternAtom(XDisplay, "_NET_WM_ICON", False); | ||||
| 	Atom cardinal = XInternAtom(XDisplay, "CARDINAL", False); | ||||
| 	XChangeProperty(XDisplay, XWindow, net_wm_icon, cardinal, 32, PropModeReplace, | ||||
| 			(const unsigned char *)icon_buffer, icon_buffer_len); | ||||
|  | ||||
| 	delete[] icon_buffer; | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! notifies the device that it should close itself | ||||
| void CIrrDeviceLinux::closeDevice() | ||||
| { | ||||
| @@ -1200,6 +1320,13 @@ bool CIrrDeviceLinux::isWindowMinimized() const | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns last state from maximizeWindow() and restoreWindow() | ||||
| bool CIrrDeviceLinux::isWindowMaximized() const | ||||
| { | ||||
| 	return WindowMaximized; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns color format of the window. | ||||
| video::ECOLOR_FORMAT CIrrDeviceLinux::getColorFormat() const | ||||
| { | ||||
| @@ -1284,6 +1411,8 @@ void CIrrDeviceLinux::maximizeWindow() | ||||
| 	} | ||||
|  | ||||
| 	XMapWindow(XDisplay, XWindow); | ||||
|  | ||||
| 	WindowMaximized = true; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| @@ -1310,6 +1439,8 @@ void CIrrDeviceLinux::restoreWindow() | ||||
| 	} | ||||
|  | ||||
| 	XMapWindow(XDisplay, XWindow); | ||||
|  | ||||
| 	WindowMaximized = false; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| @@ -1662,47 +1793,49 @@ void CIrrDeviceLinux::pollJoysticks() | ||||
| } | ||||
|  | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| //! gets text from the clipboard | ||||
| //! \return Returns 0 if no string is in there, otherwise utf-8 text. | ||||
| const c8 *CIrrDeviceLinux::getTextFromClipboard() const | ||||
| const c8 *CIrrDeviceLinux::getTextFromSelection(Atom selection, core::stringc &text_buffer) const | ||||
| { | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| 	Window ownerWindow = XGetSelectionOwner(XDisplay, X_ATOM_CLIPBOARD); | ||||
| 	Window ownerWindow = XGetSelectionOwner(XDisplay, selection); | ||||
| 	if (ownerWindow == XWindow) { | ||||
| 		return Clipboard.c_str(); | ||||
| 		return text_buffer.c_str(); | ||||
| 	} | ||||
|  | ||||
| 	Clipboard = ""; | ||||
| 	text_buffer = ""; | ||||
|  | ||||
| 	if (ownerWindow == None) { | ||||
| 		return Clipboard.c_str(); | ||||
| 		return text_buffer.c_str(); | ||||
| 	} | ||||
|  | ||||
| 	// delete the property to be set beforehand | ||||
| 	XDeleteProperty(XDisplay, XWindow, XA_PRIMARY); | ||||
|  | ||||
| 	XConvertSelection(XDisplay, X_ATOM_CLIPBOARD, X_ATOM_UTF8_STRING, XA_PRIMARY, | ||||
| 	XConvertSelection(XDisplay, selection, X_ATOM_UTF8_STRING, XA_PRIMARY, | ||||
| 			XWindow, CurrentTime); | ||||
| 	XFlush(XDisplay); | ||||
|  | ||||
| 	// wait for event via a blocking call | ||||
| 	XEvent event_ret; | ||||
| 	std::pair<Window, Atom> args(XWindow, selection); | ||||
| 	XIfEvent(XDisplay, &event_ret, [](Display *_display, XEvent *event, XPointer arg) { | ||||
| 		auto p = reinterpret_cast<std::pair<Window, Atom> *>(arg); | ||||
| 		return (Bool) (event->type == SelectionNotify && | ||||
| 				event->xselection.requestor == *(Window *)arg && | ||||
| 				event->xselection.selection == X_ATOM_CLIPBOARD && | ||||
| 				event->xselection.requestor == p->first && | ||||
| 				event->xselection.selection == p->second && | ||||
| 				event->xselection.target == X_ATOM_UTF8_STRING); | ||||
| 	}, (XPointer)&XWindow); | ||||
| 	}, (XPointer)&args); | ||||
|  | ||||
| 	_IRR_DEBUG_BREAK_IF(!(event_ret.type == SelectionNotify && | ||||
| 			event_ret.xselection.requestor == XWindow && | ||||
| 			event_ret.xselection.selection == X_ATOM_CLIPBOARD && | ||||
| 			event_ret.xselection.selection == selection && | ||||
| 			event_ret.xselection.target == X_ATOM_UTF8_STRING)); | ||||
|  | ||||
| 	Atom property_set = event_ret.xselection.property; | ||||
| 	if (event_ret.xselection.property == None) { | ||||
| 		// request failed => empty string | ||||
| 		return Clipboard.c_str(); | ||||
| 		return text_buffer.c_str(); | ||||
| 	} | ||||
|  | ||||
| 	// check for data | ||||
| @@ -1729,15 +1862,15 @@ const c8 *CIrrDeviceLinux::getTextFromClipboard() const | ||||
| 	// for debugging: | ||||
| 	//~ { | ||||
| 		//~ char *type_name = XGetAtomName(XDisplay, type); | ||||
| 		//~ fprintf(stderr, "CIrrDeviceLinux::getTextFromClipboard: actual type: %s (=%ld)\n", | ||||
| 		//~ fprintf(stderr, "CIrrDeviceLinux::getTextFromSelection: actual type: %s (=%ld)\n", | ||||
| 				//~ type_name, type); | ||||
| 		//~ XFree(type_name); | ||||
| 	//~ } | ||||
|  | ||||
| 	if (type != X_ATOM_UTF8_STRING && type != X_ATOM_UTF8_MIME_TYPE) { | ||||
| 		os::Printer::log("CIrrDeviceLinux::getTextFromClipboard: did not get utf-8 string", | ||||
| 		os::Printer::log("CIrrDeviceLinux::getTextFromSelection: did not get utf-8 string", | ||||
| 				ELL_WARNING); | ||||
| 		return Clipboard.c_str(); | ||||
| 		return text_buffer.c_str(); | ||||
| 	} | ||||
|  | ||||
| 	if (bytesLeft > 0) { | ||||
| @@ -1746,20 +1879,49 @@ const c8 *CIrrDeviceLinux::getTextFromClipboard() const | ||||
| 									bytesLeft, 0, AnyPropertyType, &type, &format, | ||||
| 									&numItems, &dummy, &data); | ||||
| 		if (result == Success) | ||||
| 			Clipboard = (irr::c8 *)data; | ||||
| 			text_buffer = (irr::c8 *)data; | ||||
| 		XFree (data); | ||||
| 	} | ||||
|  | ||||
| 	// delete the property again, to inform the owner about the successful transfer | ||||
| 	XDeleteProperty(XDisplay, XWindow, property_set); | ||||
|  | ||||
| 	return Clipboard.c_str(); | ||||
| 	return text_buffer.c_str(); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| //! gets text from the clipboard | ||||
| //! \return Returns 0 if no string is in there, otherwise utf-8 text. | ||||
| const c8 *CIrrDeviceLinux::getTextFromClipboard() const | ||||
| { | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| 	return getTextFromSelection(X_ATOM_CLIPBOARD, Clipboard); | ||||
| #else | ||||
| 	return nullptr; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| //! gets text from the primary selection | ||||
| //! \return Returns 0 if no string is in there, otherwise utf-8 text. | ||||
| const c8 *CIrrDeviceLinux::getTextFromPrimarySelection() const | ||||
| { | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| 	return getTextFromSelection(XA_PRIMARY, PrimarySelection); | ||||
| #else | ||||
| 	return nullptr; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| bool CIrrDeviceLinux::becomeSelectionOwner(Atom selection) const | ||||
| { | ||||
| 	XSetSelectionOwner (XDisplay, selection, XWindow, CurrentTime); | ||||
| 	XFlush (XDisplay); | ||||
| 	Window owner = XGetSelectionOwner(XDisplay, selection); | ||||
| 	return owner == XWindow; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| //! copies text to the clipboard | ||||
| void CIrrDeviceLinux::copyToClipboard(const c8 *text) const | ||||
| { | ||||
| @@ -1767,22 +1929,30 @@ void CIrrDeviceLinux::copyToClipboard(const c8 *text) const | ||||
| 	// Actually there is no clipboard on X but applications just say they own the clipboard and return text when asked. | ||||
| 	// Which btw. also means that on X you lose clipboard content when closing applications. | ||||
| 	Clipboard = text; | ||||
| 	XSetSelectionOwner (XDisplay, X_ATOM_CLIPBOARD, XWindow, CurrentTime); | ||||
| 	XFlush (XDisplay); | ||||
| 	Window owner = XGetSelectionOwner(XDisplay, X_ATOM_CLIPBOARD); | ||||
| 	if (owner != XWindow) { | ||||
| 	if (!becomeSelectionOwner(X_ATOM_CLIPBOARD)) { | ||||
| 		os::Printer::log("CIrrDeviceLinux::copyToClipboard: failed to set owner", ELL_WARNING); | ||||
| 	} | ||||
| #endif | ||||
| } | ||||
|  | ||||
| //! copies text to the primary selection | ||||
| void CIrrDeviceLinux::copyToPrimarySelection(const c8 *text) const | ||||
| { | ||||
| #if defined(_IRR_COMPILE_WITH_X11_) | ||||
| 	PrimarySelection = text; | ||||
| 	if (!becomeSelectionOwner(XA_PRIMARY)) { | ||||
| 		os::Printer::log("CIrrDeviceLinux::copyToPrimarySelection: failed to set owner", ELL_WARNING); | ||||
| 	} | ||||
| #endif | ||||
| } | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
| // return true if the passed event has the type passed in parameter arg | ||||
| Bool PredicateIsEventType(Display *display, XEvent *event, XPointer arg) | ||||
| { | ||||
| 	if ( event && event->type == *(int*)arg ) | ||||
| 	{ | ||||
| //		os::Printer::log("remove event:", core::stringc((int)arg).c_str(), ELL_INFORMATION); | ||||
| //		os::Printer::log("remove event", core::stringc((int)arg).c_str(), ELL_INFORMATION); | ||||
| 		return True; | ||||
| 	} | ||||
| 	return False; | ||||
| @@ -1810,6 +1980,28 @@ void CIrrDeviceLinux::clearSystemMessages() | ||||
| #endif //_IRR_COMPILE_WITH_X11_ | ||||
| } | ||||
|  | ||||
| //! Get the display density in dots per inch. | ||||
| float CIrrDeviceLinux::getDisplayDensity() const | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
| 	if (XDisplay != NULL) { | ||||
| 		/* try x direct */ | ||||
| 		int dh = DisplayHeight(XDisplay, 0); | ||||
| 		int dw = DisplayWidth(XDisplay, 0); | ||||
| 		int dh_mm = DisplayHeightMM(XDisplay, 0); | ||||
| 		int dw_mm = DisplayWidthMM(XDisplay, 0); | ||||
|  | ||||
| 		if (dh_mm != 0 && dw_mm != 0) { | ||||
| 			float dpi_height = floor(dh / (dh_mm * 0.039370) + 0.5); | ||||
| 			float dpi_width = floor(dw / (dw_mm * 0.039370) + 0.5); | ||||
| 			return std::max(dpi_height, dpi_width); | ||||
| 		} | ||||
| 	} | ||||
| #endif //_IRR_COMPILE_WITH_X11_ | ||||
|  | ||||
| 	return 0.0f; | ||||
| } | ||||
|  | ||||
| void CIrrDeviceLinux::initXAtoms() | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_IRR_DEVICE_LINUX_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_LINUX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ | ||||
|  | ||||
| @@ -55,6 +54,9 @@ namespace irr | ||||
| 		//! sets the caption of the window | ||||
| 		void setWindowCaption(const wchar_t* text) override; | ||||
|  | ||||
| 		//! Sets the window icon. | ||||
| 		bool setWindowIcon(const video::IImage *img) override; | ||||
|  | ||||
| 		//! returns if window is active. if not, nothing need to be drawn | ||||
| 		bool isWindowActive() const override; | ||||
|  | ||||
| @@ -64,6 +66,9 @@ namespace irr | ||||
| 		//! returns if window is minimized. | ||||
| 		bool isWindowMinimized() const override; | ||||
|  | ||||
| 		//! returns last state from maximizeWindow() and restoreWindow() | ||||
| 		bool isWindowMaximized() const override; | ||||
|  | ||||
| 		//! returns color format of the window. | ||||
| 		video::ECOLOR_FORMAT getColorFormat() const override; | ||||
|  | ||||
| @@ -95,11 +100,20 @@ namespace irr | ||||
| 		//! \return Returns 0 if no string is in there, otherwise utf-8 text. | ||||
| 		virtual const c8 *getTextFromClipboard() const; | ||||
|  | ||||
| 		//! gets text from the primary selection | ||||
| 		//! \return Returns 0 if no string is in there, otherwise utf-8 text. | ||||
| 		virtual const c8 *getTextFromPrimarySelection() const; | ||||
|  | ||||
| 		//! copies text to the clipboard | ||||
| 		//! This sets the clipboard selection and _not_ the primary selection which you have on X on the middle mouse button. | ||||
| 		//! This sets the clipboard selection and _not_ the primary selection. | ||||
| 		//! @param text The text in utf-8 | ||||
| 		virtual void copyToClipboard(const c8 *text) const; | ||||
|  | ||||
| 		//! copies text to the primary selection | ||||
| 		//! This sets the primary selection which you have on X on the middle mouse button. | ||||
| 		//! @param text The text in utf-8 | ||||
| 		virtual void copyToPrimarySelection(const c8 *text) const; | ||||
|  | ||||
| 		//! Remove all messages pending in the system message loop | ||||
| 		void clearSystemMessages() override; | ||||
|  | ||||
| @@ -109,6 +123,9 @@ namespace irr | ||||
| 			return EIDT_X11; | ||||
| 		} | ||||
|  | ||||
| 		//! Get the display density in dots per inch. | ||||
| 		float getDisplayDensity() const override; | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
| 		// convert an Irrlicht texture to a X11 cursor | ||||
| 		Cursor TextureToCursor(irr::video::ITexture * tex, const core::rect<s32>& sourceRect, const core::position2d<s32> &hotspot); | ||||
| @@ -135,10 +152,15 @@ namespace irr | ||||
|  | ||||
| 		bool switchToFullscreen(); | ||||
|  | ||||
| 		void setupTopLevelXorgWindow(); | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_X11_ | ||||
| 		bool createInputContext(); | ||||
| 		void destroyInputContext(); | ||||
| 		EKEY_CODE getKeyCode(XEvent &event); | ||||
|  | ||||
| 		const c8 *getTextFromSelection(Atom selection, core::stringc &text_buffer) const; | ||||
| 		bool becomeSelectionOwner(Atom selection) const; | ||||
| #endif | ||||
|  | ||||
| 		//! Implementation of the linux cursor control | ||||
| @@ -411,10 +433,15 @@ namespace irr | ||||
| 		bool HasNetWM; | ||||
| 		// text is utf-8 | ||||
| 		mutable core::stringc Clipboard; | ||||
| 		mutable core::stringc PrimarySelection; | ||||
| #endif | ||||
| #if defined(_IRR_LINUX_X11_XINPUT2_) | ||||
| 		int currentTouchedCount; | ||||
| #endif | ||||
| 		u32 Width, Height; | ||||
| 		bool WindowHasFocus; | ||||
| 		bool WindowMinimized; | ||||
| 		bool WindowMaximized; | ||||
| 		bool ExternalWindow; | ||||
| 		int AutorepeatSupport; | ||||
|  | ||||
| @@ -450,10 +477,6 @@ namespace irr | ||||
| 		}; | ||||
| 		core::array<JoystickInfo> ActiveJoysticks; | ||||
| #endif | ||||
|  | ||||
| #if defined(_IRR_LINUX_X11_XINPUT2_) | ||||
| 		int currentTouchedCount; | ||||
| #endif | ||||
| 	}; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #ifndef __C_IRR_DEVICE_OSX_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_OSX_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in Irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ | ||||
|  | ||||
|   | ||||
| @@ -2,12 +2,15 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | ||||
|  | ||||
| #include "CIrrDeviceSDL.h" | ||||
| #include "IEventReceiver.h" | ||||
| #include "IGUIElement.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "IImageLoader.h" | ||||
| #include "IFileSystem.h" | ||||
| #include "os.h" | ||||
| #include "CTimer.h" | ||||
| #include "irrString.h" | ||||
| @@ -19,15 +22,10 @@ | ||||
| #include <SDL_video.h> | ||||
|  | ||||
| #ifdef _IRR_EMSCRIPTEN_PLATFORM_ | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
| #include "CEGLManager.h" | ||||
| #endif | ||||
| #include <emscripten.h> | ||||
| #endif | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OPENGL_ | ||||
| #include "CSDLManager.h" | ||||
| #endif | ||||
|  | ||||
| static int SDLDeviceInstances = 0; | ||||
|  | ||||
| @@ -37,14 +35,42 @@ namespace irr | ||||
| 	{ | ||||
| 		#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 | ||||
|  | ||||
| @@ -105,13 +131,105 @@ EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEv | ||||
| } | ||||
| #endif | ||||
|  | ||||
|  | ||||
| bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key) | ||||
| { | ||||
| 	switch ( key ) | ||||
| 	{ | ||||
| 		// keys which are known to have safe special character interpretation | ||||
| 		// could need changes over time (removals and additions!) | ||||
| 		case KEY_RETURN: | ||||
| 		case KEY_PAUSE: | ||||
| 		case KEY_ESCAPE: | ||||
| 		case KEY_PRIOR: | ||||
| 		case KEY_NEXT: | ||||
| 		case KEY_HOME: | ||||
| 		case KEY_END: | ||||
| 		case KEY_LEFT: | ||||
| 		case KEY_UP: | ||||
| 		case KEY_RIGHT: | ||||
| 		case KEY_DOWN: | ||||
| 		case KEY_TAB: | ||||
| 		case KEY_PRINT: | ||||
| 		case KEY_SNAPSHOT: | ||||
| 		case KEY_INSERT: | ||||
| 		case KEY_BACK: | ||||
| 		case KEY_DELETE: | ||||
| 		case KEY_HELP: | ||||
| 		case KEY_APPS: | ||||
| 		case KEY_SLEEP: | ||||
| 		case KEY_F1: | ||||
| 		case KEY_F2: | ||||
| 		case KEY_F3: | ||||
| 		case KEY_F4: | ||||
| 		case KEY_F5: | ||||
| 		case KEY_F6: | ||||
| 		case KEY_F7: | ||||
| 		case KEY_F8: | ||||
| 		case KEY_F9: | ||||
| 		case KEY_F10: | ||||
| 		case KEY_F11: | ||||
| 		case KEY_F12: | ||||
| 		case KEY_F13: | ||||
| 		case KEY_F14: | ||||
| 		case KEY_F15: | ||||
| 		case KEY_F16: | ||||
| 		case KEY_F17: | ||||
| 		case KEY_F18: | ||||
| 		case KEY_F19: | ||||
| 		case KEY_F20: | ||||
| 		case KEY_F21: | ||||
| 		case KEY_F22: | ||||
| 		case KEY_F23: | ||||
| 		case KEY_F24: | ||||
| 		case KEY_NUMLOCK: | ||||
| 		case KEY_SCROLL: | ||||
| 		case KEY_LCONTROL: | ||||
| 		case KEY_RCONTROL: | ||||
| 			return true; | ||||
|  | ||||
| 		default: | ||||
| 			return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) { | ||||
| 	// SDL in-place ORs values with no character representation with 1<<30 | ||||
| 	// https://wiki.libsdl.org/SDL2/SDLKeycodeLookup | ||||
| 	if (assumedChar & (1<<30)) | ||||
| 		return 0; | ||||
|  | ||||
| 	switch (key) { | ||||
| 		case KEY_PRIOR: | ||||
| 		case KEY_NEXT: | ||||
| 		case KEY_HOME: | ||||
| 		case KEY_END: | ||||
| 		case KEY_LEFT: | ||||
| 		case KEY_UP: | ||||
| 		case KEY_RIGHT: | ||||
| 		case KEY_DOWN: | ||||
| 		case KEY_NUMLOCK: | ||||
| 			return 0; | ||||
| 		default: | ||||
| 			return assumedChar; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CIrrDeviceSDL::resetReceiveTextInputEvents() { | ||||
| 	gui::IGUIElement *elem = GUIEnvironment->getFocus(); | ||||
| 	if (elem && elem->acceptsIME()) | ||||
| 		SDL_StartTextInput(); | ||||
| 	else | ||||
| 		SDL_StopTextInput(); | ||||
| } | ||||
|  | ||||
| //! constructor | ||||
| CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) | ||||
| 	: CIrrDeviceStub(param), | ||||
| 	Window((SDL_Window*)param.WindowId), SDL_Flags(0), | ||||
| 	MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0), | ||||
| 	Width(param.WindowSize.Width), Height(param.WindowSize.Height), | ||||
| 	Resizable(param.WindowResizable == 1 ? true : false), WindowMinimized(false) | ||||
| 	Resizable(param.WindowResizable == 1 ? true : false) | ||||
| { | ||||
| 	#ifdef _DEBUG | ||||
| 	setDebugName("CIrrDeviceSDL"); | ||||
| @@ -127,7 +245,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) | ||||
| #endif | ||||
| 		if (SDL_Init(flags) < 0) | ||||
| 		{ | ||||
| 			os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); | ||||
| 			os::Printer::log("Unable to initialize SDL", SDL_GetError(), ELL_ERROR); | ||||
| 			Close = true; | ||||
| 		} | ||||
| 		else | ||||
| @@ -139,20 +257,6 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) | ||||
| 	// create keymap | ||||
| 	createKeyMap(); | ||||
|  | ||||
| 	if ( CreationParams.Fullscreen ) | ||||
| 		SDL_Flags |= SDL_WINDOW_FULLSCREEN; | ||||
| 	else if ( Resizable ) | ||||
| 		SDL_Flags |= SDL_WINDOW_RESIZABLE; | ||||
| 	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) | ||||
| 	{ | ||||
| @@ -160,6 +264,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) | ||||
| 		createWindow(); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	SDL_VERSION(&Info.version); | ||||
|  | ||||
| #ifndef _IRR_EMSCRIPTEN_PLATFORM_ | ||||
| @@ -241,6 +346,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); | ||||
| @@ -287,54 +405,73 @@ bool CIrrDeviceSDL::createWindow() | ||||
| 	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); | ||||
| 			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!"); | ||||
| 			} | ||||
| 		} | ||||
| 	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:; | ||||
| 	} | ||||
|  | ||||
| 		if (Window) | ||||
| 		{ | ||||
| 			Context = SDL_GL_CreateContext(Window); | ||||
| 		} | ||||
| 	} else if (!Window) | ||||
| #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); | ||||
| 			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!", ELL_WARNING); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if ( !Window && CreationParams.Doublebuffer) | ||||
| 	{ | ||||
| @@ -345,7 +482,14 @@ bool CIrrDeviceSDL::createWindow() | ||||
| 	} | ||||
| 	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; | ||||
| 	} | ||||
|  | ||||
| @@ -357,79 +501,22 @@ bool CIrrDeviceSDL::createWindow() | ||||
| //! create the driver | ||||
| void CIrrDeviceSDL::createDriver() | ||||
| { | ||||
| 	if (CreationParams.DriverType == video::EDT_NULL) { | ||||
| 		VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	ContextManager = new video::CSDLManager(this); | ||||
| 	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: | ||||
| 		VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); | ||||
| 		break; | ||||
|  | ||||
| 	default: | ||||
| 		os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	// In case we got the size from the canvas | ||||
| 	if ( VideoDriver && CreationParams.WindowSize.Width == 0 && CreationParams.WindowSize.Height == 0 && Width > 0 && Height > 0 ) | ||||
| 	{ | ||||
| #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<u32>(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); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -606,6 +693,10 @@ bool CIrrDeviceSDL::run() | ||||
| 				else | ||||
| 					key = (EKEY_CODE)KeyMap[idx].Win32Key; | ||||
|  | ||||
| 				// Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already | ||||
| 				if (SDL_IsTextInputActive() && !keyIsKnownSpecial(key) && (SDL_event.key.keysym.mod & KMOD_CTRL) == 0) | ||||
| 					break; | ||||
|  | ||||
| #ifdef _IRR_WINDOWS_API_ | ||||
| 				// handle alt+f4 in Windows, because SDL seems not to | ||||
| 				if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4) | ||||
| @@ -619,12 +710,7 @@ bool CIrrDeviceSDL::run() | ||||
| 				irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN); | ||||
| 				irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0; | ||||
| 				irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0; | ||||
| 				// These keys are handled differently in CGUIEditBox.cpp (may become out of date!) | ||||
| 				// Control key is used in special character combinations, so keep that too | ||||
| 				// Pass through the keysym only then so no extra text gets input | ||||
| 				irrevent.KeyInput.Char = 0; | ||||
| 				if (mp.SDLKey == SDLK_DELETE || mp.SDLKey == SDLK_RETURN || mp.SDLKey == SDLK_BACKSPACE || irrevent.KeyInput.Control) | ||||
| 					irrevent.KeyInput.Char = mp.SDLKey; | ||||
| 				irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key); | ||||
| 				postEventFromUser(irrevent); | ||||
| 			} | ||||
| 			break; | ||||
| @@ -636,12 +722,6 @@ bool CIrrDeviceSDL::run() | ||||
| 		case SDL_WINDOWEVENT: | ||||
| 			switch (SDL_event.window.event) | ||||
| 			{ | ||||
| 			case SDL_WINDOWEVENT_MAXIMIZED: | ||||
| 				WindowMinimized = true; | ||||
| 				break; | ||||
| 			case SDL_WINDOWEVENT_RESTORED: | ||||
| 				WindowMinimized = false; | ||||
| 				break; | ||||
| 			case SDL_WINDOWEVENT_RESIZED: | ||||
| 				if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height)) | ||||
| 				{ | ||||
| @@ -664,7 +744,7 @@ bool CIrrDeviceSDL::run() | ||||
| 		default: | ||||
| 			break; | ||||
| 		} // end switch | ||||
|  | ||||
| 	resetReceiveTextInputEvents(); | ||||
| 	} // end while | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) | ||||
| @@ -793,6 +873,29 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Get the display density in dots per inch. | ||||
| float CIrrDeviceSDL::getDisplayDensity() const | ||||
| { | ||||
| 	if (!Window) | ||||
| 		return 0.0f; | ||||
|  | ||||
| 	int window_w; | ||||
| 	int window_h; | ||||
| 	SDL_GetWindowSize(Window, &window_w, &window_h); | ||||
|  | ||||
| 	int drawable_w; | ||||
| 	int drawable_h; | ||||
| 	SDL_GL_GetDrawableSize(Window, &drawable_w, &drawable_h); | ||||
|  | ||||
| 	// assume 96 dpi | ||||
| 	float dpi_w = (float)drawable_w / (float)window_w * 96.0f; | ||||
| 	float dpi_h = (float)drawable_h / (float)window_h * 96.0f; | ||||
|  | ||||
| 	return std::max(dpi_w, dpi_h); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CIrrDeviceSDL::SwapWindow() | ||||
| { | ||||
| 	SDL_GL_SwapWindow(Window); | ||||
| @@ -830,6 +933,41 @@ void CIrrDeviceSDL::setWindowCaption(const wchar_t* text) | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Sets the window icon. | ||||
| bool CIrrDeviceSDL::setWindowIcon(const video::IImage *img) | ||||
| { | ||||
| 	if (!Window) | ||||
| 		return false; | ||||
|  | ||||
| 	u32 height = img->getDimension().Height; | ||||
| 	u32 width = img->getDimension().Width; | ||||
|  | ||||
| 	SDL_Surface *surface = SDL_CreateRGBSurface(0, width, height, 32, | ||||
| 			0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); | ||||
|  | ||||
| 	if (!surface) { | ||||
| 		os::Printer::log("Failed to create SDL suface", ELL_ERROR); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	SDL_LockSurface(surface); | ||||
| 	bool succ = img->copyToNoScaling(surface->pixels, width, height, video::ECF_A8R8G8B8, surface->pitch); | ||||
| 	SDL_UnlockSurface(surface); | ||||
|  | ||||
| 	if (!succ) { | ||||
| 		os::Printer::log("Could not copy icon image. Is the format not ECF_A8R8G8B8?", ELL_ERROR); | ||||
| 		SDL_FreeSurface(surface); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	SDL_SetWindowIcon(Window, surface); | ||||
|  | ||||
| 	SDL_FreeSurface(surface); | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! notifies the device that it should close itself | ||||
| void CIrrDeviceSDL::closeDevice() | ||||
| { | ||||
| @@ -862,16 +1000,16 @@ void CIrrDeviceSDL::setResizable(bool resize) | ||||
| //! Minimizes window if possible | ||||
| void CIrrDeviceSDL::minimizeWindow() | ||||
| { | ||||
| 	if (Window) { | ||||
| 	if (Window) | ||||
| 		SDL_MinimizeWindow(Window); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Maximize window | ||||
| void CIrrDeviceSDL::maximizeWindow() | ||||
| { | ||||
| 	// do nothing | ||||
| 	if (Window) | ||||
| 		SDL_MaximizeWindow(Window); | ||||
| } | ||||
|  | ||||
| //! Get the position of this window on screen | ||||
| @@ -884,7 +1022,13 @@ core::position2di CIrrDeviceSDL::getWindowPosition() | ||||
| //! Restore original window size | ||||
| void CIrrDeviceSDL::restoreWindow() | ||||
| { | ||||
| 	// do nothing | ||||
| 	if (Window) | ||||
| 		SDL_RestoreWindow(Window); | ||||
| } | ||||
|  | ||||
| bool CIrrDeviceSDL::isWindowMaximized() const | ||||
| { | ||||
| 	return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MAXIMIZED) != 0; | ||||
| } | ||||
|  | ||||
| bool CIrrDeviceSDL::isFullscreen() const | ||||
| @@ -919,14 +1063,14 @@ bool CIrrDeviceSDL::isWindowActive() const | ||||
| //! returns if window has focus. | ||||
| bool CIrrDeviceSDL::isWindowFocused() const | ||||
| { | ||||
| 	return SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS; | ||||
| 	return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS) != 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns if window is minimized. | ||||
| bool CIrrDeviceSDL::isWindowMinimized() const | ||||
| { | ||||
| 	return WindowMinimized; | ||||
| 	return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
| #ifndef __C_IRR_DEVICE_SDL_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_SDL_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | ||||
|  | ||||
| @@ -49,6 +48,9 @@ namespace irr | ||||
| 		//! sets the caption of the window | ||||
| 		void setWindowCaption(const wchar_t* text) override; | ||||
|  | ||||
| 		//! Sets the window icon. | ||||
| 		bool setWindowIcon(const video::IImage *img) override; | ||||
|  | ||||
| 		//! returns if window is active. if not, nothing need to be drawn | ||||
| 		bool isWindowActive() const override; | ||||
|  | ||||
| @@ -76,6 +78,9 @@ namespace irr | ||||
| 		//! Restores the window size. | ||||
| 		void restoreWindow() override; | ||||
|  | ||||
| 		//! Checks if the window is maximized. | ||||
| 		bool isWindowMaximized() const override; | ||||
|  | ||||
| 		//! Checks if the Irrlicht window is running in fullscreen mode | ||||
| 		/** \return True if window is fullscreen. */ | ||||
| 		bool isFullscreen() const override; | ||||
| @@ -92,6 +97,9 @@ namespace irr | ||||
| 			return EIDT_SDL; | ||||
| 		} | ||||
|  | ||||
| 		//! Get the display density in dots per inch. | ||||
| 		float getDisplayDensity() const override; | ||||
|  | ||||
| 		void SwapWindow(); | ||||
|  | ||||
| 		//! Implementation of the linux cursor control | ||||
| @@ -261,6 +269,15 @@ namespace irr | ||||
| 	static EM_BOOL MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); | ||||
|  | ||||
| #endif | ||||
| 		// Check if a key is a known special character with no side effects on text boxes. | ||||
| 		static bool keyIsKnownSpecial(EKEY_CODE key); | ||||
|  | ||||
| 		// Return the Char that should be sent to Irrlicht for the given key (either the one passed in or 0). | ||||
| 		static int findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key); | ||||
|  | ||||
| 		// Check if a text box is in focus. Enable or disable SDL_TEXTINPUT events only if in focus. | ||||
| 		void resetReceiveTextInputEvents(); | ||||
|  | ||||
| 		//! create the driver | ||||
| 		void createDriver(); | ||||
|  | ||||
| @@ -283,7 +300,6 @@ namespace irr | ||||
| 		u32 Width, Height; | ||||
|  | ||||
| 		bool Resizable; | ||||
| 		bool WindowMinimized; | ||||
|  | ||||
| 		struct SKeyMap | ||||
| 		{ | ||||
|   | ||||
| @@ -9,10 +9,10 @@ | ||||
| #include "IGUIElement.h" | ||||
| #include "IGUIEnvironment.h" | ||||
| #include "os.h" | ||||
| #include "IrrCompileConfig.h" | ||||
| #include "CTimer.h" | ||||
| #include "CLogger.h" | ||||
| #include "irrString.h" | ||||
| #include "IrrCompileConfig.h" // for IRRLICHT_SDK_VERSION | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| @@ -88,13 +88,11 @@ CIrrDeviceStub::~CIrrDeviceStub() | ||||
|  | ||||
| void CIrrDeviceStub::createGUIAndScene() | ||||
| { | ||||
| 	#ifdef _IRR_COMPILE_WITH_GUI_ | ||||
| 	// create gui environment | ||||
| 	GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); | ||||
| 	#endif | ||||
|  | ||||
| 	// create Scene manager | ||||
| 	SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); | ||||
| 	SceneManager = scene::createSceneManager(VideoDriver, CursorControl); | ||||
|  | ||||
| 	setEventReceiver(UserReceiver); | ||||
| } | ||||
| @@ -138,6 +136,13 @@ ITimer* CIrrDeviceStub::getTimer() | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Sets the window icon. | ||||
| bool CIrrDeviceStub::setWindowIcon(const video::IImage *img) | ||||
| { | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Returns the version of the engine. | ||||
| const char* CIrrDeviceStub::getVersion() const | ||||
| { | ||||
| @@ -272,6 +277,13 @@ void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneMa | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Checks if the window is maximized. | ||||
| bool CIrrDeviceStub::isWindowMaximized() const | ||||
| { | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Checks if the window is running in fullscreen mode | ||||
| bool CIrrDeviceStub::isFullscreen() const | ||||
| { | ||||
| @@ -380,6 +392,12 @@ void CIrrDeviceStub::clearSystemMessages() | ||||
| { | ||||
| } | ||||
|  | ||||
| //! Get the display density in dots per inch. | ||||
| float CIrrDeviceStub::getDisplayDensity() const | ||||
| { | ||||
| 	return 0.0f; | ||||
| } | ||||
|  | ||||
| //! Checks whether the input device should take input from the IME | ||||
| bool CIrrDeviceStub::acceptsIME() | ||||
| { | ||||
|   | ||||
| @@ -24,8 +24,7 @@ namespace irr | ||||
|  | ||||
| 	namespace scene | ||||
| 	{ | ||||
| 		ISceneManager* createSceneManager(video::IVideoDriver* driver, | ||||
| 			io::IFileSystem* fs, gui::ICursorControl* cc, gui::IGUIEnvironment *gui); | ||||
| 		ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cc); | ||||
| 	} | ||||
|  | ||||
| 	namespace io | ||||
| @@ -72,6 +71,9 @@ namespace irr | ||||
| 		//! Returns a pointer to the ITimer object. With it the current Time can be received. | ||||
| 		ITimer* getTimer() override; | ||||
|  | ||||
| 		//! Sets the window icon. | ||||
| 		bool setWindowIcon(const video::IImage *img) override; | ||||
|  | ||||
| 		//! Returns the version of the engine. | ||||
| 		const char* getVersion() const override; | ||||
|  | ||||
| @@ -94,6 +96,9 @@ namespace irr | ||||
| 		//! Returns the operation system opertator object. | ||||
| 		IOSOperator* getOSOperator() override; | ||||
|  | ||||
| 		//! Checks if the window is maximized. | ||||
| 		bool isWindowMaximized() const override; | ||||
|  | ||||
| 		//! Checks if the window is running in fullscreen mode. | ||||
| 		bool isFullscreen() const override; | ||||
|  | ||||
| @@ -103,41 +108,41 @@ namespace irr | ||||
| 		//! Activate any joysticks, and generate events for them. | ||||
| 		bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) override; | ||||
|  | ||||
|         //! Activate accelerometer. | ||||
|         bool activateAccelerometer(float updateInterval = 0.016666f) override; | ||||
|          | ||||
|         //! Deactivate accelerometer. | ||||
|         bool deactivateAccelerometer() override; | ||||
|          | ||||
|         //! Is accelerometer active. | ||||
|         bool isAccelerometerActive() override; | ||||
|          | ||||
|         //! Is accelerometer available. | ||||
|         bool isAccelerometerAvailable() override; | ||||
|          | ||||
|         //! Activate gyroscope. | ||||
|         bool activateGyroscope(float updateInterval = 0.016666f) override; | ||||
|          | ||||
|         //! Deactivate gyroscope. | ||||
|         bool deactivateGyroscope() override; | ||||
|          | ||||
|         //! Is gyroscope active. | ||||
|         bool isGyroscopeActive() override; | ||||
|          | ||||
|         //! Is gyroscope available. | ||||
|         bool isGyroscopeAvailable() override; | ||||
|          | ||||
|         //! Activate device motion. | ||||
|         bool activateDeviceMotion(float updateInterval = 0.016666f) override; | ||||
|          | ||||
|         //! Deactivate device motion. | ||||
|         bool deactivateDeviceMotion() override; | ||||
|          | ||||
|         //! Is device motion active. | ||||
|         bool isDeviceMotionActive() override; | ||||
|          | ||||
|         //! Is device motion available. | ||||
|         bool isDeviceMotionAvailable() override; | ||||
| 		//! Activate accelerometer. | ||||
| 		bool activateAccelerometer(float updateInterval = 0.016666f) override; | ||||
|  | ||||
| 		//! Deactivate accelerometer. | ||||
| 		bool deactivateAccelerometer() override; | ||||
|  | ||||
| 		//! Is accelerometer active. | ||||
| 		bool isAccelerometerActive() override; | ||||
|  | ||||
| 		//! Is accelerometer available. | ||||
| 		bool isAccelerometerAvailable() override; | ||||
|  | ||||
| 		//! Activate gyroscope. | ||||
| 		bool activateGyroscope(float updateInterval = 0.016666f) override; | ||||
|  | ||||
| 		//! Deactivate gyroscope. | ||||
| 		bool deactivateGyroscope() override; | ||||
|  | ||||
| 		//! Is gyroscope active. | ||||
| 		bool isGyroscopeActive() override; | ||||
|  | ||||
| 		//! Is gyroscope available. | ||||
| 		bool isGyroscopeAvailable() override; | ||||
|  | ||||
| 		//! Activate device motion. | ||||
| 		bool activateDeviceMotion(float updateInterval = 0.016666f) override; | ||||
|  | ||||
| 		//! Deactivate device motion. | ||||
| 		bool deactivateDeviceMotion() override; | ||||
|  | ||||
| 		//! Is device motion active. | ||||
| 		bool isDeviceMotionActive() override; | ||||
|  | ||||
| 		//! Is device motion available. | ||||
| 		bool isDeviceMotionAvailable() override; | ||||
|  | ||||
| 		//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. | ||||
| 		//! When set to 0 no double- and tripleclicks will be generated. | ||||
| @@ -149,6 +154,9 @@ namespace irr | ||||
| 		//! Remove all messages pending in the system message loop | ||||
| 		void clearSystemMessages() override; | ||||
|  | ||||
| 		//! Get the display density in dots per inch. | ||||
| 		float getDisplayDensity() const override; | ||||
|  | ||||
| 		//! Resize the render window. | ||||
| 		void setWindowSize(const irr::core::dimension2d<u32>& size) override {} | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | ||||
|  | ||||
| @@ -122,8 +121,8 @@ namespace irr | ||||
| 			if (dev) | ||||
| 			{ | ||||
| 				dev->Unacquire(); | ||||
| 				dev->Release(); | ||||
| 			} | ||||
| 			dev->Release(); | ||||
| 		} | ||||
|  | ||||
| 		if (DirectInputDevice) | ||||
| @@ -784,7 +783,8 @@ namespace irr | ||||
| //! constructor | ||||
| CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) | ||||
| : CIrrDeviceStub(params), HWnd(0), Resized(false), | ||||
| 	ExternalWindow(false), Win32CursorControl(0), JoyControl(0) | ||||
| 	ExternalWindow(false), Win32CursorControl(0), JoyControl(0), | ||||
| 	WindowMaximized(params.WindowMaximized) | ||||
| { | ||||
| 	#ifdef _DEBUG | ||||
| 	setDebugName("CIrrDeviceWin32"); | ||||
| @@ -923,6 +923,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) | ||||
|  | ||||
| 	// inform driver about the window size etc. | ||||
| 	resizeIfNecessary(); | ||||
|  | ||||
| 	if (params.WindowMaximized) | ||||
| 		maximizeWindow(); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1109,6 +1112,26 @@ void CIrrDeviceWin32::setWindowCaption(const wchar_t* text) | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Sets the window icon. | ||||
| bool CIrrDeviceWin32::setWindowIcon(const video::IImage *img) | ||||
| { | ||||
| 	// Ignore the img, instead load the ICON from resource file | ||||
| 	// (This is minetest-specific!) | ||||
| 	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; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! notifies the device that it should close itself | ||||
| void CIrrDeviceWin32::closeDevice() | ||||
| { | ||||
| @@ -1154,6 +1177,13 @@ bool CIrrDeviceWin32::isWindowMinimized() const | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns last state from maximizeWindow() and restoreWindow() | ||||
| bool CIrrDeviceWin32::isWindowMaximized() const | ||||
| { | ||||
| 	return WindowMaximized; | ||||
| } | ||||
|  | ||||
|  | ||||
| //! switches to fullscreen | ||||
| bool CIrrDeviceWin32::switchToFullScreen() | ||||
| { | ||||
| @@ -1278,6 +1308,8 @@ void CIrrDeviceWin32::maximizeWindow() | ||||
| 	GetWindowPlacement(HWnd, &wndpl); | ||||
| 	wndpl.showCmd = SW_SHOWMAXIMIZED; | ||||
| 	SetWindowPlacement(HWnd, &wndpl); | ||||
|  | ||||
| 	WindowMaximized = true; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1289,6 +1321,8 @@ void CIrrDeviceWin32::restoreWindow() | ||||
| 	GetWindowPlacement(HWnd, &wndpl); | ||||
| 	wndpl.showCmd = SW_SHOWNORMAL; | ||||
| 	SetWindowPlacement(HWnd, &wndpl); | ||||
|  | ||||
| 	WindowMaximized = false; | ||||
| } | ||||
|  | ||||
| core::position2di CIrrDeviceWin32::getWindowPosition() | ||||
| @@ -1359,6 +1393,17 @@ void CIrrDeviceWin32::clearSystemMessages() | ||||
| 	{} | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Get the display density in dots per inch. | ||||
| float CIrrDeviceWin32::getDisplayDensity() const | ||||
| { | ||||
| 	HDC hdc = GetDC(HWnd); | ||||
| 	float dpi = GetDeviceCaps(hdc, LOGPIXELSX); | ||||
| 	ReleaseDC(HWnd, hdc); | ||||
| 	return dpi; | ||||
| } | ||||
|  | ||||
|  | ||||
| // Convert an Irrlicht texture to a Windows cursor | ||||
| // Based on http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/ | ||||
| HCURSOR CIrrDeviceWin32::TextureToCursor(HWND hwnd, irr::video::ITexture * tex, const core::rect<s32>& sourceRect, const core::position2d<s32> &hotspot) | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_IRR_DEVICE_WIN32_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_WIN32_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | ||||
|  | ||||
| #include "CIrrDeviceStub.h" | ||||
| @@ -48,6 +47,9 @@ namespace irr | ||||
| 		//! sets the caption of the window | ||||
| 		void setWindowCaption(const wchar_t* text) override; | ||||
|  | ||||
| 		//! Sets the window icon. | ||||
| 		bool setWindowIcon(const video::IImage *img) override; | ||||
|  | ||||
| 		//! returns if window is active. if not, nothing need to be drawn | ||||
| 		bool isWindowActive() const override; | ||||
|  | ||||
| @@ -57,6 +59,9 @@ namespace irr | ||||
| 		//! returns if window is minimized | ||||
| 		bool isWindowMinimized() const override; | ||||
|  | ||||
| 		//! returns last state from maximizeWindow() and restoreWindow() | ||||
| 		bool isWindowMaximized() const override; | ||||
|  | ||||
| 		//! notifies the device that it should close itself | ||||
| 		void closeDevice() override; | ||||
|  | ||||
| @@ -94,6 +99,9 @@ namespace irr | ||||
| 			return EIDT_WIN32; | ||||
| 		} | ||||
|  | ||||
| 		//! Get the display density in dots per inch. | ||||
| 		float getDisplayDensity() const override; | ||||
|  | ||||
| 		//! Compares to the last call of this function to return double and triple clicks. | ||||
| 		//! \return Returns only 1,2 or 3. A 4th click will start with 1 again. | ||||
| 		u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) override | ||||
| @@ -413,6 +421,8 @@ namespace irr | ||||
| 		CCursorControl* Win32CursorControl; | ||||
|  | ||||
| 		SJoystickWin32Control* JoyControl; | ||||
|  | ||||
| 		bool WindowMaximized; | ||||
| 	}; | ||||
|  | ||||
| } // end namespace irr | ||||
|   | ||||
| @@ -1,77 +0,0 @@ | ||||
| // Copyright (C) 2002-2008 Nikolaus Gebhardt | ||||
| // Copyright (C) 2008 Redshift Software, Inc. | ||||
| // Copyright (C) 2012-2015 Patryk Nadrowski | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #ifndef __C_IRR_DEVICE_IOS_H_INCLUDED__ | ||||
| #define __C_IRR_DEVICE_IOS_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ | ||||
|  | ||||
| #include "CIrrDeviceStub.h" | ||||
| #include "IrrlichtDevice.h" | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
|  | ||||
| 	class CIrrDeviceiOS : public CIrrDeviceStub | ||||
| 	{ | ||||
| 	public: | ||||
| 		CIrrDeviceiOS(const SIrrlichtCreationParameters& params); | ||||
| 		virtual ~CIrrDeviceiOS(); | ||||
|  | ||||
| 		bool run() override; | ||||
| 		void yield() override; | ||||
| 		void sleep(u32 timeMs, bool pauseTimer) override; | ||||
|  | ||||
| 		void setWindowCaption(const wchar_t* text) override; | ||||
|  | ||||
| 		bool isWindowActive() const override; | ||||
| 		bool isWindowFocused() const override; | ||||
| 		bool isWindowMinimized() const override; | ||||
|  | ||||
| 		void closeDevice() override; | ||||
|  | ||||
| 		void setResizable(bool resize = false) override; | ||||
|  | ||||
| 		void minimizeWindow() override; | ||||
| 		void maximizeWindow() override; | ||||
| 		void restoreWindow() override; | ||||
|  | ||||
| 		core::position2di getWindowPosition() override; | ||||
|  | ||||
|         bool activateAccelerometer(float updateInterval = 0.016666f) override; | ||||
|         bool deactivateAccelerometer() override; | ||||
|         bool isAccelerometerActive() override; | ||||
|         bool isAccelerometerAvailable() override; | ||||
|         bool activateGyroscope(float updateInterval = 0.016666f) override; | ||||
|         bool deactivateGyroscope() override; | ||||
|         bool isGyroscopeActive() override; | ||||
|         bool isGyroscopeAvailable() override; | ||||
|         bool activateDeviceMotion(float updateInterval = 0.016666f) override; | ||||
|         bool deactivateDeviceMotion() override; | ||||
|         bool isDeviceMotionActive() override; | ||||
|         bool isDeviceMotionAvailable() override; | ||||
|  | ||||
|         E_DEVICE_TYPE getType() const override; | ||||
|  | ||||
| 	private: | ||||
|         void createWindow(); | ||||
|         void createViewAndDriver(); | ||||
|          | ||||
|         void* DataStorage; | ||||
| 		 | ||||
| 		bool Close; | ||||
| 	}; | ||||
|  | ||||
| } | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| extern void irrlicht_main(); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
| @@ -1,819 +0,0 @@ | ||||
| // Copyright (C) 2002-2008 Nikolaus Gebhardt | ||||
| // Copyright (C) 2008 Redshift Software, Inc. | ||||
| // Copyright (C) 2012 Patryk Nadrowski | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #import "CIrrDeviceiOS.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ | ||||
|  | ||||
| #include "IFileSystem.h" | ||||
| #include "CTimer.h" | ||||
| #include "CEAGLManager.h" | ||||
|  | ||||
| #import <UIKit/UIKit.h> | ||||
| #import <CoreMotion/CoreMotion.h> | ||||
|  | ||||
| /* Important information */ | ||||
|  | ||||
| // The application state events and following methods: IrrlichtDevice::isWindowActive, IrrlichtDevice::isWindowFocused | ||||
| // and IrrlichtDevice::isWindowMinimized works out of box only if you'll use built-in CIrrDelegateiOS, | ||||
| // so _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ must be enabled in this case. If you need a custom UIApplicationDelegate you must | ||||
| // handle all application events yourself. | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| 	class CIrrDeviceiOS; | ||||
| } | ||||
|  | ||||
| /* CIrrDelegateiOS */ | ||||
|  | ||||
| @interface CIrrDelegateiOS : NSObject<UIApplicationDelegate> | ||||
|  | ||||
| - (void)setDevice:(irr::CIrrDeviceiOS*)device; | ||||
| - (bool)isActive; | ||||
| - (bool)hasFocus; | ||||
|  | ||||
| @property (strong, nonatomic) UIWindow* window; | ||||
|  | ||||
| @end | ||||
|  | ||||
| @implementation CIrrDelegateiOS | ||||
| { | ||||
| 	irr::CIrrDeviceiOS* Device; | ||||
| 	bool Active; | ||||
| 	bool Focus; | ||||
| } | ||||
|  | ||||
| - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)options | ||||
| { | ||||
| 	Device = nil; | ||||
| 	Active = true; | ||||
| 	Focus = false; | ||||
| 	 | ||||
| 	[self performSelectorOnMainThread:@selector(runIrrlicht) withObject:nil waitUntilDone:NO]; | ||||
| 	 | ||||
| 	return YES; | ||||
| } | ||||
|  | ||||
| - (void)applicationWillTerminate:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_WILL_TERMINATE; | ||||
|  | ||||
| 		Device->postEventFromUser(ev); | ||||
| 		 | ||||
| 		Device->closeDevice(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| - (void)applicationDidReceiveMemoryWarning:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_MEMORY_WARNING; | ||||
| 		 | ||||
| 		Device->postEventFromUser(ev); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| - (void)applicationWillResignActive:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_WILL_PAUSE; | ||||
| 		 | ||||
| 		Device->postEventFromUser(ev); | ||||
| 	} | ||||
| 	 | ||||
| 	Focus = false; | ||||
| } | ||||
|  | ||||
| - (void)applicationDidEnterBackground:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_DID_PAUSE; | ||||
| 		 | ||||
| 		Device->postEventFromUser(ev); | ||||
| 	} | ||||
| 	 | ||||
| 	Active = false; | ||||
| } | ||||
|  | ||||
| - (void)applicationWillEnterForeground:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_WILL_RESUME; | ||||
| 		 | ||||
| 		Device->postEventFromUser(ev); | ||||
| 	} | ||||
| 	 | ||||
| 	Active = true; | ||||
| } | ||||
|  | ||||
| - (void)applicationDidBecomeActive:(UIApplication*)application | ||||
| { | ||||
| 	if (Device != nil) | ||||
| 	{ | ||||
| 		irr::SEvent ev; | ||||
| 		ev.EventType = irr::EET_APPLICATION_EVENT; | ||||
| 		ev.ApplicationEvent.EventType = irr::EAET_DID_RESUME; | ||||
| 		 | ||||
| 		Device->postEventFromUser(ev); | ||||
| 	} | ||||
| 	 | ||||
| 	Focus = true; | ||||
| } | ||||
|  | ||||
| - (void)runIrrlicht | ||||
| { | ||||
| 	irrlicht_main(); | ||||
| } | ||||
|  | ||||
| - (void)setDevice:(irr::CIrrDeviceiOS*)device | ||||
| { | ||||
| 	Device = device; | ||||
| } | ||||
|  | ||||
| - (bool)isActive | ||||
| { | ||||
| 	return Active; | ||||
| } | ||||
|  | ||||
| - (bool)hasFocus | ||||
| { | ||||
| 	return Focus; | ||||
| } | ||||
|  | ||||
| @end | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* CIrrViewiOS */ | ||||
|  | ||||
| @interface CIrrViewiOS : UIView | ||||
|  | ||||
| - (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device; | ||||
|  | ||||
| @end | ||||
|  | ||||
| @implementation CIrrViewiOS | ||||
| { | ||||
|     irr::CIrrDeviceiOS* Device; | ||||
|     float Scale; | ||||
| } | ||||
|  | ||||
| - (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device; | ||||
| { | ||||
|     self = [super initWithFrame:frame]; | ||||
|      | ||||
|     if (self) | ||||
|     { | ||||
|         Device = device; | ||||
|         Scale = ([self respondsToSelector:@selector(setContentScaleFactor:)]) ? [[UIScreen mainScreen] scale] : 1.f; | ||||
|     } | ||||
|      | ||||
|     return self; | ||||
| } | ||||
|  | ||||
| - (BOOL)isMultipleTouchEnabled | ||||
| { | ||||
| 	return YES; | ||||
| } | ||||
|  | ||||
| - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event | ||||
| { | ||||
| 	irr::SEvent ev; | ||||
| 	ev.EventType = irr::EET_TOUCH_INPUT_EVENT; | ||||
| 	ev.TouchInput.Event = irr::ETIE_PRESSED_DOWN; | ||||
|      | ||||
| 	for (UITouch* touch in touches) | ||||
| 	{ | ||||
|         ev.TouchInput.ID = (size_t)touch; | ||||
|  | ||||
| 		CGPoint touchPoint = [touch locationInView:self]; | ||||
|          | ||||
|         ev.TouchInput.X = touchPoint.x*Scale; | ||||
|         ev.TouchInput.Y = touchPoint.y*Scale; | ||||
|  | ||||
|         Device->postEventFromUser(ev); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event | ||||
| { | ||||
| 	irr::SEvent ev; | ||||
| 	ev.EventType = irr::EET_TOUCH_INPUT_EVENT; | ||||
| 	ev.TouchInput.Event = irr::ETIE_MOVED; | ||||
|      | ||||
| 	for (UITouch* touch in touches) | ||||
| 	{ | ||||
|         ev.TouchInput.ID = (size_t)touch; | ||||
|  | ||||
| 		CGPoint touchPoint = [touch locationInView:self]; | ||||
|          | ||||
|         ev.TouchInput.X = touchPoint.x*Scale; | ||||
|         ev.TouchInput.Y = touchPoint.y*Scale; | ||||
|          | ||||
|         Device->postEventFromUser(ev); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event | ||||
| { | ||||
| 	irr::SEvent ev; | ||||
| 	ev.EventType = irr::EET_TOUCH_INPUT_EVENT; | ||||
| 	ev.TouchInput.Event = irr::ETIE_LEFT_UP; | ||||
|      | ||||
| 	for (UITouch* touch in touches) | ||||
| 	{ | ||||
|         ev.TouchInput.ID = (size_t)touch; | ||||
|  | ||||
| 		CGPoint touchPoint = [touch locationInView:self]; | ||||
|          | ||||
|         ev.TouchInput.X = touchPoint.x*Scale; | ||||
|         ev.TouchInput.Y = touchPoint.y*Scale; | ||||
|          | ||||
|         Device->postEventFromUser(ev); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event | ||||
| { | ||||
| 	irr::SEvent ev; | ||||
| 	ev.EventType = irr::EET_TOUCH_INPUT_EVENT; | ||||
| 	ev.TouchInput.Event = irr::ETIE_LEFT_UP; | ||||
|      | ||||
| 	for (UITouch* touch in touches) | ||||
| 	{ | ||||
|         ev.TouchInput.ID = (size_t)touch; | ||||
|  | ||||
| 		CGPoint touchPoint = [touch locationInView:self]; | ||||
|          | ||||
|         ev.TouchInput.X = touchPoint.x*Scale; | ||||
|         ev.TouchInput.Y = touchPoint.y*Scale; | ||||
|          | ||||
|         Device->postEventFromUser(ev); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @end | ||||
|  | ||||
| /* CIrrViewEAGLiOS */ | ||||
|  | ||||
| @interface CIrrViewEAGLiOS : CIrrViewiOS | ||||
|  | ||||
| @end | ||||
|  | ||||
| @implementation CIrrViewEAGLiOS | ||||
|  | ||||
| + (Class)layerClass | ||||
| { | ||||
| 	return [CAEAGLLayer class]; | ||||
| } | ||||
|  | ||||
| @end | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
| 	namespace video | ||||
| 	{ | ||||
| 		IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); | ||||
| 		 | ||||
| 		IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager); | ||||
| 	} | ||||
| 	 | ||||
|     struct SIrrDeviceiOSDataStorage | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage() : Window(0), ViewController(0), View(0), MotionManager(0), ReferenceAttitude(0) | ||||
|         { | ||||
|             MotionManager = [[CMMotionManager alloc] init]; | ||||
|         } | ||||
|          | ||||
|         UIWindow* Window; | ||||
|         UIViewController* ViewController; | ||||
|         CIrrViewiOS* View; | ||||
|         CMMotionManager* MotionManager; | ||||
|         CMAttitude* ReferenceAttitude; | ||||
|     }; | ||||
|      | ||||
|     CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params) : CIrrDeviceStub(params), DataStorage(0), Close(false) | ||||
|     { | ||||
| #ifdef _DEBUG | ||||
|         setDebugName("CIrrDeviceiOS"); | ||||
| #endif | ||||
| 		 | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| 		CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; | ||||
| 		[delegate setDevice:this]; | ||||
| #endif | ||||
|          | ||||
|         DataStorage = new SIrrDeviceiOSDataStorage(); | ||||
|  | ||||
|         FileSystem->changeWorkingDirectoryTo([[[NSBundle mainBundle] resourcePath] UTF8String]); | ||||
|  | ||||
| 		createWindow(); | ||||
|         createViewAndDriver(); | ||||
|          | ||||
|         if (!VideoDriver) | ||||
|             return; | ||||
|          | ||||
|         createGUIAndScene(); | ||||
|     } | ||||
|  | ||||
|     CIrrDeviceiOS::~CIrrDeviceiOS() | ||||
|     { | ||||
|         deactivateDeviceMotion(); | ||||
|         deactivateGyroscope(); | ||||
|         deactivateAccelerometer(); | ||||
|          | ||||
|         delete static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| 		CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; | ||||
| 		[delegate setDevice:nil]; | ||||
| #endif | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::run() | ||||
|     { | ||||
| 		if (!Close) | ||||
| 		{ | ||||
| 			const CFTimeInterval timeInSeconds = 0.000002; | ||||
| 			 | ||||
| 			s32 result = 0; | ||||
| 			 | ||||
| 			do | ||||
| 			{ | ||||
| 				result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeInSeconds, TRUE); | ||||
| 			} | ||||
| 			while (result == kCFRunLoopRunHandledSource); | ||||
| 			 | ||||
| 			os::Timer::tick(); | ||||
| 			 | ||||
| 			//! Update events | ||||
| 			 | ||||
| 			SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
| 			CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
| 			 | ||||
| 			//! Accelerometer | ||||
| 			if (motionManager.isAccelerometerActive) | ||||
| 			{ | ||||
| 				irr::SEvent ev; | ||||
| 				ev.EventType = irr::EET_ACCELEROMETER_EVENT; | ||||
| 				ev.AccelerometerEvent.X = motionManager.accelerometerData.acceleration.x; | ||||
| 				ev.AccelerometerEvent.Y = motionManager.accelerometerData.acceleration.y; | ||||
| 				ev.AccelerometerEvent.Z = motionManager.accelerometerData.acceleration.z; | ||||
| 				 | ||||
| 				postEventFromUser(ev); | ||||
| 			} | ||||
| 			 | ||||
| 			//! Gyroscope | ||||
| 			if (motionManager.isGyroActive) | ||||
| 			{ | ||||
| 				irr::SEvent ev; | ||||
| 				ev.EventType = irr::EET_GYROSCOPE_EVENT; | ||||
| 				ev.GyroscopeEvent.X = motionManager.gyroData.rotationRate.x; | ||||
| 				ev.GyroscopeEvent.Y = motionManager.gyroData.rotationRate.y; | ||||
| 				ev.GyroscopeEvent.Z = motionManager.gyroData.rotationRate.z; | ||||
| 				 | ||||
| 				postEventFromUser(ev); | ||||
| 			} | ||||
| 			 | ||||
| 			//! Device Motion | ||||
| 			if (motionManager.isDeviceMotionActive) | ||||
| 			{ | ||||
| 				CMAttitude* currentAttitude = motionManager.deviceMotion.attitude; | ||||
| 				CMAttitude* referenceAttitude = dataStorage->ReferenceAttitude; | ||||
| 				 | ||||
| 				if (referenceAttitude != nil) | ||||
| 					[currentAttitude multiplyByInverseOfAttitude: referenceAttitude]; | ||||
| 				else | ||||
| 					referenceAttitude = motionManager.deviceMotion.attitude; | ||||
| 				 | ||||
| 				irr::SEvent ev; | ||||
| 				ev.EventType = irr::EET_DEVICE_MOTION_EVENT; | ||||
| 				ev.AccelerometerEvent.X = currentAttitude.roll; | ||||
| 				ev.AccelerometerEvent.Y = currentAttitude.pitch; | ||||
| 				ev.AccelerometerEvent.Z = currentAttitude.yaw; | ||||
| 				 | ||||
| 				postEventFromUser(ev); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return !Close; | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::yield() | ||||
|     { | ||||
|         struct timespec ts = {0,0}; | ||||
|         nanosleep(&ts, NULL); | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::sleep(u32 timeMs, bool pauseTimer=false) | ||||
|     { | ||||
|         bool wasStopped = Timer ? Timer->isStopped() : true; | ||||
| 		 | ||||
|         struct timespec ts; | ||||
|         ts.tv_sec = (time_t) (timeMs / 1000); | ||||
|         ts.tv_nsec = (long) (timeMs % 1000) * 1000000; | ||||
|          | ||||
|         if (pauseTimer && !wasStopped) | ||||
|             Timer->stop(); | ||||
|          | ||||
|         nanosleep(&ts, NULL); | ||||
|          | ||||
|         if (pauseTimer && !wasStopped) | ||||
|             Timer->start(); | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::setWindowCaption(const wchar_t* text) | ||||
|     { | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isWindowActive() const | ||||
|     { | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| 		CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; | ||||
| 		 | ||||
| 		return [delegate isActive]; | ||||
| #else | ||||
| 		return false; | ||||
| #endif | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isWindowFocused() const | ||||
|     { | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| 		CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; | ||||
| 		 | ||||
| 		return [delegate hasFocus]; | ||||
| #else | ||||
| 		return false; | ||||
| #endif | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isWindowMinimized() const | ||||
|     { | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| 		CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; | ||||
| 		 | ||||
| 		return ![delegate isActive]; | ||||
| #else | ||||
| 		return false; | ||||
| #endif | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::closeDevice() | ||||
|     { | ||||
|         CFRunLoopStop(CFRunLoopGetMain()); | ||||
| 		 | ||||
| 		Close = true; | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::setResizable(bool resize) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::minimizeWindow() | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::maximizeWindow() | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::restoreWindow() | ||||
|     { | ||||
|     } | ||||
|      | ||||
|     core::position2di CIrrDeviceiOS::getWindowPosition() | ||||
|     { | ||||
|         return core::position2di(0, 0); | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::activateAccelerometer(float updateInterval) | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isAccelerometerAvailable) | ||||
|         { | ||||
|             if (!motionManager.isAccelerometerActive) | ||||
|             { | ||||
|                 motionManager.accelerometerUpdateInterval = updateInterval; | ||||
|                 [motionManager startAccelerometerUpdates]; | ||||
|             } | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::deactivateAccelerometer() | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isAccelerometerAvailable) | ||||
|         { | ||||
|             if (motionManager.isAccelerometerActive) | ||||
|                 [motionManager stopAccelerometerUpdates]; | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isAccelerometerActive() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|  | ||||
|         return (dataStorage->MotionManager.isAccelerometerActive); | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::isAccelerometerAvailable() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|          | ||||
|         return (dataStorage->MotionManager.isAccelerometerAvailable); | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::activateGyroscope(float updateInterval) | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isGyroAvailable) | ||||
|         { | ||||
|             if (!motionManager.isGyroActive) | ||||
|             { | ||||
|                 motionManager.gyroUpdateInterval = updateInterval; | ||||
|                 [motionManager startGyroUpdates]; | ||||
|             } | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::deactivateGyroscope() | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isGyroAvailable) | ||||
|         { | ||||
|             if (motionManager.isGyroActive) | ||||
|                 [motionManager stopGyroUpdates]; | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isGyroscopeActive() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|          | ||||
|         return (dataStorage->MotionManager.isGyroActive); | ||||
|     } | ||||
|  | ||||
|     bool CIrrDeviceiOS::isGyroscopeAvailable() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|          | ||||
|         return (dataStorage->MotionManager.isGyroAvailable); | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::activateDeviceMotion(float updateInterval) | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isDeviceMotionAvailable) | ||||
|         { | ||||
|             if (!motionManager.isDeviceMotionActive) | ||||
|             { | ||||
|                 dataStorage->ReferenceAttitude = nil; | ||||
|                  | ||||
|                 motionManager.deviceMotionUpdateInterval = updateInterval; | ||||
|                 [motionManager startDeviceMotionUpdates]; | ||||
|             } | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::deactivateDeviceMotion() | ||||
|     { | ||||
|         bool status = false; | ||||
|          | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|         CMMotionManager* motionManager = dataStorage->MotionManager; | ||||
|          | ||||
|         if (motionManager.isDeviceMotionAvailable) | ||||
|         { | ||||
|             if (motionManager.isDeviceMotionActive) | ||||
|             { | ||||
|                 [motionManager stopDeviceMotionUpdates]; | ||||
|                  | ||||
|                 dataStorage->ReferenceAttitude = nil; | ||||
|             } | ||||
|              | ||||
|             status = true; | ||||
|         } | ||||
|          | ||||
|         return status; | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isDeviceMotionActive() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|          | ||||
|         return (dataStorage->MotionManager.isDeviceMotionActive); | ||||
|     } | ||||
|      | ||||
|     bool CIrrDeviceiOS::isDeviceMotionAvailable() | ||||
|     { | ||||
|         SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
|          | ||||
|         return (dataStorage->MotionManager.isDeviceMotionAvailable); | ||||
|     } | ||||
|      | ||||
|     E_DEVICE_TYPE CIrrDeviceiOS::getType() const | ||||
|     { | ||||
|         return EIDT_IOS; | ||||
|     } | ||||
|  | ||||
|     void CIrrDeviceiOS::createWindow() | ||||
|     { | ||||
| 		if (CreationParams.DriverType != video::EDT_NULL) | ||||
| 		{ | ||||
| 			SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
| 			 | ||||
| 			UIView* externalView = (__bridge UIView*)CreationParams.WindowId; | ||||
| 			 | ||||
| 			if (externalView == nil) | ||||
| 			{ | ||||
| 				dataStorage->Window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||||
| 				dataStorage->ViewController = [[UIViewController alloc] init]; | ||||
| 				dataStorage->Window.rootViewController = dataStorage->ViewController; | ||||
| 				 | ||||
| 				[dataStorage->Window makeKeyAndVisible]; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				dataStorage->Window = externalView.window; | ||||
| 				 | ||||
| 				UIResponder* currentResponder = externalView.nextResponder; | ||||
| 				 | ||||
| 				do | ||||
| 				{ | ||||
| 					if ([currentResponder isKindOfClass:[UIViewController class]]) | ||||
| 					{ | ||||
| 						dataStorage->ViewController = (UIViewController*)currentResponder; | ||||
| 						 | ||||
| 						currentResponder = nil; | ||||
| 					} | ||||
| 					else if ([currentResponder isKindOfClass:[UIView class]]) | ||||
| 					{ | ||||
| 						currentResponder = currentResponder.nextResponder; | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						currentResponder = nil; | ||||
| 						 | ||||
| 						// Could not find view controller. | ||||
| 						_IRR_DEBUG_BREAK_IF(true); | ||||
| 					} | ||||
| 				} | ||||
| 				while (currentResponder != nil); | ||||
| 			} | ||||
| 		} | ||||
|     } | ||||
|      | ||||
|     void CIrrDeviceiOS::createViewAndDriver() | ||||
|     { | ||||
| 		SIrrDeviceiOSDataStorage* dataStorage = static_cast<SIrrDeviceiOSDataStorage*>(DataStorage); | ||||
| 		 | ||||
| 		video::SExposedVideoData data; | ||||
| 		data.OpenGLiOS.Window = (__bridge void*)dataStorage->Window; | ||||
| 		data.OpenGLiOS.ViewController = (__bridge void*)dataStorage->ViewController; | ||||
| 		 | ||||
| 		UIView* externalView = (__bridge UIView*)CreationParams.WindowId; | ||||
| 		 | ||||
| 		CGRect resolution = (externalView == nil) ? [[UIScreen mainScreen] bounds] : externalView.bounds; | ||||
|  | ||||
|         switch (CreationParams.DriverType) | ||||
|         { | ||||
|             case video::EDT_OGLES1: | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES1_ | ||||
|                 { | ||||
| 					CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this]; | ||||
| 					CreationParams.WindowSize = core::dimension2d<u32>(view.frame.size.width, view.frame.size.height); | ||||
| 					 | ||||
| 					dataStorage->View = view; | ||||
| 					data.OpenGLiOS.View = (__bridge void*)view; | ||||
|  | ||||
|                     ContextManager = new video::CEAGLManager(); | ||||
|                     ContextManager->initialize(CreationParams, data); | ||||
| 					 | ||||
|                     VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager); | ||||
|                      | ||||
|                     if (!VideoDriver) | ||||
|                         os::Printer::log("Could not create OpenGL ES 1.x driver.", ELL_ERROR); | ||||
|                 } | ||||
| #else | ||||
|                 os::Printer::log("No OpenGL ES 1.x support compiled in.", ELL_ERROR); | ||||
| #endif | ||||
|                 break; | ||||
| 				 | ||||
| 			case video::EDT_OGLES2: | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
| 				{ | ||||
| 					CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this]; | ||||
| 					CreationParams.WindowSize = core::dimension2d<u32>(view.frame.size.width, view.frame.size.height); | ||||
| 				 | ||||
| 					dataStorage->View = view; | ||||
| 					data.OpenGLiOS.View = (__bridge void*)view; | ||||
| 				 | ||||
| 					ContextManager = new video::CEAGLManager(); | ||||
| 					ContextManager->initialize(CreationParams, data); | ||||
| 				 | ||||
| 					VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); | ||||
| 				 | ||||
| 					if (!VideoDriver) | ||||
| 						os::Printer::log("Could not create OpenGL ES 2.x driver.", ELL_ERROR); | ||||
| 				} | ||||
| #else | ||||
| 				os::Printer::log("No OpenGL ES 2.x support compiled in.", ELL_ERROR); | ||||
| #endif | ||||
| 				break; | ||||
| 				 | ||||
|             case video::EDT_SOFTWARE: | ||||
|             case video::EDT_BURNINGSVIDEO: | ||||
|             case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS: | ||||
|             case video::EDT_DIRECT3D9: | ||||
|             case video::EDT_OPENGL: | ||||
|                 os::Printer::log("This driver is not available in iOS. Try OpenGL ES.", ELL_ERROR); | ||||
|                 break; | ||||
|                  | ||||
|             case 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; | ||||
|         } | ||||
| 		 | ||||
| 		if (externalView == nil) | ||||
| 			dataStorage->ViewController.view = dataStorage->View; | ||||
| 		else | ||||
| 			[externalView addSubview:dataStorage->View]; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ | ||||
| int main(int argc, char** argv) | ||||
| { | ||||
|     int result = UIApplicationMain(argc, argv, 0, NSStringFromClass([CIrrDelegateiOS class])); | ||||
|      | ||||
|     return result; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -1,11 +1,21 @@ | ||||
| option(BUILD_SHARED_LIBS "Build shared library" TRUE) | ||||
| option(USE_SDL2 "Use the SDL2 backend" FALSE) | ||||
|  | ||||
| # Compiler flags | ||||
|  | ||||
| add_definitions(-DIRRLICHT_EXPORTS) | ||||
| if(NOT BUILD_SHARED_LIBS) | ||||
| if(BUILD_SHARED_LIBS) | ||||
| 	if(WIN32) | ||||
| 		set(API_IMPORT "__declspec(dllimport)") | ||||
| 		set(API_EXPORT "__declspec(dllexport)") | ||||
| 	elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") | ||||
| 		set(API_EXPORT "__attribute__ ((visibility(\"default\")))") # only necessary if default visibility is set to hidden | ||||
| 	endif() | ||||
| else() | ||||
| 	add_definitions(-D_IRR_STATIC_LIB_) | ||||
| endif() | ||||
| add_definitions("-DIRRLICHT_API=${API_EXPORT}") | ||||
|  | ||||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||||
| 	add_definitions(-D_DEBUG) | ||||
| endif() | ||||
| @@ -56,46 +66,205 @@ if(NOT REVISION_SANITY_CHECK) | ||||
| 	message(FATAL_ERROR "IrrlichtMt revision number mismatches between CMake and headers.") | ||||
| endif() | ||||
|  | ||||
| # Platform-independent configuration (hard-coded currently) | ||||
| add_definitions( | ||||
| 	-DIRR_ENABLE_BUILTIN_FONT | ||||
| 	-D_IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ | ||||
| ) | ||||
|  | ||||
| # Platform-specific configuration | ||||
|  | ||||
| if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") | ||||
| 	set(SOLARIS TRUE) | ||||
| endif() | ||||
|  | ||||
| # Device | ||||
|  | ||||
| if(WIN32) | ||||
| 	add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_) | ||||
| 	set(DEVICE "WINDOWS") | ||||
| 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(FATAL_ERROR "SDL2 device is not (yet) supported on Android") | ||||
| 	endif() | ||||
| 	set(DEVICE "Android") | ||||
| elseif(EMSCRIPTEN) | ||||
| 	add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_) | ||||
| 	set(LINUX_PLATFORM TRUE) | ||||
| 	set(DEVICE "SDL") | ||||
| elseif(SOLARIS) | ||||
| 	add_definitions(-D_IRR_SOLARIS_PLATFORM_ -D_IRR_POSIX_API_) | ||||
| 	set(DEVICE "X11") | ||||
| else() | ||||
| 	add_definitions(-D_IRR_POSIX_API_) | ||||
| 	set(LINUX_PLATFORM TRUE) | ||||
| 	set(DEVICE "X11") | ||||
| endif() | ||||
|  | ||||
| if(LINUX_PLATFORM) | ||||
| 	add_definitions(-D_IRR_LINUX_PLATFORM_) | ||||
| endif() | ||||
|  | ||||
| if(USE_SDL2) | ||||
| 	set(DEVICE "SDL") | ||||
| elseif(DEVICE STREQUAL "SDL") | ||||
| 	message(FATAL_ERROR "SDL was used but not enabled?!") | ||||
| endif() | ||||
|  | ||||
| add_definitions("-D_IRR_COMPILE_WITH_${DEVICE}_DEVICE_") | ||||
|  | ||||
| # X11 | ||||
|  | ||||
| if(DEVICE STREQUAL "X11") | ||||
| 	option(USE_X11 "Use X11" TRUE) | ||||
| else() | ||||
| 	set(USE_X11 FALSE) | ||||
| endif() | ||||
|  | ||||
| if(LINUX_PLATFORM AND USE_X11) | ||||
| 	option(USE_XINPUT2 "Use XInput2" TRUE) | ||||
| 	option(USE_XCURSOR "Use XCursor" FALSE) | ||||
| else() | ||||
| 	set(USE_XINPUT2 FALSE) | ||||
| 	set(USE_XCURSOR FALSE) | ||||
| endif() | ||||
|  | ||||
| # Joystick | ||||
|  | ||||
| if(NOT (BSD OR SOLARIS OR EMSCRIPTEN)) | ||||
| 	add_definitions(-D_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) | ||||
| endif() | ||||
|  | ||||
| # OpenGL | ||||
|  | ||||
| option(ENABLE_OPENGL3 "Enable OpenGL 3+" FALSE) | ||||
|  | ||||
| if(ANDROID OR EMSCRIPTEN) | ||||
| 	set(ENABLE_OPENGL FALSE) | ||||
| else() | ||||
| 	option(ENABLE_OPENGL "Enable OpenGL" TRUE) | ||||
| endif() | ||||
|  | ||||
| if(EMSCRIPTEN OR APPLE) | ||||
| 	set(ENABLE_GLES1 FALSE) | ||||
| else() | ||||
| 	if(ANDROID) | ||||
| 		set(DEFAULT_GLES1 TRUE) | ||||
| 	endif() | ||||
| 	option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1}) | ||||
| endif() | ||||
|  | ||||
| if(APPLE) | ||||
| 	set(ENABLE_GLES2 FALSE) | ||||
| 	set(ENABLE_WEBGL1 FALSE) | ||||
| else() | ||||
| 	if(ANDROID OR EMSCRIPTEN) | ||||
| 		set(DEFAULT_GLES2 TRUE) | ||||
| 	endif() | ||||
| 	if(EMSCRIPTEN) | ||||
| 		set(DEFAULT_WEBGL1 TRUE) | ||||
| 	endif() | ||||
| 	option(ENABLE_GLES2 "Enable OpenGL ES 2+" ${DEFAULT_GLES2}) | ||||
| 	option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1}) | ||||
| 	if(ENABLE_WEBGL1) | ||||
| 		set(ENABLE_GLES2 TRUE) | ||||
| 	endif() | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_OPENGL) | ||||
| 	add_definitions(-D_IRR_COMPILE_WITH_OPENGL_) | ||||
| 	if(DEVICE STREQUAL "WINDOWS") | ||||
| 		add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_) | ||||
| 	elseif(DEVICE STREQUAL "X11") | ||||
| 		add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_) | ||||
| 	elseif(DEVICE STREQUAL "OSX") | ||||
| 		add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_) | ||||
| 	elseif(DEVICE STREQUAL "SDL") | ||||
| 		add_definitions(-D_IRR_OPENGL_USE_EXTPOINTER_) | ||||
| 	endif() | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_OPENGL3) | ||||
| 	if (NOT USE_SDL2) | ||||
| 		message(FATAL_ERROR "OpenGL 3 driver requires SDL2") | ||||
| 	endif() | ||||
| 	set(USE_SDLGL ON) | ||||
| 	set(USE_SDLGL3 ON) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_GLES1) | ||||
| 	if (USE_SDL2) | ||||
| 		message(FATAL_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_) | ||||
| 	endif() | ||||
| endif() | ||||
|  | ||||
| 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 "SDL") | ||||
| 		set(USE_SDLGL ON) | ||||
| 		set(USE_SDLGLES2 ON) | ||||
| 	endif() | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_WEBGL1) | ||||
| 	add_definitions(-D_IRR_COMPILE_WITH_WEBGL1_) | ||||
| endif() | ||||
|  | ||||
| # Misc | ||||
|  | ||||
| include(TestBigEndian) | ||||
| TEST_BIG_ENDIAN(BIG_ENDIAN) | ||||
| if(BIG_ENDIAN) | ||||
| 	add_definitions(-D__BIG_ENDIAN__) | ||||
| endif() | ||||
|  | ||||
| # Configuration report | ||||
|  | ||||
| message(STATUS "Device: ${DEVICE}") | ||||
| message(STATUS "OpenGL: ${ENABLE_OPENGL}") | ||||
| message(STATUS "OpenGL 3: ${ENABLE_OPENGL3}") | ||||
| message(STATUS "OpenGL ES: ${ENABLE_GLES1}") | ||||
| if (USE_SDLGLES2) | ||||
| 	message(STATUS "OpenGL ES 2: ON (unified)") | ||||
| elseif (ENABLE_GLES2) | ||||
| 	message(STATUS "OpenGL ES 2: ON (legacy)") | ||||
| else() | ||||
| 	message(STATUS "OpenGL ES 2: OFF") | ||||
| endif() | ||||
| message(STATUS "WebGL: ${ENABLE_WEBGL1}") | ||||
|  | ||||
| # Required libs | ||||
|  | ||||
| find_package(ZLIB REQUIRED) | ||||
| find_package(JPEG REQUIRED) | ||||
| find_package(PNG REQUIRED) | ||||
|  | ||||
| # To configure the features available in this Irrlicht build please edit include/IrrCompileConfig.h. | ||||
| include(CheckSymbolExists) | ||||
| set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) | ||||
| unset(OGLES1_ENABLED CACHE) | ||||
| unset(OGLES2_ENABLED CACHE) | ||||
| unset(OGL_ENABLED CACHE) | ||||
| unset(XINPUT2_ENABLED CACHE) | ||||
| unset(SDL_ENABLED CACHE) | ||||
|  | ||||
| # tell cmake about the dependency | ||||
| set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_REQUIRED_INCLUDES}/IrrCompileConfig.h) | ||||
|  | ||||
| check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED) | ||||
| if(OGLES1_ENABLED) | ||||
| if(ENABLE_GLES1) | ||||
| 	# only tested on Android, probably works on Linux (is this needed anywhere else?) | ||||
| 	find_library(OPENGLES_LIBRARY NAMES GLESv1_CM REQUIRED) | ||||
| 	find_library(EGL_LIBRARY NAMES EGL REQUIRED) | ||||
|  | ||||
| 	message(STATUS "Found OpenGLES: ${OPENGLES_LIBRARY}") | ||||
| endif() | ||||
| check_symbol_exists(_IRR_COMPILE_WITH_OGLES2_ "IrrCompileConfig.h" OGLES2_ENABLED) | ||||
| if(OGLES2_ENABLED) | ||||
| if(ENABLE_GLES2) | ||||
| 	find_package(OpenGLES2 REQUIRED) | ||||
| endif() | ||||
| check_symbol_exists(_IRR_COMPILE_WITH_OPENGL_ "IrrCompileConfig.h" OGL_ENABLED) | ||||
| if(OGL_ENABLED) | ||||
| if(ENABLE_OPENGL OR ENABLE_OPENGL3) | ||||
| 	set(OpenGL_GL_PREFERENCE "LEGACY") | ||||
| 	find_package(OpenGL REQUIRED) | ||||
| endif() | ||||
| if(UNIX AND NOT ANDROID AND NOT APPLE) | ||||
| 	check_symbol_exists(_IRR_LINUX_X11_XINPUT2_ "IrrCompileConfig.h" XINPUT2_ENABLED) | ||||
| endif() | ||||
| check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED) | ||||
| if(SDL_ENABLED) | ||||
| if(USE_SDL2) | ||||
| 	find_package(SDL2 CONFIG REQUIRED) | ||||
| 	message(STATUS "Found SDL2: ${SDL2_LIBRARIES}") | ||||
| endif() | ||||
| @@ -110,33 +279,71 @@ elseif(APPLE) | ||||
| 	find_library(IOKIT_LIB IOKit REQUIRED) | ||||
|  | ||||
| 	add_definitions(-DGL_SILENCE_DEPRECATION) | ||||
| else() | ||||
| elseif(NOT USE_SDL2) | ||||
| 	# Unix probably | ||||
| 	find_package(X11 REQUIRED) | ||||
| 	if(XINPUT2_ENABLED AND NOT X11_Xi_FOUND) | ||||
| 	if(USE_XINPUT2 AND NOT X11_Xi_FOUND) | ||||
| 		message(FATAL_ERROR "XInput not found") | ||||
| 	endif() | ||||
| endif() | ||||
|  | ||||
| add_library(IrrlichtMt) | ||||
| set(link_includes | ||||
| 	"${PROJECT_SOURCE_DIR}/include" | ||||
| 	"${CMAKE_CURRENT_SOURCE_DIR}" | ||||
|  | ||||
| # alias allows for consistent target name with add_subdirectory | ||||
| add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt) | ||||
| 	"${ZLIB_INCLUDE_DIR}" | ||||
| 	"${JPEG_INCLUDE_DIR}" | ||||
| 	"${PNG_INCLUDE_DIR}" | ||||
| 	"$<$<BOOL:${USE_SDL2}>:${SDL2_INCLUDE_DIRS}>" | ||||
|  | ||||
| target_sources(IrrlichtMt PRIVATE | ||||
| 	# IRRMESHLOADER | ||||
| 	${OPENGL_INCLUDE_DIR} | ||||
| 	${OPENGLES2_INCLUDE_DIR} | ||||
| 	${EGL_INCLUDE_DIR} | ||||
|  | ||||
| 	"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>" | ||||
| 	"$<$<BOOL:${USE_X11}>:${X11_INCLUDE_DIR}>" | ||||
| ) | ||||
|  | ||||
| set(link_libs | ||||
| 	"${ZLIB_LIBRARY}" | ||||
| 	"${JPEG_LIBRARY}" | ||||
| 	"${PNG_LIBRARY}" | ||||
| 	"$<$<BOOL:${USE_SDL2}>:${SDL2_LIBRARIES}>" | ||||
|  | ||||
| 	${OPENGL_LIBRARIES} | ||||
| 	${OPENGLES_LIBRARY} | ||||
| 	${OPENGLES2_LIBRARIES} | ||||
| 	${EGL_LIBRARY} | ||||
|  | ||||
| 	"$<$<PLATFORM_ID:Android>:native_app_glue -landroid -llog>" | ||||
| 	${COCOA_LIB} | ||||
| 	${IOKIT_LIB} | ||||
| 	"$<$<PLATFORM_ID:Windows>:gdi32>" | ||||
| 	"$<$<PLATFORM_ID:Windows>:winmm>" | ||||
| 	"$<$<BOOL:${USE_X11}>:${X11_X11_LIB}>" | ||||
| 	"$<$<BOOL:${USE_X11}>:${X11_Xi_LIB}>" | ||||
| ) | ||||
|  | ||||
| # Source files | ||||
|  | ||||
| set(IRRMESHLOADER | ||||
| 	CB3DMeshFileLoader.cpp | ||||
| 	COBJMeshFileLoader.cpp | ||||
| 	CXMeshFileLoader.cpp | ||||
| 	CGLTFMeshFileLoader.cpp | ||||
|         CGLTFMeshFileLoader.cpp | ||||
| ) | ||||
|  | ||||
| 	#IRRMESH | ||||
| add_library(IRRMESHOBJ OBJECT | ||||
| 	CSkinnedMesh.cpp | ||||
| 	CBoneSceneNode.cpp | ||||
| 	CMeshSceneNode.cpp | ||||
| 	CAnimatedMeshSceneNode.cpp | ||||
| 	${IRRMESHLOADER} | ||||
| ) | ||||
|  | ||||
| 	#IRR | ||||
| target_link_libraries(IRRMESHOBJ PRIVATE tinygltf::tinygltf) | ||||
|  | ||||
| add_library(IRROBJ OBJECT | ||||
| 	CBillboardSceneNode.cpp | ||||
| 	CCameraSceneNode.cpp | ||||
| 	CDummyTransformationSceneNode.cpp | ||||
| @@ -145,29 +352,37 @@ target_sources(IrrlichtMt PRIVATE | ||||
| 	CSceneCollisionManager.cpp | ||||
| 	CSceneManager.cpp | ||||
| 	CMeshCache.cpp | ||||
| ) | ||||
|  | ||||
| 	#IRRDRVR | ||||
| set(IRRDRVROBJ | ||||
| 	CNullDriver.cpp | ||||
| 	COpenGLCacheHandler.cpp | ||||
| 	COpenGLDriver.cpp | ||||
| 	COpenGLShaderMaterialRenderer.cpp | ||||
| 	COpenGLSLMaterialRenderer.cpp | ||||
| 	COpenGLExtensionHandler.cpp | ||||
| 	COGLESDriver.cpp | ||||
| 	COGLESExtensionHandler.cpp | ||||
| 	COGLES2Driver.cpp | ||||
| 	COGLES2ExtensionHandler.cpp | ||||
| 	COGLES2FixedPipelineRenderer.cpp | ||||
| 	COGLES2MaterialRenderer.cpp | ||||
| 	COGLES2Renderer2D.cpp | ||||
| 	CWebGL1Driver.cpp | ||||
| 	CGLXManager.cpp | ||||
| 	CWGLManager.cpp | ||||
| 	CEGLManager.cpp | ||||
| 	CSDLManager.cpp | ||||
| 	mt_opengl_loader.cpp | ||||
| ) | ||||
|  | ||||
| 	#IRRIMAGE | ||||
| if(ENABLE_OPENGL) | ||||
| 	set(IRRDRVROBJ | ||||
| 		${IRRDRVROBJ} | ||||
| 		COpenGLCacheHandler.cpp | ||||
| 		COpenGLDriver.cpp | ||||
| 		COpenGLShaderMaterialRenderer.cpp | ||||
| 		COpenGLSLMaterialRenderer.cpp | ||||
| 		COpenGLExtensionHandler.cpp | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_GLES1) | ||||
| 	set(IRRDRVROBJ | ||||
| 		${IRRDRVROBJ} | ||||
| 		COGLESDriver.cpp | ||||
| 		COGLESExtensionHandler.cpp | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| set(IRRIMAGEOBJ | ||||
| 	CColorConverter.cpp | ||||
| 	CImage.cpp | ||||
| 	CImageLoaderBMP.cpp | ||||
| @@ -176,11 +391,46 @@ target_sources(IrrlichtMt PRIVATE | ||||
| 	CImageLoaderTGA.cpp | ||||
| 	CImageWriterJPG.cpp | ||||
| 	CImageWriterPNG.cpp | ||||
| ) | ||||
|  | ||||
| 	# IRRVIDEO | ||||
| add_library(IRRVIDEOOBJ OBJECT | ||||
| 	CFPSCounter.cpp | ||||
| 	${IRRDRVROBJ} | ||||
| 	${IRRIMAGEOBJ} | ||||
| ) | ||||
|  | ||||
| 	# IRRI | ||||
| if(USE_SDLGL) | ||||
| 	target_sources(IRRVIDEOOBJ PRIVATE | ||||
| 		OpenGL/Driver.cpp | ||||
| 		OpenGL/ExtensionHandler.cpp | ||||
| 		OpenGL/FixedPipelineRenderer.cpp | ||||
| 		OpenGL/MaterialRenderer.cpp | ||||
| 		OpenGL/Renderer2D.cpp | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| if(USE_SDLGL3) | ||||
| 	target_sources(IRRVIDEOOBJ PRIVATE | ||||
| 		OpenGL3/Driver.cpp | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| if(USE_SDLGLES2) | ||||
| 	target_sources(IRRVIDEOOBJ PRIVATE | ||||
| 		OpenGLES2/Driver.cpp | ||||
| 	) | ||||
| elseif(ENABLE_GLES2) | ||||
| 	target_sources(IRRVIDEOOBJ PRIVATE | ||||
| 		COGLES2Driver.cpp | ||||
| 		COGLES2ExtensionHandler.cpp | ||||
| 		COGLES2FixedPipelineRenderer.cpp | ||||
| 		COGLES2MaterialRenderer.cpp | ||||
| 		COGLES2Renderer2D.cpp | ||||
| 		CWebGL1Driver.cpp | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| add_library(IRRIOOBJ OBJECT | ||||
| 	CFileList.cpp | ||||
| 	CFileSystem.cpp | ||||
| 	CLimitReadFile.cpp | ||||
| @@ -189,8 +439,9 @@ target_sources(IrrlichtMt PRIVATE | ||||
| 	CWriteFile.cpp | ||||
| 	CZipReader.cpp | ||||
| 	CAttributes.cpp | ||||
| ) | ||||
|  | ||||
| 	# IRROTHER | ||||
| add_library(IRROTHEROBJ OBJECT | ||||
| 	CIrrDeviceSDL.cpp | ||||
| 	CIrrDeviceLinux.cpp | ||||
| 	CIrrDeviceStub.cpp | ||||
| @@ -199,8 +450,41 @@ target_sources(IrrlichtMt PRIVATE | ||||
| 	COSOperator.cpp | ||||
| 	Irrlicht.cpp | ||||
| 	os.cpp | ||||
| ) | ||||
|  | ||||
| 	# IRRGUI | ||||
| if(ENABLE_OPENGL3) | ||||
| 	target_compile_definitions(IRROTHEROBJ PRIVATE ENABLE_OPENGL3) | ||||
| endif() | ||||
|  | ||||
| if(ANDROID) | ||||
| 	target_sources(IRROTHEROBJ PRIVATE | ||||
| 		Android/CIrrDeviceAndroid.cpp | ||||
| 		Android/CAndroidAssetReader.cpp | ||||
| 		Android/CAndroidAssetFileArchive.cpp | ||||
| 		Android/CKeyEventWrapper.cpp | ||||
| 	) | ||||
| elseif(APPLE) | ||||
| 	# Build all IRROTHEROBJ sources as objc++, including the .cpp's | ||||
| 	set_target_properties(IRROTHEROBJ PROPERTIES COMPILE_OPTIONS "-xobjective-c++") | ||||
| 	target_sources(IRROTHEROBJ PRIVATE | ||||
| 		CIrrDeviceOSX.mm | ||||
| 		CNSOGLManager.mm | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| if(USE_X11) | ||||
| 	target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_COMPILE_WITH_X11_) | ||||
| endif() | ||||
|  | ||||
| if(USE_XINPUT2) | ||||
| 	target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_LINUX_X11_XINPUT2_) | ||||
| endif() | ||||
|  | ||||
| if(USE_XCURSOR) | ||||
| 	target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_LINUX_XCURSOR_) | ||||
| endif() | ||||
|  | ||||
| add_library(IRRGUIOBJ OBJECT | ||||
| 	CGUIButton.cpp | ||||
| 	CGUICheckBox.cpp | ||||
| 	CGUIComboBox.cpp | ||||
| @@ -218,44 +502,20 @@ target_sources(IrrlichtMt PRIVATE | ||||
| 	CGUIImageList.cpp | ||||
| ) | ||||
|  | ||||
| if(ANDROID) | ||||
| 	target_sources(IrrlichtMt PRIVATE | ||||
| 		Android/CIrrDeviceAndroid.cpp | ||||
| 		Android/CAndroidAssetReader.cpp | ||||
| 		Android/CAndroidAssetFileArchive.cpp | ||||
| 		Android/CKeyEventWrapper.cpp | ||||
| 	) | ||||
| elseif(APPLE) | ||||
| 	target_sources(IrrlichtMt PRIVATE | ||||
| 		CIrrDeviceOSX.mm | ||||
| 		CNSOGLManager.mm | ||||
| 	) | ||||
|  | ||||
| 	# build all IRROTHEROBJ sources as objc++, including the .cpp's | ||||
| 	set_source_files_properties( | ||||
| 		CIrrDeviceSDL.cpp | ||||
| 		CIrrDeviceLinux.cpp | ||||
| 		CIrrDeviceStub.cpp | ||||
| 		CIrrDeviceWin32.cpp | ||||
| 		CLogger.cpp | ||||
| 		COSOperator.cpp | ||||
| 		Irrlicht.cpp | ||||
| 		os.cpp | ||||
| 		leakHunter.cpp | ||||
| 		CProfiler.cpp | ||||
| 		CIrrDeviceOSX.mm | ||||
| 		CNSOGLManager.mm | ||||
| 		PROPERTIES | ||||
| 			COMPILE_FLAGS "-xobjective-c++" | ||||
| 	) | ||||
| endif() | ||||
|  | ||||
| # Library | ||||
|  | ||||
| # Propagate static library flag to lib users, only needed for Windows | ||||
| if(NOT BUILD_SHARED_LIBS) | ||||
| 	target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_) | ||||
| endif() | ||||
| add_library(IrrlichtMt) | ||||
| foreach(object_lib | ||||
| 	IRRMESHOBJ IRROBJ IRRVIDEOOBJ | ||||
| 	IRRIOOBJ IRROTHEROBJ IRRGUIOBJ) | ||||
| 	# Set include directories for object library compilation | ||||
| 	target_include_directories(${object_lib} PRIVATE ${link_includes}) | ||||
| 	# Add objects from object library to main library | ||||
| 	target_sources(IrrlichtMt PRIVATE $<TARGET_OBJECTS:${object_lib}>) | ||||
| endforeach() | ||||
|  | ||||
| # Alias target provides add_submodule compatibility | ||||
| add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt) | ||||
|  | ||||
| target_include_directories(IrrlichtMt | ||||
| 	PUBLIC | ||||
| @@ -263,43 +523,18 @@ target_include_directories(IrrlichtMt | ||||
| 		"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" | ||||
| 		"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>" | ||||
| 	PRIVATE | ||||
| 		"${PROJECT_SOURCE_DIR}/include" | ||||
| 		"${CMAKE_CURRENT_SOURCE_DIR}" | ||||
|  | ||||
| 		${ZLIB_INCLUDE_DIR} | ||||
| 		${JPEG_INCLUDE_DIR} | ||||
| 		${PNG_INCLUDE_DIR} | ||||
| 		${SDL2_INCLUDE_DIRS} | ||||
|  | ||||
| 		${OPENGL_INCLUDE_DIR} | ||||
| 		${OPENGLES2_INCLUDE_DIR} | ||||
| 		${EGL_INCLUDE_DIR} | ||||
|  | ||||
| 		"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>" | ||||
| 		${X11_INCLUDE_DIR} | ||||
| 		${link_includes} | ||||
| ) | ||||
|  | ||||
| target_link_libraries(IrrlichtMt | ||||
| 	PRIVATE | ||||
| 		${ZLIB_LIBRARY} | ||||
| 		${JPEG_LIBRARY} | ||||
| 		${PNG_LIBRARY} | ||||
| 		${SDL2_LIBRARIES} | ||||
| 		tinygltf::tinygltf | ||||
| target_link_libraries(IrrlichtMt PRIVATE ${link_libs}) | ||||
|  | ||||
| 		${OPENGL_LIBRARIES} | ||||
| 		${OPENGLES_LIBRARY} | ||||
| 		${OPENGLES2_LIBRARIES} | ||||
| 		${EGL_LIBRARY} | ||||
|  | ||||
| 		"$<$<PLATFORM_ID:Android>:native_app_glue -landroid -llog>" | ||||
| 		${COCOA_LIB} | ||||
| 		${IOKIT_LIB} | ||||
| 		"$<$<PLATFORM_ID:Windows>:gdi32>" | ||||
| 		"$<$<PLATFORM_ID:Windows>:winmm>" | ||||
| 		${X11_X11_LIB} | ||||
| 		${X11_Xi_LIB} | ||||
| ) | ||||
| if(WIN32) | ||||
| 	target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header | ||||
| endif() | ||||
| target_compile_definitions(IrrlichtMt INTERFACE "IRRLICHT_API=${API_IMPORT}") | ||||
| if(APPLE OR ANDROID OR EMSCRIPTEN) | ||||
| 	target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) | ||||
| endif() | ||||
|  | ||||
| set_target_properties(IrrlichtMt PROPERTIES | ||||
| 	VERSION ${PROJECT_VERSION} | ||||
| @@ -309,10 +544,6 @@ if(WIN32) | ||||
| 	set_target_properties(IrrlichtMt PROPERTIES PREFIX "") # for DLL name | ||||
| endif() | ||||
|  | ||||
| if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND BUILD_TESTING) | ||||
|         add_subdirectory(tests) | ||||
| endif() | ||||
|  | ||||
| # Installation of library | ||||
| if(ANDROID) | ||||
| 	set(INSTALL_TARGETS IrrlichtMt native_app_glue) | ||||
| @@ -320,6 +551,10 @@ else() | ||||
| 	set(INSTALL_TARGETS IrrlichtMt) | ||||
| endif() | ||||
|  | ||||
| if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND BUILD_TESTING) | ||||
|         add_subdirectory(tests) | ||||
| endif() | ||||
|  | ||||
| install(TARGETS ${INSTALL_TARGETS} | ||||
| 	EXPORT IrrlichtMt-export | ||||
| 	DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_NSOGL_MANAGER_H_INCLUDED__ | ||||
| #define __C_NSOGL_MANAGER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_NSOGL_MANAGER_ | ||||
|  | ||||
|   | ||||
| @@ -32,57 +32,15 @@ IImageLoader* createImageLoaderJPG(); | ||||
| //! creates a loader which is able to load targa images | ||||
| IImageLoader* createImageLoaderTGA(); | ||||
|  | ||||
| //! creates a loader which is able to load psd images | ||||
| IImageLoader* createImageLoaderPSD(); | ||||
|  | ||||
| //! creates a loader which is able to load psd images | ||||
| IImageLoader* createImageLoaderPVR(); | ||||
|  | ||||
| //! creates a loader which is able to load dds images | ||||
| IImageLoader* createImageLoaderDDS(); | ||||
|  | ||||
| //! creates a loader which is able to load pcx images | ||||
| IImageLoader* createImageLoaderPCX(); | ||||
|  | ||||
| //! creates a loader which is able to load png images | ||||
| IImageLoader* createImageLoaderPNG(); | ||||
|  | ||||
| //! creates a loader which is able to load WAL images | ||||
| IImageLoader* createImageLoaderWAL(); | ||||
|  | ||||
| //! creates a loader which is able to load halflife images | ||||
| IImageLoader* createImageLoaderHalfLife(); | ||||
|  | ||||
| //! creates a loader which is able to load lmp images | ||||
| IImageLoader* createImageLoaderLMP(); | ||||
|  | ||||
| //! creates a loader which is able to load ppm/pgm/pbm images | ||||
| IImageLoader* createImageLoaderPPM(); | ||||
|  | ||||
| //! creates a loader which is able to load rgb images | ||||
| IImageLoader* createImageLoaderRGB(); | ||||
|  | ||||
|  | ||||
| //! creates a writer which is able to save bmp images | ||||
| IImageWriter* createImageWriterBMP(); | ||||
|  | ||||
| //! creates a writer which is able to save jpg images | ||||
| IImageWriter* createImageWriterJPG(); | ||||
|  | ||||
| //! creates a writer which is able to save tga images | ||||
| IImageWriter* createImageWriterTGA(); | ||||
|  | ||||
| //! creates a writer which is able to save psd images | ||||
| IImageWriter* createImageWriterPSD(); | ||||
|  | ||||
| //! creates a writer which is able to save pcx images | ||||
| IImageWriter* createImageWriterPCX(); | ||||
|  | ||||
| //! creates a writer which is able to save png images | ||||
| IImageWriter* createImageWriterPNG(); | ||||
|  | ||||
| //! creates a writer which is able to save ppm images | ||||
| IImageWriter* createImageWriterPPM(); | ||||
|  | ||||
| //! constructor | ||||
| CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize) | ||||
| @@ -95,8 +53,8 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre | ||||
| 	#endif | ||||
|  | ||||
| 	DriverAttributes = new io::CAttributes(); | ||||
| 	DriverAttributes->addInt("MaxTextures", _IRR_MATERIAL_MAX_TEXTURES_); | ||||
| 	DriverAttributes->addInt("MaxSupportedTextures", _IRR_MATERIAL_MAX_TEXTURES_); | ||||
| 	DriverAttributes->addInt("MaxTextures", MATERIAL_MAX_TEXTURES); | ||||
| 	DriverAttributes->addInt("MaxSupportedTextures", MATERIAL_MAX_TEXTURES); | ||||
| 	DriverAttributes->addInt("MaxAnisotropy", 1); | ||||
| //	DriverAttributes->addInt("MaxUserClipPlanes", 0); | ||||
| //	DriverAttributes->addInt("MaxAuxBuffers", 0); | ||||
| @@ -124,68 +82,14 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre | ||||
| 	if (FileSystem) | ||||
| 		FileSystem->grab(); | ||||
|  | ||||
| 	// create surface loader | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_WAL_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderHalfLife()); | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderWAL()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_LMP_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderLMP()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PPM_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderPPM()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_RGB_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderRGB()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PSD_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderPSD()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PVR_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderPVR()); | ||||
| #endif | ||||
| #if defined(_IRR_COMPILE_WITH_DDS_LOADER_) || defined(_IRR_COMPILE_WITH_DDS_DECODER_LOADER_) | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderDDS()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PCX_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderPCX()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_TGA_LOADER_ | ||||
| 	// create surface loaders and writers | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderTGA()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderPNG()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderJPG()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_BMP_LOADER_ | ||||
| 	SurfaceLoader.push_back(video::createImageLoaderBMP()); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_PPM_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterPPM()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PCX_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterPCX()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PSD_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterPSD()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_TGA_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterTGA()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_JPG_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterJPG()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_PNG_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterPNG()); | ||||
| #endif | ||||
| #ifdef _IRR_COMPILE_WITH_BMP_WRITER_ | ||||
| 	SurfaceWriter.push_back(video::createImageWriterBMP()); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| 	// set ExposedData to 0 | ||||
| @@ -440,10 +344,7 @@ ITexture* CNullDriver::addTexture(const core::dimension2d<u32>& size, const io:: | ||||
| 	IImage* image = new CImage(format, size); | ||||
| 	ITexture* t = 0; | ||||
|  | ||||
| 	core::array<IImage*> imageArray(1); | ||||
| 	imageArray.push_back(image); | ||||
|  | ||||
| 	if (checkImage(imageArray)) | ||||
| 	if (checkImage(image)) | ||||
| 	{ | ||||
| 		t = createDeviceDependentTexture(name, image); | ||||
| 	} | ||||
| @@ -472,10 +373,7 @@ ITexture* CNullDriver::addTexture(const io::path& name, IImage* image) | ||||
|  | ||||
| 	ITexture* t = 0; | ||||
|  | ||||
| 	core::array<IImage*> imageArray(1); | ||||
| 	imageArray.push_back(image); | ||||
|  | ||||
| 	if (checkImage(imageArray)) | ||||
| 	if (checkImage(image)) | ||||
| 	{ | ||||
| 		t = createDeviceDependentTexture(name, image); | ||||
| 	} | ||||
| @@ -649,39 +547,19 @@ ITexture* CNullDriver::getTexture(io::IReadFile* file) | ||||
| //! opens the file and loads it into the surface | ||||
| video::ITexture* CNullDriver::loadTextureFromFile(io::IReadFile* file, const io::path& hashName ) | ||||
| { | ||||
| 	ITexture* texture = 0; | ||||
| 	ITexture *texture = nullptr; | ||||
|  | ||||
| 	E_TEXTURE_TYPE type = ETT_2D; | ||||
|  | ||||
| 	core::array<IImage*> imageArray = createImagesFromFile(file, &type); | ||||
|  | ||||
| 	if (checkImage(imageArray)) | ||||
| 	{ | ||||
| 		switch (type) | ||||
| 		{ | ||||
| 		case ETT_2D: | ||||
| 			texture = createDeviceDependentTexture(hashName.size() ? hashName : file->getFileName(), imageArray[0]); | ||||
| 			break; | ||||
| 		case ETT_CUBEMAP: | ||||
| 			if (imageArray.size() >= 6 && imageArray[0] && imageArray[1] && imageArray[2] && imageArray[3] && imageArray[4] && imageArray[5]) | ||||
| 			{ | ||||
| 				texture = createDeviceDependentTextureCubemap(hashName.size() ? hashName : file->getFileName(), imageArray); | ||||
| 			} | ||||
| 			break; | ||||
| 		default: | ||||
| 			_IRR_DEBUG_BREAK_IF(true); | ||||
| 			break; | ||||
| 		} | ||||
| 	IImage *image = createImageFromFile(file); | ||||
| 	if (!image) | ||||
| 		return nullptr; | ||||
|  | ||||
| 	if (checkImage(image)) { | ||||
| 		texture = createDeviceDependentTexture(hashName.size() ? hashName : file->getFileName(), image); | ||||
| 		if (texture) | ||||
| 			os::Printer::log("Loaded texture", file->getFileName(), ELL_DEBUG); | ||||
| 	} | ||||
|  | ||||
| 	for (u32 i = 0; i < imageArray.size(); ++i) | ||||
| 	{ | ||||
| 		if (imageArray[i]) | ||||
| 			imageArray[i]->drop(); | ||||
| 	} | ||||
| 	image->drop(); | ||||
|  | ||||
| 	return texture; | ||||
| } | ||||
| @@ -815,27 +693,6 @@ void CNullDriver::draw3DLine(const core::vector3df& start, | ||||
| } | ||||
|  | ||||
|  | ||||
| //! 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<f32>& box, SColor color) | ||||
| { | ||||
| @@ -875,31 +732,6 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::positi | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| //! 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<s32>& pos, | ||||
| 				const core::array<core::rect<s32> >& sourceRects, | ||||
| 				const core::array<s32>& indices, | ||||
| 				s32 kerningWidth, | ||||
| 				const core::rect<s32>* clipRect, SColor color, | ||||
| 				bool useAlphaChannelOfTexture) | ||||
| { | ||||
| 	core::position2d<s32> target(pos); | ||||
|  | ||||
| 	for (u32 i=0; i<indices.size(); ++i) | ||||
| 	{ | ||||
| 		draw2DImage(texture, target, sourceRects[indices[i]], | ||||
| 				clipRect, color, useAlphaChannelOfTexture); | ||||
| 		target.X += sourceRects[indices[i]].getWidth(); | ||||
| 		target.X += kerningWidth; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //! draws a set of 2d images, using a color and the alpha channel of the | ||||
| //! texture if desired. | ||||
| void CNullDriver::draw2DImageBatch(const video::ITexture* texture, | ||||
| @@ -940,16 +772,6 @@ void CNullDriver::draw2DImage(const video::ITexture* texture, const core::positi | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Draws the outline of a 2d rectangle | ||||
| void CNullDriver::draw2DRectangleOutline(const core::recti& pos, SColor color) | ||||
| { | ||||
| 	draw2DLine(pos.UpperLeftCorner, core::position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), color); | ||||
| 	draw2DLine(core::position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), pos.LowerRightCorner, color); | ||||
| 	draw2DLine(pos.LowerRightCorner, core::position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), color); | ||||
| 	draw2DLine(core::position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), pos.UpperLeftCorner, color); | ||||
| } | ||||
|  | ||||
|  | ||||
| //! Draw a 2d rectangle | ||||
| void CNullDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip) | ||||
| { | ||||
| @@ -973,38 +795,6 @@ void CNullDriver::draw2DLine(const core::position2d<s32>& start, | ||||
| { | ||||
| } | ||||
|  | ||||
| //! 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<s32> center, | ||||
| 	f32 radius, video::SColor color, s32 count) | ||||
| { | ||||
| 	if (count < 2) | ||||
| 		return; | ||||
|  | ||||
| 	core::position2d<s32> first; | ||||
| 	core::position2d<s32> a,b; | ||||
|  | ||||
| 	for (s32 j=0; j<count; ++j) | ||||
| 	{ | ||||
| 		b = a; | ||||
|  | ||||
| 		f32 p = j / (f32)count * (core::PI*2); | ||||
| 		a = center + core::position2d<s32>((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 | ||||
| @@ -1075,25 +865,6 @@ const wchar_t* CNullDriver::getName() const | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| //! 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<core::vector3df>& 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, | ||||
| @@ -1260,90 +1031,92 @@ bool CNullDriver::checkPrimitiveCount(u32 prmCount) const | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool CNullDriver::checkImage(IImage *image) const | ||||
| { | ||||
| 	ECOLOR_FORMAT format = image->getColorFormat(); | ||||
| 	core::dimension2d<u32> size = image->getDimension(); | ||||
|  | ||||
| 	switch (format) | ||||
| 	{ | ||||
| 	case ECF_DXT1: | ||||
| 	case ECF_DXT2: | ||||
| 	case ECF_DXT3: | ||||
| 	case ECF_DXT4: | ||||
| 	case ECF_DXT5: | ||||
| 		if (!queryFeature(EVDF_TEXTURE_COMPRESSED_DXT)) | ||||
| 		{ | ||||
| 			os::Printer::log("DXT texture compression not available.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		else if (size.getOptimalSize(true, false) != size) | ||||
| 		{ | ||||
| 			os::Printer::log("Invalid size of image for DXT texture, size of image must be power of two.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		break; | ||||
| 	case ECF_PVRTC_RGB2: | ||||
| 	case ECF_PVRTC_ARGB2: | ||||
| 	case ECF_PVRTC_RGB4: | ||||
| 	case ECF_PVRTC_ARGB4: | ||||
| 		if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC)) | ||||
| 		{ | ||||
| 			os::Printer::log("PVRTC texture compression not available.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		else if (size.getOptimalSize(true, false) != size) | ||||
| 		{ | ||||
| 			os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be power of two and squared.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		break; | ||||
| 	case ECF_PVRTC2_ARGB2: | ||||
| 	case ECF_PVRTC2_ARGB4: | ||||
| 		if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2)) | ||||
| 		{ | ||||
| 			os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		break; | ||||
| 	case ECF_ETC1: | ||||
| 		if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC1)) | ||||
| 		{ | ||||
| 			os::Printer::log("ETC1 texture compression not available.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		break; | ||||
| 	case ECF_ETC2_RGB: | ||||
| 	case ECF_ETC2_ARGB: | ||||
| 		if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC2)) | ||||
| 		{ | ||||
| 			os::Printer::log("ETC2 texture compression not available.", ELL_ERROR); | ||||
| 			return false; | ||||
| 		} | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| bool CNullDriver::checkImage(const core::array<IImage*>& image) const | ||||
| { | ||||
| 	bool status = true; | ||||
| 	if (!image.size()) | ||||
| 		return false; | ||||
|  | ||||
| 	if (image.size() > 0) | ||||
| 	{ | ||||
| 		ECOLOR_FORMAT lastFormat = image[0]->getColorFormat(); | ||||
| 		core::dimension2d<u32> lastSize = image[0]->getDimension(); | ||||
| 	ECOLOR_FORMAT lastFormat = image[0]->getColorFormat(); | ||||
| 	core::dimension2d<u32> lastSize = image[0]->getDimension(); | ||||
|  | ||||
| 		for (u32 i = 0; i < image.size() && status; ++i) | ||||
| 		{ | ||||
| 			ECOLOR_FORMAT format = image[i]->getColorFormat(); | ||||
| 			core::dimension2d<u32> size = image[i]->getDimension(); | ||||
| 	for (u32 i = 0; i < image.size(); ++i) { | ||||
| 		ECOLOR_FORMAT format = image[i]->getColorFormat(); | ||||
| 		core::dimension2d<u32> size = image[i]->getDimension(); | ||||
|  | ||||
| 			switch (format) | ||||
| 			{ | ||||
| 			case ECF_DXT1: | ||||
| 			case ECF_DXT2: | ||||
| 			case ECF_DXT3: | ||||
| 			case ECF_DXT4: | ||||
| 			case ECF_DXT5: | ||||
| 				if (!queryFeature(EVDF_TEXTURE_COMPRESSED_DXT)) | ||||
| 				{ | ||||
| 					os::Printer::log("DXT texture compression not available.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				else if (size.getOptimalSize(true, false) != size) | ||||
| 				{ | ||||
| 					os::Printer::log("Invalid size of image for DXT texture, size of image must be power of two.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				break; | ||||
| 			case ECF_PVRTC_RGB2: | ||||
| 			case ECF_PVRTC_ARGB2: | ||||
| 			case ECF_PVRTC_RGB4: | ||||
| 			case ECF_PVRTC_ARGB4: | ||||
| 				if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC)) | ||||
| 				{ | ||||
| 					os::Printer::log("PVRTC texture compression not available.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				else if (size.getOptimalSize(true, false) != size) | ||||
| 				{ | ||||
| 					os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be power of two and squared.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				break; | ||||
| 			case ECF_PVRTC2_ARGB2: | ||||
| 			case ECF_PVRTC2_ARGB4: | ||||
| 				if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2)) | ||||
| 				{ | ||||
| 					os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				break; | ||||
| 			case ECF_ETC1: | ||||
| 				if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC1)) | ||||
| 				{ | ||||
| 					os::Printer::log("ETC1 texture compression not available.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				break; | ||||
| 			case ECF_ETC2_RGB: | ||||
| 			case ECF_ETC2_ARGB: | ||||
| 				if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC2)) | ||||
| 				{ | ||||
| 					os::Printer::log("ETC2 texture compression not available.", ELL_ERROR); | ||||
| 					status = false; | ||||
| 				} | ||||
| 				break; | ||||
| 			default: | ||||
| 				break; | ||||
| 			} | ||||
| 		if (!checkImage(image[i])) | ||||
| 			return false; | ||||
|  | ||||
| 			if (format != lastFormat || size != lastSize) | ||||
| 				status = false; | ||||
| 		} | ||||
| 		if (format != lastFormat || size != lastSize) | ||||
| 			return false; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		status = false; | ||||
| 	} | ||||
|  | ||||
| 	return status; | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| //! Enables or disables a texture creation flag. | ||||
| @@ -1371,89 +1144,51 @@ bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const | ||||
| 	return (TextureCreationFlags & flag)!=0; | ||||
| } | ||||
|  | ||||
| core::array<IImage*> CNullDriver::createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type) | ||||
| IImage *CNullDriver::createImageFromFile(const io::path& filename) | ||||
| { | ||||
| 	// TO-DO -> use 'move' feature from C++11 standard. | ||||
| 	if (!filename.size()) | ||||
| 		return nullptr; | ||||
|  | ||||
| 	core::array<IImage*> imageArray; | ||||
|  | ||||
| 	if (filename.size() > 0) | ||||
| 	{ | ||||
| 		io::IReadFile* file = FileSystem->createAndOpenFile(filename); | ||||
|  | ||||
| 		if (file) | ||||
| 		{ | ||||
| 			imageArray = createImagesFromFile(file, type); | ||||
| 			file->drop(); | ||||
| 		} | ||||
| 		else | ||||
| 			os::Printer::log("Could not open file of image", filename, ELL_WARNING); | ||||
| 	io::IReadFile* file = FileSystem->createAndOpenFile(filename); | ||||
| 	if (!file) { | ||||
| 		os::Printer::log("Could not open file of image", filename, ELL_WARNING); | ||||
| 		return nullptr; | ||||
| 	} | ||||
|  | ||||
| 	return imageArray; | ||||
| 	IImage *image = createImageFromFile(file); | ||||
| 	file->drop(); | ||||
| 	return image; | ||||
| } | ||||
|  | ||||
| core::array<IImage*> CNullDriver::createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type) | ||||
| IImage *CNullDriver::createImageFromFile(io::IReadFile* file) | ||||
| { | ||||
| 	// TO-DO -> use 'move' feature from C++11 standard. | ||||
| 	if (!file) | ||||
| 		return nullptr; | ||||
|  | ||||
| 	core::array<IImage*> imageArray; | ||||
| 	// try to load file based on file extension | ||||
| 	for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { | ||||
| 		if (!SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) | ||||
| 			continue; | ||||
|  | ||||
| 	if (file) | ||||
| 	{ | ||||
| 		s32 i; | ||||
|  | ||||
| 		// try to load file based on file extension | ||||
| 		for (i = SurfaceLoader.size() - 1; i >= 0; --i) | ||||
| 		{ | ||||
| 			if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) | ||||
| 			{ | ||||
| 				// reset file position which might have changed due to previous loadImage calls | ||||
| 				file->seek(0); | ||||
| 				imageArray = SurfaceLoader[i]->loadImages(file, type); | ||||
|  | ||||
| 				if (imageArray.size() == 0) | ||||
| 				{ | ||||
| 					file->seek(0); | ||||
| 					IImage* image = SurfaceLoader[i]->loadImage(file); | ||||
|  | ||||
| 					if (image) | ||||
| 						imageArray.push_back(image); | ||||
| 				} | ||||
|  | ||||
| 				if (imageArray.size() > 0) | ||||
| 					return imageArray; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// try to load file based on what is in it | ||||
| 		for (i = SurfaceLoader.size() - 1; i >= 0; --i) | ||||
| 		{ | ||||
| 			// dito | ||||
| 			file->seek(0); | ||||
| 			if (SurfaceLoader[i]->isALoadableFileFormat(file) | ||||
| 				&& !SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())	// extension was tried above already | ||||
| 				) | ||||
| 			{ | ||||
| 				file->seek(0); | ||||
| 				imageArray = SurfaceLoader[i]->loadImages(file, type); | ||||
|  | ||||
| 				if (imageArray.size() == 0) | ||||
| 				{ | ||||
| 					file->seek(0); | ||||
| 					IImage* image = SurfaceLoader[i]->loadImage(file); | ||||
|  | ||||
| 					if (image) | ||||
| 						imageArray.push_back(image); | ||||
| 				} | ||||
|  | ||||
| 				if (imageArray.size() > 0) | ||||
| 					return imageArray; | ||||
| 			} | ||||
| 		} | ||||
| 		file->seek(0); // reset file position which might have changed due to previous loadImage calls | ||||
| 		if (IImage *image = SurfaceLoader[i]->loadImage(file)) | ||||
| 			return image; | ||||
| 	} | ||||
|  | ||||
| 	return imageArray; | ||||
| 	// try to load file based on what is in it | ||||
| 	for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { | ||||
| 		if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) | ||||
| 			continue; // extension was tried above already | ||||
| 		file->seek(0); // dito | ||||
| 		if (!SurfaceLoader[i]->isALoadableFileFormat(file)) | ||||
| 			continue; | ||||
|  | ||||
| 		file->seek(0); | ||||
| 		if (IImage *image = SurfaceLoader[i]->loadImage(file)) | ||||
| 			return image; | ||||
| 	} | ||||
|  | ||||
| 	return nullptr; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1920,10 +1655,10 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na | ||||
|  | ||||
|  | ||||
| //! 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; | ||||
|   | ||||
| @@ -126,9 +126,8 @@ namespace video | ||||
| 		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<f32>& box, | ||||
| @@ -154,14 +153,14 @@ namespace video | ||||
| 		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<s32>& pos, | ||||
| 				const core::array<core::rect<s32> >& sourceRects, | ||||
| 				const core::array<s32>& indices, | ||||
| 				s32 kerningWidth = 0, | ||||
| 				const core::rect<s32>* 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). | ||||
| @@ -205,7 +204,7 @@ namespace video | ||||
| 			const core::rect<s32>* 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<s32>& start, | ||||
| @@ -213,11 +212,11 @@ namespace video | ||||
| 					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<s32> center, | ||||
| 			f32 radius, video::SColor Color, s32 vertexCount) override; | ||||
| 		[[deprecated]] virtual void draw2DPolygon(core::position2d<s32> 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, | ||||
| @@ -268,17 +267,17 @@ namespace video | ||||
| 		//! 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<core::vector3df>& triangles, | ||||
| 			bool zfail=true, u32 debugDataVisible=0) override; | ||||
| 		[[deprecated]] virtual void drawStencilShadowVolume(const core::array<core::vector3df>& 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 | ||||
| @@ -315,9 +314,9 @@ namespace video | ||||
| 		//! Returns if a texture creation flag is enabled or disabled. | ||||
| 		bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const override; | ||||
|  | ||||
| 		core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) override; | ||||
| 		IImage *createImageFromFile(const io::path& filename) override; | ||||
|  | ||||
| 		core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) override; | ||||
| 		IImage *createImageFromFile(io::IReadFile* file) override; | ||||
|  | ||||
| 		//! Creates a software image from a byte array. | ||||
| 		/** \param useForeignMemory: If true, the image will use the data pointer | ||||
| @@ -585,7 +584,7 @@ namespace video | ||||
| 		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; | ||||
| @@ -671,6 +670,8 @@ namespace video | ||||
| 		//! checks triangle count and print warning if wrong | ||||
| 		bool checkPrimitiveCount(u32 prmcnt) const; | ||||
|  | ||||
| 		bool checkImage(IImage *image) const; | ||||
|  | ||||
| 		bool checkImage(const core::array<IImage*>& image) const; | ||||
|  | ||||
| 		// adds a material renderer and drops it afterwards. To be used for internal creation | ||||
|   | ||||
| @@ -2,9 +2,6 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in irrlicht.h | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_OBJ_LOADER_ | ||||
|  | ||||
| #include "COBJMeshFileLoader.h" | ||||
| #include "IMeshManipulator.h" | ||||
| #include "IVideoDriver.h" | ||||
| @@ -27,23 +24,18 @@ namespace scene | ||||
| #endif | ||||
|  | ||||
| //! Constructor | ||||
| COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) | ||||
| : SceneManager(smgr), FileSystem(fs) | ||||
| COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr) | ||||
| : SceneManager(smgr) | ||||
| { | ||||
| 	#ifdef _DEBUG | ||||
| 	setDebugName("COBJMeshFileLoader"); | ||||
| 	#endif | ||||
|  | ||||
| 	if (FileSystem) | ||||
| 		FileSystem->grab(); | ||||
| } | ||||
|  | ||||
|  | ||||
| //! destructor | ||||
| COBJMeshFileLoader::~COBJMeshFileLoader() | ||||
| { | ||||
| 	if (FileSystem) | ||||
| 		FileSystem->drop(); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -79,7 +71,6 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) | ||||
| 	u32 smoothingGroup=0; | ||||
|  | ||||
| 	const io::path fullName = file->getFileName(); | ||||
| 	const io::path relPath = FileSystem->getFileDir(fullName)+"/"; | ||||
|  | ||||
| 	c8* buf = new c8[filesize]; | ||||
| 	memset(buf, 0, filesize); | ||||
| @@ -233,7 +224,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) | ||||
| 					v.Pos = vertexBuffer[Idx[0]]; | ||||
| 				else | ||||
| 				{ | ||||
| 					os::Printer::log("Invalid vertex index in this line:", wordBuffer.c_str(), ELL_ERROR); | ||||
| 					os::Printer::log("Invalid vertex index in this line", wordBuffer.c_str(), ELL_ERROR); | ||||
| 					delete [] buf; | ||||
| 					return 0; | ||||
| 				} | ||||
| @@ -612,6 +603,3 @@ void COBJMeshFileLoader::cleanUp() | ||||
|  | ||||
| } // end namespace scene | ||||
| } // end namespace irr | ||||
|  | ||||
| #endif // _IRR_COMPILE_WITH_OBJ_LOADER_ | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
|  | ||||
| #include <map> | ||||
| #include "IMeshLoader.h" | ||||
| #include "IFileSystem.h" | ||||
| #include "ISceneManager.h" | ||||
| #include "irrString.h" | ||||
| #include "SMeshBuffer.h" | ||||
| @@ -23,7 +22,7 @@ class COBJMeshFileLoader : public IMeshLoader | ||||
| public: | ||||
|  | ||||
| 	//! Constructor | ||||
| 	COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); | ||||
| 	COBJMeshFileLoader(scene::ISceneManager* smgr); | ||||
|  | ||||
| 	//! destructor | ||||
| 	virtual ~COBJMeshFileLoader(); | ||||
| @@ -104,7 +103,6 @@ private: | ||||
| 	void cleanUp(); | ||||
|  | ||||
| 	scene::ISceneManager* SceneManager; | ||||
| 	io::IFileSystem* FileSystem; | ||||
|  | ||||
| 	core::array<SObjMtl*> Materials; | ||||
| }; | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES2_COMMON_H_INCLUDED__ | ||||
| #define __C_OGLES2_COMMON_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #ifndef __C_OGLES2_DRIVER_H_INCLUDED__ | ||||
| #define __C_OGLES2_DRIVER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "SIrrCreationParameters.h" | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #ifndef __C_OGLES2_EXTENSION_HANDLER_H_INCLUDED__ | ||||
| #define __C_OGLES2_EXTENSION_HANDLER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
|  | ||||
|   | ||||
| @@ -176,7 +176,7 @@ void COGLES2MaterialSolid2CB::OnSetConstants(IMaterialRendererServices* services | ||||
| 	core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0); | ||||
| 	services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16); | ||||
|  | ||||
| 	Matrix = driver->getTransform(ETS_TEXTURE_1); | ||||
| 	Matrix = driver->getTransform(E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + 1)); | ||||
| 	services->setPixelShaderConstant(TMatrix1ID, Matrix.pointer(), 16); | ||||
|  | ||||
| 	services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1); | ||||
| @@ -223,7 +223,7 @@ void COGLES2MaterialLightmapCB::OnSetConstants(IMaterialRendererServices* servic | ||||
| 	core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0); | ||||
| 	services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16); | ||||
|  | ||||
| 	Matrix = driver->getTransform(ETS_TEXTURE_1); | ||||
| 	Matrix = driver->getTransform(E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + 1)); | ||||
| 	services->setPixelShaderConstant(TMatrix1ID, Matrix.pointer(), 16); | ||||
|  | ||||
| 	services->setPixelShaderConstant(ModulateID, &Modulate, 1); | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES2_FIXED_PIPELINE_SHADER_H_INCLUDED__ | ||||
| #define __C_OGLES2_FIXED_PIPELINE_SHADER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES2_SL_MATERIAL_RENDERER_H_INCLUDED__ | ||||
| #define __C_OGLES2_SL_MATERIAL_RENDERER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES2_RENDERER_2D_H_INCLUDED__ | ||||
| #define __C_OGLES2_RENDERER_2D_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES2_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES_COMMON_H_INCLUDED__ | ||||
| #define __C_OGLES_COMMON_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES1_ | ||||
|  | ||||
|   | ||||
| @@ -2,14 +2,10 @@ | ||||
| // This file is part of the "Irrlicht Engine". | ||||
| // For conditions of distribution and use, see copyright notice in Irrlicht.h | ||||
|  | ||||
| #ifndef __E_OGLES_CORE_EXTENSION_HANDLER_H_INCLUDED__ | ||||
| #define __E_OGLES_CORE_EXTENSION_HANDLER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #pragma once | ||||
|  | ||||
| // Can be included from different ES versions | ||||
| // (this is also the reason why this file is header-only as correct OGL ES headers have to be included first) | ||||
| #if defined(_IRR_COMPILE_WITH_OGLES2_) || defined(_IRR_COMPILE_WITH_OGLES1_) | ||||
|  | ||||
| #include "irrMath.h" | ||||
| #include "COpenGLCoreFeature.h" | ||||
| @@ -774,6 +770,3 @@ namespace video | ||||
| 	}; | ||||
| } | ||||
| } | ||||
|  | ||||
| #endif // defined(_IRR_COMPILE_WITH_OGLES2_) || defined(_IRR_COMPILE_WITH_OGLES1_) | ||||
| #endif // __E_OGLES_CORE_EXTENSION_HANDLER_H_INCLUDED__ | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES1_DRIVER_H_INCLUDED__ | ||||
| #define __C_OGLES1_DRIVER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #include "SIrrCreationParameters.h" | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
| #ifndef __C_OGLES_EXTENSION_HANDLER_H_INCLUDED__ | ||||
| #define __C_OGLES_EXTENSION_HANDLER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES1_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OGLES1_MATERIAL_RENDERER_H_INCLUDED__ | ||||
| #define __C_OGLES1_MATERIAL_RENDERER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
| #ifdef _IRR_COMPILE_WITH_OGLES1_ | ||||
|  | ||||
| #include "COGLESDriver.h" | ||||
|   | ||||
| @@ -17,7 +17,10 @@ | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_X11_DEVICE_) | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| #include <SDL_clipboard.h> | ||||
| #include <SDL_version.h> | ||||
| #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) | ||||
| #include "CIrrDeviceLinux.h" | ||||
| #endif | ||||
| #if defined(_IRR_COMPILE_WITH_OSX_DEVICE_) | ||||
| @@ -26,6 +29,19 @@ | ||||
|  | ||||
| #include "fast_atof.h" | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| static const bool sdl_supports_primary_selection = [] { | ||||
| #if SDL_VERSION_ATLEAST(2, 25, 0) | ||||
| 	SDL_version linked_version; | ||||
| 	SDL_GetVersion(&linked_version); | ||||
| 	return (linked_version.major == 2 && linked_version.minor >= 25) | ||||
| 			|| linked_version.major > 2; | ||||
| #else | ||||
| 	return false; | ||||
| #endif | ||||
| }(); | ||||
| #endif | ||||
|  | ||||
| namespace irr | ||||
| { | ||||
|  | ||||
| @@ -46,6 +62,15 @@ COSOperator::COSOperator(const core::stringc& osVersion) : OperatingSystem(osVer | ||||
| } | ||||
|  | ||||
|  | ||||
| COSOperator::~COSOperator() | ||||
| { | ||||
| #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | ||||
| 	SDL_free(ClipboardSelectionText); | ||||
| 	SDL_free(PrimarySelectionText); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| //! returns the current operating system version as string. | ||||
| const core::stringc& COSOperator::getOperatingSystemVersion() const | ||||
| { | ||||
| @@ -54,14 +79,15 @@ const core::stringc& COSOperator::getOperatingSystemVersion() const | ||||
|  | ||||
|  | ||||
| //! copies text to the clipboard | ||||
| //! \param text: text in utf-8 | ||||
| void COSOperator::copyToClipboard(const c8 *text) const | ||||
| { | ||||
| 	if (strlen(text)==0) | ||||
| 		return; | ||||
|  | ||||
| // Windows version | ||||
| #if defined(_IRR_WINDOWS_API_) | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| 	SDL_SetClipboardText(text); | ||||
|  | ||||
| #elif defined(_IRR_WINDOWS_API_) | ||||
| 	if (!OpenClipboard(NULL) || text == 0) | ||||
| 		return; | ||||
|  | ||||
| @@ -102,11 +128,34 @@ void COSOperator::copyToClipboard(const c8 *text) const | ||||
| } | ||||
|  | ||||
|  | ||||
| //! copies text to the primary selection | ||||
| void COSOperator::copyToPrimarySelection(const c8 *text) const | ||||
| { | ||||
| 	if (strlen(text)==0) | ||||
| 		return; | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| #if SDL_VERSION_ATLEAST(2, 25, 0) | ||||
| 	if (sdl_supports_primary_selection) | ||||
| 		SDL_SetPrimarySelectionText(text); | ||||
| #endif | ||||
|  | ||||
| #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) | ||||
|     if ( IrrDeviceLinux ) | ||||
|         IrrDeviceLinux->copyToPrimarySelection(text); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| //! gets text from the clipboard | ||||
| //! \return Returns 0 if no string is in there, otherwise an utf-8 string. | ||||
| const c8* COSOperator::getTextFromClipboard() const | ||||
| { | ||||
| #if defined(_IRR_WINDOWS_API_) | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| 	SDL_free(ClipboardSelectionText); | ||||
| 	ClipboardSelectionText = SDL_GetClipboardText(); | ||||
| 	return ClipboardSelectionText; | ||||
|  | ||||
| #elif defined(_IRR_WINDOWS_API_) | ||||
| 	if (!OpenClipboard(NULL)) | ||||
| 		return 0; | ||||
|  | ||||
| @@ -147,6 +196,31 @@ const c8* COSOperator::getTextFromClipboard() const | ||||
| } | ||||
|  | ||||
|  | ||||
| //! gets text from the primary selection | ||||
| const c8* COSOperator::getTextFromPrimarySelection() const | ||||
| { | ||||
| #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||||
| #if SDL_VERSION_ATLEAST(2, 25, 0) | ||||
| 	if (sdl_supports_primary_selection) { | ||||
| 		SDL_free(PrimarySelectionText); | ||||
| 		PrimarySelectionText = SDL_GetPrimarySelectionText(); | ||||
| 		return PrimarySelectionText; | ||||
| 	} | ||||
| #endif | ||||
| 	return 0; | ||||
|  | ||||
| #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) | ||||
| 	if ( IrrDeviceLinux ) | ||||
| 		return IrrDeviceLinux->getTextFromPrimarySelection(); | ||||
| 	return 0; | ||||
|  | ||||
| #else | ||||
|  | ||||
| 	return 0; | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const | ||||
| { | ||||
| #if defined(_IRR_WINDOWS_API_) | ||||
|   | ||||
| @@ -23,17 +23,26 @@ public: | ||||
| #endif | ||||
| 	COSOperator(const core::stringc& osversion); | ||||
|  | ||||
| 	~COSOperator(); | ||||
|  | ||||
| 	COSOperator(const COSOperator &) = delete; | ||||
| 	COSOperator &operator=(const COSOperator &) = delete; | ||||
|  | ||||
| 	//! returns the current operation system version as string. | ||||
| 	const core::stringc& getOperatingSystemVersion() const override; | ||||
|  | ||||
| 	//! copies text to the clipboard | ||||
| 	//! \param text: text in utf-8 | ||||
| 	void copyToClipboard(const c8 *text) const override; | ||||
|  | ||||
| 	//! copies text to the primary selection | ||||
| 	void copyToPrimarySelection(const c8 *text) const override; | ||||
|  | ||||
| 	//! gets text from the clipboard | ||||
| 	//! \return Returns 0 if no string is in there, otherwise an utf-8 string. | ||||
| 	const c8* getTextFromClipboard() const override; | ||||
|  | ||||
| 	//! gets text from the primary selection | ||||
| 	const c8* getTextFromPrimarySelection() const override; | ||||
|  | ||||
| 	//! gets the total and available system RAM in kB | ||||
| 	//! \param Total: will contain the total system memory | ||||
| 	//! \param Avail: will contain the available memory | ||||
| @@ -52,6 +61,12 @@ private: | ||||
| 	mutable core::stringc ClipboardBuf; | ||||
| #endif | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | ||||
| 	// These need to be freed with SDL_free | ||||
| 	mutable char *ClipboardSelectionText = nullptr; | ||||
| 	mutable char *PrimarySelectionText = nullptr; | ||||
| #endif | ||||
|  | ||||
| }; | ||||
|  | ||||
| } // end namespace | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OPENGL_CACHE_HANDLER_H_INCLUDED__ | ||||
| #define __C_OPENGL_CACHE_HANDLER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OPENGL_ | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
| #ifndef __C_OPENGL_COMMON_H_INCLUDED__ | ||||
| #define __C_OPENGL_COMMON_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #ifdef _IRR_COMPILE_WITH_OPENGL_ | ||||
|  | ||||
|   | ||||
| @@ -5,9 +5,6 @@ | ||||
| #ifndef __C_OGLCORE_CACHE_HANDLER_H_INCLUDED__ | ||||
| #define __C_OGLCORE_CACHE_HANDLER_H_INCLUDED__ | ||||
|  | ||||
| #include "IrrCompileConfig.h" | ||||
|  | ||||
| #if defined(_IRR_COMPILE_WITH_OPENGL_) || defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_) | ||||
|  | ||||
| #include "SMaterial.h" | ||||
| #include "ITexture.h" | ||||
| @@ -644,4 +641,3 @@ protected: | ||||
| } | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user