* Move the BLP loader into Irrlicht
GOODBYE SImage!!!
This commit is contained in:
parent
8c99f05ae7
commit
51df075a80
@ -2,7 +2,6 @@ include_directories (${PROJECT_SOURCE_DIR}/src/dep/include)
|
|||||||
add_library(PseuGUI
|
add_library(PseuGUI
|
||||||
CBoneSceneNode.cpp
|
CBoneSceneNode.cpp
|
||||||
CCursorController.cpp
|
CCursorController.cpp
|
||||||
CImageLoaderBLP.cpp
|
|
||||||
CIrrKlangAudioStreamLoaderMP3.cpp
|
CIrrKlangAudioStreamLoaderMP3.cpp
|
||||||
CIrrKlangAudioStreamMP3.cpp
|
CIrrKlangAudioStreamMP3.cpp
|
||||||
CM2MeshFileLoader.cpp
|
CM2MeshFileLoader.cpp
|
||||||
@ -20,6 +19,5 @@ SceneGuiStart.cpp
|
|||||||
SceneLogin.cpp
|
SceneLogin.cpp
|
||||||
SceneWorld.cpp
|
SceneWorld.cpp
|
||||||
ShTlTerrainSceneNode.cpp
|
ShTlTerrainSceneNode.cpp
|
||||||
SImage.cpp
|
|
||||||
CM2Mesh.cpp
|
CM2Mesh.cpp
|
||||||
)
|
)
|
||||||
@ -2,7 +2,6 @@
|
|||||||
#include "irrlicht/irrlicht.h"
|
#include "irrlicht/irrlicht.h"
|
||||||
#include "CM2MeshFileLoader.h"
|
#include "CM2MeshFileLoader.h"
|
||||||
#include "CWMOMeshFileLoader.h"
|
#include "CWMOMeshFileLoader.h"
|
||||||
#include "CImageLoaderBLP.h"
|
|
||||||
#include "World/Object.h"
|
#include "World/Object.h"
|
||||||
#include "DrawObject.h"
|
#include "DrawObject.h"
|
||||||
#include "PseuWoW.h"
|
#include "PseuWoW.h"
|
||||||
@ -129,8 +128,6 @@ void PseuGUI::_Init(void)
|
|||||||
_device->getLogger()->setLogLevel(ELL_NONE);
|
_device->getLogger()->setLogLevel(ELL_NONE);
|
||||||
|
|
||||||
// register external loaders for not supported filetypes
|
// register external loaders for not supported filetypes
|
||||||
video::CImageLoaderBLP* BLPloader = new video::CImageLoaderBLP();
|
|
||||||
_driver->addExternalImageLoader(BLPloader);
|
|
||||||
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(_device);
|
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(_device);
|
||||||
_smgr->addExternalMeshLoader(m2loader);
|
_smgr->addExternalMeshLoader(m2loader);
|
||||||
scene::CWMOMeshFileLoader* wmoloader = new scene::CWMOMeshFileLoader(_device);
|
scene::CWMOMeshFileLoader* wmoloader = new scene::CWMOMeshFileLoader(_device);
|
||||||
|
|||||||
@ -1,499 +0,0 @@
|
|||||||
// Copyright (C) 2002-2010 Nikolaus Gebhardt / Thomas Alten
|
|
||||||
// This file is part of the "Irrlicht Engine".
|
|
||||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
||||||
|
|
||||||
#include "SImage.h"
|
|
||||||
|
|
||||||
namespace irr
|
|
||||||
{
|
|
||||||
namespace video
|
|
||||||
{
|
|
||||||
|
|
||||||
//! Constructor of empty image
|
|
||||||
SImage::SImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size)
|
|
||||||
:Data(0), Size(size), Format(format), DeleteMemory(true)
|
|
||||||
{
|
|
||||||
initData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Constructor from raw data
|
|
||||||
SImage::SImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* data,
|
|
||||||
bool ownForeignMemory, bool deleteForeignMemory)
|
|
||||||
: Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory)
|
|
||||||
{
|
|
||||||
if (ownForeignMemory)
|
|
||||||
{
|
|
||||||
Data = (u8*)0xbadf00d;
|
|
||||||
initData();
|
|
||||||
Data = (u8*)data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Data = 0;
|
|
||||||
initData();
|
|
||||||
memcpy(Data, data, Size.Height * Pitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! assumes format and size has been set and creates the rest
|
|
||||||
void SImage::initData()
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
setDebugName("SImage");
|
|
||||||
#endif
|
|
||||||
BytesPerPixel = getBitsPerPixelFromFormat(Format) / 8;
|
|
||||||
|
|
||||||
// Pitch should be aligned...
|
|
||||||
Pitch = BytesPerPixel * Size.Width;
|
|
||||||
|
|
||||||
if (!Data)
|
|
||||||
Data = new u8[Size.Height * Pitch];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! destructor
|
|
||||||
SImage::~SImage()
|
|
||||||
{
|
|
||||||
if ( DeleteMemory )
|
|
||||||
delete [] Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns width and height of image data.
|
|
||||||
const core::dimension2d<u32>& SImage::getDimension() const
|
|
||||||
{
|
|
||||||
return Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns bits per pixel.
|
|
||||||
u32 SImage::getBitsPerPixel() const
|
|
||||||
{
|
|
||||||
return getBitsPerPixelFromFormat(Format);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns bytes per pixel
|
|
||||||
u32 SImage::getBytesPerPixel() const
|
|
||||||
{
|
|
||||||
return BytesPerPixel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns image data size in bytes
|
|
||||||
u32 SImage::getImageDataSizeInBytes() const
|
|
||||||
{
|
|
||||||
return Pitch * Size.Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns image data size in pixels
|
|
||||||
u32 SImage::getImageDataSizeInPixels() const
|
|
||||||
{
|
|
||||||
return Size.Width * Size.Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns mask for red value of a pixel
|
|
||||||
u32 SImage::getRedMask() const
|
|
||||||
{
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
return 0x1F<<10;
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
return 0x1F<<11;
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
return 0x00FF0000;
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
return 0x00FF0000;
|
|
||||||
default:
|
|
||||||
return 0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns mask for green value of a pixel
|
|
||||||
u32 SImage::getGreenMask() const
|
|
||||||
{
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
return 0x1F<<5;
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
return 0x3F<<5;
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
return 0x0000FF00;
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
return 0x0000FF00;
|
|
||||||
default:
|
|
||||||
return 0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns mask for blue value of a pixel
|
|
||||||
u32 SImage::getBlueMask() const
|
|
||||||
{
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
return 0x1F;
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
return 0x1F;
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
return 0x000000FF;
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
return 0x000000FF;
|
|
||||||
default:
|
|
||||||
return 0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns mask for alpha value of a pixel
|
|
||||||
u32 SImage::getAlphaMask() const
|
|
||||||
{
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
return 0x1<<15;
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
return 0x0;
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
return 0x0;
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
return 0xFF000000;
|
|
||||||
default:
|
|
||||||
return 0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! sets a pixel
|
|
||||||
void SImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
|
|
||||||
{
|
|
||||||
if (x >= Size.Width || y >= Size.Height)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
{
|
|
||||||
u16 * dest = (u16*) (Data + ( y * Pitch ) + ( x << 1 ));
|
|
||||||
*dest = video::A8R8G8B8toA1R5G5B5( color.color );
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
{
|
|
||||||
u16 * dest = (u16*) (Data + ( y * Pitch ) + ( x << 1 ));
|
|
||||||
*dest = video::A8R8G8B8toR5G6B5( color.color );
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
{
|
|
||||||
u8* dest = Data + ( y * Pitch ) + ( x * 3 );
|
|
||||||
dest[0] = (u8)color.getRed();
|
|
||||||
dest[1] = (u8)color.getGreen();
|
|
||||||
dest[2] = (u8)color.getBlue();
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
{
|
|
||||||
u32 * dest = (u32*) (Data + ( y * Pitch ) + ( x << 2 ));
|
|
||||||
*dest = color.color;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns a pixel
|
|
||||||
SColor SImage::getPixel(u32 x, u32 y) const
|
|
||||||
{
|
|
||||||
if (x >= Size.Width || y >= Size.Height)
|
|
||||||
return SColor(0);
|
|
||||||
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
return A1R5G5B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]);
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
return R5G6B5toA8R8G8B8(((u16*)Data)[y*Size.Width + x]);
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
return ((u32*)Data)[y*Size.Width + x];
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
{
|
|
||||||
u8* p = Data+(y*3)*Size.Width + (x*3);
|
|
||||||
return SColor(255,p[0],p[1],p[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SColor(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! returns the color format
|
|
||||||
ECOLOR_FORMAT SImage::getColorFormat() const
|
|
||||||
{
|
|
||||||
return Format;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface into another at given position
|
|
||||||
void SImage::copyTo(IImage* target, const core::position2d<s32>& pos)
|
|
||||||
{
|
|
||||||
// Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface partially into another at given position
|
|
||||||
void SImage::copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect)
|
|
||||||
{
|
|
||||||
// Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface into another, using the alpha mask, a cliprect and a color to add with
|
|
||||||
void SImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const SColor &color, const core::rect<s32>* clipRect)
|
|
||||||
{
|
|
||||||
// color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF
|
|
||||||
// Blit(color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND: BLITTER_TEXTURE_ALPHA_COLOR_BLEND,
|
|
||||||
// target, clipRect, &pos, this, &sourceRect, color.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface into another, scaling it to the target image size
|
|
||||||
// note: this is very very slow.
|
|
||||||
void SImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch)
|
|
||||||
{
|
|
||||||
if (!target || !width || !height)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const u32 bpp=getBitsPerPixelFromFormat(format)/8;
|
|
||||||
if (0==pitch)
|
|
||||||
pitch = width*bpp;
|
|
||||||
|
|
||||||
if (Format==format && Size.Width==width && Size.Height==height)
|
|
||||||
{
|
|
||||||
if (pitch==Pitch)
|
|
||||||
{
|
|
||||||
memcpy(target, Data, height*pitch);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u8* tgtpos = (u8*) target;
|
|
||||||
u8* srcpos = Data;
|
|
||||||
const u32 bwidth = width*bpp;
|
|
||||||
const u32 rest = pitch-bwidth;
|
|
||||||
for (u32 y=0; y<height; ++y)
|
|
||||||
{
|
|
||||||
// copy scanline
|
|
||||||
memcpy(tgtpos, srcpos, bwidth);
|
|
||||||
// clear pitch
|
|
||||||
memset(tgtpos+bwidth, 0, rest);
|
|
||||||
tgtpos += pitch;
|
|
||||||
srcpos += Pitch;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const f32 sourceXStep = (f32)Size.Width / (f32)width;
|
|
||||||
const f32 sourceYStep = (f32)Size.Height / (f32)height;
|
|
||||||
s32 yval=0, syval=0;
|
|
||||||
f32 sy = 0.0f;
|
|
||||||
for (u32 y=0; y<height; ++y)
|
|
||||||
{
|
|
||||||
f32 sx = 0.0f;
|
|
||||||
for (u32 x=0; x<width; ++x)
|
|
||||||
{
|
|
||||||
// CColorConverter::convert_viaFormat(Data+ syval + ((s32)sx)*BytesPerPixel, Format, 1, ((u8*)target)+ yval + (x*bpp), format);
|
|
||||||
sx+=sourceXStep;
|
|
||||||
}
|
|
||||||
sy+=sourceYStep;
|
|
||||||
syval=((s32)sy)*Pitch;
|
|
||||||
yval+=pitch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface into another, scaling it to the target image size
|
|
||||||
// note: this is very very slow.
|
|
||||||
void SImage::copyToScaling(IImage* target)
|
|
||||||
{
|
|
||||||
if (!target)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const core::dimension2d<u32>& targetSize = target->getDimension();
|
|
||||||
|
|
||||||
if (targetSize==Size)
|
|
||||||
{
|
|
||||||
copyTo(target);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
copyToScaling(target->lock(), targetSize.Width, targetSize.Height, target->getColorFormat());
|
|
||||||
target->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! copies this surface into another, scaling it to fit it.
|
|
||||||
void SImage::copyToScalingBoxFilter(IImage* target, s32 bias, bool blend)
|
|
||||||
{
|
|
||||||
const core::dimension2d<u32> destSize = target->getDimension();
|
|
||||||
|
|
||||||
const f32 sourceXStep = (f32) Size.Width / (f32) destSize.Width;
|
|
||||||
const f32 sourceYStep = (f32) Size.Height / (f32) destSize.Height;
|
|
||||||
|
|
||||||
target->lock();
|
|
||||||
|
|
||||||
s32 fx = core::ceil32( sourceXStep );
|
|
||||||
s32 fy = core::ceil32( sourceYStep );
|
|
||||||
f32 sx;
|
|
||||||
f32 sy;
|
|
||||||
|
|
||||||
sy = 0.f;
|
|
||||||
for ( u32 y = 0; y != destSize.Height; ++y )
|
|
||||||
{
|
|
||||||
sx = 0.f;
|
|
||||||
for ( u32 x = 0; x != destSize.Width; ++x )
|
|
||||||
{
|
|
||||||
target->setPixel( x, y,
|
|
||||||
getPixelBox( core::floor32(sx), core::floor32(sy), fx, fy, bias ), blend );
|
|
||||||
sx += sourceXStep;
|
|
||||||
}
|
|
||||||
sy += sourceYStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
target->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! fills the surface with given color
|
|
||||||
void SImage::fill(const SColor &color)
|
|
||||||
{
|
|
||||||
u32 c;
|
|
||||||
|
|
||||||
switch ( Format )
|
|
||||||
{
|
|
||||||
case ECF_A1R5G5B5:
|
|
||||||
c = color.toA1R5G5B5();
|
|
||||||
c |= c << 16;
|
|
||||||
break;
|
|
||||||
case ECF_R5G6B5:
|
|
||||||
c = video::A8R8G8B8toR5G6B5( color.color );
|
|
||||||
c |= c << 16;
|
|
||||||
break;
|
|
||||||
case ECF_A8R8G8B8:
|
|
||||||
c = color.color;
|
|
||||||
break;
|
|
||||||
case ECF_R8G8B8:
|
|
||||||
{
|
|
||||||
u8 rgb[3];
|
|
||||||
// CColorConverter::convert_A8R8G8B8toR8G8B8(&color, 1, rgb);
|
|
||||||
const u32 size = getImageDataSizeInBytes();
|
|
||||||
for (u32 i=0; i<size; i+=3)
|
|
||||||
{
|
|
||||||
memcpy(Data+i, rgb, 3);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Format != ECF_A1R5G5B5 && Format != ECF_R5G6B5 &&
|
|
||||||
Format != ECF_A8R8G8B8)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// memset32( Data, c, getImageDataSizeInBytes() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! get a filtered pixel
|
|
||||||
inline SColor SImage::getPixelBox( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const
|
|
||||||
{
|
|
||||||
SColor c;
|
|
||||||
s32 a = 0, r = 0, g = 0, b = 0;
|
|
||||||
|
|
||||||
for ( s32 dx = 0; dx != fx; ++dx )
|
|
||||||
{
|
|
||||||
for ( s32 dy = 0; dy != fy; ++dy )
|
|
||||||
{
|
|
||||||
c = getPixel( core::s32_min ( x + dx, Size.Width - 1 ) ,
|
|
||||||
core::s32_min ( y + dy, Size.Height - 1 )
|
|
||||||
);
|
|
||||||
|
|
||||||
a += c.getAlpha();
|
|
||||||
r += c.getRed();
|
|
||||||
g += c.getGreen();
|
|
||||||
b += c.getBlue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// s32 sdiv = s32_log2_s32(fx * fy);
|
|
||||||
|
|
||||||
// a = core::s32_clamp( ( a >> sdiv ) + bias, 0, 255 );
|
|
||||||
// r = core::s32_clamp( ( r >> sdiv ) + bias, 0, 255 );
|
|
||||||
// g = core::s32_clamp( ( g >> sdiv ) + bias, 0, 255 );
|
|
||||||
// b = core::s32_clamp( ( b >> sdiv ) + bias, 0, 255 );
|
|
||||||
|
|
||||||
c.set( a, r, g, b );
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Methods for Software drivers, non-virtual and not necessary to copy into other image classes
|
|
||||||
//! draws a rectangle
|
|
||||||
void SImage::drawRectangle(const core::rect<s32>& rect, const SColor &color)
|
|
||||||
{
|
|
||||||
// Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA,
|
|
||||||
// this, 0, &rect.UpperLeftCorner, 0, &rect, color.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! draws a line from to with color
|
|
||||||
void SImage::drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color)
|
|
||||||
{
|
|
||||||
// AbsRectangle clip;
|
|
||||||
// GetClip( clip, this );
|
|
||||||
|
|
||||||
// core::position2d<s32> p[2];
|
|
||||||
//
|
|
||||||
// if ( ClipLine( clip, p[0], p[1], from, to ) )
|
|
||||||
// {
|
|
||||||
// u32 alpha = extractAlpha( color.color );
|
|
||||||
//
|
|
||||||
// switch ( Format )
|
|
||||||
// {
|
|
||||||
// case ECF_A1R5G5B5:
|
|
||||||
// if ( alpha == 256 )
|
|
||||||
// {
|
|
||||||
// RenderLine16_Decal( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ) );
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// RenderLine16_Blend( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ), alpha >> 3 );
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case ECF_A8R8G8B8:
|
|
||||||
// if ( alpha == 256 )
|
|
||||||
// {
|
|
||||||
// RenderLine32_Decal( this, p[0], p[1], color.color );
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// RenderLine32_Blend( this, p[0], p[1], color.color, alpha );
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace video
|
|
||||||
} // end namespace irr
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
//most simplistic IImage Implementation, copypasted form irrlichts CImage
|
|
||||||
|
|
||||||
#ifndef __S_IMAGE_H_INCLUDED__
|
|
||||||
#define __S_IMAGE_H_INCLUDED__
|
|
||||||
|
|
||||||
#include "irrlicht/irrlicht.h"
|
|
||||||
|
|
||||||
namespace irr
|
|
||||||
{
|
|
||||||
namespace video
|
|
||||||
{
|
|
||||||
|
|
||||||
//! IImage implementation with a lot of special image operations for
|
|
||||||
//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice.
|
|
||||||
class SImage : public IImage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//! constructor from raw image data
|
|
||||||
/** \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. */
|
|
||||||
SImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size,
|
|
||||||
void* data, bool ownForeignMemory=true, bool deleteMemory = true);
|
|
||||||
|
|
||||||
//! constructor for empty image
|
|
||||||
SImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size);
|
|
||||||
|
|
||||||
//! destructor
|
|
||||||
virtual ~SImage();
|
|
||||||
|
|
||||||
//! Lock function.
|
|
||||||
virtual void* lock()
|
|
||||||
{
|
|
||||||
return Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Unlock function.
|
|
||||||
virtual void unlock() {}
|
|
||||||
|
|
||||||
//! Returns width and height of image data.
|
|
||||||
virtual const core::dimension2d<u32>& getDimension() const;
|
|
||||||
|
|
||||||
//! Returns bits per pixel.
|
|
||||||
virtual u32 getBitsPerPixel() const;
|
|
||||||
|
|
||||||
//! Returns bytes per pixel
|
|
||||||
virtual u32 getBytesPerPixel() const;
|
|
||||||
|
|
||||||
//! Returns image data size in bytes
|
|
||||||
virtual u32 getImageDataSizeInBytes() const;
|
|
||||||
|
|
||||||
//! Returns image data size in pixels
|
|
||||||
virtual u32 getImageDataSizeInPixels() const;
|
|
||||||
|
|
||||||
//! returns mask for red value of a pixel
|
|
||||||
virtual u32 getRedMask() const;
|
|
||||||
|
|
||||||
//! returns mask for green value of a pixel
|
|
||||||
virtual u32 getGreenMask() const;
|
|
||||||
|
|
||||||
//! returns mask for blue value of a pixel
|
|
||||||
virtual u32 getBlueMask() const;
|
|
||||||
|
|
||||||
//! returns mask for alpha value of a pixel
|
|
||||||
virtual u32 getAlphaMask() const;
|
|
||||||
|
|
||||||
//! returns a pixel
|
|
||||||
virtual SColor getPixel(u32 x, u32 y) const;
|
|
||||||
|
|
||||||
//! sets a pixel
|
|
||||||
virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false );
|
|
||||||
|
|
||||||
//! returns the color format
|
|
||||||
virtual ECOLOR_FORMAT getColorFormat() const;
|
|
||||||
|
|
||||||
//! returns pitch of image
|
|
||||||
virtual u32 getPitch() const { return Pitch; }
|
|
||||||
|
|
||||||
//! copies this surface into another, scaling it to fit.
|
|
||||||
virtual void copyToScaling(void* target, u32 width, u32 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
|
|
||||||
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(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);
|
|
||||||
|
|
||||||
//! 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);
|
|
||||||
|
|
||||||
//! copies this surface into another, scaling it to fit, appyling a box filter
|
|
||||||
virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false);
|
|
||||||
|
|
||||||
//! fills the surface with black or white
|
|
||||||
virtual void fill(const SColor &color);
|
|
||||||
|
|
||||||
//! draws a rectangle
|
|
||||||
void drawRectangle(const core::rect<s32>& rect, const SColor &color);
|
|
||||||
|
|
||||||
//! draws a line from to
|
|
||||||
void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! assumes format and size has been set and creates the rest
|
|
||||||
void initData();
|
|
||||||
|
|
||||||
inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const;
|
|
||||||
|
|
||||||
u8* Data;
|
|
||||||
core::dimension2d<u32> Size;
|
|
||||||
u32 BytesPerPixel;
|
|
||||||
u32 Pitch;
|
|
||||||
ECOLOR_FORMAT Format;
|
|
||||||
|
|
||||||
bool DeleteMemory;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace video
|
|
||||||
} // end namespace irr
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@ -63,12 +63,6 @@ libpng/pngwrite.c
|
|||||||
libpng/pngwtran.c
|
libpng/pngwtran.c
|
||||||
libpng/pngwutil.c
|
libpng/pngwutil.c
|
||||||
|
|
||||||
# jpeglib/ansi2knr.c
|
|
||||||
# # jpeglib/cdjpeg.c
|
|
||||||
# jpeglib/cjpeg.c
|
|
||||||
# jpeglib/ckconfig.c
|
|
||||||
# jpeglib/djpeg.c
|
|
||||||
# jpeglib/example.c
|
|
||||||
jpeglib/jaricom.c
|
jpeglib/jaricom.c
|
||||||
jpeglib/jcapimin.c
|
jpeglib/jcapimin.c
|
||||||
jpeglib/jcapistd.c
|
jpeglib/jcapistd.c
|
||||||
@ -110,32 +104,11 @@ jpeglib/jfdctint.c
|
|||||||
jpeglib/jidctflt.c
|
jpeglib/jidctflt.c
|
||||||
jpeglib/jidctfst.c
|
jpeglib/jidctfst.c
|
||||||
jpeglib/jidctint.c
|
jpeglib/jidctint.c
|
||||||
# jpeglib/jmemansi.c
|
|
||||||
# # jpeglib/jmemdos.c
|
|
||||||
# # jpeglib/jmemmac.c
|
|
||||||
jpeglib/jmemmgr.c
|
jpeglib/jmemmgr.c
|
||||||
# jpeglib/jmemname.c
|
|
||||||
jpeglib/jmemnobs.c
|
jpeglib/jmemnobs.c
|
||||||
# jpeglib/jpegtran.c
|
|
||||||
jpeglib/jquant1.c
|
jpeglib/jquant1.c
|
||||||
jpeglib/jquant2.c
|
jpeglib/jquant2.c
|
||||||
jpeglib/jutils.c
|
jpeglib/jutils.c
|
||||||
# jpeglib/rdbmp.c
|
|
||||||
# jpeglib/rdcolmap.c
|
|
||||||
# jpeglib/rdgif.c
|
|
||||||
# # jpeglib/rdjpgcom.c
|
|
||||||
# jpeglib/rdppm.c
|
|
||||||
# jpeglib/rdrle.c
|
|
||||||
# jpeglib/rdswitch.c
|
|
||||||
# jpeglib/rdtarga.c
|
|
||||||
# jpeglib/transupp.c
|
|
||||||
# jpeglib/wrbmp.c
|
|
||||||
# jpeglib/wrgif.c
|
|
||||||
# # jpeglib/wrjpgcom.c
|
|
||||||
# jpeglib/wrppm.c
|
|
||||||
# jpeglib/wrrle.c
|
|
||||||
# jpeglib/wrtarga.c
|
|
||||||
|
|
||||||
|
|
||||||
C3DSMeshFileLoader.cpp
|
C3DSMeshFileLoader.cpp
|
||||||
CAnimatedMeshMD2.cpp
|
CAnimatedMeshMD2.cpp
|
||||||
@ -348,6 +321,8 @@ Irrlicht-gcc.cbp
|
|||||||
Irrlicht.cpp
|
Irrlicht.cpp
|
||||||
irrXML.cpp
|
irrXML.cpp
|
||||||
os.cpp
|
os.cpp
|
||||||
|
|
||||||
|
additions/CImageLoaderBLP.cpp
|
||||||
)
|
)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
SET_TARGET_PROPERTIES (irrlicht PROPERTIES DEFINE_SYMBOL "IRRLICHT_EXPORTS" )
|
SET_TARGET_PROPERTIES (irrlicht PROPERTIES DEFINE_SYMBOL "IRRLICHT_EXPORTS" )
|
||||||
|
|||||||
@ -47,6 +47,9 @@ IImageLoader* createImageLoaderPPM();
|
|||||||
//! creates a loader which is able to load rgb images
|
//! creates a loader which is able to load rgb images
|
||||||
IImageLoader* createImageLoaderRGB();
|
IImageLoader* createImageLoaderRGB();
|
||||||
|
|
||||||
|
//! creates a loader which is able to load rgb images
|
||||||
|
IImageLoader* createImageLoaderBLP();
|
||||||
|
|
||||||
|
|
||||||
//! creates a writer which is able to save bmp images
|
//! creates a writer which is able to save bmp images
|
||||||
IImageWriter* createImageWriterBMP();
|
IImageWriter* createImageWriterBMP();
|
||||||
@ -122,6 +125,7 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
|
|||||||
#ifdef _IRR_COMPILE_WITH_RGB_LOADER_
|
#ifdef _IRR_COMPILE_WITH_RGB_LOADER_
|
||||||
SurfaceLoader.push_back(video::createImageLoaderRGB());
|
SurfaceLoader.push_back(video::createImageLoaderRGB());
|
||||||
#endif
|
#endif
|
||||||
|
SurfaceLoader.push_back(video::createImageLoaderBLP());
|
||||||
|
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_BMP_WRITER_
|
#ifdef _IRR_COMPILE_WITH_BMP_WRITER_
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
#include "common.h"
|
|
||||||
#include "irrlicht/irrlicht.h"
|
|
||||||
#include "SImage.h"
|
|
||||||
#include "CImageLoaderBLP.h"
|
#include "CImageLoaderBLP.h"
|
||||||
|
|
||||||
|
#include "IReadFile.h"
|
||||||
|
#include "irrString.h"
|
||||||
|
#include "irrArray.h"
|
||||||
|
#include "../CImage.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace video
|
namespace video
|
||||||
@ -23,26 +25,26 @@ bool CImageLoaderBLP::isALoadableFileFormat(io::IReadFile* file) const
|
|||||||
//Checking if file is a BLP file
|
//Checking if file is a BLP file
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
DEBUG(logdebug("No such file: %s",file->getFileName()));
|
// logerror("No such file: %s",file->getFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string fileId;
|
core::stringc fileId;
|
||||||
// Read the first few bytes of the BLP file
|
// Read the first few bytes of the BLP file
|
||||||
if (file->read(&fileId[0], 4) != 4)
|
if (file->read(&fileId[0], 4) != 4)
|
||||||
{
|
{
|
||||||
DEBUG(logdebug("Cannot read BLP file header\n"));
|
// logerror("Cannot read BLP file header\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileId[0]=='B' && fileId[1]=='L' && fileId[2]=='P' && fileId[3]=='2')
|
if(fileId[0]=='B' && fileId[1]=='L' && fileId[2]=='P' && fileId[3]=='2')
|
||||||
{
|
{
|
||||||
DEBUG(logdebug("Header is BLP2, file should be loadable"));
|
// logerror("Header is BLP2, file should be loadable");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG(logdebug("Header doesn't match, this is no BLP file"));
|
// logerror("Header doesn't match, this is no BLP file");
|
||||||
DEBUG(logdebug("Expected:BLP2 Got:%s",fileId.c_str()));
|
// DEBUG(logdebug("Expected:BLP2 Got:%s",fileId.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +58,8 @@ IImage* CImageLoaderBLP::loadImage(io::IReadFile* file) const
|
|||||||
|
|
||||||
BLPHeader header;
|
BLPHeader header;
|
||||||
file->read(&header,sizeof(BLPHeader));
|
file->read(&header,sizeof(BLPHeader));
|
||||||
|
// logdebug("X: %u Y: %u",header.x_res, header.y_res);
|
||||||
|
// logdebug("Compression: %u ABD %u AU %u",header.compression,header.alpha_bitdepth,header.alpha_unk);
|
||||||
u32 usedMips=0;
|
u32 usedMips=0;
|
||||||
for(u32 i=0;i<16;i++)
|
for(u32 i=0;i<16;i++)
|
||||||
{
|
{
|
||||||
@ -76,7 +79,7 @@ IImage* CImageLoaderBLP::loadImage(io::IReadFile* file) const
|
|||||||
file->seek(header.mip_ofs[0]);
|
file->seek(header.mip_ofs[0]);
|
||||||
|
|
||||||
video::IImage* image = 0;
|
video::IImage* image = 0;
|
||||||
image = new SImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.x_res, header.y_res));
|
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.x_res, header.y_res));
|
||||||
|
|
||||||
if(header.compression==2)
|
if(header.compression==2)
|
||||||
{
|
{
|
||||||
@ -288,6 +291,10 @@ IImage* CImageLoaderBLP::loadImage(io::IReadFile* file) const
|
|||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
IImageLoader* createImageLoaderBLP()
|
||||||
|
{
|
||||||
|
return new CImageLoaderBLP();
|
||||||
|
}
|
||||||
|
|
||||||
}//namespace video
|
}//namespace video
|
||||||
}//namespace irr
|
}//namespace irr
|
||||||
@ -1,5 +1,4 @@
|
|||||||
#include <vector>
|
#include "IImageLoader.h"
|
||||||
#include "irrlicht/IImageLoader.h"
|
|
||||||
typedef unsigned long long int u64;
|
typedef unsigned long long int u64;
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
@ -4,8 +4,6 @@ add_executable (viewer
|
|||||||
main.cpp
|
main.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/CM2MeshFileLoader.cpp
|
${PROJECT_SOURCE_DIR}/src/Client/GUI/CM2MeshFileLoader.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/CWMOMeshFileLoader.cpp
|
${PROJECT_SOURCE_DIR}/src/Client/GUI/CWMOMeshFileLoader.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/CImageLoaderBLP.cpp
|
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/SImage.cpp
|
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/MemoryInterface.cpp
|
${PROJECT_SOURCE_DIR}/src/Client/GUI/MemoryInterface.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/CMDHMemoryReadFile.cpp
|
${PROJECT_SOURCE_DIR}/src/Client/GUI/CMDHMemoryReadFile.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/Client/GUI/CBoneSceneNode.cpp
|
${PROJECT_SOURCE_DIR}/src/Client/GUI/CBoneSceneNode.cpp
|
||||||
|
|||||||
@ -18,7 +18,6 @@ tutorial, we use a lot stuff from the gui namespace.
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "GUI/CM2MeshFileLoader.h"
|
#include "GUI/CM2MeshFileLoader.h"
|
||||||
#include "GUI/CWMOMeshFileLoader.h"
|
#include "GUI/CWMOMeshFileLoader.h"
|
||||||
#include "GUI/CImageLoaderBLP.h"
|
|
||||||
#include "GUI/MemoryInterface.h"
|
#include "GUI/MemoryInterface.h"
|
||||||
#include "MemoryDataHolder.h"
|
#include "MemoryDataHolder.h"
|
||||||
|
|
||||||
@ -141,6 +140,7 @@ void loadModel(const c8* fn)
|
|||||||
core::stringc extension;
|
core::stringc extension;
|
||||||
core::getFileNameExtension(extension, filename);
|
core::getFileNameExtension(extension, filename);
|
||||||
extension.make_lower();
|
extension.make_lower();
|
||||||
|
io::IReadFile* modelfile = io::IrrCreateIReadFileBasic(Device, filename.c_str());
|
||||||
|
|
||||||
// if a texture is loaded apply it to the current model..
|
// if a texture is loaded apply it to the current model..
|
||||||
if (extension == ".jpg" || extension == ".pcx" ||
|
if (extension == ".jpg" || extension == ".pcx" ||
|
||||||
@ -150,12 +150,12 @@ void loadModel(const c8* fn)
|
|||||||
extension == ".bmp" || extension == ".wal" || extension == ".blp")
|
extension == ".bmp" || extension == ".wal" || extension == ".blp")
|
||||||
{
|
{
|
||||||
video::ITexture * texture =
|
video::ITexture * texture =
|
||||||
Device->getVideoDriver()->getTexture( filename.c_str() );
|
Device->getVideoDriver()->getTexture( modelfile );
|
||||||
if ( texture && Model )
|
if ( texture && Model )
|
||||||
{
|
{
|
||||||
// always reload texture
|
// always reload texture
|
||||||
Device->getVideoDriver()->removeTexture(texture);
|
Device->getVideoDriver()->removeTexture(texture);
|
||||||
texture = Device->getVideoDriver()->getTexture( filename.c_str() );
|
texture = Device->getVideoDriver()->getTexture( modelfile );
|
||||||
|
|
||||||
Model->setMaterialTexture(0, texture);
|
Model->setMaterialTexture(0, texture);
|
||||||
}
|
}
|
||||||
@ -179,7 +179,6 @@ void loadModel(const c8* fn)
|
|||||||
Model->remove();
|
Model->remove();
|
||||||
|
|
||||||
Model = 0;
|
Model = 0;
|
||||||
io::IReadFile* modelfile = io::IrrCreateIReadFileBasic(Device, filename.c_str());
|
|
||||||
|
|
||||||
scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh( modelfile );
|
scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh( modelfile );
|
||||||
|
|
||||||
@ -719,8 +718,6 @@ int main(int argc, char* argv[])
|
|||||||
smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);
|
smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);
|
||||||
|
|
||||||
// register external loaders for not supported filetypes
|
// register external loaders for not supported filetypes
|
||||||
video::CImageLoaderBLP* BLPloader = new video::CImageLoaderBLP();
|
|
||||||
driver->addExternalImageLoader(BLPloader);
|
|
||||||
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(Device);
|
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(Device);
|
||||||
smgr->addExternalMeshLoader(m2loader);
|
smgr->addExternalMeshLoader(m2loader);
|
||||||
scene::CWMOMeshFileLoader* wmoloader = new scene::CWMOMeshFileLoader(Device);
|
scene::CWMOMeshFileLoader* wmoloader = new scene::CWMOMeshFileLoader(Device);
|
||||||
@ -882,6 +879,8 @@ int main(int argc, char* argv[])
|
|||||||
img->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,
|
img->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,
|
||||||
EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
|
EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// draw everything
|
// draw everything
|
||||||
|
|
||||||
while(Device->run() && driver)
|
while(Device->run() && driver)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user