From: <axl...@us...> - 2008-12-07 02:57:00
|
Revision: 57 http://hgengine.svn.sourceforge.net/hgengine/?rev=57&view=rev Author: axlecrusher Date: 2008-12-07 02:56:50 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Seperate textures and image types, and use an image loader to load registered image types Modified Paths: -------------- Mercury2/src/Callback.h Mercury2/src/Texture.cpp Mercury2/src/Texture.h Added Paths: ----------- Mercury2/src/BMPLoader.cpp Mercury2/src/ImageLoader.cpp Mercury2/src/ImageLoader.h Mercury2/src/RawImageData.cpp Mercury2/src/RawImageData.h Added: Mercury2/src/BMPLoader.cpp =================================================================== --- Mercury2/src/BMPLoader.cpp (rev 0) +++ Mercury2/src/BMPLoader.cpp 2008-12-07 02:56:50 UTC (rev 57) @@ -0,0 +1,187 @@ +#include <RawImageData.h> +#include <MercuryUtil.h> +#include <ImageLoader.h> + +using namespace std; + +RawImageData* LoadBMP( FILE* file ) +{ + int offset; + char* tmp = new char[sizeof(int)]; + int compression = 0; + int length; + int rawlength = 0; + int bitsapix = 0; + unsigned char b[3]; + unsigned int res_x, res_y; + +// FILE* file = fopen(filename.c_str(), "rb"); + printf( "BMP Load Start\n" ); + if (file==NULL) + { + printf("Could not open BMP (null file pointer)\n"); + SAFE_DELETE_ARRAY(tmp); + return NULL; + } + + //Get the type of file and test + memset(tmp, 0, 4); +// file->Read(tmp, sizeof(char) * 2); + fread(tmp, sizeof(char) * 2, 1, file); + string type(tmp); + + if (type != "BM") + { + printf("not a valid BMP\n"); + SAFE_DELETE_ARRAY(tmp); + return NULL; + } + //Offset of bitmap data. + fseek(file, 10, SEEK_SET); +// file->Seek(10); + fread(tmp, 4, 1, file); +// file->Read(tmp, 4); + memcpy(&offset, tmp, 4); + TO_ENDIAN( offset ); + + RawImageData* image = new RawImageData; + + //width & width + fseek(file, 18, SEEK_SET); +// file->Seek(18); + fread(tmp, sizeof(int), 1, file); +// file->Read(tmp, sizeof(int)); + memcpy(&image->m_width, tmp, sizeof(int)); + TO_ENDIAN( image->m_width ); + fread(tmp, sizeof(int), 1, file); +// file->Read(tmp, sizeof(int)); + memcpy(&image->m_height, tmp, sizeof(int)); + TO_ENDIAN( image->m_height ); + + //bits per pixel + memset(tmp, 0, sizeof(int)); + fseek(file, 28, SEEK_SET); +// file->Seek(28); +// file->Read(tmp, sizeof(int)); + fread(tmp, sizeof(int), 1, file); + memcpy(&bitsapix, tmp, sizeof(int)); + TO_ENDIAN( bitsapix ); + + if (bitsapix != 24) + { + printf("is not 24b/pix\n"); + SAFE_DELETE_ARRAY(tmp); + SAFE_DELETE_ARRAY(image); + return NULL; + } + + //compression +// file->Seek(30); + fseek(file, 30, SEEK_SET); +// file->Read(tmp, sizeof(int)); + fread(tmp, sizeof(int), 1, file); + memcpy(&compression, tmp, sizeof(int)); + TO_ENDIAN(compression); + + if (compression != 0) + { + printf("uses compression (not supported)\n"); + SAFE_DELETE_ARRAY(tmp); + SAFE_DELETE_ARRAY(image); + return NULL; + } + + //pix/m X + memset(tmp, 0, sizeof(int)); +// file->Seek(38); + fseek(file, 38, SEEK_SET); +// file->Read(tmp, sizeof(int)); + fread(tmp, sizeof(int), 1, file); + memcpy(&res_x, tmp, sizeof(int)); + TO_ENDIAN(res_x); + + //pix/m Y + memset(tmp, 0, sizeof(int)); + fseek(file, 42, SEEK_SET); +// file->Seek(42); +// file->Read(tmp, sizeof(int)); + fread(tmp, sizeof(int), 1, file); + memcpy(&res_y, tmp, sizeof(int)); + TO_ENDIAN(res_y); + + if (res_x > 0) + { +// image->attrs.m_dpi_x = M2DPI(res_x); + } + + if (res_y > 0) + { +// image->attrs.m_dpi_y = M2DPI(res_y); + } + + //Get the file length +// length = file->Length(); + fseek(file,0,SEEK_END); + length = ftell(file); + rawlength = (length) - (offset-1); //Remember to subtract 1 from the offset. + + //Allocate space + SAFE_DELETE_ARRAY(image->m_data); + image->m_data = new unsigned char[rawlength]; + + memset(image->m_data, 0, rawlength); + + //Get raw data and convert BGR->RGB +// file->Seek(offset); + fseek(file, offset, SEEK_SET); +// for (unsigned int x = 0; !file->Eof(); x += 3) + for (unsigned int x = 0; !feof(file); x += 3) + { + memset(b, 0, sizeof(unsigned char) * 3); +// file->Read((char*)&b, sizeof(unsigned char) * 3); + fread(&b, sizeof(unsigned char) * 3, 1, file); + + image->m_data[x] = b[2]; + image->m_data[x+1] = b[1]; + image->m_data[x+2] = b[0]; + } +// image->attrs.m_ColorByteType = RGB; + SAFE_DELETE_ARRAY(tmp); + printf( "BMP Load End\n" ); +// RID = image; + return image; +} + +REGISTER_IMAGE_TYPE(BM6, LoadBMP); + +/**************************************************************************** + * Copyright (C) 2008 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Modified: Mercury2/src/Callback.h =================================================================== --- Mercury2/src/Callback.h 2008-12-06 21:58:06 UTC (rev 56) +++ Mercury2/src/Callback.h 2008-12-07 02:56:50 UTC (rev 57) @@ -35,7 +35,24 @@ R (*functor)(void); }; +template <typename P1, typename R1> + class Callback1R +{ + public: + Callback1R(R1(*f)(P1)) + :functor(f) + {} + R1 operator()(P1 p1) const + { + functor(p1); + } + + private: + R1 (*functor)(P1); +}; + + template <typename P1> class Callback1 { Added: Mercury2/src/ImageLoader.cpp =================================================================== --- Mercury2/src/ImageLoader.cpp (rev 0) +++ Mercury2/src/ImageLoader.cpp 2008-12-07 02:56:50 UTC (rev 57) @@ -0,0 +1,77 @@ +#include <ImageLoader.h> +#include <string> +#include <MercuryUtil.h> + +using namespace std; + +ImageLoader& ImageLoader::GetInstance() +{ + static ImageLoader* instance = NULL; + if (!instance) + instance = new ImageLoader; + return *instance; +} + +bool ImageLoader::RegisterFactoryCallback(const std::string& type, Callback1R< FILE*, RawImageData* > functor) +{ + string t = ToUpper( type ); + std::pair<std::string, Callback1R< FILE*, RawImageData* > > pp(t, functor); + m_factoryCallbacks.push_back( pp ); + return true; +} + +RawImageData* ImageLoader::LoadImage(const std::string& filename) +{ + FILE* f = fopen(filename.c_str(), "rb"); + char fingerprint[4]; + fingerprint[3] = 0; + + fread(fingerprint, sizeof(char)*3, 1, f); + fseek(f, 0, SEEK_SET); + + string t(fingerprint);// = ToUpper( type ); + std::list< std::pair< std::string, Callback1R< FILE*, RawImageData* > > >::iterator i; + for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i) + { + if (i->first == t) + { + RawImageData* d = i->second(f); + fclose(f); + return d; + } + } + fclose(f); + return NULL; +} + +/**************************************************************************** + * Copyright (C) 2008 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/src/ImageLoader.h =================================================================== --- Mercury2/src/ImageLoader.h (rev 0) +++ Mercury2/src/ImageLoader.h 2008-12-07 02:56:50 UTC (rev 57) @@ -0,0 +1,60 @@ +#ifndef IMAGELOADER_H +#define IMAGELOADER_H + +#include <string> +#include <RawImageData.h> +#include <Callback.h> +#include <list> +#include <MercuryUtil.h> + +class ImageLoader +{ + public: + static ImageLoader& GetInstance(); + bool RegisterFactoryCallback(const std::string& type, Callback1R< FILE*, RawImageData* >); + RawImageData* LoadImage(const std::string& filename); + + private: + std::list< std::pair< std::string, Callback1R< FILE*, RawImageData* > > > m_factoryCallbacks; +}; + +static InstanceCounter<ImageLoader> ILcounter("ImageLoader"); + +#define REGISTER_IMAGE_TYPE(fingerprint,functor)\ + Callback1R< FILE*, RawImageData* > factoryclbk##functor( functor ); \ + bool GlobalImageRegisterSuccess##functor = ImageLoader::GetInstance().RegisterFactoryCallback(#fingerprint, factoryclbk##functor); + + +#endif + +/**************************************************************************** + * Copyright (C) 2008 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/src/RawImageData.cpp =================================================================== --- Mercury2/src/RawImageData.cpp (rev 0) +++ Mercury2/src/RawImageData.cpp 2008-12-07 02:56:50 UTC (rev 57) @@ -0,0 +1,44 @@ +#include <RawImageData.h> +#include <MercuryUtil.h> + +RawImageData::RawImageData() + :m_data(NULL) +{ +} + +RawImageData::~RawImageData() +{ + SAFE_DELETE_ARRAY(m_data); +} + +/**************************************************************************** + * Copyright (C) 2008 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/src/RawImageData.h =================================================================== --- Mercury2/src/RawImageData.h (rev 0) +++ Mercury2/src/RawImageData.h 2008-12-07 02:56:50 UTC (rev 57) @@ -0,0 +1,48 @@ +#ifndef RAWIMAGEDATA_H +#define RAWIMAGEDATA_H + +class RawImageData +{ + public: + RawImageData(); + ~RawImageData(); + + unsigned int m_width; + unsigned int m_height; + unsigned short m_bits; + unsigned char* m_data; +}; + +#endif + +/**************************************************************************** + * Copyright (C) 2008 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2008-12-06 21:58:06 UTC (rev 56) +++ Mercury2/src/Texture.cpp 2008-12-07 02:56:50 UTC (rev 57) @@ -1,5 +1,6 @@ #include <Texture.h> #include <RenderableNode.h> +#include <ImageLoader.h> #define GL_GLEXT_PROTOTYPES @@ -10,165 +11,6 @@ REGISTER_ASSET_TYPE(Texture); -RawImageData* LoadBMP( const string& filename ) -{ - int offset; - char* tmp = new char[sizeof(int)]; - int compression = 0; - int length; - int rawlength = 0; - int bitsapix = 0; - unsigned char b[3]; - unsigned int res_x, res_y; - - FILE* file = fopen(filename.c_str(), "rb"); - printf( "BMP Load Start\n" ); - if (file==NULL) - { - printf("Could not open BMP (null file pointer)\n"); - SAFE_DELETE_ARRAY(tmp); - return NULL; - } - - //Get the type of file and test - memset(tmp, 0, 4); -// file->Read(tmp, sizeof(char) * 2); - fread(tmp, sizeof(char) * 2, 1, file); - string type(tmp); - - if (type != "BM") - { - printf("not a valid BMP\n"); - SAFE_DELETE_ARRAY(tmp); - return NULL; - } - //Offset of bitmap data. - fseek(file, 10, SEEK_SET); -// file->Seek(10); - fread(tmp, 4, 1, file); -// file->Read(tmp, 4); - memcpy(&offset, tmp, 4); - TO_ENDIAN( offset ); - - RawImageData* image = new RawImageData; - - //width & width - fseek(file, 18, SEEK_SET); -// file->Seek(18); - fread(tmp, sizeof(int), 1, file); -// file->Read(tmp, sizeof(int)); - memcpy(&image->m_width, tmp, sizeof(int)); - TO_ENDIAN( image->m_width ); - fread(tmp, sizeof(int), 1, file); -// file->Read(tmp, sizeof(int)); - memcpy(&image->m_height, tmp, sizeof(int)); - TO_ENDIAN( image->m_height ); - - //bits per pixel - memset(tmp, 0, sizeof(int)); - fseek(file, 28, SEEK_SET); -// file->Seek(28); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); - memcpy(&bitsapix, tmp, sizeof(int)); - TO_ENDIAN( bitsapix ); - - if (bitsapix != 24) - { - printf("is not 24b/pix\n"); - SAFE_DELETE_ARRAY(tmp); - SAFE_DELETE_ARRAY(image); - return NULL; - } - - //compression -// file->Seek(30); - fseek(file, 30, SEEK_SET); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); - memcpy(&compression, tmp, sizeof(int)); - TO_ENDIAN(compression); - - if (compression != 0) - { - printf("uses compression (not supported)\n"); - SAFE_DELETE_ARRAY(tmp); - SAFE_DELETE_ARRAY(image); - return NULL; - } - - //pix/m X - memset(tmp, 0, sizeof(int)); -// file->Seek(38); - fseek(file, 38, SEEK_SET); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); - memcpy(&res_x, tmp, sizeof(int)); - TO_ENDIAN(res_x); - - //pix/m Y - memset(tmp, 0, sizeof(int)); - fseek(file, 42, SEEK_SET); -// file->Seek(42); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); - memcpy(&res_y, tmp, sizeof(int)); - TO_ENDIAN(res_y); - - if (res_x > 0) - { -// image->attrs.m_dpi_x = M2DPI(res_x); - } - - if (res_y > 0) - { -// image->attrs.m_dpi_y = M2DPI(res_y); - } - - //Get the file length -// length = file->Length(); - fseek(file,0,SEEK_END); - length = ftell(file); - rawlength = (length) - (offset-1); //Remember to subtract 1 from the offset. - - //Allocate space - SAFE_DELETE_ARRAY(image->m_data); - image->m_data = new unsigned char[rawlength]; - - memset(image->m_data, 0, rawlength); - - //Get raw data and convert BGR->RGB -// file->Seek(offset); - fseek(file, offset, SEEK_SET); -// for (unsigned int x = 0; !file->Eof(); x += 3) - for (unsigned int x = 0; !feof(file); x += 3) - { - memset(b, 0, sizeof(unsigned char) * 3); -// file->Read((char*)&b, sizeof(unsigned char) * 3); - fread(&b, sizeof(unsigned char) * 3, 1, file); - - image->m_data[x] = b[2]; - image->m_data[x+1] = b[1]; - image->m_data[x+2] = b[0]; - } -// image->attrs.m_ColorByteType = RGB; - SAFE_DELETE_ARRAY(tmp); - printf( "BMP Load End\n" ); -// RID = image; - return image; -} - - -RawImageData::RawImageData() - :m_data(NULL) -{ -} - -RawImageData::~RawImageData() -{ - SAFE_DELETE_ARRAY(m_data); -} - Texture::Texture() :m_raw(NULL),m_textureID(0) { @@ -218,8 +60,8 @@ // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); }; @@ -237,7 +79,8 @@ { if ( !node.Attribute("imagefile").empty() ) { - RawImageData* d = LoadBMP( node.Attribute("imagefile") ); +// RawImageData* d = LoadBMP( node.Attribute("imagefile") ); + RawImageData* d = ImageLoader::GetInstance().LoadImage( node.Attribute("imagefile") ); if (d) LoadFromRaw( d ); } } Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2008-12-06 21:58:06 UTC (rev 56) +++ Mercury2/src/Texture.h 2008-12-07 02:56:50 UTC (rev 57) @@ -1,17 +1,6 @@ #include <MercuryAsset.h> +#include <RawImageData.h> -class RawImageData -{ - public: - RawImageData(); - ~RawImageData(); - - unsigned int m_width; - unsigned int m_height; - unsigned short m_bits; - unsigned char* m_data; -}; - class Texture : public MercuryAsset { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |