Resolve conflicts with master

This commit is contained in:
numzero 2023-03-25 10:42:11 +03:00
commit d97d1708d6
55 changed files with 474 additions and 7166 deletions

File diff suppressed because it is too large Load Diff

View File

@ -87,8 +87,12 @@ int main(int argc, char *argv[])
const io::path mediaPath = getExampleMediaPath();
scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "coolguy_opt.x");
auto mesh_file = device->getFileSystem()->createAndOpenFile(mediaPath + "coolguy_opt.x");
check(mesh_file, "mesh file loading");
scene::IAnimatedMesh* mesh = smgr->getMesh(mesh_file);
check(mesh, "mesh loading");
if (mesh_file)
mesh_file->drop();
if (mesh)
{
video::ITexture* tex = driver->getTexture(mediaPath + "cooltexture.png");

View File

@ -75,18 +75,18 @@ namespace scene
CVertexBuffer(video::E_VERTEX_TYPE vertexType) : Vertices(0),
MappingHint(EHM_NEVER), ChangedID(1)
{
setType(vertexType);
CVertexBuffer::setType(vertexType);
}
CVertexBuffer(const IVertexBuffer &VertexBufferCopy) :
Vertices(0), MappingHint(EHM_NEVER),
ChangedID(1)
{
setType(VertexBufferCopy.getType());
reallocate(VertexBufferCopy.size());
CVertexBuffer::setType(VertexBufferCopy.getType());
CVertexBuffer::reallocate(VertexBufferCopy.size());
for (u32 n=0;n<VertexBufferCopy.size();++n)
push_back(VertexBufferCopy[n]);
CVertexBuffer::push_back(VertexBufferCopy[n]);
}
virtual ~CVertexBuffer()
@ -97,6 +97,9 @@ namespace scene
void setType(video::E_VERTEX_TYPE vertexType) override
{
if ( Vertices && Vertices->getType() == vertexType )
return;
IVertexList *NewVertices=0;
switch (vertexType)

View File

@ -24,10 +24,6 @@ namespace irr
//! A device native to Mac OSX
/** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */
EIDT_OSX,
//! A device native to the iOS
/** This device should be used with the OpenGL-ES driver. */
EIDT_IOS,
//! A device which uses Simple DirectMedia Layer
/** The SDL device works under all platforms supported by SDL but first must be compiled

View File

@ -54,9 +54,9 @@ namespace gui
//! Sets text justification of the text area
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge,
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Set the maximal number of rows for the selection listbox

View File

@ -433,7 +433,7 @@ public:
if (el)
{
// find the highest element number
el->getNextElement(-1, true, IsTabGroup, first, closest, true);
el->getNextElement(-1, true, IsTabGroup, first, closest, true, true);
if (first)
{
TabOrder = first->getTabOrder() + 1;
@ -706,7 +706,7 @@ public:
}
}
// search within children
if ((*it)->getNextElement(startOrder, reverse, group, first, closest))
if ((*it)->getNextElement(startOrder, reverse, group, first, closest, includeInvisible, includeDisabled))
{
return true;
}

View File

@ -88,9 +88,9 @@ namespace gui
//! Sets text justification mode
/** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
EGUIA_LOWEERRIGHT for right justified, or EGUIA_CENTER for centered text.
EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
\param vertical: EGUIA_UPPERLEFT to align with top edge (default),
EGUIA_LOWEERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */
EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
//! Enables or disables word wrap for using the static text as multiline text control.

View File

@ -26,12 +26,23 @@ public:
}
//! Copies text to the clipboard
//! \param text: text in utf-8
virtual void copyToClipboard(const c8* text) const = 0;
//! Copies text to the primary selection
//! This is a no-op on some platforms.
//! \param text: text in utf-8
virtual void copyToPrimarySelection(const c8* text) const = 0;
//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
//! \return Returns 0 if no string is in there, otherwise an utf-8 string.
virtual const c8* getTextFromClipboard() const = 0;
//! Get text from the primary selection
//! This is a no-op on some platforms.
//! \return Returns 0 if no string is in there, otherwise an utf-8 string.
virtual const c8* getTextFromPrimarySelection() const = 0;
//! Get the total and available system RAM
/** \param totalBytes: will contain the total system memory in Kilobytes (1024 B)
\param availableBytes: will contain the available memory in Kilobytes (1024 B)

View File

@ -318,20 +318,10 @@ namespace scene
* \endcode
* If you would like to implement and add your own file format loader to Irrlicht,
* see addExternalMeshLoader().
* \param filename: Filename of the mesh to load.
* \param alternativeCacheName: In case you want to have the mesh under another name in the cache (to create real copies)
* \param file File handle of the mesh to load.
* \return Null if failed, otherwise pointer to the mesh.
* This pointer should not be dropped. See IReferenceCounted::drop() for more information.
**/
virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName=io::path("")) = 0;
//! Get pointer to an animateable mesh. Loads the file if not loaded already.
/** Works just as getMesh(const char* filename). If you want to
remove a loaded mesh from the cache again, use removeMesh().
\param file File handle of the mesh to load.
\return NULL if failed and pointer to the mesh if successful.
This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0;
//! Get interface to the mesh cache which is shared between all existing scene managers.
@ -345,16 +335,6 @@ namespace scene
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual video::IVideoDriver* getVideoDriver() = 0;
//! Get the active GUIEnvironment
/** \return Pointer to the GUIEnvironment
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual gui::IGUIEnvironment* getGUIEnvironment() = 0;
//! Get the active FileSystem
/** \return Pointer to the FileSystem
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual io::IFileSystem* getFileSystem() = 0;
//! Adds a scene node for rendering an animated mesh model.
/** \param mesh: Pointer to the loaded animated mesh to be displayed.
\param parent: Parent of the scene node. Can be NULL if no parent.

View File

@ -747,7 +747,7 @@ namespace video
\param texture Texture to be drawn.
\param destPos Upper left 2d destination position where the
image will be drawn.
\param sourceRect Source rectangle in the image.
\param sourceRect Source rectangle in the texture (based on it's OriginalSize)
\param clipRect Pointer to rectangle on the screen where the
image is clipped to.
If this pointer is NULL the image is not clipped.
@ -768,7 +768,7 @@ namespace video
\param texture Texture to be drawn.
\param positions Array of upper left 2d destinations where the
images will be drawn.
\param sourceRects Source rectangles of the image.
\param sourceRects Source rectangles of the texture (based on it's OriginalSize)
\param clipRect Pointer to rectangle on the screen where the
images are clipped to.
If this pointer is 0 then the image is not clipped.
@ -788,7 +788,7 @@ namespace video
/** Suggested and first implemented by zola.
\param texture The texture to draw from
\param destRect The rectangle to draw into
\param sourceRect The rectangle denoting a part of the texture
\param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize)
\param clipRect Clips the destination rectangle (may be 0)
\param colors Array of 4 colors denoting the color values of
the corners of the destRect
@ -1160,7 +1160,7 @@ namespace video
E_MATERIAL_TYPE enum or a value which was returned by
addMaterialRenderer().
\param name: New name of the material renderer. */
virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
virtual void setMaterialRendererName(u32 idx, const c8* name) =0;
//! Swap the material renderers used for certain id's
/** Swap the IMaterialRenderers responsible for rendering specific

View File

@ -25,7 +25,7 @@ enum E_VERTEX_TYPE
EVT_2TCOORDS,
//! Vertex with a tangent and binormal vector, video::S3DVertexTangents.
/** Usually used for tangent space normal mapping.
/** Usually used for tangent space normal mapping.
Usually tangent and binormal get send to shaders as texture coordinate sets 1 and 2.
*/
EVT_TANGENTS
@ -44,7 +44,7 @@ const char* const sBuiltInVertexTypeNames[] =
struct S3DVertex
{
//! default constructor
S3DVertex() {}
S3DVertex() : Color(0xffffffff) {}
//! constructor
S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
@ -142,7 +142,7 @@ struct S3DVertex2TCoords : public S3DVertex
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
//! constructor from S3DVertex
S3DVertex2TCoords(S3DVertex& o) : S3DVertex(o) {}
S3DVertex2TCoords(const S3DVertex& o) : S3DVertex(o) {}
//! Second set of texture coordinates
core::vector2d<f32> TCoords2;
@ -150,21 +150,21 @@ struct S3DVertex2TCoords : public S3DVertex
//! Equality operator
bool operator==(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(TCoords2 == other.TCoords2));
}
//! Inequality operator
bool operator!=(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(TCoords2 != other.TCoords2));
}
bool operator<(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (TCoords2 < other.TCoords2)));
}
static E_VERTEX_TYPE getType()
@ -186,7 +186,7 @@ struct S3DVertex2TCoords : public S3DVertex
//! Vertex with a tangent and binormal vector.
/** Usually used for tangent space normal mapping.
/** Usually used for tangent space normal mapping.
Usually tangent and binormal get send to shaders as texture coordinate sets 1 and 2.
*/
struct S3DVertexTangents : public S3DVertex
@ -214,6 +214,9 @@ struct S3DVertexTangents : public S3DVertex
const core::vector3df& binormal=core::vector3df())
: S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
//! constructor from S3DVertex
S3DVertexTangents(const S3DVertex& o) : S3DVertex(o) {}
//! Tangent vector along the x-axis of the texture
core::vector3df Tangent;
@ -222,14 +225,14 @@ struct S3DVertexTangents : public S3DVertex
bool operator==(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
return ((static_cast<S3DVertex>(*this)==static_cast<const S3DVertex&>(other)) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
}
bool operator!=(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
return ((static_cast<S3DVertex>(*this)!=static_cast<const S3DVertex&>(other)) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
}
@ -237,8 +240,8 @@ struct S3DVertexTangents : public S3DVertex
bool operator<(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == static_cast<const S3DVertex&>(other)) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
}
static E_VERTEX_TYPE getType()

View File

@ -78,21 +78,6 @@ struct SExposedVideoData
//! The EGLNativeWindowType object.
void* Window;
};
struct SOpenGLiOS
{
//! The EAGLContext object.
void* Context;
//! The subview UIView object where the drawing happens.
void* View;
//! The UIViewController object.
void* ViewController;
//! The UIWindow object.
void* Window;
};
struct SOGLESAndroid
{
@ -107,7 +92,6 @@ struct SExposedVideoData
SOpenGLLinux OpenGLLinux;
SOpenGLOSX OpenGLOSX;
SOpenGLFB OpenGLFB;
SOpenGLiOS OpenGLiOS;
SOGLESAndroid OGLESAndroid;
};
};

View File

@ -235,7 +235,6 @@ namespace irr
/** If this is set to a value other than 0, the Irrlicht Engine
will be created in an already existing window.
For Windows, set this to the HWND of the window you want.
For iOS, assign UIView to this variable.
The windowSize and FullScreen options will be ignored when using
the WindowId parameter. Default this is set to 0.
To make Irrlicht run inside the custom window, you still will

View File

@ -143,7 +143,7 @@ namespace core
//! Set this matrix to the product of two matrices
/** Calculate b*a, no optimization used,
use it if you know you never have a identity matrix */
use it if you know you never have an identity matrix */
CMatrix4<T>& setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b );
//! Multiply by another matrix.
@ -151,7 +151,8 @@ namespace core
CMatrix4<T> operator*(const CMatrix4<T>& other) const;
//! Multiply by another matrix.
/** Calculate and return other*this */
/** Like calling: (*this) = (*this) * other
*/
CMatrix4<T>& operator*=(const CMatrix4<T>& other);
//! Multiply by scalar.
@ -187,14 +188,25 @@ namespace core
//! Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation );
//! Get the rotation, as set by setRotation() when you already know the scale.
/** If you already know the scale then this function is faster than the other getRotationDegrees overload.
NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
//! Get the rotation, as set by setRotation() when you already know the scale used to create the matrix
/** NOTE: The scale needs to be the correct one used to create this matrix.
You can _not_ use the result of getScale(), but have to save your scale
variable in another place (like ISceneNode does).
NOTE: No scale value can be 0 or the result is undefined.
NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(),
but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node.
NOTE: It will (usually) give wrong results when further transformations have been added in the matrix (like shear).
WARNING: There have been troubles with this function over the years and we may still have missed some corner cases.
It's generally safer to keep the rotation and scale you used to create the matrix around and work with those.
*/
core::vector3d<T> getRotationDegrees(const vector3d<T>& scale) const;
//! Returns the rotation, as set by setRotation().
/** NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
NOTE: This only works correct if no other matrix operations have been done on the inner 3x3 matrix besides
setting rotation (so no scale/shear). Thought it (probably) works as long as scale doesn't flip handedness.
NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(),
but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node.
*/
core::vector3d<T> getRotationDegrees() const;
@ -828,11 +840,9 @@ namespace core
//! Returns the absolute values of the scales of the matrix.
/**
Note that this returns the absolute (positive) values unless only scale is set.
Unfortunately it does not appear to be possible to extract any original negative
values. The best that we could do would be to arbitrarily make one scale
negative if one or three of them were negative.
FIXME - return the original values.
Note: You only get back original values if the matrix only set the scale.
Otherwise the result is a scale you can use to normalize the matrix axes,
but it's usually no longer what you did set with setScale.
*/
template <class T>
inline vector3d<T> CMatrix4<T>::getScale() const
@ -895,33 +905,16 @@ namespace core
}
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was originally written by by Chev.
//! Returns a rotation which (mostly) works in combination with the given scale
/**
This code was originally written by by Chev (assuming no scaling back then,
we can be blamed for all problems added by regarding scale)
*/
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees(const vector3d<T>& scale_) const
{
const CMatrix4<T> &mat = *this;
core::vector3d<T> scale(scale_);
// we need to check for negative scale on to axes, which would bring up wrong results
if (scale.Y<0 && scale.Z<0)
{
scale.Y =-scale.Y;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Z<0)
{
scale.X =-scale.X;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Y<0)
{
scale.X =-scale.X;
scale.Y =-scale.Y;
}
const core::vector3d<f64> scale(core::iszero(scale_.X) ? FLT_MAX : scale_.X , core::iszero(scale_.Y) ? FLT_MAX : scale_.Y, core::iszero(scale_.Z) ? FLT_MAX : scale_.Z);
const core::vector3d<f64> invScale(core::reciprocal(scale.X),core::reciprocal(scale.Y),core::reciprocal(scale.Z));
f64 Y = -asin(core::clamp(mat[2]*invScale.X, -1.0, 1.0));
@ -930,7 +923,7 @@ namespace core
f64 rotx, roty, X, Z;
if (!core::iszero(C))
if (!core::iszero((T)C))
{
const f64 invC = core::reciprocal(C);
rotx = mat[10] * invC * invScale.Z;
@ -957,14 +950,37 @@ namespace core
}
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was originally written by by Chev. */
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const
{
return getRotationDegrees(getScale());
// Note: Using getScale() here make it look like it could do matrix decomposition.
// It can't! It works (or should work) as long as rotation doesn't flip the handedness
// aka scale swapping 1 or 3 axes. (I think we could catch that as well by comparing
// crossproduct of first 2 axes to direction of third axis, but TODO)
// And maybe it should also offer the solution for the simple calculation
// without regarding scaling as Irrlicht did before 1.7
core::vector3d<T> scale(getScale());
// We assume the matrix uses rotations instead of negative scaling 2 axes.
// Otherwise it fails even for some simple cases, like rotating around
// 2 axes by 180° which getScale thinks is a negative scaling.
if (scale.Y<0 && scale.Z<0)
{
scale.Y =-scale.Y;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Z<0)
{
scale.X =-scale.X;
scale.Z =-scale.Z;
}
else if (scale.X<0 && scale.Y<0)
{
scale.X =-scale.X;
scale.Y =-scale.Y;
}
return getRotationDegrees(scale);
}
@ -1156,10 +1172,10 @@ namespace core
template <class T>
inline void CMatrix4<T>::rotateVect( vector3df& vect ) const
{
vector3df tmp = vect;
vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8];
vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9];
vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10];
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]);
vect.Y = static_cast<f32>(tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]);
vect.Z = static_cast<f32>(tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]);
}
//! An alternate transform vector method, writing into a second vector
@ -1183,24 +1199,24 @@ namespace core
template <class T>
inline void CMatrix4<T>::inverseRotateVect( vector3df& vect ) const
{
vector3df tmp = vect;
vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2];
vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6];
vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10];
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]);
vect.Y = static_cast<f32>(tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]);
vect.Z = static_cast<f32>(tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]);
}
template <class T>
inline void CMatrix4<T>::transformVect( vector3df& vect) const
{
f32 vector[3];
T vector[3];
vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12];
vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13];
vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14];
vect.X = vector[0];
vect.Y = vector[1];
vect.Z = vector[2];
vect.X = static_cast<f32>(vector[0]);
vect.Y = static_cast<f32>(vector[1]);
vect.Z = static_cast<f32>(vector[2]);
}
template <class T>

View File

@ -94,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);
}
@ -476,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++)

View File

@ -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);

View File

@ -141,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;
}
@ -162,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);
}
@ -182,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);
}

View File

@ -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();

View File

@ -1,86 +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__
#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

View File

@ -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

View File

@ -24,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>

View File

@ -1135,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;
}
@ -1624,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);
}
}

View File

@ -22,10 +22,10 @@ namespace gui
CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip,
bool drawBack, bool moveOverSelect)
: IGUIListBox(environment, parent, id, rectangle), Selected(-1),
: IGUIListBox(environment, parent, id, rectangle), Selected(-1), HoverSelected(-1),
ItemHeight(0),ItemHeightOverride(0),
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
ScrollBar(0), SelectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
{
#ifdef _DEBUG
@ -116,7 +116,7 @@ void CGUIListBox::removeItem(u32 id)
else if ((u32)Selected > id)
{
Selected -= 1;
selectTime = os::Timer::getTime();
SelectTime = os::Timer::getTime();
}
Items.erase(id);
@ -148,6 +148,7 @@ void CGUIListBox::clear()
Items.clear();
ItemsIconWidth = 0;
Selected = -1;
HoverSelected = -1;
ScrollBar->setPos(0);
@ -192,7 +193,7 @@ void CGUIListBox::recalculateItemHeight()
//! returns id of selected item. returns -1 if no item is selected.
s32 CGUIListBox::getSelected() const
{
return Selected;
return HoverSelected >= 0 ? HoverSelected : Selected;
}
@ -204,7 +205,8 @@ void CGUIListBox::setSelected(s32 id)
else
Selected = id;
selectTime = os::Timer::getTime();
HoverSelected = -1;
SelectTime = os::Timer::getTime();
recalculateScrollPos();
}
@ -454,14 +456,19 @@ void CGUIListBox::selectNew(s32 ypos, bool onlyHover)
u32 now = os::Timer::getTime();
s32 oldSelected = Selected;
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
if (Selected<0 && !Items.empty())
Selected = 0;
HoverSelected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
if (HoverSelected<0 && !Items.empty())
HoverSelected = 0;
if (!onlyHover)
{
Selected = HoverSelected;
HoverSelected = -1;
}
recalculateScrollPos();
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
selectTime = now;
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < SelectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
SelectTime = now;
// post the news
if (Parent && !onlyHover)
{
@ -527,13 +534,14 @@ void CGUIListBox::draw()
frameRect.LowerRightCorner.Y -= ScrollBar->getPos();
bool hl = (HighlightWhenNotFocused || Environment->hasFocus(this) || Environment->hasFocus(ScrollBar));
const irr::s32 selected = getSelected();
for (s32 i=0; i<(s32)Items.size(); ++i)
{
if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y &&
frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y)
{
if (i == Selected && hl)
if (i == selected && hl)
skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip);
core::rect<s32> textRect = frameRect;
@ -547,24 +555,24 @@ void CGUIListBox::draw()
iconPos.Y += textRect.getHeight() / 2;
iconPos.X += ItemsIconWidth/2;
if ( i==Selected && hl )
if ( i==selected && hl )
{
IconBank->draw2DSprite( (u32)Items[i].Icon, iconPos, &clientClip,
hasItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) ?
getItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_ICON_HIGHLIGHT),
selectTime, os::Timer::getTime(), false, true);
SelectTime, os::Timer::getTime(), false, true);
}
else
{
IconBank->draw2DSprite( (u32)Items[i].Icon, iconPos, &clientClip,
hasItemOverrideColor(i, EGUI_LBC_ICON) ? getItemOverrideColor(i, EGUI_LBC_ICON) : getItemDefaultColor(EGUI_LBC_ICON),
0 , (i==Selected) ? os::Timer::getTime() : 0, false, true);
0 , (i==selected) ? os::Timer::getTime() : 0, false, true);
}
}
textRect.UpperLeftCorner.X += ItemsIconWidth+3;
if ( i==Selected && hl )
if ( i==selected && hl )
{
Font->draw(Items[i].Text.c_str(), textRect,
hasItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) ?

View File

@ -154,6 +154,7 @@ namespace gui
core::array< ListItem > Items;
s32 Selected;
s32 HoverSelected; // When >= 0 we're in the middle of changing selection while mouse is pressed. We need to know so selected again isn't called too often.
s32 ItemHeight;
s32 ItemHeightOverride;
s32 TotalItemHeight;
@ -161,7 +162,7 @@ namespace gui
gui::IGUIFont* Font;
gui::IGUISpriteBank* IconBank;
gui::IGUIScrollBar* ScrollBar;
u32 selectTime;
u32 SelectTime;
u32 LastKeyTime;
core::stringw KeyBuffer;
bool Selecting;

View File

@ -31,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)
@ -132,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;
@ -162,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;
@ -200,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;

View File

@ -64,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
{

View File

@ -194,7 +194,7 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo
{
if (pitch==Pitch)
{
memcpy(target, Data, height*pitch);
memcpy(target, Data, (size_t)height*pitch);
return;
}
else

View File

@ -80,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;
}
@ -96,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;
}
@ -104,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;
}
@ -212,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;
}
@ -221,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;

View File

@ -106,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;
}

View File

@ -69,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;
}
@ -77,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;
}
@ -126,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;
}
@ -160,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;

View File

@ -287,26 +287,26 @@ 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;
}
}
@ -380,7 +380,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
@ -1000,12 +1000,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:
//~ {
@ -1026,8 +1029,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;
}
@ -1052,8 +1055,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 {
@ -1676,47 +1679,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
@ -1743,15 +1748,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) {
@ -1760,20 +1765,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
{
@ -1781,22 +1815,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;

View File

@ -97,11 +97,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;
@ -141,6 +150,9 @@ namespace irr
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
@ -413,6 +425,7 @@ 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;

View File

@ -243,7 +243,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());
Close = true;
}
else

View File

@ -92,7 +92,7 @@ void CIrrDeviceStub::createGUIAndScene()
GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator);
// create Scene manager
SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment);
SceneManager = scene::createSceneManager(VideoDriver, CursorControl);
setEventReceiver(UserReceiver);
}

View File

@ -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

View File

@ -121,8 +121,8 @@ namespace irr
if (dev)
{
dev->Unacquire();
dev->Release();
}
dev->Release();
}
if (DirectInputDevice)

View File

@ -1,76 +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__
#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

View File

@ -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

View File

@ -77,22 +77,13 @@ add_definitions(
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(SOLARIS TRUE)
endif()
if(APPLE AND NOT IOS)
set(OSX TRUE)
endif()
# Device
if(WIN32)
add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_)
set(DEVICE "WINDOWS")
elseif(IOS)
add_definitions(-D_IRR_IOS_PLATFORM_ -D_IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_)
if(USE_SDL2)
message(SEND_ERROR "SDL2 backend is not supported on iOS")
endif()
set(DEVICE "IOS")
elseif(OSX)
elseif(APPLE)
add_definitions(-D_IRR_OSX_PLATFORM_)
set(DEVICE "OSX")
elseif(ANDROID)
@ -150,26 +141,26 @@ endif()
option(ENABLE_OPENGL3 "Enable OpenGL 3+" FALSE)
if(IOS OR ANDROID OR EMSCRIPTEN)
if(ANDROID OR EMSCRIPTEN)
set(ENABLE_OPENGL FALSE)
else()
option(ENABLE_OPENGL "Enable OpenGL" TRUE)
endif()
if(EMSCRIPTEN OR OSX)
if(EMSCRIPTEN OR APPLE)
set(ENABLE_GLES1 FALSE)
else()
if(ANDROID OR IOS)
if(ANDROID)
set(DEFAULT_GLES1 TRUE)
endif()
option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1})
endif()
if(OSX)
if(APPLE)
set(ENABLE_GLES2 FALSE)
set(ENABLE_WEBGL1 FALSE)
else()
if(ANDROID OR IOS OR EMSCRIPTEN)
if(ANDROID OR EMSCRIPTEN)
set(DEFAULT_GLES2 TRUE)
endif()
if(EMSCRIPTEN)
@ -210,8 +201,6 @@ if(ENABLE_GLES1)
add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$")
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_)
elseif(DEVICE STREQUAL "IOS")
add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
endif()
endif()
@ -219,8 +208,6 @@ if(ENABLE_GLES2)
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN)
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_)
elseif(DEVICE STREQUAL "IOS")
add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
elseif(DEVICE STREQUAL "SDL")
set(USE_SDLGL ON)
set(USE_SDLGLES2 ON)

View File

@ -1717,10 +1717,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;

View File

@ -584,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;

View File

@ -24,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();
}
@ -76,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);
@ -230,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;
}

View File

@ -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;
};

View File

@ -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 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
{
@ -54,14 +70,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 +119,36 @@ 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_)
static char *text = nullptr;
if (text)
SDL_free(text);
text = SDL_GetClipboardText();
return text;
#elif defined(_IRR_WINDOWS_API_)
if (!OpenClipboard(NULL))
return 0;
@ -147,6 +189,33 @@ 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) {
static char *text = nullptr;
if (text)
SDL_free(text);
text = SDL_GetPrimarySelectionText();
return text;
}
#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_)

View File

@ -27,13 +27,17 @@ public:
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

View File

@ -746,10 +746,10 @@ IRenderTarget* COpenGLDriver::addRenderTarget()
}
// small helper function to create vertex buffer object adress offsets
static inline u8* buffer_offset(const long offset)
// small helper function to create vertex buffer object address offsets
static inline const GLvoid * buffer_offset(const long offset)
{
return ((u8*)0 + offset);
return (const GLvoid *)offset;
}

View File

@ -33,10 +33,9 @@ namespace scene
{
//! constructor
CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
gui::ICursorControl* cursorControl, IMeshCache* cache,
gui::IGUIEnvironment* gui)
: ISceneNode(0, 0), Driver(driver), FileSystem(fs), GUIEnvironment(gui),
CSceneManager::CSceneManager(video::IVideoDriver* driver,
gui::ICursorControl* cursorControl, IMeshCache* cache)
: ISceneNode(0, 0), Driver(driver),
CursorControl(cursorControl),
ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0), Parameters(0),
MeshCache(cache), CurrentRenderPass(ESNRP_NONE)
@ -52,15 +51,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
if (Driver)
Driver->grab();
if (FileSystem)
FileSystem->grab();
if (CursorControl)
CursorControl->grab();
if (GUIEnvironment)
GUIEnvironment->grab();
// create mesh cache if not there already
if (!MeshCache)
MeshCache = new CMeshCache();
@ -79,8 +72,8 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
// TODO: now that we have multiple scene managers, these should be
// shallow copies from the previous manager if there is one.
MeshLoaderList.push_back(new CXMeshFileLoader(this, FileSystem));
MeshLoaderList.push_back(new COBJMeshFileLoader(this, FileSystem));
MeshLoaderList.push_back(new CXMeshFileLoader(this));
MeshLoaderList.push_back(new COBJMeshFileLoader(this));
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
}
@ -96,18 +89,12 @@ CSceneManager::~CSceneManager()
if (Driver)
Driver->removeAllHardwareBuffers();
if (FileSystem)
FileSystem->drop();
if (CursorControl)
CursorControl->drop();
if (CollisionManager)
CollisionManager->drop();
if (GUIEnvironment)
GUIEnvironment->drop();
u32 i;
for (i=0; i<MeshLoaderList.size(); ++i)
MeshLoaderList[i]->drop();
@ -132,29 +119,6 @@ CSceneManager::~CSceneManager()
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(const io::path& filename, const io::path& alternativeCacheName)
{
io::path cacheName = alternativeCacheName.empty() ? filename : alternativeCacheName;
IAnimatedMesh* msh = MeshCache->getMeshByName(cacheName);
if (msh)
return msh;
io::IReadFile* file = FileSystem->createAndOpenFile(filename);
if (!file)
{
os::Printer::log("Could not load mesh, because file could not be opened: ", filename, ELL_ERROR);
return 0;
}
msh = getUncachedMesh(file, filename, cacheName);
file->drop();
return msh;
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file)
{
@ -209,21 +173,6 @@ video::IVideoDriver* CSceneManager::getVideoDriver()
}
//! returns the GUI Environment
gui::IGUIEnvironment* CSceneManager::getGUIEnvironment()
{
return GUIEnvironment;
}
//! Get the active FileSystem
/** \return Pointer to the FileSystem
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
io::IFileSystem* CSceneManager::getFileSystem()
{
return FileSystem;
}
//! adds a scene node for rendering a static mesh
//! the returned pointer must not be dropped.
IMeshSceneNode* CSceneManager::addMeshSceneNode(IMesh* mesh, ISceneNode* parent, s32 id,
@ -888,7 +837,7 @@ IMeshCache* CSceneManager::getMeshCache()
//! Creates a new scene manager.
ISceneManager* CSceneManager::createNewSceneManager(bool cloneContent)
{
CSceneManager* manager = new CSceneManager(Driver, FileSystem, CursorControl, MeshCache, GUIEnvironment);
CSceneManager* manager = new CSceneManager(Driver, CursorControl, MeshCache);
if (cloneContent)
manager->cloneMembers(this, manager);
@ -925,11 +874,9 @@ IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type)
// creates a scenemanager
ISceneManager* createSceneManager(video::IVideoDriver* driver,
io::IFileSystem* fs, gui::ICursorControl* cursorcontrol,
gui::IGUIEnvironment *guiEnvironment)
ISceneManager* createSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorcontrol)
{
return new CSceneManager(driver, fs, cursorcontrol, 0, guiEnvironment );
return new CSceneManager(driver, cursorcontrol, nullptr);
}

View File

@ -31,16 +31,11 @@ namespace scene
public:
//! constructor
CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
gui::ICursorControl* cursorControl, IMeshCache* cache = 0,
gui::IGUIEnvironment *guiEnvironment = 0);
CSceneManager(video::IVideoDriver* driver, gui::ICursorControl* cursorControl, IMeshCache* cache = 0);
//! destructor
virtual ~CSceneManager();
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName) override;
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* getMesh(io::IReadFile* file) override;
@ -50,12 +45,6 @@ namespace scene
//! returns the video driver
video::IVideoDriver* getVideoDriver() override;
//! return the gui environment
gui::IGUIEnvironment* getGUIEnvironment() override;
//! return the filesystem
io::IFileSystem* getFileSystem() override;
//! adds a scene node for rendering an animated mesh model
virtual IAnimatedMeshSceneNode* addAnimatedMeshSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0),
@ -282,12 +271,6 @@ namespace scene
//! video driver
video::IVideoDriver* Driver;
//! file system
io::IFileSystem* FileSystem;
//! GUI Enviroment ( Debug Purpose )
gui::IGUIEnvironment* GUIEnvironment;
//! cursor control
gui::ICursorControl* CursorControl;

View File

@ -1134,27 +1134,27 @@ void CSkinnedMesh::finalize()
if ( redundantPosKeys > 0 )
{
os::Printer::log("Skinned Mesh - redundant position frames kicked:", core::stringc(redundantPosKeys).c_str(), ELL_DEBUG);
os::Printer::log("Skinned Mesh - redundant position frames kicked", core::stringc(redundantPosKeys).c_str(), ELL_DEBUG);
}
if ( unorderedPosKeys > 0 )
{
irr::os::Printer::log("Skinned Mesh - unsorted position frames kicked:", irr::core::stringc(unorderedPosKeys).c_str(), irr::ELL_DEBUG);
irr::os::Printer::log("Skinned Mesh - unsorted position frames kicked", irr::core::stringc(unorderedPosKeys).c_str(), irr::ELL_DEBUG);
}
if ( redundantScaleKeys > 0 )
{
os::Printer::log("Skinned Mesh - redundant scale frames kicked:", core::stringc(redundantScaleKeys).c_str(), ELL_DEBUG);
os::Printer::log("Skinned Mesh - redundant scale frames kicked", core::stringc(redundantScaleKeys).c_str(), ELL_DEBUG);
}
if ( unorderedScaleKeys > 0 )
{
irr::os::Printer::log("Skinned Mesh - unsorted scale frames kicked:", irr::core::stringc(unorderedScaleKeys).c_str(), irr::ELL_DEBUG);
irr::os::Printer::log("Skinned Mesh - unsorted scale frames kicked", irr::core::stringc(unorderedScaleKeys).c_str(), irr::ELL_DEBUG);
}
if ( redundantRotationKeys > 0 )
{
os::Printer::log("Skinned Mesh - redundant rotation frames kicked:", core::stringc(redundantRotationKeys).c_str(), ELL_DEBUG);
os::Printer::log("Skinned Mesh - redundant rotation frames kicked", core::stringc(redundantRotationKeys).c_str(), ELL_DEBUG);
}
if ( unorderedRotationKeys > 0 )
{
irr::os::Printer::log("Skinned Mesh - unsorted rotation frames kicked:", irr::core::stringc(unorderedRotationKeys).c_str(), irr::ELL_DEBUG);
irr::os::Printer::log("Skinned Mesh - unsorted rotation frames kicked", irr::core::stringc(unorderedRotationKeys).c_str(), irr::ELL_DEBUG);
}
}
@ -1347,9 +1347,24 @@ void CSkinnedMesh::recoverJointsFromMesh(core::array<IBoneSceneNode*> &jointChil
{
IBoneSceneNode* node=jointChildSceneNodes[i];
SJoint *joint=AllJoints[i];
node->setPosition(joint->LocalAnimatedMatrix.getTranslation());
node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees());
node->setScale(joint->LocalAnimatedMatrix.getScale());
if ( joint->UseAnimationFrom ) // Seems to work better (else solution seems to mess up sometimes) and would be faster. Any disadvantage?
{
node->setPosition(joint->Animatedposition);
core::quaternion qrot = joint->Animatedrotation;
qrot.W *= -1.f; // Animation system uses right-handed rotations? Argh...
irr::core::vector3df euler;
qrot.toEuler(euler);
euler *= core::RADTODEG;
node->setRotation(euler);
node->setScale(joint->Animatedscale);
}
else
{
node->setPosition(joint->LocalAnimatedMatrix.getTranslation());
node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees());
node->setScale(joint->LocalAnimatedMatrix.getScale());
}
node->positionHint=joint->positionHint;
node->scaleHint=joint->scaleHint;

View File

@ -464,7 +464,7 @@ bool CWGLManager::activateContext(const SExposedVideoData& videoData, bool resto
{
if (!wglMakeCurrent((HDC)PrimaryContext.OpenGLWin32.HDc, (HGLRC)PrimaryContext.OpenGLWin32.HRc))
{
os::Printer::log("Render Context switch failed.");
os::Printer::log("Render Context switch (back to main) failed.");
return false;
}
CurrentContext=PrimaryContext;

View File

@ -10,7 +10,6 @@
#include "coreutil.h"
#include "ISceneManager.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "IReadFile.h"
#ifdef _DEBUG
@ -24,7 +23,7 @@ namespace scene
{
//! Constructor
CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs)
CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr)
: AnimatedMesh(0), Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0),
CurFrame(0), MajorVersion(0), MinorVersion(0), BinaryFormat(false), FloatSize(0)
{
@ -480,7 +479,7 @@ bool CXMeshFileLoader::parseDataObject()
// parse specific object
#ifdef _XREADER_DEBUG
os::Printer::log("debug DataObject:", objectName.c_str(), ELL_DEBUG);
os::Printer::log("debug DataObject", objectName.c_str(), ELL_DEBUG);
#endif
if (objectName == "template")
@ -833,7 +832,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
}
#ifdef _XREADER_DEBUG
os::Printer::log("debug DataObject in mesh:", objectName.c_str(), ELL_DEBUG);
os::Printer::log("debug DataObject in mesh", objectName.c_str(), ELL_DEBUG);
#endif
if (objectName == "MeshNormals")

View File

@ -14,7 +14,6 @@ namespace irr
{
namespace io
{
class IFileSystem;
class IReadFile;
} // end namespace io
namespace scene
@ -27,7 +26,7 @@ class CXMeshFileLoader : public IMeshLoader
public:
//! Constructor
CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
CXMeshFileLoader(scene::ISceneManager* smgr);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".cob")

View File

@ -29,10 +29,6 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Geb
#include "CIrrDeviceSDL.h"
#endif
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_
#include "CIrrDeviceiOS.h"
#endif
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
#include "Android/CIrrDeviceAndroid.h"
#endif
@ -78,11 +74,6 @@ namespace irr
if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceLinux(params);
#endif
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_
if (params.DeviceType == EIDT_IOS || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceiOS(params);
#endif
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST))

View File

@ -17,7 +17,7 @@
#define bswap_32(X) _byteswap_ulong(X)
#define bswap_64(X) _byteswap_uint64(X)
#define localtime _localtime_s
#elif defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)
#elif defined(_IRR_OSX_PLATFORM_)
#include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0)
#define bswap_32(X) OSReadSwapInt32(&X,0)

View File

@ -38,6 +38,8 @@ namespace os
static void print(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION);
static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION);
static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION);
// The string ": " is added between message and hint
static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION);
static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION);
static ILogger* Logger;