12 Commits

Author SHA1 Message Date
1d43ea17ca Bump revision 2023-03-05 21:45:09 +01:00
09e6eeb65b Remove irr::core::hash
Its use of std::unary_function was deprecated.
And it wasn't used anywhere.
2023-02-22 11:43:42 +01:00
839bdc1a65 Fix -Wignored-qualifiers warnings in irrUString.h 2023-02-22 11:43:42 +01:00
ea297196b7 Resolve some -Wreorder warnings 2023-02-22 11:43:42 +01:00
DS
5527b9f373 SDL: Use SDL_WINDOW_FULLSCREEN_DESKTOP and allow to maximize+fullscreen at once (#156) 2023-02-20 13:22:28 +01:00
cd3e784534 Refactor SDL input code to fix menu exit (#146) 2023-02-18 16:16:17 +01:00
DS
51dffc416a Add WindowMaximized creation parameter and isWindowMaximized() (#142) 2023-02-06 15:05:44 +01:00
8f13ae81e5 Merge pull request #154 from lhofhansl/skinned
Avoid reskinning joints for animated meshes twice for each frame.
2023-01-12 11:02:52 -08:00
3de3ff524a Avoid reskinning joints for animated meshes twice for each frame. 2023-01-07 16:59:02 -08:00
7d3142b969 Remove leftover code from software rendering 2023-01-02 21:21:53 +01:00
a9230e5f49 Delete profiler 2023-01-02 21:05:07 +01:00
b5a6dc0a15 Delete leak hunter 2023-01-02 20:37:18 +01:00
36 changed files with 258 additions and 1434 deletions

View File

@ -7,7 +7,7 @@ else()
cmake_policy(VERSION 3.9)
endif()
set(IRRLICHTMT_REVISION 9)
set(IRRLICHTMT_REVISION 10)
project(Irrlicht
VERSION 1.9.0.${IRRLICHTMT_REVISION}

View File

@ -91,9 +91,6 @@ enum EGUI_ELEMENT_TYPE
//! The root of the GUI
EGUIET_ROOT,
//! IGUIProfiler
EGUIET_PROFILER,
//! Not an element, amount of elements in there
EGUIET_COUNT,

View File

@ -1,480 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __I_PROFILER_H_INCLUDED__
#define __I_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "irrString.h"
#include "irrArray.h"
#include "ITimer.h"
#include <limits.h> // for INT_MAX (we should have a S32_MAX...)
namespace irr
{
class ITimer;
//! Used to store the profile data (and also used for profile group data).
struct SProfileData
{
friend class IProfiler;
SProfileData()
{
GroupIndex = 0;
reset();
}
bool operator<(const SProfileData& pd) const
{
return Id < pd.Id;
}
bool operator==(const SProfileData& pd) const
{
return Id == pd.Id;
}
u32 getGroupIndex() const
{
return GroupIndex;
}
const core::stringw& getName() const
{
return Name;
}
//! Each time profiling for this data is stopped it increases the counter by 1.
u32 getCallsCounter() const
{
return CountCalls;
}
//! Longest time a profile call for this id took from start until it was stopped again.
u32 getLongestTime() const
{
return LongestTime;
}
//! Time spend between start/stop
u32 getTimeSum() const
{
return TimeSum;
}
private:
// just to be used for searching as it does no initialization besides id
SProfileData(u32 id) : Id(id) {}
void reset()
{
CountCalls = 0;
LongestTime = 0;
TimeSum = 0;
LastTimeStarted = 0;
StartStopCounter = 0;
}
s32 Id;
u32 GroupIndex;
core::stringw Name;
s32 StartStopCounter; // 0 means stopped > 0 means it runs.
u32 CountCalls;
u32 LongestTime;
u32 TimeSum;
u32 LastTimeStarted;
};
//! Code-profiler. Please check the example in the Irrlicht examples folder about how to use it.
// Implementer notes:
// The design is all about allowing to use the central start/stop mechanism with minimal time overhead.
// This is why the class works without a virtual functions interface contrary to the usual Irrlicht design.
// And also why it works with id's instead of strings in the start/stop functions even if it makes using
// the class slightly harder.
// The class comes without reference-counting because the profiler instance is never released (TBD).
class IProfiler
{
public:
//! Constructor. You could use this to create a new profiler, but usually getProfiler() is used to access the global instance.
IProfiler() : Timer(0), NextAutoId(INT_MAX)
{}
virtual ~IProfiler()
{}
//! Add an id with given name and group which can be used for profiling with start/stop
/** After calling this once you can start/stop profiling for the given id.
\param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been added automatically by the other add function.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
inline void add(s32 id, const core::stringw &name, const core::stringw &groupName);
//! Add an automatically generated for the given name and group which can be used for profiling with start/stop.
/** After calling this once you can start/stop profiling with the returned id.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data.
\return Automatic id's start at INT_MAX and count down for each new id. If the name already has an id then that id will be returned. */
inline s32 add(const core::stringw &name, const core::stringw &groupName);
//! Return the number of profile data blocks. There is one for each id.
u32 getProfileDataCount() const
{
return ProfileDatas.size();
}
//! Search for the index of the profile data by name
/** \param result Receives the resulting data index when one was found.
\param name String with name to search for
\return true when found, false when not found */
inline bool findDataIndex(u32 & result, const core::stringw &name) const;
//! Get the profile data
/** \param index A value between 0 and getProfileDataCount()-1. Indices can change when new id's are added.*/
const SProfileData& getProfileDataByIndex(u32 index) const
{
return ProfileDatas[index];
}
//! Get the profile data
/** \param id Same value as used in ::add
\return Profile data for the given id or 0 when it does not exist. */
inline const SProfileData* getProfileDataById(u32 id);
//! Get the number of profile groups. Will be at least 1.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
inline u32 getGroupCount() const
{
return ProfileGroups.size();
}
//! Get profile data for a group.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
inline const SProfileData& getGroupData(u32 index) const
{
return ProfileGroups[index];
}
//! Find the group index by the group-name
/** \param result Receives the resulting group index when one was found.
\param name String with name to search for
\return true when found, false when not found */
inline bool findGroupIndex(u32 & result, const core::stringw &name) const;
//! Start profile-timing for the given id
/** This increases an internal run-counter for the given id. It will profile as long as that counter is > 0.
NOTE: you have to add the id first with one of the ::add functions
*/
inline void start(s32 id);
//! Stop profile-timing for the given id
/** This increases an internal run-counter for the given id. If it reaches 0 the time since start is recorded.
You should have the same amount of start and stop calls. If stop is called more often than start
then the additional stop calls will be ignored (counter never goes below 0)
*/
inline void stop(s32 id);
//! Reset profile data for the given id
inline void resetDataById(s32 id);
//! Reset profile data for the given index
inline void resetDataByIndex(u32 index);
//! Reset profile data for a whole group
inline void resetGroup(u32 index);
//! Reset all profile data
/** NOTE: This is not deleting id's or groups, just resetting all timers to 0. */
inline void resetAll();
//! Write all profile-data into a string
/** \param result Receives the result string.
\param includeOverview When true a group-overview is attached first
\param suppressUncalled When true elements which got never called are not printed */
virtual void printAll(core::stringw &result, bool includeOverview=false,bool suppressUncalled=true) const = 0;
//! Write the profile data of one group into a string
/** \param result Receives the result string.
\param groupIndex_ */
virtual void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const = 0;
protected:
inline u32 addGroup(const core::stringw &name);
// I would prefer using os::Timer, but os.h is not in the public interface so far.
// Timer must be initialized by the implementation.
ITimer * Timer;
core::array<SProfileData> ProfileDatas;
core::array<SProfileData> ProfileGroups;
private:
s32 NextAutoId; // for giving out id's automatically
};
//! Access the Irrlicht profiler object.
/** Profiler is always accessible, except in destruction of global objects.
If you want to get internal profiling information about the engine itself
you will have to re-compile the engine with _IRR_COMPILE_WITH_PROFILING_ enabled.
But you can use the profiler for profiling your own projects without that. */
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler();
//! Class where the objects profile their own life-time.
/** This is a comfort wrapper around the IProfiler start/stop mechanism which is easier to use
when you want to profile a scope. You only have to create an object and it will profile it's own lifetime
for the given id. */
class CProfileScope
{
public:
//! Construct with an known id.
/** This is the fastest scope constructor, but the id must have been added before.
\param id Any id which you did add to the profiler before. */
CProfileScope(s32 id)
: Id(id), Profiler(getProfiler())
{
Profiler.start(Id);
}
//! Object will create the given name, groupName combination for the id if it doesn't exist already
/** \param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been created already by the automatic add function of ::IProfiler.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(s32 id, const core::stringw &name, const core::stringw &groupName)
: Id(id), Profiler(getProfiler())
{
Profiler.add(Id, name, groupName);
Profiler.start(Id);
}
//! Object will create an id for the given name, groupName combination if they don't exist already
/** Slowest scope constructor, but usually still fine unless speed is very critical.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(const core::stringw &name, const core::stringw &groupName)
: Profiler(getProfiler())
{
Id = Profiler.add(name, groupName);
Profiler.start(Id);
}
~CProfileScope()
{
Profiler.stop(Id);
}
protected:
s32 Id;
IProfiler& Profiler;
};
// IMPLEMENTATION for in-line stuff
void IProfiler::start(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 && Timer )
{
++ProfileDatas[idx].StartStopCounter;
if (ProfileDatas[idx].StartStopCounter == 1 )
ProfileDatas[idx].LastTimeStarted = Timer->getRealTime();
}
}
void IProfiler::stop(s32 id)
{
if ( Timer )
{
u32 timeNow = Timer->getRealTime();
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
SProfileData &data = ProfileDatas[idx];
--ProfileDatas[idx].StartStopCounter;
if ( data.LastTimeStarted != 0 && ProfileDatas[idx].StartStopCounter == 0)
{
// update data for this id
++data.CountCalls;
u32 diffTime = timeNow - data.LastTimeStarted;
data.TimeSum += diffTime;
if ( diffTime > data.LongestTime )
data.LongestTime = diffTime;
data.LastTimeStarted = 0;
// update data of it's group
SProfileData & group = ProfileGroups[data.GroupIndex];
++group.CountCalls;
group.TimeSum += diffTime;
if ( diffTime > group.LongestTime )
group.LongestTime = diffTime;
group.LastTimeStarted = 0;
}
else if ( ProfileDatas[idx].StartStopCounter < 0 )
{
// ignore additional stop calls
ProfileDatas[idx].StartStopCounter = 0;
}
}
}
}
s32 IProfiler::add(const core::stringw &name, const core::stringw &groupName)
{
u32 index;
if ( findDataIndex(index, name) )
{
add( ProfileDatas[index].Id, name, groupName );
return ProfileDatas[index].Id;
}
else
{
s32 id = NextAutoId;
--NextAutoId;
add( id, name, groupName );
return id;
}
}
void IProfiler::add(s32 id, const core::stringw &name, const core::stringw &groupName)
{
u32 groupIdx;
if ( !findGroupIndex(groupIdx, groupName) )
{
groupIdx = addGroup(groupName);
}
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx < 0 )
{
data.reset();
data.GroupIndex = groupIdx;
data.Name = name;
ProfileDatas.push_back(data);
ProfileDatas.sort();
}
else
{
// only reset on group changes, otherwise we want to keep the data or coding CProfileScope would become tricky.
if ( groupIdx != ProfileDatas[idx].GroupIndex )
{
resetDataByIndex((u32)idx);
ProfileDatas[idx].GroupIndex = groupIdx;
}
ProfileDatas[idx].Name = name;
}
}
u32 IProfiler::addGroup(const core::stringw &name)
{
SProfileData group;
group.Id = -1; // Id for groups doesn't matter so far
group.Name = name;
ProfileGroups.push_back(group);
return ProfileGroups.size()-1;
}
bool IProfiler::findDataIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
const SProfileData* IProfiler::getProfileDataById(u32 id)
{
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx >= 0 )
return &ProfileDatas[idx];
return NULL;
}
bool IProfiler::findGroupIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileGroups.size(); ++i )
{
if ( ProfileGroups[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
void IProfiler::resetDataById(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
resetDataByIndex((u32)idx);
}
}
void IProfiler::resetDataByIndex(u32 index)
{
SProfileData &data = ProfileDatas[index];
SProfileData & group = ProfileGroups[data.GroupIndex];
group.CountCalls -= data.CountCalls;
group.TimeSum -= data.TimeSum;
data.reset();
}
//! Reset profile data for a whole group
void IProfiler::resetGroup(u32 index)
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].GroupIndex == index )
ProfileDatas[i].reset();
}
if ( index < ProfileGroups.size() )
ProfileGroups[index].reset();
}
void IProfiler::resetAll()
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
ProfileDatas[i].reset();
}
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
ProfileGroups[i].reset();
}
}
//! For internal engine use:
//! Code inside IRR_PROFILE is only executed when _IRR_COMPILE_WITH_PROFILING_ is set
//! This allows disabling all profiler code completely by changing that define.
//! It's generally useful to wrap profiler-calls in application code with a similar macro.
#ifdef _IRR_COMPILE_WITH_PROFILING_
#define IRR_PROFILE(X) X
#else
#define IRR_PROFILE(X)
#endif // IRR_PROFILE
} // namespace irr
#endif // __I_PROFILER_H_INCLUDED__

View File

@ -7,10 +7,6 @@
#include "irrTypes.h"
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
#include "leakHunter.h"
#endif
namespace irr
{
@ -50,17 +46,11 @@ namespace irr
IReferenceCounted()
: DebugName(0), ReferenceCounter(1)
{
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
LeakHunter::addObject(this);
#endif
}
//! Destructor.
virtual ~IReferenceCounted()
{
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
LeakHunter::removeObject(this);
#endif
}
//! Grabs the object. Increments the reference counter by one.

View File

@ -6,8 +6,8 @@
#define __IRR_COMPILE_CONFIG_H_INCLUDED__
//! Identifies the IrrlichtMt fork customized for the Minetest engine
#define IRRLICHT_VERSION_MT_REVISION 9
#define IRRLICHT_VERSION_MT "mt9"
#define IRRLICHT_VERSION_MT_REVISION 10
#define IRRLICHT_VERSION_MT "mt10"
//! Irrlicht SDK Version
#define IRRLICHT_VERSION_MAJOR 1

View File

@ -156,6 +156,12 @@ namespace irr
/** \return True if window is minimized. */
virtual bool isWindowMinimized() const = 0;
//! Checks if the Irrlicht window is maximized
//! Only fully works on SDL. Returns false, or the last value set via
//! maximizeWindow() and restoreWindow(), on other backends.
/** \return True if window is maximized. */
virtual bool isWindowMaximized() const = 0;
//! Checks if the Irrlicht window is running in fullscreen mode
/** \return True if window is fullscreen. */
virtual bool isFullscreen() const = 0;

View File

@ -30,6 +30,7 @@ namespace irr
Bits(32),
ZBufferBits(24),
Fullscreen(false),
WindowMaximized(false),
WindowResizable(2),
Stencilbuffer(true),
Vsync(false),
@ -73,6 +74,7 @@ namespace irr
Bits = other.Bits;
ZBufferBits = other.ZBufferBits;
Fullscreen = other.Fullscreen;
WindowMaximized = other.WindowMaximized;
WindowResizable = other.WindowResizable;
Stencilbuffer = other.Stencilbuffer;
Vsync = other.Vsync;
@ -127,6 +129,9 @@ namespace irr
/** Otherwise the device runs in windowed mode. Default: false. */
bool Fullscreen;
//! Maximised window. (Only supported on SDL.) Default: false
bool WindowMaximized;
//! Should a non-fullscreen window be resizable.
/** Might not be supported by all devices. Ignored when Fullscreen is true.
Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself

View File

@ -963,11 +963,11 @@ public:
#endif
if (sizeof(wchar_t) == 4)
append(reinterpret_cast<const uchar32_t* const>(c));
append(reinterpret_cast<const uchar32_t*>(c));
else if (sizeof(wchar_t) == 2)
append(reinterpret_cast<const uchar16_t* const>(c));
append(reinterpret_cast<const uchar16_t*>(c));
else if (sizeof(wchar_t) == 1)
append(reinterpret_cast<const uchar8_t* const>(c));
append(reinterpret_cast<const uchar8_t*>(c));
}
@ -982,11 +982,11 @@ public:
#endif
if (sizeof(wchar_t) == 4)
append(reinterpret_cast<const uchar32_t* const>(c), length);
append(reinterpret_cast<const uchar32_t*>(c), length);
else if (sizeof(wchar_t) == 2)
append(reinterpret_cast<const uchar16_t* const>(c), length);
append(reinterpret_cast<const uchar16_t*>(c), length);
else if (sizeof(wchar_t) == 1)
append(reinterpret_cast<const uchar8_t* const>(c), length);
append(reinterpret_cast<const uchar8_t*>(c), length);
}
@ -1116,11 +1116,11 @@ public:
ustring16& operator=(const wchar_t* const c)
{
if (sizeof(wchar_t) == 4)
*this = reinterpret_cast<const uchar32_t* const>(c);
*this = reinterpret_cast<const uchar32_t*>(c);
else if (sizeof(wchar_t) == 2)
*this = reinterpret_cast<const uchar16_t* const>(c);
*this = reinterpret_cast<const uchar16_t*>(c);
else if (sizeof(wchar_t) == 1)
*this = reinterpret_cast<const uchar8_t* const>(c);
*this = reinterpret_cast<const uchar8_t*>(c);
return *this;
}
@ -3049,14 +3049,14 @@ public:
//! Gets the encoding of the Unicode string this class contains.
//! \return An enum describing the current encoding of this string.
const unicode::EUTF_ENCODE getEncoding() const
unicode::EUTF_ENCODE getEncoding() const
{
return encoding;
}
//! Gets the endianness of the Unicode string this class contains.
//! \return An enum describing the endianness of this string.
const unicode::EUTF_ENDIAN getEndianness() const
unicode::EUTF_ENDIAN getEndianness() const
{
if (encoding == unicode::EUTFE_UTF16_LE ||
encoding == unicode::EUTFE_UTF32_LE)
@ -3612,33 +3612,5 @@ inline std::wostream& operator<<(std::wostream& out, const ustring16& in)
return out;
}
namespace unicode
{
//! Hashing algorithm for hashing a ustring. Used for things like unordered_maps.
//! Algorithm taken from std::hash<std::string>.
class hash : public std::unary_function<core::ustring, size_t>
{
public:
size_t operator()(const core::ustring& s) const
{
size_t ret = 2166136261U;
size_t index = 0;
size_t stride = 1 + s.size_raw() / 10;
core::ustring::const_iterator i = s.begin();
while (i != s.end())
{
// TODO: Don't force u32 on an x64 OS. Make it agnostic.
ret = 16777619U * ret ^ (size_t)s[(u32)index];
index += stride;
i += stride;
}
return (ret);
}
};
} // end namespace unicode
} // end namespace core
} // end namespace irr

View File

@ -35,7 +35,6 @@
#include "CMeshBuffer.h"
#include "coreutil.h"
#include "CVertexBuffer.h"
#include "IProfiler.h"
#include "dimension2d.h"
#include "ECullingTypes.h"
#include "EDebugSceneTypes.h"

View File

@ -1,70 +0,0 @@
// Copyright (C) 2013 Michael Zeilfelder
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __LEAK_HUNTER_INCLUDED__
#define __LEAK_HUNTER_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
#include "irrArray.h"
namespace irr
{
class IReferenceCounted;
//! A class helping to find unreleased objects of type IReferenceCounted.
/** To use this you have recompile Irrlicht with _IRR_COMPILE_WITH_LEAK_HUNTER_.
Note that this will slow down your application and should only be used for debugging.
The way to use is that you can check after you closed and dropped your last Irrlicht device
if there are still any IReferenceCounted left over which have not been deleted.
*/
class LeakHunter
{
public:
friend class IReferenceCounted;
//! Clear all IReferenceCounted objects inside LeakHunter
/** This does not affect the IReferenceCounted themselves only the
counting of them. Usually you don't ever need to clear, but
sometimes it helps when for example you want to ignore
certain leaks.
*/
static void clearReferenceCountedObjects()
{
ReferenceCountedObjects.clear();
}
//! Access all objects which are currently reference counted.
static inline irr::core::array<const IReferenceCounted*> getReferenceCountedObjects()
{
return ReferenceCountedObjects;
}
protected:
static inline void addObject(const IReferenceCounted* object)
{
ReferenceCountedObjects.push_back(object);
}
static inline void removeObject(const IReferenceCounted* object)
{
irr::s32 idx = ReferenceCountedObjects.linear_search(object );
if ( idx >= 0 )
{
irr::core::swap( ReferenceCountedObjects[idx], ReferenceCountedObjects.getLast() );
ReferenceCountedObjects.erase( ReferenceCountedObjects.size()-1 );
}
}
private:
// NOTE: We don't do additional grab()/drop()'s here as we want to supervise reference counted objects and not affect them otherwise.
IRRLICHT_API static irr::core::array<const IReferenceCounted*> ReferenceCountedObjects;
};
} // end namespace irr
#endif // _IRR_COMPILE_WITH_LEAK_HUNTER_
#endif

View File

@ -180,11 +180,6 @@ void CIrrDeviceAndroid::setWindowCaption(const wchar_t* text)
{
}
bool CIrrDeviceAndroid::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip)
{
return true;
}
bool CIrrDeviceAndroid::isWindowActive() const
{
return (Focused && !Paused);

View File

@ -11,7 +11,6 @@
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "ICursorControl.h"
#include <android/sensor.h>
@ -19,7 +18,7 @@
namespace irr
{
class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter
class CIrrDeviceAndroid : public CIrrDeviceStub
{
public:
CIrrDeviceAndroid(const SIrrlichtCreationParameters& param);
@ -34,8 +33,6 @@ namespace irr
virtual void setWindowCaption(const wchar_t* text);
virtual bool present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip);
virtual bool isWindowActive() const;
virtual bool isWindowFocused() const;

View File

@ -236,15 +236,6 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
// set CurrentFrameNr
buildFrameNr(timeMs-LastTimeMs);
// update bbox
if (Mesh)
{
scene::IMesh * mesh = getMeshForCurrentFrame();
if (mesh)
Box = mesh->getBoundingBox();
}
LastTimeMs = timeMs;
IAnimatedMeshSceneNode::OnAnimate(timeMs);

View File

@ -110,7 +110,7 @@ namespace irr
CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param),
#ifdef _IRR_COMPILE_WITH_X11_
XDisplay(0), VisualInfo(0), Screennr(0), XWindow(0), StdHints(0), SoftwareImage(0),
XDisplay(0), VisualInfo(0), Screennr(0), XWindow(0), StdHints(0),
XInputMethod(0), XInputContext(0),
HasNetWM(false),
#endif
@ -118,7 +118,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
currentTouchedCount(0),
#endif
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
WindowHasFocus(false), WindowMinimized(false),
WindowHasFocus(false), WindowMinimized(false), WindowMaximized(param.WindowMaximized),
ExternalWindow(false), AutorepeatSupport(0)
{
#ifdef _DEBUG
@ -168,6 +168,9 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
return;
createGUIAndScene();
if (param.WindowMaximized)
maximizeWindow();
}
@ -211,9 +214,6 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
ContextManager->destroySurface();
}
if (SoftwareImage)
XDestroyImage(SoftwareImage);
if (!ExternalWindow)
{
XDestroyWindow(XDisplay,XWindow);
@ -487,21 +487,6 @@ bool CIrrDeviceLinux::createWindow()
long num;
XGetWMNormalHints(XDisplay, XWindow, StdHints, &num);
// create an XImage for the software renderer
//(thx to Nadav for some clues on how to do that!)
if (CreationParams.DriverType == video::EDT_SOFTWARE || CreationParams.DriverType == video::EDT_BURNINGSVIDEO)
{
SoftwareImage = XCreateImage(XDisplay,
VisualInfo->visual, VisualInfo->depth,
ZPixmap, 0, 0, Width, Height,
BitmapPad(XDisplay), 0);
// use malloc because X will free it later on
if (SoftwareImage)
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
}
initXInput2();
#endif // #ifdef _IRR_COMPILE_WITH_X11_
@ -515,20 +500,6 @@ void CIrrDeviceLinux::createDriver()
switch(CreationParams.DriverType)
{
#ifdef _IRR_COMPILE_WITH_X11_
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
{
@ -765,21 +736,6 @@ bool CIrrDeviceLinux::run()
Width = event.xconfigure.width;
Height = event.xconfigure.height;
// resize image data
if (SoftwareImage)
{
XDestroyImage(SoftwareImage);
SoftwareImage = XCreateImage(XDisplay,
VisualInfo->visual, VisualInfo->depth,
ZPixmap, 0, 0, Width, Height,
BitmapPad(XDisplay), 0);
// use malloc because X will free it later on
if (SoftwareImage)
SoftwareImage->data = (char*) malloc(SoftwareImage->bytes_per_line * SoftwareImage->height * sizeof(char));
}
if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
}
@ -1219,60 +1175,6 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
}
//! presents a surface in the client area
bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect)
{
#ifdef _IRR_COMPILE_WITH_X11_
// this is only necessary for software drivers.
if (!SoftwareImage)
return true;
// thx to Nadav, who send me some clues of how to display the image
// to the X Server.
const u32 destwidth = SoftwareImage->width;
const u32 minWidth = core::min_(image->getDimension().Width, destwidth);
const u32 destPitch = SoftwareImage->bytes_per_line;
video::ECOLOR_FORMAT destColor;
switch (SoftwareImage->bits_per_pixel)
{
case 16:
if (SoftwareImage->depth==16)
destColor = video::ECF_R5G6B5;
else
destColor = video::ECF_A1R5G5B5;
break;
case 24: destColor = video::ECF_R8G8B8; break;
case 32: destColor = video::ECF_A8R8G8B8; break;
default:
os::Printer::log("Unsupported screen depth.");
return false;
}
u8* srcdata = reinterpret_cast<u8*>(image->getData());
u8* destData = reinterpret_cast<u8*>(SoftwareImage->data);
const u32 destheight = SoftwareImage->height;
const u32 srcheight = core::min_(image->getDimension().Height, destheight);
const u32 srcPitch = image->getPitch();
for (u32 y=0; y!=srcheight; ++y)
{
video::CColorConverter::convert_viaFormat(srcdata,image->getColorFormat(), minWidth, destData, destColor);
srcdata+=srcPitch;
destData+=destPitch;
}
GC gc = DefaultGC(XDisplay, DefaultScreen(XDisplay));
Window myWindow=XWindow;
if (windowId)
myWindow = reinterpret_cast<Window>(windowId);
XPutImage(XDisplay, myWindow, gc, SoftwareImage, 0, 0, 0, 0, destwidth, destheight);
#endif
return true;
}
//! notifies the device that it should close itself
void CIrrDeviceLinux::closeDevice()
{
@ -1301,6 +1203,13 @@ bool CIrrDeviceLinux::isWindowMinimized() const
}
//! returns last state from maximizeWindow() and restoreWindow()
bool CIrrDeviceLinux::isWindowMaximized() const
{
return WindowMaximized;
}
//! returns color format of the window.
video::ECOLOR_FORMAT CIrrDeviceLinux::getColorFormat() const
{
@ -1385,6 +1294,8 @@ void CIrrDeviceLinux::maximizeWindow()
}
XMapWindow(XDisplay, XWindow);
WindowMaximized = true;
#endif
}
@ -1411,6 +1322,8 @@ void CIrrDeviceLinux::restoreWindow()
}
XMapWindow(XDisplay, XWindow);
WindowMaximized = false;
#endif
}

View File

@ -11,7 +11,6 @@
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "ICursorControl.h"
#include "os.h"
@ -33,7 +32,7 @@
namespace irr
{
class CIrrDeviceLinux : public CIrrDeviceStub, public video::IImagePresenter
class CIrrDeviceLinux : public CIrrDeviceStub
{
public:
@ -65,12 +64,12 @@ namespace irr
//! returns if window is minimized.
bool isWindowMinimized() const override;
//! returns last state from maximizeWindow() and restoreWindow()
bool isWindowMaximized() const override;
//! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const override;
//! presents a surface in the client area
bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ) override;
//! notifies the device that it should close itself
void closeDevice() override;
@ -410,16 +409,19 @@ namespace irr
Window XWindow;
XSetWindowAttributes WndAttributes;
XSizeHints* StdHints;
XImage* SoftwareImage;
XIM XInputMethod;
XIC XInputContext;
bool HasNetWM;
// text is utf-8
mutable core::stringc Clipboard;
#endif
#if defined(_IRR_LINUX_X11_XINPUT2_)
int currentTouchedCount;
#endif
u32 Width, Height;
bool WindowHasFocus;
bool WindowMinimized;
bool WindowMaximized;
bool ExternalWindow;
int AutorepeatSupport;
@ -455,10 +457,6 @@ namespace irr
};
core::array<JoystickInfo> ActiveJoysticks;
#endif
#if defined(_IRR_LINUX_X11_XINPUT2_)
int currentTouchedCount;
#endif
};

View File

@ -12,7 +12,6 @@
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "IGUIEnvironment.h"
#include "ICursorControl.h"
@ -36,7 +35,7 @@ namespace irr
namespace irr
{
class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter
class CIrrDeviceMacOSX : public CIrrDeviceStub
{
public:
@ -68,9 +67,6 @@ namespace irr
//! Checks if the Irrlicht window is minimized
bool isWindowMinimized() const override;
//! presents a surface in the client area
bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ) override;
//! notifies the device that it should close itself
void closeDevice() override;
@ -237,14 +233,12 @@ namespace irr
NSWindow* Window;
CGDirectDisplayID Display;
NSBitmapImageRep* SoftwareDriverTarget;
std::map<int,int> KeyCodes;
int DeviceWidth;
int DeviceHeight;
int ScreenWidth;
int ScreenHeight;
u32 MouseButtonStates;
u32 SoftwareRendererType;
bool IsFullscreen;
bool IsActive;
bool IsShiftDown;

View File

@ -547,8 +547,8 @@ namespace irr
//! constructor
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), Window(NULL), Display(NULL),
SoftwareDriverTarget(0), DeviceWidth(0), DeviceHeight(0),
ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0), SoftwareRendererType(0),
DeviceWidth(0), DeviceHeight(0),
ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0),
IsActive(true), IsFullscreen(false), IsShiftDown(false), IsControlDown(false), IsResizable(false)
{
struct utsname name;
@ -617,7 +617,6 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
CIrrDeviceMacOSX::~CIrrDeviceMacOSX()
{
[SoftwareDriverTarget release];
[NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
closeDevice();
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
@ -731,24 +730,6 @@ void CIrrDeviceMacOSX::createDriver()
{
switch (CreationParams.DriverType)
{
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
SoftwareRendererType = 2;
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
SoftwareRendererType = 1;
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
{
@ -1358,87 +1339,6 @@ core::position2di CIrrDeviceMacOSX::getWindowPosition()
}
bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src )
{
// todo: implement window ID and src rectangle
if (!surface)
return false;
if (SoftwareRendererType > 0)
{
const u32 colorSamples=3;
// do we need to change the size?
const bool updateSize = !SoftwareDriverTarget ||
s32([SoftwareDriverTarget size].width) != surface->getDimension().Width ||
s32([SoftwareDriverTarget size].height) != surface->getDimension().Height;
NSRect areaRect = NSMakeRect(0.0, 0.0, surface->getDimension().Width, surface->getDimension().Height);
const u32 destPitch = (colorSamples * areaRect.size.width);
// create / update the target
if (updateSize)
{
[SoftwareDriverTarget release];
// allocate target for IImage
SoftwareDriverTarget = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: nil
pixelsWide: areaRect.size.width
pixelsHigh: areaRect.size.height
bitsPerSample: 8
samplesPerPixel: colorSamples
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: destPitch
bitsPerPixel: 8*colorSamples];
}
if (SoftwareDriverTarget==nil)
return false;
// get pointer to image data
unsigned char* imgData = (unsigned char*)surface->getData();
u8* srcdata = reinterpret_cast<u8*>(imgData);
u8* destData = reinterpret_cast<u8*>([SoftwareDriverTarget bitmapData]);
const u32 srcheight = core::min_(surface->getDimension().Height, (u32)areaRect.size.height);
const u32 srcPitch = surface->getPitch();
const u32 minWidth = core::min_(surface->getDimension().Width, (u32)areaRect.size.width);
for (u32 y=0; y!=srcheight; ++y)
{
if(SoftwareRendererType == 2)
{
if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData);
else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData);
else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
}
else
{
if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toR8G8B8(srcdata, minWidth, destData);
else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
video::CColorConverter::convert_A1R5G5B5toR8G8B8(srcdata, minWidth, destData);
else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
}
srcdata += srcPitch;
destData += destPitch;
}
// todo: draw properly into a sub-view
[SoftwareDriverTarget draw];
}
return false;
}
#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
static void joystickRemovalCallback(void * target,
IOReturn result, void * refcon, void * sender)

View File

@ -8,6 +8,8 @@
#include "CIrrDeviceSDL.h"
#include "IEventReceiver.h"
#include "IGUIElement.h"
#include "IGUIEnvironment.h"
#include "os.h"
#include "CTimer.h"
#include "irrString.h"
@ -105,13 +107,105 @@ EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEv
}
#endif
bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key)
{
switch ( key )
{
// keys which are known to have safe special character interpretation
// could need changes over time (removals and additions!)
case KEY_RETURN:
case KEY_PAUSE:
case KEY_ESCAPE:
case KEY_PRIOR:
case KEY_NEXT:
case KEY_HOME:
case KEY_END:
case KEY_LEFT:
case KEY_UP:
case KEY_RIGHT:
case KEY_DOWN:
case KEY_TAB:
case KEY_PRINT:
case KEY_SNAPSHOT:
case KEY_INSERT:
case KEY_BACK:
case KEY_DELETE:
case KEY_HELP:
case KEY_APPS:
case KEY_SLEEP:
case KEY_F1:
case KEY_F2:
case KEY_F3:
case KEY_F4:
case KEY_F5:
case KEY_F6:
case KEY_F7:
case KEY_F8:
case KEY_F9:
case KEY_F10:
case KEY_F11:
case KEY_F12:
case KEY_F13:
case KEY_F14:
case KEY_F15:
case KEY_F16:
case KEY_F17:
case KEY_F18:
case KEY_F19:
case KEY_F20:
case KEY_F21:
case KEY_F22:
case KEY_F23:
case KEY_F24:
case KEY_NUMLOCK:
case KEY_SCROLL:
case KEY_LCONTROL:
case KEY_RCONTROL:
return true;
default:
return false;
}
}
int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
// SDL in-place ORs values with no character representation with 1<<30
// https://wiki.libsdl.org/SDL2/SDLKeycodeLookup
if (assumedChar & (1<<30))
return 0;
switch (key) {
case KEY_PRIOR:
case KEY_NEXT:
case KEY_HOME:
case KEY_END:
case KEY_LEFT:
case KEY_UP:
case KEY_RIGHT:
case KEY_DOWN:
case KEY_NUMLOCK:
return 0;
default:
return assumedChar;
}
}
void CIrrDeviceSDL::resetReceiveTextInputEvents() {
gui::IGUIElement *elem = GUIEnvironment->getFocus();
if (elem && elem->acceptsIME())
SDL_StartTextInput();
else
SDL_StopTextInput();
}
//! constructor
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param),
Window((SDL_Window*)param.WindowId), SDL_Flags(0),
MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Resizable(param.WindowResizable == 1 ? true : false), WindowMinimized(false)
Resizable(param.WindowResizable == 1 ? true : false)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceSDL");
@ -139,10 +233,18 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
// create keymap
createKeyMap();
if ( CreationParams.Fullscreen )
if (CreationParams.Fullscreen) {
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
SDL_Flags |= SDL_WINDOW_FULLSCREEN;
else if ( Resizable )
#else
SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#endif
}
if (Resizable)
SDL_Flags |= SDL_WINDOW_RESIZABLE;
if (CreationParams.WindowMaximized)
SDL_Flags |= SDL_WINDOW_MAXIMIZED;
if (CreationParams.DriverType == video::EDT_OPENGL)
{
SDL_Flags |= SDL_WINDOW_OPENGL;
@ -160,6 +262,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
createWindow();
}
SDL_VERSION(&Info.version);
#ifndef _IRR_EMSCRIPTEN_PLATFORM_
@ -372,22 +475,6 @@ void CIrrDeviceSDL::createDriver()
break;
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
ContextManager = new video::CSDLManager(this);
@ -622,6 +709,10 @@ bool CIrrDeviceSDL::run()
else
key = (EKEY_CODE)KeyMap[idx].Win32Key;
// Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already
if (SDL_IsTextInputActive() && !keyIsKnownSpecial(key) && (SDL_event.key.keysym.mod & KMOD_CTRL) == 0)
break;
#ifdef _IRR_WINDOWS_API_
// handle alt+f4 in Windows, because SDL seems not to
if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4)
@ -635,12 +726,7 @@ bool CIrrDeviceSDL::run()
irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;
// These keys are handled differently in CGUIEditBox.cpp (may become out of date!)
// Control key is used in special character combinations, so keep that too
// Pass through the keysym only then so no extra text gets input
irrevent.KeyInput.Char = 0;
if (mp.SDLKey == SDLK_DELETE || mp.SDLKey == SDLK_RETURN || mp.SDLKey == SDLK_BACKSPACE || irrevent.KeyInput.Control)
irrevent.KeyInput.Char = mp.SDLKey;
irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key);
postEventFromUser(irrevent);
}
break;
@ -652,12 +738,6 @@ bool CIrrDeviceSDL::run()
case SDL_WINDOWEVENT:
switch (SDL_event.window.event)
{
case SDL_WINDOWEVENT_MAXIMIZED:
WindowMinimized = true;
break;
case SDL_WINDOWEVENT_RESTORED:
WindowMinimized = false;
break;
case SDL_WINDOWEVENT_RESIZED:
if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height))
{
@ -680,7 +760,7 @@ bool CIrrDeviceSDL::run()
default:
break;
} // end switch
resetReceiveTextInputEvents();
} // end while
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
@ -846,90 +926,6 @@ void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)
}
//! presents a surface in the client area
bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip)
{
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
return true;
#else // !_IRR_EMSCRIPTEN_PLATFORM_
SDL_Surface *sdlSurface = SDL_CreateRGBSurfaceFrom(
surface->getData(), surface->getDimension().Width, surface->getDimension().Height,
surface->getBitsPerPixel(), surface->getPitch(),
surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask());
if (!sdlSurface)
return false;
SDL_SetSurfaceAlphaMod(sdlSurface, 0);
SDL_SetColorKey(sdlSurface, 0, 0);
sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel();
sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel();
if ((surface->getColorFormat()==video::ECF_R8G8B8) ||
(surface->getColorFormat()==video::ECF_A8R8G8B8))
{
sdlSurface->format->Rloss=0;
sdlSurface->format->Gloss=0;
sdlSurface->format->Bloss=0;
sdlSurface->format->Rshift=16;
sdlSurface->format->Gshift=8;
sdlSurface->format->Bshift=0;
if (surface->getColorFormat()==video::ECF_R8G8B8)
{
sdlSurface->format->Aloss=8;
sdlSurface->format->Ashift=32;
}
else
{
sdlSurface->format->Aloss=0;
sdlSurface->format->Ashift=24;
}
}
else if (surface->getColorFormat()==video::ECF_R5G6B5)
{
sdlSurface->format->Rloss=3;
sdlSurface->format->Gloss=2;
sdlSurface->format->Bloss=3;
sdlSurface->format->Aloss=8;
sdlSurface->format->Rshift=11;
sdlSurface->format->Gshift=5;
sdlSurface->format->Bshift=0;
sdlSurface->format->Ashift=16;
}
else if (surface->getColorFormat()==video::ECF_A1R5G5B5)
{
sdlSurface->format->Rloss=3;
sdlSurface->format->Gloss=3;
sdlSurface->format->Bloss=3;
sdlSurface->format->Aloss=7;
sdlSurface->format->Rshift=10;
sdlSurface->format->Gshift=5;
sdlSurface->format->Bshift=0;
sdlSurface->format->Ashift=15;
}
SDL_Surface* scr = (SDL_Surface* )windowId;
if (!scr)
scr = SDL_GetWindowSurface(Window);
if (scr)
{
if (srcClip)
{
SDL_Rect sdlsrcClip;
sdlsrcClip.x = srcClip->UpperLeftCorner.X;
sdlsrcClip.y = srcClip->UpperLeftCorner.Y;
sdlsrcClip.w = srcClip->getWidth();
sdlsrcClip.h = srcClip->getHeight();
SDL_BlitSurface(sdlSurface, &sdlsrcClip, scr, NULL);
}
else
SDL_BlitSurface(sdlSurface, NULL, scr, NULL);
SDL_RenderPresent(SDL_GetRenderer(Window));
}
SDL_FreeSurface(sdlSurface);
return (scr != 0);
#endif // !_IRR_EMSCRIPTEN_PLATFORM_
}
//! notifies the device that it should close itself
void CIrrDeviceSDL::closeDevice()
{
@ -962,16 +958,16 @@ void CIrrDeviceSDL::setResizable(bool resize)
//! Minimizes window if possible
void CIrrDeviceSDL::minimizeWindow()
{
if (Window) {
if (Window)
SDL_MinimizeWindow(Window);
}
}
//! Maximize window
void CIrrDeviceSDL::maximizeWindow()
{
// do nothing
if (Window)
SDL_MaximizeWindow(Window);
}
//! Get the position of this window on screen
@ -984,7 +980,13 @@ core::position2di CIrrDeviceSDL::getWindowPosition()
//! Restore original window size
void CIrrDeviceSDL::restoreWindow()
{
// do nothing
if (Window)
SDL_RestoreWindow(Window);
}
bool CIrrDeviceSDL::isWindowMaximized() const
{
return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MAXIMIZED) != 0;
}
bool CIrrDeviceSDL::isFullscreen() const
@ -1019,14 +1021,14 @@ bool CIrrDeviceSDL::isWindowActive() const
//! returns if window has focus.
bool CIrrDeviceSDL::isWindowFocused() const
{
return SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS;
return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
}
//! returns if window is minimized.
bool CIrrDeviceSDL::isWindowMinimized() const
{
return WindowMinimized;
return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0;
}

View File

@ -13,7 +13,6 @@
#include "IrrlichtDevice.h"
#include "CIrrDeviceStub.h"
#include "IImagePresenter.h"
#include "ICursorControl.h"
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
@ -28,7 +27,7 @@
namespace irr
{
class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter
class CIrrDeviceSDL : public CIrrDeviceStub
{
public:
@ -62,9 +61,6 @@ namespace irr
//! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const override;
//! presents a surface in the client area
bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0) override;
//! notifies the device that it should close itself
void closeDevice() override;
@ -80,6 +76,9 @@ namespace irr
//! Restores the window size.
void restoreWindow() override;
//! Checks if the window is maximized.
bool isWindowMaximized() const override;
//! Checks if the Irrlicht window is running in fullscreen mode
/** \return True if window is fullscreen. */
bool isFullscreen() const override;
@ -265,6 +264,15 @@ namespace irr
static EM_BOOL MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
#endif
// Check if a key is a known special character with no side effects on text boxes.
static bool keyIsKnownSpecial(EKEY_CODE key);
// Return the Char that should be sent to Irrlicht for the given key (either the one passed in or 0).
static int findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key);
// Check if a text box is in focus. Enable or disable SDL_TEXTINPUT events only if in focus.
void resetReceiveTextInputEvents();
//! create the driver
void createDriver();
@ -287,7 +295,6 @@ namespace irr
u32 Width, Height;
bool Resizable;
bool WindowMinimized;
struct SKeyMap
{

View File

@ -272,6 +272,13 @@ void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneMa
}
//! Checks if the window is maximized.
bool CIrrDeviceStub::isWindowMaximized() const
{
return false;
}
//! Checks if the window is running in fullscreen mode
bool CIrrDeviceStub::isFullscreen() const
{

View File

@ -6,7 +6,6 @@
#define __C_IRR_DEVICE_STUB_H_INCLUDED__
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "SIrrCreationParameters.h"
#include "IContextManager.h"
@ -36,11 +35,6 @@ namespace irr
namespace video
{
IVideoDriver* createSoftwareDriver(const core::dimension2d<u32>& windowSize,
bool fullscreen, io::IFileSystem* io,
video::IImagePresenter* presenter);
IVideoDriver* createBurningVideoDriver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, video::IImagePresenter* presenter);
IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize);
}
@ -100,6 +94,9 @@ namespace irr
//! Returns the operation system opertator object.
IOSOperator* getOSOperator() override;
//! Checks if the window is maximized.
bool isWindowMaximized() const override;
//! Checks if the window is running in fullscreen mode.
bool isFullscreen() const override;
@ -109,41 +106,41 @@ namespace irr
//! Activate any joysticks, and generate events for them.
bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) override;
//! Activate accelerometer.
bool activateAccelerometer(float updateInterval = 0.016666f) override;
//! Deactivate accelerometer.
bool deactivateAccelerometer() override;
//! Is accelerometer active.
bool isAccelerometerActive() override;
//! Is accelerometer available.
bool isAccelerometerAvailable() override;
//! Activate gyroscope.
bool activateGyroscope(float updateInterval = 0.016666f) override;
//! Deactivate gyroscope.
bool deactivateGyroscope() override;
//! Is gyroscope active.
bool isGyroscopeActive() override;
//! Is gyroscope available.
bool isGyroscopeAvailable() override;
//! Activate device motion.
bool activateDeviceMotion(float updateInterval = 0.016666f) override;
//! Deactivate device motion.
bool deactivateDeviceMotion() override;
//! Is device motion active.
bool isDeviceMotionActive() override;
//! Is device motion available.
bool isDeviceMotionAvailable() override;
//! Activate accelerometer.
bool activateAccelerometer(float updateInterval = 0.016666f) override;
//! Deactivate accelerometer.
bool deactivateAccelerometer() override;
//! Is accelerometer active.
bool isAccelerometerActive() override;
//! Is accelerometer available.
bool isAccelerometerAvailable() override;
//! Activate gyroscope.
bool activateGyroscope(float updateInterval = 0.016666f) override;
//! Deactivate gyroscope.
bool deactivateGyroscope() override;
//! Is gyroscope active.
bool isGyroscopeActive() override;
//! Is gyroscope available.
bool isGyroscopeAvailable() override;
//! Activate device motion.
bool activateDeviceMotion(float updateInterval = 0.016666f) override;
//! Deactivate device motion.
bool deactivateDeviceMotion() override;
//! Is device motion active.
bool isDeviceMotionActive() override;
//! Is device motion available.
bool isDeviceMotionAvailable() override;
//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.
//! When set to 0 no double- and tripleclicks will be generated.

View File

@ -784,7 +784,8 @@ namespace irr
//! constructor
CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), HWnd(0), Resized(false),
ExternalWindow(false), Win32CursorControl(0), JoyControl(0)
ExternalWindow(false), Win32CursorControl(0), JoyControl(0),
WindowMaximized(params.WindowMaximized)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceWin32");
@ -923,6 +924,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
// inform driver about the window size etc.
resizeIfNecessary();
if (params.WindowMaximized)
maximizeWindow();
}
@ -1009,24 +1013,6 @@ void CIrrDeviceWin32::createDriver()
case video::EDT_WEBGL1:
os::Printer::log("WebGL1 driver not supported on Win32 device.", ELL_ERROR);
break;
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
switchToFullScreen();
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
switchToFullScreen();
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
@ -1127,54 +1113,6 @@ void CIrrDeviceWin32::setWindowCaption(const wchar_t* text)
}
//! presents a surface in the client area
bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect<s32>* src)
{
HWND hwnd = HWnd;
if ( windowId )
hwnd = static_cast<HWND>(windowId);
HDC dc = GetDC(hwnd);
if ( dc )
{
RECT rect;
GetClientRect(hwnd, &rect);
const void* memory = (const void *)image->getData();
BITMAPV4HEADER bi;
ZeroMemory (&bi, sizeof(bi));
bi.bV4Size = sizeof(BITMAPINFOHEADER);
bi.bV4BitCount = (WORD)image->getBitsPerPixel();
bi.bV4Planes = 1;
bi.bV4Width = image->getDimension().Width;
bi.bV4Height = -((s32)image->getDimension().Height);
bi.bV4V4Compression = BI_BITFIELDS;
bi.bV4AlphaMask = image->getAlphaMask();
bi.bV4RedMask = image->getRedMask();
bi.bV4GreenMask = image->getGreenMask();
bi.bV4BlueMask = image->getBlueMask();
if ( src )
{
StretchDIBits(dc, 0,0, rect.right, rect.bottom,
src->UpperLeftCorner.X, src->UpperLeftCorner.Y,
src->getWidth(), src->getHeight(),
memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
}
else
{
StretchDIBits(dc, 0,0, rect.right, rect.bottom,
0, 0, image->getDimension().Width, image->getDimension().Height,
memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
}
ReleaseDC(hwnd, dc);
}
return true;
}
//! notifies the device that it should close itself
void CIrrDeviceWin32::closeDevice()
{
@ -1220,6 +1158,13 @@ bool CIrrDeviceWin32::isWindowMinimized() const
}
//! returns last state from maximizeWindow() and restoreWindow()
bool CIrrDeviceWin32::isWindowMaximized() const
{
return WindowMaximized;
}
//! switches to fullscreen
bool CIrrDeviceWin32::switchToFullScreen()
{
@ -1344,6 +1289,8 @@ void CIrrDeviceWin32::maximizeWindow()
GetWindowPlacement(HWnd, &wndpl);
wndpl.showCmd = SW_SHOWMAXIMIZED;
SetWindowPlacement(HWnd, &wndpl);
WindowMaximized = true;
}
@ -1355,6 +1302,8 @@ void CIrrDeviceWin32::restoreWindow()
GetWindowPlacement(HWnd, &wndpl);
wndpl.showCmd = SW_SHOWNORMAL;
SetWindowPlacement(HWnd, &wndpl);
WindowMaximized = false;
}
core::position2di CIrrDeviceWin32::getWindowPosition()

View File

@ -10,7 +10,6 @@
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -25,7 +24,7 @@ namespace irr
{
struct SJoystickWin32Control;
class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter
class CIrrDeviceWin32 : public CIrrDeviceStub
{
friend struct SJoystickWin32Control;
public:
@ -58,8 +57,8 @@ namespace irr
//! returns if window is minimized
bool isWindowMinimized() const override;
//! presents a surface in the client area
bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0) override;
//! returns last state from maximizeWindow() and restoreWindow()
bool isWindowMaximized() const override;
//! notifies the device that it should close itself
void closeDevice() override;
@ -417,6 +416,8 @@ namespace irr
CCursorControl* Win32CursorControl;
SJoystickWin32Control* JoyControl;
bool WindowMaximized;
};
} // end namespace irr

View File

@ -13,12 +13,11 @@
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
namespace irr
{
class CIrrDeviceiOS : public CIrrDeviceStub, public video::IImagePresenter
class CIrrDeviceiOS : public CIrrDeviceStub
{
public:
CIrrDeviceiOS(const SIrrlichtCreationParameters& params);
@ -34,8 +33,6 @@ namespace irr
bool isWindowFocused() const override;
bool isWindowMinimized() const override;
bool present(video::IImage* surface, void * windowId = 0, core::rect<s32>* src = 0) override;
void closeDevice() override;
void setResizable(bool resize = false) override;

View File

@ -480,11 +480,6 @@ namespace irr
#endif
}
bool CIrrDeviceiOS::present(video::IImage* image, void * windowId, core::rect<s32>* src)
{
return false;
}
void CIrrDeviceiOS::closeDevice()
{
CFRunLoopStop(CFRunLoopGetMain());

View File

@ -241,8 +241,6 @@ add_library(IRROTHEROBJ OBJECT
COSOperator.cpp
Irrlicht.cpp
os.cpp
leakHunter.cpp
CProfiler.cpp
)
if(ANDROID)

View File

@ -7,7 +7,6 @@
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "IImagePresenter.h"
#include "IGPUProgrammingServices.h"
#include "irrArray.h"
#include "irrString.h"

View File

@ -20,8 +20,6 @@
#include "EVertexAttributes.h"
#include "CImage.h"
#include "os.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
#include "android_native_app_glue.h"
@ -46,28 +44,6 @@ COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFil
setDebugName("COGLES2Driver");
#endif
IRR_PROFILE(
static bool initProfile = false;
if (!initProfile )
{
initProfile = true;
getProfiler().add(EPID_ES2_END_SCENE, L"endScene", L"ES2");
getProfiler().add(EPID_ES2_BEGIN_SCENE, L"beginScene", L"ES2");
getProfiler().add(EPID_ES2_UPDATE_VERTEX_HW_BUF, L"upVertBuf", L"ES2");
getProfiler().add(EPID_ES2_UPDATE_INDEX_HW_BUF, L"upIdxBuf", L"ES2");
getProfiler().add(EPID_ES2_DRAW_PRIMITIVES, L"drawPrim", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DIMAGE, L"draw2dImg", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DIMAGE_BATCH, L"draw2dImgB", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DRECTANGLE, L"draw2dRect", L"ES2");
getProfiler().add(EPID_ES2_DRAW_2DLINE, L"draw2dLine", L"ES2");
getProfiler().add(EPID_ES2_DRAW_3DLINE, L"draw3dLine", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_2D, L"rstate2d", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_3D, L"rstate3d", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_BASIC, L"rstateBasic", L"ES2");
getProfiler().add(EPID_ES2_SET_RENDERSTATE_TEXTURE, L"rstateTex", L"ES2");
getProfiler().add(EPID_ES2_DRAW_SHADOW, L"shadows", L"ES2");
}
)
if (!ContextManager)
return;
@ -384,8 +360,6 @@ COGLES2Driver::~COGLES2Driver()
bool COGLES2Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect<s32>* sourceRect)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_BEGIN_SCENE);)
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
@ -398,8 +372,6 @@ COGLES2Driver::~COGLES2Driver()
bool COGLES2Driver::endScene()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_END_SCENE);)
CNullDriver::endScene();
glFlush();
@ -431,8 +403,6 @@ COGLES2Driver::~COGLES2Driver()
if (!HWBuffer)
return false;
IRR_PROFILE(CProfileScope p1(EPID_ES2_UPDATE_VERTEX_HW_BUF);)
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
const void* vertices = mb->getVertices();
const u32 vertexCount = mb->getVertexCount();
@ -481,8 +451,6 @@ COGLES2Driver::~COGLES2Driver()
if (!HWBuffer)
return false;
IRR_PROFILE(CProfileScope p1(EPID_ES2_UPDATE_INDEX_HW_BUF);)
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
const void* indices = mb->getIndices();
@ -695,8 +663,6 @@ COGLES2Driver::~COGLES2Driver()
if (!checkPrimitiveCount(primitiveCount))
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_PRIMITIVES);)
CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType);
setRenderStates3DMode();
@ -852,8 +818,6 @@ COGLES2Driver::~COGLES2Driver()
if (!sourceRect.isValid())
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE);)
core::position2d<s32> targetPos(destPos);
core::position2d<s32> sourcePos(sourceRect.UpperLeftCorner);
core::dimension2d<s32> sourceSize(sourceRect.getSize());
@ -986,8 +950,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE);)
// texcoords need to be flipped horizontally for RTTs
const bool isRTT = texture->isRenderTarget();
const core::dimension2du& ss = texture->getOriginalSize();
@ -1111,8 +1073,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE_BATCH);)
const irr::u32 drawCount = core::min_<u32>(positions.size(), sourceRects.size());
core::array<S3DVertex> vtx(drawCount * 4);
@ -1272,8 +1232,6 @@ COGLES2Driver::~COGLES2Driver()
if (!texture)
return;
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE_BATCH);)
chooseMaterial2D();
if (!setMaterialTexture(0, texture))
return;
@ -1364,8 +1322,6 @@ COGLES2Driver::~COGLES2Driver()
const core::rect<s32>& position,
const core::rect<s32>* clip)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DRECTANGLE);)
chooseMaterial2D();
setMaterialTexture(0, 0);
@ -1409,8 +1365,6 @@ COGLES2Driver::~COGLES2Driver()
SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DRECTANGLE);)
core::rect<s32> pos = position;
if (clip)
@ -1455,8 +1409,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end, SColor color)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DLINE);)
if (start==end)
drawPixel(start.X, start.Y, color);
else
@ -1635,8 +1587,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::setRenderStates3DMode()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_3D);)
if ( LockRenderStateMode )
return;
@ -1682,8 +1632,6 @@ COGLES2Driver::~COGLES2Driver()
//! Can be called by an IMaterialRenderer to make its work easier.
void COGLES2Driver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, bool resetAllRenderStates)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_BASIC);)
// ZBuffer
switch (material.ZBuffer)
{
@ -1822,8 +1770,6 @@ COGLES2Driver::~COGLES2Driver()
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
void COGLES2Driver::setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_TEXTURE);)
// Set textures to TU/TIU and apply filters to them
for (s32 i = Feature.MaxTextureUnits - 1; i >= 0; --i)
@ -1927,8 +1873,6 @@ COGLES2Driver::~COGLES2Driver()
//! sets the needed renderstates
void COGLES2Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_2D);)
if ( LockRenderStateMode )
return;
@ -2029,8 +1973,6 @@ COGLES2Driver::~COGLES2Driver()
//! Draws a shadow volume into the stencil buffer.
void COGLES2Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_SHADOW);)
const u32 count=triangles.size();
if (!StencilBuffer || !count)
return;
@ -2109,8 +2051,6 @@ COGLES2Driver::~COGLES2Driver()
video::SColor leftUpEdge, video::SColor rightUpEdge,
video::SColor leftDownEdge, video::SColor rightDownEdge)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_SHADOW);)
if (!StencilBuffer)
return;
@ -2155,8 +2095,6 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_3DLINE);)
setRenderStates3DMode();
u16 indices[] = {0, 1};

View File

@ -17,8 +17,6 @@
#include "EVertexAttributes.h"
#include "CImage.h"
#include "os.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
#include "android_native_app_glue.h"
@ -188,8 +186,6 @@ void COGLES1Driver::createMaterialRenderers()
bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect<s32>* sourceRect)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_BEGIN_SCENE);)
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
@ -202,8 +198,6 @@ bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth,
bool COGLES1Driver::endScene()
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_END_SCENE);)
CNullDriver::endScene();
glFlush();

View File

@ -1,95 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#include "CProfiler.h"
#include "CTimer.h"
namespace irr
{
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler()
{
static CProfiler profiler;
return profiler;
}
CProfiler::CProfiler()
{
Timer = new CTimer(true);
addGroup(L"overview");
}
CProfiler::~CProfiler()
{
if ( Timer )
Timer->drop();
}
void CProfiler::printAll(core::stringw &ostream, bool includeOverview, bool suppressUncalled) const
{
ostream += makeTitleString();
ostream += L"\n";
for ( u32 i=includeOverview ?0:1; i<ProfileGroups.size(); ++i )
{
printGroup( ostream, i, suppressUncalled );
}
}
void CProfiler::printGroup(core::stringw &ostream, u32 idxGroup, bool suppressUncalled) const
{
ostream += getAsString(ProfileGroups[idxGroup]);
ostream += L"\n";
// print overview for groups
if ( idxGroup == 0 )
{
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
if ( !suppressUncalled || ProfileGroups[i].getCallsCounter() > 0)
{
ostream += getAsString(ProfileGroups[i]);
ostream += L"\n";
}
}
}
// print all data in a group
else
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( (!suppressUncalled || ProfileDatas[i].getCallsCounter() > 0)
&& ProfileDatas[i].getGroupIndex() == idxGroup )
{
ostream += getAsString(ProfileDatas[i]);
ostream += L"\n";
}
}
}
}
//! Convert the whole data into a string
core::stringw CProfiler::getAsString(const SProfileData& data) const
{
if ( data.getCallsCounter() > 0 )
{
wchar_t dummy[512];
swprintf_irr(dummy, 512, L"%-15.15s%-12u%-12u%-12u%-12u",
data.getName().c_str(), data.getCallsCounter(), data.getTimeSum(),
data.getTimeSum() / data.getCallsCounter(), data.getLongestTime());
return core::stringw(dummy);
}
else
{
return data.getName();
}
}
//! Return a string which describes the columns returned by getAsString
core::stringw CProfiler::makeTitleString() const
{
return core::stringw("name calls time(sum) time(avg) time(max)");
}
} // namespace irr

View File

@ -1,32 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __C_PROFILER_H_INCLUDED__
#define __C_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IProfiler.h"
namespace irr
{
class CProfiler : public IProfiler
{
public:
CProfiler();
virtual ~CProfiler();
//! Write all profile-data into a string
void printAll(core::stringw &result, bool includeOverview,bool suppressUncalled) const override;
//! Write the profile data of one group into a string
void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const override;
protected:
core::stringw makeTitleString() const;
core::stringw getAsString(const SProfileData& data) const;
};
} // namespace irr
#endif // __C_PROFILER_H_INCLUDED__

View File

@ -12,8 +12,6 @@
#include "IMaterialRenderer.h"
#include "IReadFile.h"
#include "IWriteFile.h"
#include "EProfileIDs.h"
#include "IProfiler.h"
#include "os.h"
@ -107,25 +105,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
#ifdef _IRR_COMPILE_WITH_B3D_LOADER_
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
#endif
IRR_PROFILE(
static bool initProfile = false;
if (!initProfile )
{
initProfile = true;
getProfiler().add(EPID_SM_DRAW_ALL, L"drawAll", L"Irrlicht scene");
getProfiler().add(EPID_SM_ANIMATE, L"animate", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_CAMERAS, L"cameras", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_LIGHTS, L"lights", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_SKYBOXES, L"skyboxes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_DEFAULT, L"defaultnodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_SHADOWS, L"shadows", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_TRANSPARENT, L"transp.nodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_EFFECT, L"effectnodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_GUI_NODES, L"guinodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_REGISTER, L"reg.render.node", L"Irrlicht scene");
}
)
}
@ -509,7 +488,6 @@ bool CSceneManager::isCulled(const ISceneNode* node) const
//! registers a node for rendering it at a specific time.
u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS pass)
{
IRR_PROFILE(CProfileScope p1(EPID_SM_REGISTER);)
u32 taken = 0;
switch(pass)
@ -625,8 +603,6 @@ void CSceneManager::clearAllRegisteredNodesForRendering()
//! draws all scene nodes
void CSceneManager::drawAll()
{
IRR_PROFILE(CProfileScope psAll(EPID_SM_DRAW_ALL);)
if (!Driver)
return;
@ -652,29 +628,24 @@ void CSceneManager::drawAll()
Driver->setAllowZWriteOnTransparent(Parameters->getAttributeAsBool(ALLOW_ZWRITE_ON_TRANSPARENT));
// do animations and other stuff.
IRR_PROFILE(getProfiler().start(EPID_SM_ANIMATE));
OnAnimate(os::Timer::getTime());
IRR_PROFILE(getProfiler().stop(EPID_SM_ANIMATE));
/*!
First Scene Node for prerendering should be the active camera
consistent Camera is needed for culling
*/
IRR_PROFILE(getProfiler().start(EPID_SM_RENDER_CAMERAS));
camWorldPos.set(0,0,0);
if (ActiveCamera)
{
ActiveCamera->render();
camWorldPos = ActiveCamera->getAbsolutePosition();
}
IRR_PROFILE(getProfiler().stop(EPID_SM_RENDER_CAMERAS));
// let all nodes register themselves
OnRegisterSceneNode();
//render camera scenes
{
IRR_PROFILE(CProfileScope psCam(EPID_SM_RENDER_CAMERAS);)
CurrentRenderPass = ESNRP_CAMERA;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -686,7 +657,6 @@ void CSceneManager::drawAll()
// render skyboxes
{
IRR_PROFILE(CProfileScope psSkyBox(EPID_SM_RENDER_SKYBOXES);)
CurrentRenderPass = ESNRP_SKY_BOX;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -698,7 +668,6 @@ void CSceneManager::drawAll()
// render default objects
{
IRR_PROFILE(CProfileScope psDefault(EPID_SM_RENDER_DEFAULT);)
CurrentRenderPass = ESNRP_SOLID;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -715,7 +684,6 @@ void CSceneManager::drawAll()
// render transparent objects.
{
IRR_PROFILE(CProfileScope psTrans(EPID_SM_RENDER_TRANSPARENT);)
CurrentRenderPass = ESNRP_TRANSPARENT;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -731,7 +699,6 @@ void CSceneManager::drawAll()
// render transparent effect objects.
{
IRR_PROFILE(CProfileScope psEffect(EPID_SM_RENDER_EFFECT);)
CurrentRenderPass = ESNRP_TRANSPARENT_EFFECT;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
@ -747,7 +714,6 @@ void CSceneManager::drawAll()
// render custom gui nodes
{
IRR_PROFILE(CProfileScope psEffect(EPID_SM_RENDER_GUI_NODES);)
CurrentRenderPass = ESNRP_GUI;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);

View File

@ -12,7 +12,7 @@ namespace io
CWriteFile::CWriteFile(const io::path& fileName, bool append)
: FileSize(0), Filename(fileName)
: Filename(fileName), FileSize(0)
{
#ifdef _DEBUG
setDebugName("CWriteFile");

View File

@ -1,55 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef E_PROFILE_IDS_H_INCLUDED__
#define E_PROFILE_IDS_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "limits.h"
namespace irr
{
#ifdef _IRR_COMPILE_WITH_PROFILING_
enum EPROFILE_ID
{
// We use negative ID's to avoid clashing with user application id's.
EPID_FIRST = -INT_MAX, // not used
//! scenemanager.
EPID_SM_DRAW_ALL,
EPID_SM_ANIMATE,
EPID_SM_RENDER_CAMERAS,
EPID_SM_RENDER_LIGHTS,
EPID_SM_RENDER_SKYBOXES,
EPID_SM_RENDER_DEFAULT,
EPID_SM_RENDER_SHADOWS,
EPID_SM_RENDER_TRANSPARENT,
EPID_SM_RENDER_EFFECT,
EPID_SM_RENDER_GUI_NODES,
EPID_SM_REGISTER,
//! octrees
EPID_OC_RENDER,
EPID_OC_CALCPOLYS,
//! es2 driver
EPID_ES2_END_SCENE,
EPID_ES2_BEGIN_SCENE,
EPID_ES2_UPDATE_VERTEX_HW_BUF,
EPID_ES2_UPDATE_INDEX_HW_BUF,
EPID_ES2_DRAW_PRIMITIVES,
EPID_ES2_DRAW_2DIMAGE,
EPID_ES2_DRAW_2DIMAGE_BATCH,
EPID_ES2_DRAW_2DRECTANGLE,
EPID_ES2_DRAW_2DLINE,
EPID_ES2_DRAW_3DLINE,
EPID_ES2_SET_RENDERSTATE_2D,
EPID_ES2_SET_RENDERSTATE_3D,
EPID_ES2_SET_RENDERSTATE_BASIC,
EPID_ES2_SET_RENDERSTATE_TEXTURE,
EPID_ES2_DRAW_SHADOW
};
#endif
} // end namespace irr
#endif // E_PROFILE_IDS_H_INCLUDED__

View File

@ -1,36 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_IMAGE_PRESENTER_H_INCLUDED__
#define __I_IMAGE_PRESENTER_H_INCLUDED__
#include "IImage.h"
namespace irr
{
namespace video
{
/*!
Interface for a class which is able to present an IImage
an the Screen. Usually only implemented by an IrrDevice for
presenting Software Device Rendered images.
This class should be used only internally.
*/
class IImagePresenter
{
public:
virtual ~IImagePresenter() {};
//! presents a surface in the client area
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ) = 0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -1,15 +0,0 @@
// Copyright (C) 2013 Michael Zeilfelder
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "leakHunter.h"
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
namespace irr
{
irr::core::array<const IReferenceCounted*> LeakHunter::ReferenceCountedObjects;
} // end namespace irr
#endif // _IRR_COMPILE_WITH_LEAK_HUNTER_