[Scummvm-cvs-logs] SF.net SVN: scummvm:[53229] scummvm/trunk/engines/sword25/gfx
sev at users.sourceforge.net
sev at users.sourceforge.net
Wed Oct 13 00:40:20 CEST 2010
Revision: 53229
http://scummvm.svn.sourceforge.net/scummvm/?rev=53229&view=rev
Author: sev
Date: 2010-10-12 22:40:20 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
SWORD25: Next step of graphics code conversion.
Now it does not depend on glsprite library and may even show something
Modified Paths:
--------------
scummvm/trunk/engines/sword25/gfx/graphicengine.h
scummvm/trunk/engines/sword25/gfx/opengl/glimage.cpp
scummvm/trunk/engines/sword25/gfx/opengl/glimage.h
scummvm/trunk/engines/sword25/gfx/opengl/glvectorimageblit.cpp
scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.cpp
scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.h
scummvm/trunk/engines/sword25/gfx/opengl/swimage.cpp
Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-12 22:40:20 UTC (rev 53229)
@@ -46,6 +46,7 @@
// Includes
#include "common/array.h"
#include "common/str.h"
+#include "graphics/surface.h"
#include "sword25/kernel/common.h"
#include "sword25/kernel/bs_stdint.h"
#include "sword25/kernel/resservice.h"
@@ -300,6 +301,9 @@
return m_RepaintedPixels;
}
+ Graphics::Surface _backSurface;
+ Graphics::Surface *getSurface() { return &_backSurface; }
+
// Access methods
/**
Modified: scummvm/trunk/engines/sword25/gfx/opengl/glimage.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/glimage.cpp 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/glimage.cpp 2010-10-12 22:40:20 UTC (rev 53229)
@@ -50,7 +50,7 @@
// -----------------------------------------------------------------------------
BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :
- m_Sprite(0),
+ _data(0),
m_Width(0),
m_Height(0) {
Result = false;
@@ -58,6 +58,8 @@
BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->GetService("package"));
BS_ASSERT(pPackage);
+ _backSurface = (static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx")))->getSurface();
+
// Datei laden
char *pFileData;
unsigned int FileSize;
@@ -122,11 +124,13 @@
return false;
}
- // GLS-Sprite mit den Bilddaten f\xFCllen
- GLS_Result GLSResult = GLS_SetSpriteData(m_Sprite, m_Width, m_Height, &Pixeldata[Offset], Stride / 4);
- if (GLSResult != GLS_OK) {
- BS_LOG_ERRORLN("CGLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(GLSResult));
- return false;
+ const byte *in = &Pixeldata[Offset];
+ byte *out = _data;
+
+ for (int i = 0; i < m_Height; i++) {
+ memcpy(out, in, m_Width * 4);
+ out += m_Width * 4;
+ in += Stride;
}
return true;
@@ -146,43 +150,78 @@
BS_Rect *pPartRect,
unsigned int Color,
int Width, int Height) {
- // BS_Rect nach GLS_Rect konvertieren
- GLS_Rect SubImage;
+ int x1 = 0, y1 = 0;
+ int w = m_Width, h = m_Height;
if (pPartRect) {
- SubImage.x1 = pPartRect->left;
- SubImage.y1 = pPartRect->top;
- SubImage.x2 = pPartRect->right;
- SubImage.y2 = pPartRect->bottom;
+ x1 = pPartRect->left;
+ y1 = pPartRect->top;
+ w = pPartRect->right - pPartRect->left;
+ h = pPartRect->bottom - pPartRect->top;
}
- // Farbe nach GLS_Color konvertieren
- GLS_Color GLSColor;
- GLSColor.a = Color >> 24;
- GLSColor.r = (Color >> 16) & 0xff;
- GLSColor.g = (Color >> 8) & 0xff;
- GLSColor.b = Color & 0xff;
-
// Skalierungen berechnen
- GLS_Float ScaleX, ScaleY;
- if (Width == -1) Width = m_Width;
- ScaleX = (GLS_Float) Width / (GLS_Float) m_Width;
+ float ScaleX, ScaleY;
+ if (Width == -1)
+ Width = m_Width;
+ ScaleX = (float) Width / (float) m_Width;
- if (Height == -1) Height = m_Height;
- ScaleY = (GLS_Float) Height / (GLS_Float) m_Height;
+ if (Height == -1)
+ Height = m_Height;
+ ScaleY = (float) Height / (float) m_Height;
+ if (Color != 0xffffffff) {
+ warning("STUB: Image bg color: %x", Color);
+ }
+
+ if (ScaleX != 1.0 || ScaleY != 1.0) {
+ warning("STUB: Sprite scaling (%f x %f)", ScaleX, ScaleY);
+ }
+
+ if (Flipping & (BS_Image::FLIP_V | BS_Image::FLIP_H)) {
+ warning("STUB: Sprite flipping");
+ }
+
+ w = CLIP(x1 + w, 0, (int)_backSurface->w);
+ h = CLIP(y1 + h, 0, (int)_backSurface->h);
+
// Rendern
// TODO:
// Die Bedeutung von FLIP_V und FLIP_H ist vertauscht. Allerdings glaubt der Rest der Engine auch daran, daher war es einfacher diesen Fehler
// weiterzuf\xFChren. Bei Gelegenheit ist dieses aber zu \xE4ndern.
- GLS_Result Result = GLS_Blit(m_Sprite,
- PosX, PosY,
- pPartRect ? &SubImage : 0, &GLSColor,
- (Flipping & BS_Image::FLIP_V) ? GLS_True : GLS_False,
- (Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
- ScaleX, ScaleY);
- if (Result != GLS_OK) BS_LOG_ERRORLN("GLS_Blit() failed. Reason: %s", GLS_ResultString(Result));
- return Result == GLS_OK;
+ // TODO: scaling
+ // TODO: Flipping
+ byte *ino = &_data[y1 * m_Width * 4 + x1 * 4];
+ byte *outo = (byte *)_backSurface->getBasePtr(PosX, PosY);
+ byte *in, *out;
+ bool alphawarn = false;
+
+ for (int i = 0; i < h; i++) {
+ out = outo;
+ in = ino;
+ for (int j = 0; j < w; j++) {
+ if (*in == 0) {
+ in += 4;
+ out += 4;
+ continue;
+ }
+
+ if (*in != 255)
+ alphawarn = true;
+
+ *in++ = *out++; // TODO: alpha blending
+ *in++ = *out++;
+ *in++ = *out++;
+ *in++ = *out++;
+ }
+ outo += _backSurface->pitch;
+ ino += m_Width * 4;
+ }
+
+ if (alphawarn)
+ warning("STUB: alpha image");
+
+ return true;
}
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/gfx/opengl/glimage.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/glimage.h 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/glimage.h 2010-10-12 22:40:20 UTC (rev 53229)
@@ -43,8 +43,6 @@
#include "sword25/gfx/image/image.h"
#include "sword25/gfx/graphicengine.h"
-#include <vector>
-
namespace Sword25 {
// -----------------------------------------------------------------------------
@@ -116,6 +114,8 @@
byte *_data;
int m_Width;
int m_Height;
+
+ Graphics::Surface *_backSurface;
};
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/gfx/opengl/glvectorimageblit.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/glvectorimageblit.cpp 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/glvectorimageblit.cpp 2010-10-12 22:40:20 UTC (rev 53229)
@@ -61,6 +61,7 @@
BS_Rect *pPartRect,
unsigned int Color,
int Width, int Height) {
+#if 0
static BS_VectorImageRenderer VectorImageRenderer;
static byte *PixelData;
static GLS_Sprite Sprite = 0;
@@ -138,8 +139,13 @@
(Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
1.0f, 1.0f);
if (Result != GLS_OK) BS_LOG_ERRORLN("GLS_Blit() failed. Reason: %s", GLS_ResultString(Result));
+#else
+ warning("STUB: BS_VectorImage::Blit()");
- return Result == GLS_OK;
+ return true;
+#endif
+
+ return true;
}
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.cpp 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.cpp 2010-10-12 22:40:20 UTC (rev 53229)
@@ -32,6 +32,8 @@
*
*/
+#include "common/system.h"
+
#include "sword25/gfx/bitmapresource.h"
#include "sword25/gfx/animationresource.h"
#include "sword25/gfx/fontresource.h"
@@ -56,8 +58,8 @@
// -----------------------------------------------------------------------------
namespace {
-const unsigned int BIT_DEPTH = 32;
-const unsigned int BACKBUFFER_COUNT = 1;
+const int BIT_DEPTH = 32;
+const int BACKBUFFER_COUNT = 1;
const Common::String PNG_EXTENSION(".png");
const Common::String PNG_S_EXTENSION("_s.png");
const Common::String ANI_EXTENSION("_ani.xml");
@@ -79,7 +81,7 @@
// -----------------------------------------------------------------------------
BS_OpenGLGfx::~BS_OpenGLGfx() {
- if (m_GLspritesInitialized) GLS_Quit();
+ _backSurface.free();
}
// -----------------------------------------------------------------------------
@@ -116,6 +118,8 @@
m_ScreenRect.right = m_Width;
m_ScreenRect.bottom = m_Height;
+ _backSurface.create(Width, Height, 4);
+
// We already iniitalized gfx after the engine creation
m_GLspritesInitialized = true;
Modified: scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.h 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/openglgfx.h 2010-10-12 22:40:20 UTC (rev 53229)
@@ -39,15 +39,9 @@
// INCLUDES
// -----------------------------------------------------------------------------
-#include "sword25/kernel/memlog_off.h"
-#include <memory>
-#include <vector>
-#include "sword25/kernel/memlog_on.h"
-
#include "sword25/kernel/common.h"
#include "sword25/gfx/graphicengine.h"
#include "sword25/gfx/renderobjectptr.h"
-#include "sword25/util/glsprites/glsprites.h"
namespace Sword25 {
@@ -94,7 +88,6 @@
// Debugging Methoden
// ------------------
virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color);
- static const char *GetGLSResultString(GLS_Result Result);
// Persistenz Methoden
// -------------------
@@ -103,6 +96,7 @@
private:
bool m_GLspritesInitialized;
+ byte *_backBuffer;
BS_RenderObjectPtr<BS_Panel> m_MainPanelPtr;
Modified: scummvm/trunk/engines/sword25/gfx/opengl/swimage.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/opengl/swimage.cpp 2010-10-12 22:39:41 UTC (rev 53228)
+++ scummvm/trunk/engines/sword25/gfx/opengl/swimage.cpp 2010-10-12 22:40:20 UTC (rev 53229)
@@ -76,7 +76,7 @@
}
// Das Bild dekomprimieren
- char *pUncompressedData;
+ byte *pUncompressedData;
if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) {
BS_LOG_ERRORLN("Could not decode image.");
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list