From afc87eb5aea19de2d1ada70d61802fd6116a6289 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Fri, 26 Dec 2008 12:24:15 +0000 Subject: [PATCH] cut dependencies, clean code git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1685 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/VideoCommon/Src/VideoCommon.h | 5 ++++ .../Plugin_VideoOGL/Src/ImageWrite.cpp | 16 ----------- .../Src/PixelShaderManager.cpp | 5 ++-- .../Plugin_VideoOGL/Src/PixelShaderManager.h | 1 - .../Plugin_VideoOGL/Src/TextureConverter.h | 3 +- .../Plugin_VideoOGL/Src/TextureMngr.cpp | 28 +++++++++++++++++-- .../Plugins/Plugin_VideoOGL/Src/TextureMngr.h | 10 ++----- 7 files changed, 38 insertions(+), 30 deletions(-) diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 33a91c2798..1f891631f3 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -52,4 +52,9 @@ inline float Memory_Read_Float(u32 _uAddress) return temp.f; } +struct TRectangle +{ + int left, top, right, bottom; +}; + #endif // _VIDEOCOMMON_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ImageWrite.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ImageWrite.cpp index 64423b66e7..987e2e6641 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ImageWrite.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ImageWrite.cpp @@ -16,7 +16,6 @@ // http://code.google.com/p/dolphin-emu/ #include "Globals.h" -#include "GLUtil.h" #include #include @@ -74,21 +73,6 @@ bool SaveTGA(const char* filename, int width, int height, void* pdata) return true; } -bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height) -{ - GL_REPORT_ERRORD(); - std::vector data(width * height); - glBindTexture(textarget, tex); - glGetTexImage(textarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]); - GLenum err; - GL_REPORT_ERROR(); - if (err != GL_NO_ERROR) - { - return false; - } - return SaveTGA(filename, width, height, &data[0]); -} - bool SaveData(const char* filename, const char* data) { FILE *f = fopen(filename, "wb"); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp index 169d16596d..3bed787d6a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp @@ -16,7 +16,6 @@ // http://code.google.com/p/dolphin-emu/ #include "Common.h" -#include "Globals.h" #include "Profiler.h" #include @@ -24,9 +23,11 @@ #include "Statistics.h" #include "Config.h" -#include "Render.h" #include "PixelShaderManager.h" +// TODO: move logging to VideoCommon. Until then - +#define PRIM_LOG(x, ...) + static int s_nColorsChanged[2]; // 0 - regular colors, 1 - k colors static int s_nIndTexMtxChanged = 0; static bool s_bAlphaChanged; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h index 5b08ac25b2..a68b8c6e80 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h @@ -27,7 +27,6 @@ void SetPSConstant4fv(int const_number, const float *f); // The non-API dependent parts. class PixelShaderManager { - static void SetPSTextureDims(int texid); public: static void Init(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h index a5a7eda607..83ae000f06 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h @@ -18,7 +18,8 @@ #ifndef _TEXTURECONVERTER_H #define _TEXTURECONVERTER_H -#include "TextureMngr.h" +#include "VideoCommon.h" +#include "GLutil.h" // Converts textures between formats // TODO: support multiple texture formats diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index 23efba2430..203d365407 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -15,6 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include + #include "Globals.h" #ifdef _WIN32 @@ -66,7 +68,27 @@ const GLint c_MinLinearFilter[8] = { GL_LINEAR }; -const GLint c_WrapSettings[4] = { GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT, GL_REPEAT }; +const GLint c_WrapSettings[4] = { + GL_CLAMP_TO_EDGE, + GL_REPEAT, + GL_MIRRORED_REPEAT, + GL_REPEAT +}; + +bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height) +{ + GL_REPORT_ERRORD(); + std::vector data(width * height); + glBindTexture(textarget, tex); + glGetTexImage(textarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, &data[0]); + GLenum err; + GL_REPORT_ERROR(); + if (err != GL_NO_ERROR) + { + return false; + } + return SaveTGA(filename, width, height, &data[0]); +} void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode) { @@ -103,13 +125,13 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode) if (g_Config.iMaxAnisotropy >= 1) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 << g_Config.iMaxAnisotropy); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)(1 << g_Config.iMaxAnisotropy)); } } void TextureMngr::TCacheEntry::Destroy() { - if(!texture) + if (!texture) return; glDeleteTextures(1, &texture); if (!isRenderTarget) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h index 3ae72ab7e2..6bfa2ec669 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h @@ -20,14 +20,10 @@ #include +#include "VideoCommon.h" #include "GLUtil.h" #include "BPStructs.h" -struct TRectangle -{ - int left, top, right, bottom; -}; - class TextureMngr { public: @@ -73,7 +69,6 @@ private: static int nTex2DEnabled, nTexRECTEnabled; public: - static void Init(); static void Cleanup(); static void Shutdown(); @@ -86,5 +81,6 @@ public: static void DisableStage(int stage); // sets active texture }; -#endif +bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height); +#endif