Commit f5dbad31 authored by bitplane's avatar bitplane

Added Silicon Graphics RGB texture loader by Gary Conway.

Added dummy os::Byteswap methods to prevent implicit byte swapping on char types.
Updated meshviewer config.xml to include PLY files, also removed the statement that the combo box has no function as it has worked for some time. 
Fixed some comments in CNullDriver.cpp.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2262 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 229ff7da
Changes in 1.6 Changes in 1.6
- Added SGI RGB file reader by Gary Conway, for loading Silicon Graphics .rgb, .rgba, .sgi, .int and .inta textures
- Renamed setResizeAble to setResizeable - Renamed setResizeAble to setResizeable
- Added new device method minimizeWindow which minimizes the window (just as if the minimize button has been clicked). - Added new device method minimizeWindow which minimizes the window (just as if the minimize button has been clicked).
......
...@@ -297,6 +297,8 @@ B3D, MS3D or X meshes */ ...@@ -297,6 +297,8 @@ B3D, MS3D or X meshes */
#define _IRR_COMPILE_WITH_TGA_LOADER_ #define _IRR_COMPILE_WITH_TGA_LOADER_
//! Define _IRR_COMPILE_WITH_WAL_LOADER_ if you want to load .wal files //! Define _IRR_COMPILE_WITH_WAL_LOADER_ if you want to load .wal files
#define _IRR_COMPILE_WITH_WAL_LOADER_ #define _IRR_COMPILE_WITH_WAL_LOADER_
//! Define _IRR_COMPILE_WITH_RGB_LOADER_ if you want to load Silicon Graphics .rgb/.rgba/.sgi/.int/.inta/.bw files
#define _IRR_COMPILE_WITH_RGB_LOADER_
//! Define _IRR_COMPILE_WITH_BMP_WRITER_ if you want to write .bmp files //! Define _IRR_COMPILE_WITH_BMP_WRITER_ if you want to write .bmp files
#define _IRR_COMPILE_WITH_BMP_WRITER_ #define _IRR_COMPILE_WITH_BMP_WRITER_
......
...@@ -22,8 +22,8 @@ Supported formats are: ...@@ -22,8 +22,8 @@ Supported formats are:
- Pulsar LMTools (.lmts) - Pulsar LMTools (.lmts)
- Quake 3 levels (.bsp) - Quake 3 levels (.bsp)
- Quake 2 models (.md2) - Quake 2 models (.md2)
- Stanford Triangle (.ply)
- Stereolithography format (.stl) - Stereolithography format (.stl)
Please note that this program is also a demo of the user interface capabilities of the engine, so for example the combo box in the toolbar has no function.
</messageText> </messageText>
</config> </config>
This diff is collapsed.
// Copyright (C) 2009 Gary Conway
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
/*
Author: Gary Conway (Viper) - co-author of the ZIP file format, Feb 1989,
see the story at http://www.idcnet.us/ziphistory.html
Website: http://idcnet.us
Email: codeslinger@vipergc.com
Created: March 1, 2009
Version: 1.0
Updated:
*/
#ifndef __C_IMAGE_LOADER_RGB_H_INCLUDED__
#define __C_IMAGE_LOADER_RGB_H_INCLUDED__
// define _IRR_RGB_FILE_INVERTED_IMAGE_ to preserve the inverted format of the RGB file
// commenting this out will invert the inverted image,resulting in the image being upright
#define _IRR_RGB_FILE_INVERTED_IMAGE_
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_RGB_LOADER_
#include "IImageLoader.h"
namespace irr
{
namespace video
{
// byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
// the RGB image file header structure
struct SRGBHeader
{
u16 Magic; // IRIS image file magic number
u8 Storage; // Storage format
u8 BPC; // Number of bytes per pixel channel
u16 Dimension; // Number of dimensions
u16 Xsize; // X size in pixels
u16 Ysize; // Y size in pixels
u16 Zsize; // Z size in pixels
u32 Pixmin; // Minimum pixel value
u32 Pixmax; // Maximum pixel value
u32 Dummy1; // ignored
char Imagename[80]; // Image name
u32 Colormap; // Colormap ID
char Dummy2[404]; // Ignored
} PACK_STRUCT;
// Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
// this structure holds context specific data about the file being loaded.
typedef struct _RGBdata
{
u8 *tmp,
*tmpR,
*tmpG,
*tmpB,
*tmpA;
u32 *StartTable; // compressed data table, holds file offsets
u32 *LengthTable; // length for the above data, hold lengths for above
u32 TableLen; // len of above tables
//bool swapFlag;
SRGBHeader header; // define the .rgb file header
u32 ImageSize;
u8 *rgbData;
public:
_RGBdata() : tmp(0), tmpR(0), tmpG(0), tmpB(0), tmpA(0),
StartTable(0), LengthTable(0), TableLen(0), ImageSize(0), rgbData(0)
{
}
~_RGBdata()
{
if (tmp) delete [] tmp;
if (tmpR) delete [] tmpR;
if (tmpG) delete [] tmpG;
if (tmpB) delete [] tmpB;
if (tmpA) delete [] tmpA;
if (StartTable) delete [] StartTable;
if (LengthTable) delete [] LengthTable;
if (rgbData) delete [] rgbData;
}
bool allocateTemps()
{
tmp = tmpR = tmpG = tmpB = tmpA = 0;
tmp = new u8 [header.Xsize * 256 * header.BPC];
if (!tmp)
return false;
if (header.Zsize >= 1)
{
if ( !(tmpR = new u8 [header.Xsize * header.BPC]) )
return false;
}
if (header.Zsize >= 2)
{
if ( !(tmpG = new u8 [header.Xsize * header.BPC]) )
return false;
}
if (header.Zsize >= 3)
{
if ( !(tmpB = new u8 [header.Xsize * header.BPC]) )
return false;
}
if (header.Zsize >= 4)
{
if ( !(tmpA = new u8 [header.Xsize * header.BPC]) )
return false;
}
return true;
}
//typedef unsigned char * BytePtr;
/*
template <class T>
inline void swapBytes( T &s )
{
if( sizeof( T ) == 1 )
return;
T d = s;
BytePtr sptr = (BytePtr)&s;
BytePtr dptr = &(((BytePtr)&d)[sizeof(T)-1]);
for( unsigned int i = 0; i < sizeof(T); i++ )
*(sptr++) = *(dptr--);
}
*/
} rgbStruct;
//! Surface Loader for Silicon Graphics RGB files
class CImageLoaderRGB : public IImageLoader
{
public:
//! constructor
CImageLoaderRGB();
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".tga")
virtual bool isALoadableFileExtension(const irr::core::stringc &fileName) const;
//! returns true if the file maybe is able to be loaded by this class
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
//! creates a surface from the file
virtual IImage* loadImage(io::IReadFile* file) const;
private:
bool readHeader(io::IReadFile* file, rgbStruct* rgb) const;
void readRGBrow( u8 *buf, int y, int z, io::IReadFile* file, rgbStruct* rgb) const;
void convertLong(u32 *array, long length) const;
void convertShort(u16 *array, long length) const;
void processFile(rgbStruct *rgb, io::IReadFile *file) const;
bool checkFormat(io::IReadFile *file, rgbStruct *rgb) const;
bool readOffsetTables(io::IReadFile* file, rgbStruct *rgb) const;
void converttoARGB(u8* in, rgbStruct *rgb) const;
};
} // end namespace video
} // end namespace irr
#endif
#endif
...@@ -44,29 +44,32 @@ IImageLoader* createImageLoaderWAL(); ...@@ -44,29 +44,32 @@ IImageLoader* createImageLoaderWAL();
//! creates a loader which is able to load ppm/pgm/pbm images //! creates a loader which is able to load ppm/pgm/pbm images
IImageLoader* createImageLoaderPPM(); IImageLoader* createImageLoaderPPM();
//! creates a loader which is able to load bmp images //! creates a loader which is able to load rgb images
IImageLoader* createImageLoaderRGB();
//! creates a writer which is able to save bmp images
IImageWriter* createImageWriterBMP(); IImageWriter* createImageWriterBMP();
//! creates a loader which is able to load jpg images //! creates a writer which is able to save jpg images
IImageWriter* createImageWriterJPG(); IImageWriter* createImageWriterJPG();
//! creates a loader which is able to load tga images //! creates a writer which is able to save tga images
IImageWriter* createImageWriterTGA(); IImageWriter* createImageWriterTGA();
//! creates a loader which is able to load psd images //! creates a writer which is able to save psd images
IImageWriter* createImageWriterPSD(); IImageWriter* createImageWriterPSD();
//! creates a loader which is able to load pcx images //! creates a writer which is able to save pcx images
IImageWriter* createImageWriterPCX(); IImageWriter* createImageWriterPCX();
//! creates a loader which is able to load png images //! creates a writer which is able to save png images
IImageWriter* createImageWriterPNG(); IImageWriter* createImageWriterPNG();
//! creates a loader which is able to load ppm images //! creates a writer which is able to save ppm images
IImageWriter* createImageWriterPPM(); IImageWriter* createImageWriterPPM();
//! constructor //! constructor
CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize) CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize)
: FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize), : FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize),
...@@ -116,6 +119,10 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre ...@@ -116,6 +119,10 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
#ifdef _IRR_COMPILE_WITH_PPM_LOADER_ #ifdef _IRR_COMPILE_WITH_PPM_LOADER_
SurfaceLoader.push_back(video::createImageLoaderPPM()); SurfaceLoader.push_back(video::createImageLoaderPPM());
#endif #endif
#ifdef _IRR_COMPILE_WITH_RGB_LOADER_
SurfaceLoader.push_back(video::createImageLoaderRGB());
#endif
#ifdef _IRR_COMPILE_WITH_BMP_WRITER_ #ifdef _IRR_COMPILE_WITH_BMP_WRITER_
SurfaceWriter.push_back(video::createImageWriterBMP()); SurfaceWriter.push_back(video::createImageWriterBMP());
......
...@@ -494,6 +494,8 @@ ...@@ -494,6 +494,8 @@
<Unit filename="CImageLoaderPPM.h" /> <Unit filename="CImageLoaderPPM.h" />
<Unit filename="CImageLoaderPSD.cpp" /> <Unit filename="CImageLoaderPSD.cpp" />
<Unit filename="CImageLoaderPSD.h" /> <Unit filename="CImageLoaderPSD.h" />
<Unit filename="CImageLoaderRGB.cpp" />
<Unit filename="CImageLoaderRGB.h" />
<Unit filename="CImageLoaderTGA.cpp" /> <Unit filename="CImageLoaderTGA.cpp" />
<Unit filename="CImageLoaderTGA.h" /> <Unit filename="CImageLoaderTGA.h" />
<Unit filename="CImageLoaderWAL.cpp" /> <Unit filename="CImageLoaderWAL.cpp" />
......
This diff is collapsed.
...@@ -1220,6 +1220,12 @@ ...@@ -1220,6 +1220,12 @@
<File <File
RelativePath="CImageLoaderPSD.h"> RelativePath="CImageLoaderPSD.h">
</File> </File>
<File
RelativePath="CImageLoaderRGB.cpp">
</File>
<File
RelativePath="CImageLoaderRGB.h">
</File>
<File <File
RelativePath="CImageLoaderTGA.cpp"> RelativePath="CImageLoaderTGA.cpp">
</File> </File>
......
...@@ -1737,6 +1737,14 @@ ...@@ -1737,6 +1737,14 @@
RelativePath="CImageLoaderPSD.h" RelativePath="CImageLoaderPSD.h"
> >
</File> </File>
<File
RelativePath="CImageLoaderRGB.cpp"
>
</File>
<File
RelativePath="CImageLoaderRGB.h"
>
</File>
<File <File
RelativePath="CImageLoaderTGA.cpp" RelativePath="CImageLoaderTGA.cpp"
> >
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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