diff options
| author | Eugene Sandulenko | 2010-08-13 15:24:23 +0000 | 
|---|---|---|
| committer | Eugene Sandulenko | 2010-10-12 22:39:23 +0000 | 
| commit | fd40021a722956a3c37119c72b1350acb313574e (patch) | |
| tree | b61dd65523d8a26a3b39cfa7fa44c36fc81982f8 | |
| parent | d50dcb80ad44465745a38ea42bd87db9480db949 (diff) | |
| download | scummvm-rg350-fd40021a722956a3c37119c72b1350acb313574e.tar.gz scummvm-rg350-fd40021a722956a3c37119c72b1350acb313574e.tar.bz2 scummvm-rg350-fd40021a722956a3c37119c72b1350acb313574e.zip  | |
SWORD25: Started rewriting gfx subsystem
svn-id: r53227
| -rw-r--r-- | engines/sword25/gfx/image/b25sloader.cpp | 2 | ||||
| -rw-r--r-- | engines/sword25/gfx/image/b25sloader.h | 2 | ||||
| -rw-r--r-- | engines/sword25/gfx/image/imageloader.cpp | 2 | ||||
| -rw-r--r-- | engines/sword25/gfx/image/imageloader.h | 4 | ||||
| -rw-r--r-- | engines/sword25/gfx/image/pngloader.cpp | 6 | ||||
| -rw-r--r-- | engines/sword25/gfx/image/pngloader.h | 4 | ||||
| -rw-r--r-- | engines/sword25/gfx/opengl/glimage.cpp | 29 | ||||
| -rw-r--r-- | engines/sword25/gfx/opengl/glimage.h | 2 | ||||
| -rw-r--r-- | engines/sword25/gfx/opengl/openglgfx.cpp | 69 | 
9 files changed, 28 insertions, 92 deletions
diff --git a/engines/sword25/gfx/image/b25sloader.cpp b/engines/sword25/gfx/image/b25sloader.cpp index e45a4cddcb..9288e2c461 100644 --- a/engines/sword25/gfx/image/b25sloader.cpp +++ b/engines/sword25/gfx/image/b25sloader.cpp @@ -85,7 +85,7 @@ bool BS_B25SLoader::IsCorrectImageFormat(const char *FileDataPtr, unsigned int F  // ----------------------------------------------------------------------------- -bool BS_B25SLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr, +bool BS_B25SLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, byte *&UncompressedDataPtr,                                  int &Width, int &Height, int &Pitch) {  	// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.  	unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize); diff --git a/engines/sword25/gfx/image/b25sloader.h b/engines/sword25/gfx/image/b25sloader.h index 4a2cf3b841..8d8a68e6e8 100644 --- a/engines/sword25/gfx/image/b25sloader.h +++ b/engines/sword25/gfx/image/b25sloader.h @@ -58,7 +58,7 @@ public:  protected:  	virtual bool IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize); -	virtual bool DecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr, +	virtual bool DecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, byte *&UncompressedDataPtr,  	                         int &Width, int &Height, int &Pitch);  	virtual bool ImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height); diff --git a/engines/sword25/gfx/image/imageloader.cpp b/engines/sword25/gfx/image/imageloader.cpp index 02eea59f56..f350dba3f8 100644 --- a/engines/sword25/gfx/image/imageloader.cpp +++ b/engines/sword25/gfx/image/imageloader.cpp @@ -48,7 +48,7 @@ bool BS_ImageLoader::_ImageLoaderListInitialized = false;  bool BS_ImageLoader::LoadImage(const char *pFileData, unsigned int FileSize,                                 BS_GraphicEngine::COLOR_FORMATS ColorFormat, -                               char*& pUncompressedData, +                               byte *&pUncompressedData,                                 int &Width, int &Height,                                 int &Pitch) {  	// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan. diff --git a/engines/sword25/gfx/image/imageloader.h b/engines/sword25/gfx/image/imageloader.h index 204a56b144..968ea35af8 100644 --- a/engines/sword25/gfx/image/imageloader.h +++ b/engines/sword25/gfx/image/imageloader.h @@ -106,7 +106,7 @@ public:  	*/  	static bool LoadImage(const char *pFileData, unsigned int FileSize,  	                      BS_GraphicEngine::COLOR_FORMATS ColorFormat, -	                      char*& pUncompressedData, +	                      byte *&pUncompressedData,  	                      int &Width, int &Height,  	                      int &Pitch); @@ -175,7 +175,7 @@ protected:  	*/  	virtual bool DecodeImage(const char *pFileData, unsigned int FileSize,  	                         BS_GraphicEngine::COLOR_FORMATS ColorFormat, -	                         char*& pUncompressedData, +	                         byte *&pUncompressedData,  	                         int &Width, int &Height,  	                         int &Pitch) = 0; diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp index 3f892c7af1..605dca8635 100644 --- a/engines/sword25/gfx/image/pngloader.cpp +++ b/engines/sword25/gfx/image/pngloader.cpp @@ -62,7 +62,7 @@ static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t l  // ----------------------------------------------------------------------------- -bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr, +bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, byte *&UncompressedDataPtr,                                   int &Width, int &Height, int &Pitch) {  	png_structp png_ptr = NULL;  	png_infop   info_ptr = NULL; @@ -115,7 +115,7 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  	// Speicher für die endgültigen Bilddaten reservieren  	// 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 byte[Pitch * Height];  	if (!UncompressedDataPtr) {  		error("Could not allocate memory for output image.");  	} @@ -256,7 +256,7 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  // ----------------------------------------------------------------------------- -bool BS_PNGLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr, +bool BS_PNGLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, byte *&UncompressedDataPtr,                                 int &Width, int &Height, int &Pitch) {  	return DoDecodeImage(FileDataPtr, FileSize, ColorFormat, UncompressedDataPtr, Width, Height, Pitch);  } diff --git a/engines/sword25/gfx/image/pngloader.h b/engines/sword25/gfx/image/pngloader.h index 85d12a7a94..17655c6fdc 100644 --- a/engines/sword25/gfx/image/pngloader.h +++ b/engines/sword25/gfx/image/pngloader.h @@ -61,7 +61,7 @@ public:  	// Alle virtuellen Methoden von BS_ImageLoader sind hier als static-Methode implementiert, damit sie von BS_B25SLoader aufgerufen werden können.  	// Die virtuellen Methoden rufen diese Methoden auf.  	static bool DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize); -	static bool DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr, +	static bool DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,  BS_GraphicEngine::COLOR_FORMATS ColorFormat, byte *&UncompressedDataPtr,  	                          int &Width, int &Height, int &Pitch);  	static bool DoImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height); @@ -69,7 +69,7 @@ protected:  	BS_PNGLoader();  	bool DecodeImage(const char *pFileData, unsigned int FileSize,  	                 BS_GraphicEngine::COLOR_FORMATS ColorFormat, -	                 char * & pUncompressedData, +	                 byte *&pUncompressedData,  	                 int &Width, int &Height,  	                 int &Pitch);  	bool IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize); diff --git a/engines/sword25/gfx/opengl/glimage.cpp b/engines/sword25/gfx/opengl/glimage.cpp index d5e1376299..3ab20016de 100644 --- a/engines/sword25/gfx/opengl/glimage.cpp +++ b/engines/sword25/gfx/opengl/glimage.cpp @@ -75,8 +75,7 @@ BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :  	}  	// Das Bild dekomprimieren -	char *pUncompressedData; -	if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) { +	if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, _data, m_Width, m_Height, Pitch)) {  		BS_LOG_ERRORLN("Could not decode image.");  		return;  	} @@ -84,19 +83,6 @@ BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :  	// Dateidaten freigeben  	delete[] pFileData; -	// GLS-Sprite mit den Bilddaten erstellen -	GLS_Result GLSResult = GLS_NewSprite(m_Width, m_Height, -	                                     (ColorFormat == BS_GraphicEngine::CF_ARGB32) ? GLS_True : GLS_False, -	                                     pUncompressedData, -	                                     &m_Sprite); -	if (Result != GLS_OK) { -		BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult)); -		return; -	} - -	// Bilddaten freigeben -	delete[] pUncompressedData; -  	Result = true;  	return;  } @@ -104,20 +90,11 @@ BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :  // -----------------------------------------------------------------------------  BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool &Result) : -	m_Sprite(0),  	m_Width(Width),  	m_Height(Height) {  	Result = false; -	// GLS-Sprite mit den Bilddaten erstellen -	GLS_Result GLSResult = GLS_NewSprite(m_Width, m_Height, -	                                     GLS_True, -	                                     0, -	                                     &m_Sprite); -	if (GLSResult != GLS_OK) { -		BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult)); -		return; -	} +	_data = new byte[Width * Height * 4];  	Result = true;  	return; @@ -126,7 +103,7 @@ BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool &Result) :  // -----------------------------------------------------------------------------  BS_GLImage::~BS_GLImage() { -	if (m_Sprite) GLS_DeleteSprite(m_Sprite); +	delete[] _data;  }  // ----------------------------------------------------------------------------- diff --git a/engines/sword25/gfx/opengl/glimage.h b/engines/sword25/gfx/opengl/glimage.h index 9679089cee..c1dfbdc0b9 100644 --- a/engines/sword25/gfx/opengl/glimage.h +++ b/engines/sword25/gfx/opengl/glimage.h @@ -113,7 +113,7 @@ public:  		return true;  	}  private: -	GLS_Sprite  m_Sprite; +	byte *_data;  	int         m_Width;  	int         m_Height;  }; diff --git a/engines/sword25/gfx/opengl/openglgfx.cpp b/engines/sword25/gfx/opengl/openglgfx.cpp index 6937efb813..7e6ad4d392 100644 --- a/engines/sword25/gfx/opengl/openglgfx.cpp +++ b/engines/sword25/gfx/opengl/openglgfx.cpp @@ -32,15 +32,6 @@   *   */ -// ----------------------------------------------------------------------------- -// INCLUDES -// ----------------------------------------------------------------------------- - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <GL/GL.h> - -#include "sword25/util/glsprites/glsprites.h"  #include "sword25/gfx/bitmapresource.h"  #include "sword25/gfx/animationresource.h"  #include "sword25/gfx/fontresource.h" @@ -125,13 +116,7 @@ bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount  	m_ScreenRect.right = m_Width;  	m_ScreenRect.bottom = m_Height; -	// GLsprites initialisieren -	HWND hwnd = reinterpret_cast<HWND>(BS_Kernel::GetInstance()->GetWindow()->GetWindowHandle()); -	GLS_Result Result = GLS_InitExternalWindow(Width, Height, Windowed ? GLS_False : GLS_True, hwnd); -	if (Result != GLS_OK) { -		BS_LOG_ERRORLN("Could not initialize GLsprites. Reason: %s", GLS_ResultString(Result)); -		return false; -	} +	// We already iniitalized gfx after the engine creation  	m_GLspritesInitialized = true;  	// Standardmäßig ist Vsync an. @@ -158,13 +143,6 @@ bool BS_OpenGLGfx::StartFrame(bool UpdateAll) {  	// Den Layer-Manager auf den nächsten Frame vorbereiten  	m_RenderObjectManagerPtr->StartFrame(); -	// GLsprites bescheidgeben -	GLS_Result Result = GLS_StartFrame(); -	if (Result != GLS_OK) { -		BS_LOG_ERRORLN("Call to GLS_StartFrame() failed. Reason: %s", GLS_ResultString(Result)); -		return false; -	} -  	return true;  } @@ -174,8 +152,11 @@ bool BS_OpenGLGfx::EndFrame() {  	// Scene zeichnen  	m_RenderObjectManagerPtr->Render(); +	g_system->updateScreen(); +  	// Debug-Lines zeichnen  	if (!m_DebugLines.empty()) { +#if 0  		glEnable(GL_LINE_SMOOTH);  		glBegin(GL_LINES); @@ -192,15 +173,11 @@ bool BS_OpenGLGfx::EndFrame() {  		glEnd();  		glDisable(GL_LINE_SMOOTH); +#endif -		m_DebugLines.clear(); -	} +		warning("STUB: Drawing debug lines"); -	// Flippen -	GLS_Result Result = GLS_EndFrame(); -	if (Result != GLS_OK) { -		BS_LOG_ERRORLN("Call to GLS_EndFrame() failed. Reason: %s", GLS_ResultString(Result)); -		return false; +		m_DebugLines.clear();  	}  	// Framecounter aktualisieren @@ -218,21 +195,15 @@ BS_RenderObjectPtr<BS_Panel> BS_OpenGLGfx::GetMainPanel() {  // -----------------------------------------------------------------------------  void BS_OpenGLGfx::SetVsync(bool Vsync) { -	GLS_Result Result = GLS_SetVSync(Vsync ? GLS_True : GLS_False); -	if (Result != GLS_OK) BS_LOG_WARNINGLN("Could not set vsync status. Reason: %s", GLS_ResultString(Result)); +	warning("STUB: SetVsync(%d)", Vsync);  }  // -----------------------------------------------------------------------------  bool BS_OpenGLGfx::GetVsync() const { -	GLS_Bool Status; -	GLS_Result Result = GLS_IsVsync(&Status); -	if (Result != GLS_OK) { -		BS_LOG_WARNINGLN("Could not get vsync status. Returning false. Reason: %s", GLS_ResultString(Result)); -		return false; -	} +	warning("STUB: GetVsync()"); -	return Status == GLS_True ? true : false; +	return true;  }  // ----------------------------------------------------------------------------- @@ -248,16 +219,9 @@ bool BS_OpenGLGfx::Fill(const BS_Rect *FillRectPtr, unsigned int Color) {  		FillRectPtr = &Rect;  	} -	glBegin(GL_QUADS); -	glColor4ub((Color >> 16) & 0xff, (Color >> 8) & 0xff, Color & 0xff, Color >> 24); +	warning("STUB: Fill()"); -	glVertex2i(FillRectPtr->left, FillRectPtr->top); -	glVertex2i(FillRectPtr->right, FillRectPtr->top); -	glVertex2i(FillRectPtr->right, FillRectPtr->bottom); -	glVertex2i(FillRectPtr->left, FillRectPtr->bottom); -	glEnd(); - -	return glGetError() == 0; +	return true;  }  // ----------------------------------------------------------------------------- @@ -281,13 +245,8 @@ bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, byte  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 { -		return false; -	} +	 +	return true;  }  // -----------------------------------------------------------------------------  | 
