SWORD25: More compilation fixes

Now almost everything compiles fine. Several files were tricked
and there are references to tinyxml.h and of course fmod and agg.

OpenGL gfx renderer removed from the project, we need to create
our own from the scratch.

svn-id: r53224
This commit is contained in:
Eugene Sandulenko 2010-08-07 20:09:40 +00:00
parent 7257ee345b
commit ab85540a1b
12 changed files with 270 additions and 326 deletions

View file

@ -108,14 +108,12 @@ namespace {
bool DoSaveScreenshot(BS_GraphicEngine &GraphicEngine, const Common::String &Filename, bool Thumbnail) { bool DoSaveScreenshot(BS_GraphicEngine &GraphicEngine, const Common::String &Filename, bool Thumbnail) {
unsigned int Width; unsigned int Width;
unsigned int Height; unsigned int Height;
Common::Array<unsigned int> Data; byte *Data;
if (!GraphicEngine.GetScreenshot(Width, Height, Data)) { if (!GraphicEngine.GetScreenshot(Width, Height, &Data)) {
BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot."); BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
return false; return false;
} }
unsigned int test = Data.size();
if (Thumbnail) if (Thumbnail)
return BS_Screenshot::SaveThumbnailToFile(Width, Height, Data, Filename); return BS_Screenshot::SaveThumbnailToFile(Width, Height, Data, Filename);
else else

View file

@ -199,7 +199,7 @@ public:
* @param Height Returns the height of the frame buffer * @param Height Returns the height of the frame buffer
* @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values. * @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
*/ */
virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> &Data) = 0; virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data) = 0;
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0; virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0;

View file

@ -85,28 +85,22 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
return false; return false;
} }
try {
// PNG Signatur überprüfen // PNG Signatur überprüfen
if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) { if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) {
throw(0); error("png_check_sig failed");
} }
// Die beiden PNG Strukturen erstellen // Die beiden PNG Strukturen erstellen
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) { if (!png_ptr) {
BS_LOG_ERRORLN("Could not create libpng read struct."); error("Could not create libpng read struct.");
throw(0);
} }
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) { if (!info_ptr) {
BS_LOG_ERRORLN("Could not create libpng info struct."); error("Could not create libpng info struct.");
throw(0);
} }
// Rücksprungpunkt setzen. Wird im Falle eines Fehlers angesprungen.
if (setjmp(png_jmpbuf(png_ptr))) throw(0);
// Alternative Lesefunktion benutzen // Alternative Lesefunktion benutzen
png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data); png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
@ -114,7 +108,7 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
// PNG Informationen auslesen // PNG Informationen auslesen
png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL); png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
// Pitch des Ausgabebildes berechnen // Pitch des Ausgabebildes berechnen
Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width); Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
@ -123,8 +117,7 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
// Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten // Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
UncompressedDataPtr = new char[Pitch * Height]; UncompressedDataPtr = new char[Pitch * Height];
if (!UncompressedDataPtr) { if (!UncompressedDataPtr) {
BS_LOG_ERRORLN("Could not allocate memory for output image."); error("Could not allocate memory for output image.");
throw(0);
} }
// Bilder jeglicher Farbformate werden zunächst in ARGB Bilder umgewandelt // Bilder jeglicher Farbformate werden zunächst in ARGB Bilder umgewandelt
@ -147,15 +140,14 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
// Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen // Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen
png_read_update_info(png_ptr, info_ptr); png_read_update_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL); png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
// PNGs ohne Interlacing werden Zeilenweise eingelesen // PNGs ohne Interlacing werden Zeilenweise eingelesen
if (InterlaceType == PNG_INTERLACE_NONE) { if (InterlaceType == PNG_INTERLACE_NONE) {
// Speicher für eine Bildzeile reservieren // Speicher für eine Bildzeile reservieren
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)]; RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
if (!RawDataBuffer) { if (!RawDataBuffer) {
BS_LOG_ERRORLN("Could not allocate memory for row buffer."); error("Could not allocate memory for row buffer.");
throw(0);
} }
// Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren // Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
@ -166,60 +158,46 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
// Zeile konvertieren // Zeile konvertieren
switch (ColorFormat) { switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16: case BS_GraphicEngine::CF_RGB16:
RowARGB32ToRGB16((unsigned char *)RawDataBuffer, RowARGB32ToRGB16((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
(unsigned char *)&UncompressedDataPtr[i * Pitch],
Width);
break; break;
case BS_GraphicEngine::CF_RGB15: case BS_GraphicEngine::CF_RGB15:
RowARGB32ToRGB15((unsigned char *)RawDataBuffer, RowARGB32ToRGB15((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
(unsigned char *)&UncompressedDataPtr[i * Pitch],
Width);
break; break;
case BS_GraphicEngine::CF_RGB16_INTERLEAVED: case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
RowARGB32ToRGB16_INTERLEAVED((unsigned char *)RawDataBuffer, RowARGB32ToRGB16_INTERLEAVED((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
(unsigned char *)&UncompressedDataPtr[i * Pitch],
Width);
break; break;
case BS_GraphicEngine::CF_RGB15_INTERLEAVED: case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
RowARGB32ToRGB15_INTERLEAVED((unsigned char *)RawDataBuffer, RowARGB32ToRGB15_INTERLEAVED((byte *)RawDataBuffer,
(unsigned char *)&UncompressedDataPtr[i * Pitch], (byte *)&UncompressedDataPtr[i * Pitch], Width);
Width);
break; break;
case BS_GraphicEngine::CF_ARGB32: case BS_GraphicEngine::CF_ARGB32:
memcpy(&UncompressedDataPtr[i * Pitch], memcpy(&UncompressedDataPtr[i * Pitch], RawDataBuffer, Pitch);
RawDataBuffer,
Pitch);
break; break;
case BS_GraphicEngine::CF_ABGR32: case BS_GraphicEngine::CF_ABGR32:
RowARGB32ToABGR32((unsigned char *)RawDataBuffer, RowARGB32ToABGR32((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
(unsigned char *)&UncompressedDataPtr[i * Pitch],
Width);
break; break;
default: default:
BS_ASSERT(false); assert(0);
}
} }
} }
} else {
// PNGs mit Interlacing werden an einem Stück eingelesen // PNGs mit Interlacing werden an einem Stück eingelesen
else {
// Speicher für das komplette Bild reservieren // Speicher für das komplette Bild reservieren
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height]; RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height];
if (!RawDataBuffer) { if (!RawDataBuffer) {
BS_LOG_ERRORLN("Could not allocate memory for raw image buffer."); error("Could not allocate memory for raw image buffer.");
throw(0);
} }
// Speicher für die Rowpointer reservieren // Speicher für die Rowpointer reservieren
pRowPtr = new png_bytep[Height]; pRowPtr = new png_bytep[Height];
if (!pRowPtr) { if (!pRowPtr) {
BS_LOG_ERRORLN("Could not allocate memory for row pointers."); error("Could not allocate memory for row pointers.");
throw(0);
} }
// Alle Rowpointer mit den richtigen Offsets initialisieren // Alle Rowpointer mit den richtigen Offsets initialisieren
@ -233,37 +211,31 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
switch (ColorFormat) { switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16: case BS_GraphicEngine::CF_RGB16:
for (i = 0; i < Height; i++) for (i = 0; i < Height; i++)
RowARGB32ToRGB16((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), RowARGB32ToRGB16((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
(unsigned char *)&UncompressedDataPtr[i * Pitch], (byte *)&UncompressedDataPtr[i * Pitch], Width);
Width);
break; break;
case BS_GraphicEngine::CF_RGB15: case BS_GraphicEngine::CF_RGB15:
for (i = 0; i < Height; i++) for (i = 0; i < Height; i++)
RowARGB32ToRGB15((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), RowARGB32ToRGB15((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
(unsigned char *)&UncompressedDataPtr[i * Pitch], (byte *)&UncompressedDataPtr[i * Pitch], Width);
Width);
break; break;
case BS_GraphicEngine::CF_RGB16_INTERLEAVED: case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
for (i = 0; i < Height; i++) for (i = 0; i < Height; i++)
RowARGB32ToRGB16_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), RowARGB32ToRGB16_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
(unsigned char *)&UncompressedDataPtr[i * Pitch], (byte *)&UncompressedDataPtr[i * Pitch], Width);
Width);
break; break;
case BS_GraphicEngine::CF_RGB15_INTERLEAVED: case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
for (i = 0; i < Height; i++) for (i = 0; i < Height; i++)
RowARGB32ToRGB15_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), RowARGB32ToRGB15_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
(unsigned char *)&UncompressedDataPtr[i * Pitch], (byte *)&UncompressedDataPtr[i * Pitch], Width);
Width);
break; break;
case BS_GraphicEngine::CF_ARGB32: case BS_GraphicEngine::CF_ARGB32:
for (i = 0; i < Height; i++) for (i = 0; i < Height; i++)
memcpy(&UncompressedDataPtr[i * Pitch], memcpy(&UncompressedDataPtr[i * Pitch], &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], Pitch);
&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)],
Pitch);
break; break;
} }
} }
@ -277,17 +249,6 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
// Temporäre Buffer freigeben // Temporäre Buffer freigeben
delete[] pRowPtr; delete[] pRowPtr;
delete[] RawDataBuffer; delete[] RawDataBuffer;
}
catch (int) {
delete[] pRowPtr;
delete[] RawDataBuffer;
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
// Der Funktionsaufruf war nicht erfolgreich
return false;
}
// Der Funktionsaufruf war erfolgreich // Der Funktionsaufruf war erfolgreich
return true; return true;
@ -308,18 +269,16 @@ bool BS_PNGLoader::DoImageProperties(const char *FileDataPtr, unsigned int FileS
png_structp png_ptr = NULL; png_structp png_ptr = NULL;
png_infop info_ptr = NULL; png_infop info_ptr = NULL;
try {
// Die beiden PNG Strukturen erstellen // Die beiden PNG Strukturen erstellen
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) { if (!png_ptr) {
BS_LOG_ERRORLN("Could not create libpng read struct."); error("Could not create libpng read struct.");
throw(0);
} }
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) { if (!info_ptr) {
BS_LOG_ERRORLN("Could not create libpng info struct."); error("Could not create libpng info struct.");
throw(0);
} }
// Alternative Lesefunktion benutzen // Alternative Lesefunktion benutzen
@ -331,7 +290,7 @@ bool BS_PNGLoader::DoImageProperties(const char *FileDataPtr, unsigned int FileS
// PNG Informationen auslesen // PNG Informationen auslesen
int BitDepth; int BitDepth;
int ColorType; int ColorType;
png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL); png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
// PNG-ColorType in BS ColorFormat konvertieren. // PNG-ColorType in BS ColorFormat konvertieren.
if (ColorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) if (ColorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
@ -341,15 +300,6 @@ bool BS_PNGLoader::DoImageProperties(const char *FileDataPtr, unsigned int FileS
// Die Strukturen freigeben // Die Strukturen freigeben
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
}
catch (int) {
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
// Der Funktionsaufruf war nicht erfolgreich
return false;
}
return true; return true;
@ -367,7 +317,7 @@ bool BS_PNGLoader::ImageProperties(const char *FileDataPtr, unsigned int FileSiz
bool BS_PNGLoader::DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) { bool BS_PNGLoader::DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
if (FileSize > 8) if (FileSize > 8)
return png_check_sig((unsigned char *)FileDataPtr, 8) ? true : false; return png_check_sig((byte *)FileDataPtr, 8) ? true : false;
else else
return false; return false;
} }

View file

@ -76,7 +76,7 @@ public:
inline u32 GetBits(unsigned int BitCount) { inline u32 GetBits(unsigned int BitCount) {
if (BitCount == 0 || BitCount > 32) { if (BitCount == 0 || BitCount > 32) {
throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time")); error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time");
} }
u32 value = 0; u32 value = 0;
@ -132,7 +132,7 @@ public:
inline void FlushByte() { inline void FlushByte() {
if (m_WordMask != 128) { if (m_WordMask != 128) {
if (m_Pos >= m_End) { if (m_Pos >= m_End) {
throw(runtime_error("Attempted to read past end of file")); error("Attempted to read past end of file");
} else { } else {
m_Word = *m_Pos++; m_Word = *m_Pos++;
m_WordMask = 128; m_WordMask = 128;
@ -143,7 +143,7 @@ public:
inline void SkipBytes(unsigned int SkipLength) { inline void SkipBytes(unsigned int SkipLength) {
FlushByte(); FlushByte();
if (m_Pos + SkipLength >= m_End) { if (m_Pos + SkipLength >= m_End) {
throw(runtime_error("Attempted to read past end of file")); error("Attempted to read past end of file");
} else { } else {
m_Pos += SkipLength; m_Pos += SkipLength;
m_Word = *(m_Pos - 1); m_Word = *(m_Pos - 1);
@ -237,7 +237,6 @@ BS_VectorImage::BS_VectorImage(const unsigned char *pFileData, unsigned int File
// Im Folgenden werden die Dateidaten aus diesem ausgelesen. // Im Folgenden werden die Dateidaten aus diesem ausgelesen.
SWFBitStream bs(pFileData, FileSize); SWFBitStream bs(pFileData, FileSize);
try {
// SWF-Signatur überprüfen // SWF-Signatur überprüfen
u32 Signature[3]; u32 Signature[3];
Signature[0] = bs.GetU8(); Signature[0] = bs.GetU8();
@ -282,7 +281,8 @@ BS_VectorImage::BS_VectorImage(const unsigned char *pFileData, unsigned int File
u16 TagTypeAndLength = bs.GetU16(); u16 TagTypeAndLength = bs.GetU16();
u32 TagType = TagTypeAndLength >> 6; u32 TagType = TagTypeAndLength >> 6;
u32 TagLength = TagTypeAndLength & 0x3f; u32 TagLength = TagTypeAndLength & 0x3f;
if (TagLength == 0x3f) TagLength = bs.GetU32(); if (TagLength == 0x3f)
TagLength = bs.GetU32();
switch (TagType) { switch (TagType) {
case 2: case 2:
@ -301,14 +301,6 @@ BS_VectorImage::BS_VectorImage(const unsigned char *pFileData, unsigned int File
bs.SkipBytes(TagLength); bs.SkipBytes(TagLength);
} }
} }
}
catch (runtime_error &e) {
// Fehler loggen und Funktion verlassen
// Success ist somit "false" und signalisiert dem Programmierer, dass die Konstruktion fehlgeschlagen ist.
BS_LOG_ERRORLN("The following exception occured while parsing a SWF-file: %s", e.what());
return;
}
// Die Ausführung darf nicht an dieser Stelle ankommen: Entweder es wird ein Shape gefunden, dann wird die Funktion mit vorher verlassen, oder // Die Ausführung darf nicht an dieser Stelle ankommen: Entweder es wird ein Shape gefunden, dann wird die Funktion mit vorher verlassen, oder
// es wird keines gefunden, dann tritt eine Exception auf sobald über das Ende der Datei hinaus gelesen wird. // es wird keines gefunden, dann tritt eine Exception auf sobald über das Ende der Datei hinaus gelesen wird.
@ -329,7 +321,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
// Styles einlesen // Styles einlesen
unsigned int NumFillBits; unsigned int NumFillBits;
unsigned int NumLineBits; unsigned int NumLineBits;
if (!ParseStyles(ShapeType, bs, NumFillBits, NumLineBits)) return false; if (!ParseStyles(ShapeType, bs, NumFillBits, NumLineBits))
return false;
unsigned int LineStyle = 0; unsigned int LineStyle = 0;
unsigned int FillStyle0 = 0; unsigned int FillStyle0 = 0;
@ -409,9 +402,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
m_Elements.back().m_Paths.move_to(LastX, LastY); m_Elements.back().m_Paths.move_to(LastX, LastY);
} }
} }
} } else {
// Edge Record // Edge Record
else {
u32 EdgeFlag = bs.GetBits(1); u32 EdgeFlag = bs.GetBits(1);
u32 NumBits = bs.GetBits(4) + 2; u32 NumBits = bs.GetBits(4) + 2;
@ -427,9 +419,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
double AnchorX = ControlX + AnchorDeltaX; double AnchorX = ControlX + AnchorDeltaX;
double AnchorY = ControlY + AnchorDeltaY; double AnchorY = ControlY + AnchorDeltaY;
m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY); m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY);
} } else {
// Staight edge // Staight edge
else {
s32 DeltaX = 0; s32 DeltaX = 0;
s32 DeltaY = 0; s32 DeltaY = 0;

View file

@ -304,7 +304,7 @@ void BS_RenderObject::SetVisible(bool Visible) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::String &Filename) { BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::String &Filename) {
BS_RenderObjectPtr<BS_Animation> AniPtr(new BS_Animation(this, Filename)); BS_RenderObjectPtr<BS_Animation> AniPtr((new BS_Animation(this->GetHandle(), Filename))->GetHandle());
if (AniPtr.IsValid() && AniPtr->GetInitSuccess()) if (AniPtr.IsValid() && AniPtr->GetInitSuccess())
return AniPtr; return AniPtr;
else { else {
@ -317,9 +317,9 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::Str
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate &AnimationTemplate) { BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate &AnimationTemplate) {
BS_Animation *AniPtr = new BS_Animation(this, AnimationTemplate); BS_Animation *AniPtr = new BS_Animation(this->GetHandle(), AnimationTemplate);
if (AniPtr && AniPtr->GetInitSuccess()) if (AniPtr && AniPtr->GetInitSuccess())
return AniPtr; return AniPtr->GetHandle();
else { else {
delete AniPtr; delete AniPtr;
return BS_RenderObjectPtr<BS_Animation>(); return BS_RenderObjectPtr<BS_Animation>();
@ -329,7 +329,7 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_Animatio
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &Filename) { BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &Filename) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_StaticBitmap(this, Filename)); BS_RenderObjectPtr<BS_Bitmap> BitmapPtr((new BS_StaticBitmap(this->GetHandle(), Filename))->GetHandle());
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess()) if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr); return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr);
else { else {
@ -341,7 +341,7 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &F
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Width, unsigned int Height) { BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Width, unsigned int Height) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_DynamicBitmap(this, Width, Height)); BS_RenderObjectPtr<BS_Bitmap> BitmapPtr((new BS_DynamicBitmap(this->GetHandle(), Width, Height))->GetHandle());
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess()) if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BitmapPtr; return BitmapPtr;
else { else {
@ -353,7 +353,7 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Wid
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, unsigned int Color) { BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, unsigned int Color) {
BS_RenderObjectPtr<BS_Panel> PanelPtr(new BS_Panel(this, Width, Height, Color)); BS_RenderObjectPtr<BS_Panel> PanelPtr((new BS_Panel(this->GetHandle(), Width, Height, Color))->GetHandle());
if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess()) if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess())
return PanelPtr; return PanelPtr;
else { else {
@ -365,7 +365,7 @@ BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, un
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String &Font, const Common::String &Text) { BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String &Font, const Common::String &Text) {
BS_RenderObjectPtr<BS_Text> TextPtr(new BS_Text(this)); BS_RenderObjectPtr<BS_Text> TextPtr((new BS_Text(this->GetHandle()))->GetHandle());
if (TextPtr.IsValid() && TextPtr->GetInitSuccess() && TextPtr->SetFont(Font)) { if (TextPtr.IsValid() && TextPtr->GetInitSuccess() && TextPtr->SetFont(Font)) {
TextPtr->SetText(Text); TextPtr->SetText(Text);
return TextPtr; return TextPtr;
@ -499,23 +499,23 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
switch (Type) { switch (Type) {
case TYPE_PANEL: case TYPE_PANEL:
Result = new BS_Panel(Reader, this, Handle); Result = (new BS_Panel(Reader, this->GetHandle(), Handle))->GetHandle();
break; break;
case TYPE_STATICBITMAP: case TYPE_STATICBITMAP:
Result = new BS_StaticBitmap(Reader, this, Handle); Result = (new BS_StaticBitmap(Reader, this->GetHandle(), Handle))->GetHandle();
break; break;
case TYPE_DYNAMICBITMAP: case TYPE_DYNAMICBITMAP:
Result = new BS_DynamicBitmap(Reader, this, Handle); Result = (new BS_DynamicBitmap(Reader, this->GetHandle(), Handle))->GetHandle();
break; break;
case TYPE_TEXT: case TYPE_TEXT:
Result = new BS_Text(Reader, this, Handle); Result = (new BS_Text(Reader, this->GetHandle(), Handle))->GetHandle();
break; break;
case TYPE_ANIMATION: case TYPE_ANIMATION:
Result = new BS_Animation(Reader, this, Handle); Result = (new BS_Animation(Reader, this->GetHandle(), Handle))->GetHandle();
break; break;
default: default:

View file

@ -59,7 +59,7 @@ namespace Sword25 {
BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) : BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) :
m_FrameStarted(false) { m_FrameStarted(false) {
// Wurzel des BS_RenderObject-Baumes erzeugen. // Wurzel des BS_RenderObject-Baumes erzeugen.
m_RootPtr = new BS_RootRenderObject(this, Width, Height); m_RootPtr = (new BS_RootRenderObject(this, Width, Height))->GetHandle();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View file

@ -59,7 +59,8 @@ struct RGB_PIXEL {
unsigned char Blue; unsigned char Blue;
}; };
bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) { bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename) {
#if 0
BS_ASSERT(Data.size() == Width * Height); BS_ASSERT(Data.size() == Width * Height);
// Buffer für Bildschirminhalt in RGB reservieren // Buffer für Bildschirminhalt in RGB reservieren
@ -146,13 +147,17 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
BS_LOG_ERRORLN("Could not create screenshot (\"%s\").", Filename.c_str()); BS_LOG_ERRORLN("Could not create screenshot (\"%s\").", Filename.c_str());
return false; return false;
} }
#else
warning("STUB: BS_Screenshot::SaveToFile(%d, %d, .., %s)", Width, Height, Filename.c_str());
#endif
return true; return true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) { bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename) {
#if 0
// //
// Diese Methode nimmt ein Screenshot mit den Maßen von 800x600 und erzeugt einen Screenshot mit den Maßen von 200x125. // Diese Methode nimmt ein Screenshot mit den Maßen von 800x600 und erzeugt einen Screenshot mit den Maßen von 200x125.
// Dabei werden je 50 Pixel oben und unten abgeschnitten (die Interface-Leisten im Spiel). Das verbleibende Bild von 800x500 wird auf // Dabei werden je 50 Pixel oben und unten abgeschnitten (die Interface-Leisten im Spiel). Das verbleibende Bild von 800x500 wird auf
@ -199,6 +204,11 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
// Bild als PNG Speichern. // Bild als PNG Speichern.
return SaveToFile(200, 125, ThumbnailData, Filename); return SaveToFile(200, 125, ThumbnailData, Filename);
#else
warning("STUB: BS_Screenshot::SaveThumbnailToFile(%d, %d, .., %s)", Width, Height, Filename.c_str());
return true;
#endif
} }
} // End of namespace Sword25 } // End of namespace Sword25

View file

@ -53,8 +53,8 @@ namespace Sword25 {
class BS_Screenshot { class BS_Screenshot {
public: public:
static bool SaveToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename); static bool SaveToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename);
static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename); static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename);
}; };
} // End of namespace Sword25 } // End of namespace Sword25

View file

@ -183,7 +183,7 @@ bool BS_Text::DoRender() {
int CurX = m_AbsoluteX + (*Iter).BBox.left; int CurX = m_AbsoluteX + (*Iter).BBox.left;
int CurY = m_AbsoluteY + (*Iter).BBox.top; int CurY = m_AbsoluteY + (*Iter).BBox.top;
for (unsigned int i = 0; i < (*Iter).Text.size(); ++i) { for (unsigned int i = 0; i < (*Iter).Text.size(); ++i) {
BS_Rect CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text.at(i)); BS_Rect CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text[i]);
BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight()); BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight());
int RenderX = CurX + (RenderRect.left - RenderRect.left); int RenderX = CurX + (RenderRect.left - RenderRect.left);
@ -322,7 +322,7 @@ void BS_Text::UpdateMetrics(BS_FontResource &FontResource) {
m_Height = 0; m_Height = 0;
for (unsigned int i = 0; i < m_Text.size(); ++i) { for (unsigned int i = 0; i < m_Text.size(); ++i) {
const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i)); const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text[i]);
m_Width += CurRect.GetWidth(); m_Width += CurRect.GetWidth();
if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth(); if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth();
if (m_Height < CurRect.GetHeight()) m_Height = CurRect.GetHeight(); if (m_Height < CurRect.GetHeight()) m_Height = CurRect.GetHeight();

View file

@ -45,12 +45,12 @@ namespace Sword25 {
BS_TimedRenderObject::BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle) : BS_TimedRenderObject::BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle) :
BS_RenderObject(pParent, Type, Handle) { BS_RenderObject(pParent, Type, Handle) {
BS_ASSERT(GetManager()); BS_ASSERT(GetManager());
GetManager()->AttatchTimedRenderObject(this); GetManager()->AttatchTimedRenderObject(this->GetHandle());
} }
BS_TimedRenderObject::~BS_TimedRenderObject() { BS_TimedRenderObject::~BS_TimedRenderObject() {
BS_ASSERT(GetManager()); BS_ASSERT(GetManager());
GetManager()->DetatchTimedRenderObject(this); GetManager()->DetatchTimedRenderObject(this->GetHandle());
} }
} // End of namespace Sword25 } // End of namespace Sword25

View file

@ -46,7 +46,7 @@ namespace Sword25 {
// Constants // Constants
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
static const int infinity = INT_MAX; static const int infinity = (~(-1));
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Constructor / Destructor // Constructor / Destructor

View file

@ -31,13 +31,8 @@ MODULE_OBJS := \
gfx/image/pngloader.o \ gfx/image/pngloader.o \
gfx/image/vectorimage.o \ gfx/image/vectorimage.o \
gfx/image/vectorimagerenderer.o \ gfx/image/vectorimagerenderer.o \
gfx/opengl/glimage.o \
gfx/opengl/glvectorimageblit.o \
gfx/opengl/openglgfx.o \
gfx/opengl/swimage.o \
input/inputengine.o \ input/inputengine.o \
input/inputengine_script.o \ input/inputengine_script.o \
input/stdwininput.o \
kernel/callbackregistry.o \ kernel/callbackregistry.o \
kernel/filesystemutil.o \ kernel/filesystemutil.o \
kernel/inputpersistenceblock.o \ kernel/inputpersistenceblock.o \