Commit 565fc470 authored by hybrid's avatar hybrid

Merged 1486-1488 from 1.4 branch, IImage methods exposed and MeshManipulator moved.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1489 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ed1cd4ea
......@@ -7,6 +7,7 @@
#include "IReferenceCounted.h"
#include "position2d.h"
#include "rect.h"
#include "SColor.h"
namespace irr
......@@ -43,9 +44,6 @@ class IImage : public virtual IReferenceCounted
{
public:
//! Destructor
virtual ~IImage() {}
//! Lock function. Use this to get a pointer to the image data.
/** After you don't need the pointer anymore, you must call unlock().
\return Pointer to the image data. What type of data is pointed to
......@@ -96,13 +94,27 @@ public:
virtual u32 getAlphaMask() const = 0;
//! Returns pitch of image
virtual u32 getPitch() const = 0;
virtual u32 getPitch() const =0;
//! Copies the image into the target, scaling the image to fit
virtual void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) = 0;
virtual void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0;
//! Copies the image into the target, scaling the image to fit
virtual void copyToScaling(IImage* target) = 0;
virtual void copyToScaling(IImage* target) =0;
//! copies this surface into another
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
//! copies this surface into another
virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0;
//! copies this surface into another, using the alpha mask, an cliprect and a color to add with
virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const SColor &color,
const core::rect<s32>* clipRect = 0) =0;
//! fills the surface with black or white
virtual void fill(const SColor &color) =0;
};
......
......@@ -29,6 +29,7 @@ namespace io
namespace scene
{
class IMeshBuffer;
class IMeshManipulator;
} // end namespace scene
namespace video
......@@ -781,6 +782,35 @@ namespace video
bool ownForeignMemory=false,
bool deleteMemory = true) = 0;
//! Creates an empty software image.
/**
\param format Desired color format of the image.
\param size Size of the image to create.
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<s32>& size) =0;
//! Creates a software image by converting it to given format from another image.
/**
\param format Desired color format of the image.
\param imageToCopy Image to copy to the new image.
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
//! Creates a software image from a part of another image.
/**
\param imageToCopy Image to copy the the new image in part.
\param pos Position of rectangle to copy.
\param size Extents of rectangle to copy.
\return The created image.
If you no longer need the image, you should call IImage::drop().
See IReferenceCounted::drop() for more information. */
virtual IImage* createImage(IImage* imageToCopy,
const core::position2d<s32>& pos, const core::dimension2d<s32>& size) =0;
//! Event handler for resize events. Only used by the engine internally.
/** Used to notify the driver that the window was resized.
Usually, there is no need to call this method. */
......@@ -875,6 +905,9 @@ namespace video
Software driver and the Null driver will always return 0. */
virtual IGPUProgrammingServices* getGPUProgrammingServices() = 0;
//! Returns a pointer to the mesh manipulator.
virtual scene::IMeshManipulator* getMeshManipulator() = 0;
//! Clears the ZBuffer.
/** Note that you usually need not to call this method, as it
is automatically done in IVideoDriver::beginScene() or
......
This diff is collapsed.
......@@ -84,43 +84,39 @@ public:
//! returns the color format
virtual ECOLOR_FORMAT getColorFormat() const;
//! draws a rectangle
void drawRectangle(const core::rect<s32>& rect, const SColor &color);
//! returns pitch of image
virtual u32 getPitch() const { return Pitch; }
//! copies this surface into another, scaling it to fit.
virtual void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch=0);
//! copies this surface into another, scaling it to fit.
virtual void copyToScaling(IImage* target);
//! copies this surface into another
void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0));
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0));
//! copies this surface into another
void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0);
virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0);
//! copies this surface into another, using the alpha mask, an cliprect and a color to add with
void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const SColor &color,
const core::rect<s32>* clipRect = 0);
//! copies this surface into another, scaling it to fit.
void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format, u32 pitch=0);
//! copies this surface into another, scaling it to fit.
void copyToScaling(IImage* target);
//! copies this surface into another, scaling it to fit, appyling a box filter
void copyToScalingBoxFilter(IImage* target, s32 bias = 0);
//! draws a line from to
void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color);
//! fills the surface with black or white
void fill(const SColor &color);
virtual void fill(const SColor &color);
//! returns pitch of image
virtual u32 getPitch() const
{
return Pitch;
}
//! draws a rectangle
void drawRectangle(const core::rect<s32>& rect, const SColor &color);
static u32 getBitsPerPixelFromFormat(ECOLOR_FORMAT format);
//! draws a line from to
void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color);
static u32 getBitsPerPixelFromFormat(ECOLOR_FORMAT format);
private:
......
......@@ -12,6 +12,7 @@
#include "IImageLoader.h"
#include "IImageWriter.h"
#include "IMaterialRenderer.h"
#include "CMeshManipulator.h"
namespace irr
......@@ -68,7 +69,7 @@ IImageWriter* createImageWriterPPM();
//! constructor
CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& screenSize)
: FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize),
: FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize),
PrimitivesDrawn(0), TextureCreationFlags(0)
{
#ifdef _DEBUG
......@@ -82,6 +83,9 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& scre
ViewPort = core::rect<s32>(core::position2d<s32>(0,0), screenSize);
// create manipulator
MeshManipulator = new scene::CMeshManipulator();
if (FileSystem)
FileSystem->grab();
......@@ -139,23 +143,20 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& scre
}
//! destructor
CNullDriver::~CNullDriver()
{
// drop file system
if (FileSystem)
FileSystem->drop();
// delete textures
if (MeshManipulator)
MeshManipulator->drop();
deleteAllTextures();
// delete surface loader
u32 i;
for (i=0; i<SurfaceLoader.size(); ++i)
SurfaceLoader[i]->drop();
// delete surface writer
for (i=0; i<SurfaceWriter.size(); ++i)
SurfaceWriter[i]->drop();
......@@ -1231,9 +1232,30 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format,
}
//! Creates an empty software image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<s32>& size)
{
return new CImage(format, size);
}
//! Creates a software image from another image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, IImage *imageToCopy)
{
return new CImage(format, imageToCopy);
}
//! Creates a software image from part of another image.
IImage* CNullDriver::createImage(IImage* imageToCopy, const core::position2d<s32>& pos, const core::dimension2d<s32>& size)
{
return new CImage(imageToCopy, pos, size);
}
//! Sets the fog mode.
void CNullDriver::setFog(SColor color, bool linearFog, f32 start, f32 end, f32 density,
bool pixelFog, bool rangeFog)
void CNullDriver::setFog(SColor color, bool linearFog, f32 start, f32 end,
f32 density, bool pixelFog, bool rangeFog)
{
FogColor = color;
LinearFog = linearFog;
......@@ -1790,6 +1812,14 @@ void CNullDriver::clearZBuffer()
{
}
//! Returns a pointer to the mesh manipulator.
scene::IMeshManipulator* CNullDriver::getMeshManipulator()
{
return MeshManipulator;
}
//! Returns an image created from the last rendered frame.
IImage* CNullDriver::createScreenShot()
{
......
......@@ -286,13 +286,24 @@ namespace video
virtual IImage* createImageFromFile(io::IReadFile* file);
//! Creates a software image from a byte array.
//! \param useForeignMemory: If true, the image will use the data pointer
//! directly and own it from now on, which means it will also try to delete [] the
//! data when the image will be destructed. If false, the memory will by copied.
/** \param useForeignMemory: If true, the image will use the data pointer
directly and own it from now on, which means it will also try to delete [] the
data when the image will be destructed. If false, the memory will by copied. */
virtual IImage* createImageFromData(ECOLOR_FORMAT format,
const core::dimension2d<s32>& size, void *data,
bool ownForeignMemory=true, bool deleteForeignMemory = true);
//! Creates an empty software image.
virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<s32>& size);
//! Creates a software image from another image.
virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy);
//! Creates a software image from part of another image.
virtual IImage* createImage(IImage* imageToCopy,
const core::position2d<s32>& pos, const core::dimension2d<s32>& size);
//! Draws a mesh buffer
virtual void drawMeshBuffer(const scene::IMeshBuffer* mb);
......@@ -317,11 +328,8 @@ namespace video
u32 ChangedID_Index;
u32 LastUsed;
scene::E_HARDWARE_MAPPING Mapped;
};
//! Gets hardware buffer link from a meshbuffer (may create or update buffer)
virtual SHWBufferLink *getBufferLink(const scene::IMeshBuffer* mb);
......@@ -350,8 +358,8 @@ namespace video
virtual bool isHardwareBufferRecommend(const scene::IMeshBuffer* mb);
public:
//! Only used by the internal engine. Used to notify the driver that
//! the window was resized.
//! Only used by the engine internally.
/** Used to notify the driver that the window was resized. */
virtual void OnResize(const core::dimension2d<s32>& size);
//! Adds a new material renderer to the video device.
......@@ -442,6 +450,9 @@ namespace video
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData=0);
//! Returns a pointer to the mesh manipulator.
virtual scene::IMeshManipulator* getMeshManipulator();
//! Clears the ZBuffer.
virtual void clearZBuffer();
......@@ -570,6 +581,9 @@ namespace video
io::IFileSystem* FileSystem;
//! mesh manipulator
scene::IMeshManipulator* MeshManipulator;
core::rect<s32> ViewPort;
core::dimension2d<s32> ScreenSize;
core::matrix4 TransformationMatrix;
......
......@@ -44,9 +44,10 @@ const u16 COGRE_SUBMESH_OPERATION= 0x4010;
const u16 COGRE_SUBMESH_BONE_ASSIGNMENT= 0x4100;
const u16 COGRE_SUBMESH_TEXTURE_ALIAS= 0x4200;
//! Constructor
COgreMeshFileLoader::COgreMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver)
: FileSystem(fs), Driver(driver), SwapEndian(false), Mesh(0), Manipulator(manip), NumUV(0)
COgreMeshFileLoader::COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver)
: FileSystem(fs), Driver(driver), SwapEndian(false), Mesh(0), NumUV(0)
{
#ifdef _DEBUG
......@@ -61,7 +62,6 @@ COgreMeshFileLoader::COgreMeshFileLoader(IMeshManipulator* manip,io::IFileSystem
}
//! destructor
COgreMeshFileLoader::~COgreMeshFileLoader()
{
......@@ -78,7 +78,6 @@ COgreMeshFileLoader::~COgreMeshFileLoader()
}
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".bsp")
bool COgreMeshFileLoader::isALoadableFileExtension(const c8* filename) const
......@@ -87,7 +86,6 @@ bool COgreMeshFileLoader::isALoadableFileExtension(const c8* filename) const
}
//! creates/loads an animated mesh from the file.
//! \return Pointer to the created mesh. Returns 0 if loading failed.
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
......
......@@ -27,7 +27,7 @@ class COgreMeshFileLoader : public IMeshLoader
public:
//! Constructor
COgreMeshFileLoader(IMeshManipulator* manip,io::IFileSystem* fs, video::IVideoDriver* driver);
COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver);
//! destructor
virtual ~COgreMeshFileLoader();
......@@ -230,7 +230,6 @@ private:
core::array<OgreMaterial> Materials;
SMesh* Mesh;
IMeshManipulator* Manipulator;
u32 NumUV;
};
......
......@@ -123,7 +123,6 @@
#include "CDefaultSceneNodeFactory.h"
#include "CSceneCollisionManager.h"
#include "CMeshManipulator.h"
#include "CTriangleSelector.h"
#include "COctTreeTriangleSelector.h"
#include "CTriangleBBSelector.h"
......@@ -157,7 +156,7 @@ 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),
CursorControl(cursorControl), CollisionManager(0), MeshManipulator(0),
CursorControl(cursorControl), CollisionManager(0),
ActiveCamera(0), ShadowColor(150,0,0,0), AmbientLight(0,0,0,0),
MeshCache(cache), CurrentRendertime(ESNRP_COUNT),
IRR_XML_FORMAT_SCENE(L"irr_scene"), IRR_XML_FORMAT_NODE(L"node"), IRR_XML_FORMAT_NODE_ATTR_TYPE(L"type")
......@@ -188,9 +187,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
// create collision manager
CollisionManager = new CSceneCollisionManager(this, Driver);
// create manipulator
MeshManipulator = new CMeshManipulator();
// add file format loaders
#ifdef _IRR_COMPILE_WITH_IRR_MESH_LOADER_
......@@ -230,7 +226,7 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
MeshLoaderList.push_back(new CDMFLoader(this));
#endif
#ifdef _IRR_COMPILE_WITH_OGRE_LOADER_
MeshLoaderList.push_back(new COgreMeshFileLoader(MeshManipulator, FileSystem, Driver));
MeshLoaderList.push_back(new COgreMeshFileLoader(FileSystem, Driver));
#endif
#ifdef _IRR_COMPILE_WITH_OBJ_LOADER_
MeshLoaderList.push_back(new COBJMeshFileLoader(this, FileSystem));
......@@ -274,9 +270,6 @@ CSceneManager::~CSceneManager()
if (CollisionManager)
CollisionManager->drop();
if (MeshManipulator)
MeshManipulator->drop();
if (GUIEnvironment)
GUIEnvironment->drop();
......@@ -1464,7 +1457,6 @@ void CSceneManager::addExternalMeshLoader(IMeshLoader* externalLoader)
}
//! Returns a pointer to the scene collision manager.
ISceneCollisionManager* CSceneManager::getSceneCollisionManager()
{
......@@ -1475,7 +1467,7 @@ ISceneCollisionManager* CSceneManager::getSceneCollisionManager()
//! Returns a pointer to the mesh manipulator.
IMeshManipulator* CSceneManager::getMeshManipulator()
{
return MeshManipulator;
return Driver->getMeshManipulator();
}
......
......@@ -555,9 +555,6 @@ namespace scene
//! collision manager
ISceneCollisionManager* CollisionManager;
//! mesh manipulator
IMeshManipulator* MeshManipulator;
//! render pass lists
core::array<ISceneNode*> CameraList;
core::array<DistanceNodeEntry> LightList;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment