aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/gfx/opengl')
-rw-r--r--engines/sword25/gfx/opengl/glimage.cpp5
-rw-r--r--engines/sword25/gfx/opengl/glimage.h2
-rw-r--r--engines/sword25/gfx/opengl/glvectorimageblit.cpp4
-rw-r--r--engines/sword25/gfx/opengl/openglgfx.cpp66
-rw-r--r--engines/sword25/gfx/opengl/openglgfx.h11
-rw-r--r--engines/sword25/gfx/opengl/swimage.cpp2
-rw-r--r--engines/sword25/gfx/opengl/swimage.h2
7 files changed, 41 insertions, 51 deletions
diff --git a/engines/sword25/gfx/opengl/glimage.cpp b/engines/sword25/gfx/opengl/glimage.cpp
index 1434a93e4e..d5e1376299 100644
--- a/engines/sword25/gfx/opengl/glimage.cpp
+++ b/engines/sword25/gfx/opengl/glimage.cpp
@@ -36,7 +36,6 @@
// INCLUDES
// -----------------------------------------------------------------------------
-#include "sword25/util/glsprites/glsprites.h"
#include "sword25/package/packagemanager.h"
#include "sword25/gfx/image/imageloader.h"
#include "sword25/gfx/opengl/openglgfx.h"
@@ -139,9 +138,9 @@ bool BS_GLImage::Fill(const BS_Rect *pFillRect, unsigned int Color) {
// -----------------------------------------------------------------------------
-bool BS_GLImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
+bool BS_GLImage::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) {
// Überprüfen, ob PixelData ausreichend viele Pixel enthält um ein Bild der Größe Width * Height zu erzeugen
- if (Pixeldata.size() < static_cast<unsigned int>(m_Width * m_Height * 4)) {
+ if (size < static_cast<unsigned int>(m_Width * m_Height * 4)) {
BS_LOG_ERRORLN("PixelData vector is too small to define a 32 bit %dx%d image.", m_Width, m_Height);
return false;
}
diff --git a/engines/sword25/gfx/opengl/glimage.h b/engines/sword25/gfx/opengl/glimage.h
index c5a7480874..9679089cee 100644
--- a/engines/sword25/gfx/opengl/glimage.h
+++ b/engines/sword25/gfx/opengl/glimage.h
@@ -88,7 +88,7 @@ public:
unsigned int Color = BS_ARGB(255, 255, 255, 255),
int Width = -1, int Height = -1);
virtual bool Fill(const BS_Rect *pFillRect, unsigned int Color);
- virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0);
+ virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset = 0, unsigned int Stride = 0);
virtual unsigned int GetPixel(int X, int Y);
virtual bool IsBlitSource() const {
diff --git a/engines/sword25/gfx/opengl/glvectorimageblit.cpp b/engines/sword25/gfx/opengl/glvectorimageblit.cpp
index 9368e921e1..5689fdfcba 100644
--- a/engines/sword25/gfx/opengl/glvectorimageblit.cpp
+++ b/engines/sword25/gfx/opengl/glvectorimageblit.cpp
@@ -62,7 +62,7 @@ bool BS_VectorImage::Blit(int PosX, int PosY,
unsigned int Color,
int Width, int Height) {
static BS_VectorImageRenderer VectorImageRenderer;
- static vector<char> PixelData;
+ static byte *PixelData;
static GLS_Sprite Sprite = 0;
static BS_VectorImage *OldThis = 0;
static int OldWidth;
@@ -98,7 +98,7 @@ bool BS_VectorImage::Blit(int PosX, int PosY,
return true;
}
- GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, &PixelData[0], 0);
+ GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, PixelData, 0);
if (Result != GLS_OK) {
BS_LOG_ERRORLN("Call to GLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(Result));
return false;
diff --git a/engines/sword25/gfx/opengl/openglgfx.cpp b/engines/sword25/gfx/opengl/openglgfx.cpp
index 612e1c209e..6937efb813 100644
--- a/engines/sword25/gfx/opengl/openglgfx.cpp
+++ b/engines/sword25/gfx/opengl/openglgfx.cpp
@@ -55,12 +55,8 @@
#include "sword25/gfx/opengl/glimage.h"
#include "sword25/gfx/opengl/swimage.h"
-#include <algorithm>
-
namespace Sword25 {
-using namespace std;
-
#define BS_LOG_PREFIX "OPENGLGFX"
@@ -266,48 +262,50 @@ bool BS_OpenGLGfx::Fill(const BS_Rect *FillRectPtr, unsigned int Color) {
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, vector<unsigned int> & Data) {
- if (!ReadFramebufferContents(m_Width, m_Height, Data)) return false;
+bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data) {
+ if (!ReadFramebufferContents(m_Width, m_Height, Data))
+ return false;
// Die Größe des Framebuffers zurückgeben.
Width = m_Width;
Height = m_Height;
// Bilddaten vom OpenGL-Format in unser eigenes Format umwandeln.
- ReverseRGBAComponentOrder(Data);
- FlipImagedataVertical(Width, Height, Data);
+ ReverseRGBAComponentOrder(*Data, Width * Height);
+ FlipImagedataVertical(Width, Height, *Data);
return true;
}
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data) {
- Data.resize(Width * Height);
- glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Data[0]);
+bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, byte **Data) {
+ *Data = (byte *)malloc(Width * Height * 4);
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, *Data);
if (glGetError() == 0)
return true;
else {
- Data.clear();
return false;
}
}
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::ReverseRGBAComponentOrder(vector<unsigned int> & Data) {
- vector<unsigned int>::iterator It = Data.begin();
- while (It != Data.end()) {
- unsigned int Pixel = *It;
- *It = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16);
- ++It;
+void BS_OpenGLGfx::ReverseRGBAComponentOrder(byte *Data, uint size) {
+ uint32 *ptr = (uint32 *)Data;
+
+ for (uint i = 0; i < size; i++) {
+ unsigned int Pixel = *ptr;
+ *ptr = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16);
+ ++ptr;
}
}
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, vector<unsigned int> & Data) {
+void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, byte *Data) {
+#if 0 // TODO
vector<unsigned int> LineBuffer(Width);
for (unsigned int Y = 0; Y < Height / 2; ++Y) {
@@ -317,26 +315,18 @@ void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height
copy(Line2It, Line2It + Width, Line1It);
copy(LineBuffer.begin(), LineBuffer.end(), Line2It);
}
+#endif
}
// -----------------------------------------------------------------------------
// RESOURCE MANAGING
// -----------------------------------------------------------------------------
-static bool DoesStringEndWith(const Common::String &String, const std::string &OtherString) {
- Common::String::size_type StringPos = String.rfind(OtherString);
- if (StringPos == Common::String::npos) return false;
-
- return StringPos + OtherString.size() == String.size();
-}
-
-// -----------------------------------------------------------------------------
-
BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
BS_ASSERT(CanLoadResource(FileName));
// Bild für den Softwarebuffer laden
- if (DoesStringEndWith(FileName, PNG_S_EXTENSION)) {
+ if (FileName.hasSuffix(PNG_S_EXTENSION)) {
bool Result;
BS_SWImage *pImage = new BS_SWImage(FileName, Result);
if (!Result) {
@@ -354,7 +344,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
}
// Sprite-Bild laden
- if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION)) {
+ if (FileName.hasSuffix(PNG_EXTENSION) || FileName.hasSuffix(B25S_EXTENSION)) {
bool Result;
BS_GLImage *pImage = new BS_GLImage(FileName, Result);
if (!Result) {
@@ -373,7 +363,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
// Vectorgraphik laden
- if (DoesStringEndWith(FileName, SWF_EXTENSION)) {
+ if (FileName.hasSuffix(SWF_EXTENSION)) {
// Pointer auf Package-Manager holen
BS_PackageManager *pPackage = BS_Kernel::GetInstance()->GetPackage();
BS_ASSERT(pPackage);
@@ -406,7 +396,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
}
// Animation laden
- if (DoesStringEndWith(FileName, ANI_EXTENSION)) {
+ if (FileName.hasSuffix(ANI_EXTENSION)) {
BS_AnimationResource *pResource = new BS_AnimationResource(FileName);
if (pResource->IsValid())
return pResource;
@@ -417,7 +407,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
}
// Font laden
- if (DoesStringEndWith(FileName, FNT_EXTENSION)) {
+ if (FileName.hasSuffix(FNT_EXTENSION)) {
BS_FontResource *pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName);
if (pResource->IsValid())
return pResource;
@@ -434,11 +424,11 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
// -----------------------------------------------------------------------------
bool BS_OpenGLGfx::CanLoadResource(const Common::String &FileName) {
- return DoesStringEndWith(FileName, PNG_EXTENSION) ||
- DoesStringEndWith(FileName, ANI_EXTENSION) ||
- DoesStringEndWith(FileName, FNT_EXTENSION) ||
- DoesStringEndWith(FileName, SWF_EXTENSION) ||
- DoesStringEndWith(FileName, B25S_EXTENSION);
+ return FileName.hasSuffix(PNG_EXTENSION) ||
+ FileName.hasSuffix(ANI_EXTENSION) ||
+ FileName.hasSuffix(FNT_EXTENSION) ||
+ FileName.hasSuffix(SWF_EXTENSION) ||
+ FileName.hasSuffix(B25S_EXTENSION);
}
diff --git a/engines/sword25/gfx/opengl/openglgfx.h b/engines/sword25/gfx/opengl/openglgfx.h
index 5a7ca8a85e..ae56ff7fe3 100644
--- a/engines/sword25/gfx/opengl/openglgfx.h
+++ b/engines/sword25/gfx/opengl/openglgfx.h
@@ -84,7 +84,7 @@ public:
virtual bool GetVsync() const;
virtual bool Fill(const BS_Rect *FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0));
- virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> & Data);
+ virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data);
// Resource-Managing Methoden
// --------------------------
@@ -112,7 +112,8 @@ private:
DebugLine(const BS_Vertex &_Start, const BS_Vertex &_End, unsigned int _Color) :
Start(_Start),
End(_End),
- Color(_Color) {};
+ Color(_Color) {}
+ DebugLine() {}
BS_Vertex Start;
BS_Vertex End;
@@ -121,9 +122,9 @@ private:
Common::Array<DebugLine> m_DebugLines;
- static bool ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data);
- static void ReverseRGBAComponentOrder(Common::Array<unsigned int> & Data);
- static void FlipImagedataVertical(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data);
+ static bool ReadFramebufferContents(unsigned int Width, unsigned int Height, byte **Data);
+ static void ReverseRGBAComponentOrder(byte *Data, uint size);
+ static void FlipImagedataVertical(unsigned int Width, unsigned int Height, byte *Data);
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/opengl/swimage.cpp b/engines/sword25/gfx/opengl/swimage.cpp
index 5eebf44b10..f3aa9c1533 100644
--- a/engines/sword25/gfx/opengl/swimage.cpp
+++ b/engines/sword25/gfx/opengl/swimage.cpp
@@ -118,7 +118,7 @@ bool BS_SWImage::Fill(const BS_Rect *pFillRect, unsigned int Color) {
// -----------------------------------------------------------------------------
-bool BS_SWImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
+ bool BS_SWImage::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) {
BS_LOG_ERRORLN("SetContent() is not supported.");
return false;
}
diff --git a/engines/sword25/gfx/opengl/swimage.h b/engines/sword25/gfx/opengl/swimage.h
index 870cbeb830..d6e066661c 100644
--- a/engines/sword25/gfx/opengl/swimage.h
+++ b/engines/sword25/gfx/opengl/swimage.h
@@ -71,7 +71,7 @@ public:
unsigned int Color = BS_ARGB(255, 255, 255, 255),
int Width = -1, int Height = -1);
virtual bool Fill(const BS_Rect *FillRectPtr, unsigned int Color);
- virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
+ virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride);
virtual unsigned int GetPixel(int X, int Y);
virtual bool IsBlitSource() const {