diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-09-03 20:37:35 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-09-03 20:37:35 +0000 |
| commit | baede3a7f3f8f5d6048da82c59c81c9bbd03a8ed (patch) | |
| tree | 6acd7d523fcdd44b1c6cc138fc03c9af8be4081e /Source/Core/VideoCommon | |
| parent | fd06a656f5f6f456efe0bd60b088a9f39f40e0a0 (diff) | |
Moving more things out of GL into VideoCommon...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4187 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/OnScreenDisplay.cpp | 79 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OnScreenDisplay.h | 31 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/Render.h | 83 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/SConscript | 1 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/Statistics.h | 1 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoCommon.h | 17 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoCommon.vcproj | 12 |
7 files changed, 220 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp new file mode 100644 index 0000000000..3ea94958f9 --- /dev/null +++ b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include <list> + +#include "Common.h" + +#include "OnScreenDisplay.h" +#include "Render.h" +#include "Timer.h" + +namespace OSD +{ + +struct MESSAGE +{ + MESSAGE() {} + MESSAGE(const char* p, u32 dw) { + strncpy(str, p, 255); + str[255] = '\0'; + dwTimeStamp = dw; + } + char str[256]; + u32 dwTimeStamp; +}; + +static std::list<MESSAGE> s_listMsgs; + +void AddMessage(const char* pstr, u32 ms) +{ + s_listMsgs.push_back(MESSAGE(pstr, timeGetTime() + ms)); +} + +void DrawMessages() +{ + if (s_listMsgs.size() > 0) + { + int left = 25, top = 15; + std::list<MESSAGE>::iterator it = s_listMsgs.begin(); + while (it != s_listMsgs.end()) + { + int time_left = (int)(it->dwTimeStamp - timeGetTime()); + int alpha = 255; + + if (time_left < 1024) + { + alpha = time_left >> 2; + if (time_left < 0) alpha = 0; + } + + alpha <<= 24; + + Renderer::RenderText(it->str, left+1, top+1, 0x000000|alpha); + Renderer::RenderText(it->str, left, top, 0xffff30|alpha); + top += 15; + + if (time_left <= 0) + it = s_listMsgs.erase(it); + else + ++it; + } + } +} + +} // namespace diff --git a/Source/Core/VideoCommon/Src/OnScreenDisplay.h b/Source/Core/VideoCommon/Src/OnScreenDisplay.h new file mode 100644 index 0000000000..a656ebad1f --- /dev/null +++ b/Source/Core/VideoCommon/Src/OnScreenDisplay.h @@ -0,0 +1,31 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _OSD_H_ +#define _OSD_H_ + +namespace OSD +{ + +// On-screen message display +void AddMessage(const char* str, u32 ms); +void DrawMessages(); // draw the current messages on the screen. Only call once per frame. + +} // namespace + +#endif // _OSD_H_ + diff --git a/Source/Core/VideoCommon/Src/Render.h b/Source/Core/VideoCommon/Src/Render.h new file mode 100644 index 0000000000..53db0a75c9 --- /dev/null +++ b/Source/Core/VideoCommon/Src/Render.h @@ -0,0 +1,83 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + + +// --------------------------------------------------------------------------------------------- +// GC graphics pipeline +// --------------------------------------------------------------------------------------------- +// 3d commands are issued through the fifo. The gpu draws to the 2MB EFB. +// The efb can be copied back into ram in two forms: as textures or as XFB. +// The XFB is the region in RAM that the VI chip scans out to the television. +// So, after all rendering to EFB is done, the image is copied into one of two XFBs in RAM. +// Next frame, that one is scanned out and the other one gets the copy. = double buffering. +// --------------------------------------------------------------------------------------------- + +#ifndef _COMMON_RENDER_H_ +#define _COMMON_RENDER_H_ + +#include "VideoCommon.h" +#include "MathUtil.h" +#include "pluginspecs_video.h" + +extern int frameCount; +extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; + +class Renderer +{ +public: + static bool Init(); + static void Shutdown(); + + // What's the real difference between these? Too similar names. + static void ResetAPIState(); + static void RestoreAPIState(); + + static void ReinitView(); + + static void SwapBuffers(); + + static void SetColorMask(); + static void SetBlendMode(bool forceUpdate); + static bool SetScissorRect(); + + // Render target management + static int GetTargetWidth(); + static int GetTargetHeight(); + + // Multiply any 2D EFB coordinates by these when rendering. + static float GetTargetScaleX(); + static float GetTargetScaleY(); + + static TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc); + + static u32 AccessEFB(EFBAccessType type, int x, int y); + + // Random utilities + static void RenderText(const char* pstr, int left, int top, u32 color); + static void DrawDebugText(); + static void SetScreenshot(const char *filename); + static void FlipImageData(u8 *data, int w, int h); + static bool SaveRenderTarget(const char *filename, int w, int h, int YOffset = 0); + + static void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z); + static void RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc); + + // Finish up the current frame, print some stats + static void Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight); +}; + +#endif // _COMMON_RENDER_H_ diff --git a/Source/Core/VideoCommon/Src/SConscript b/Source/Core/VideoCommon/Src/SConscript index 2de8033410..2ceb3d8840 100644 --- a/Source/Core/VideoCommon/Src/SConscript +++ b/Source/Core/VideoCommon/Src/SConscript @@ -31,6 +31,7 @@ files = [ 'Fifo.cpp', 'VideoState.cpp', 'Profiler.cpp', + 'OnScreenDisplay.cpp', 'HiresTextures.cpp', ] diff --git a/Source/Core/VideoCommon/Src/Statistics.h b/Source/Core/VideoCommon/Src/Statistics.h index cae230f566..151cfbe2db 100644 --- a/Source/Core/VideoCommon/Src/Statistics.h +++ b/Source/Core/VideoCommon/Src/Statistics.h @@ -17,6 +17,7 @@ #include "CommonTypes.h" #include "VideoCommon.h" +#include "Render.h" // for EFBRectangle.h, unfortunately. #include <vector> #ifndef _STATISTICS_H diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 00d4782a56..c52b28691b 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -104,16 +104,25 @@ inline float Memory_Read_Float(u32 _uAddress) return temp.f; } + +// Logging +// ŻŻŻŻŻŻŻŻŻŻ +void HandleGLError(); + + +// This structure should only be used to represent a rectangle in OpenGL target +// coordinates, where the origin is at the lower left and the frame dimensions +// depend on the resolution settings. Use Renderer::ConvertEFBRectangle to +// convert an EFBRectangle to a TargetRectangle. +struct TargetRectangle : public MathUtil::Rectangle<int> +{}; + // This structure should only be used to represent a rectangle in EFB // coordinates, where the origin is at the upper left and the frame dimensions // are 640 x 528. struct EFBRectangle : public MathUtil::Rectangle<int> {}; -// Logging -// ŻŻŻŻŻŻŻŻŻŻ -void HandleGLError(); - #ifdef _WIN32 diff --git a/Source/Core/VideoCommon/VideoCommon.vcproj b/Source/Core/VideoCommon/VideoCommon.vcproj index 3606050446..8878848ea5 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcproj +++ b/Source/Core/VideoCommon/VideoCommon.vcproj @@ -549,6 +549,14 @@ >
</File>
<File
+ RelativePath=".\Src\OnScreenDisplay.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\OnScreenDisplay.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\Profiler.cpp"
>
</File>
@@ -698,6 +706,10 @@ >
</File>
<File
+ RelativePath=".\Src\Render.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\SConscript"
>
</File>
|
