aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/BRenderer.cpp
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-03-06 03:09:12 +0100
committerEinar Johan Trøan Sømåen2012-06-02 12:12:22 +0200
commitb602b511607ac7bae911a5306bbe8301fdad4708 (patch)
tree9d58ffb57d434d8330e22c059239f7f0b1849487 /engines/wintermute/BRenderer.cpp
parent72a44cdc7b2040037a97f00c0c218b7f6bd9cd31 (diff)
downloadscummvm-rg350-b602b511607ac7bae911a5306bbe8301fdad4708.tar.gz
scummvm-rg350-b602b511607ac7bae911a5306bbe8301fdad4708.tar.bz2
scummvm-rg350-b602b511607ac7bae911a5306bbe8301fdad4708.zip
WINTERMUTE: Add the files for the rest of the B-classes.
Diffstat (limited to 'engines/wintermute/BRenderer.cpp')
-rw-r--r--engines/wintermute/BRenderer.cpp259
1 files changed, 259 insertions, 0 deletions
diff --git a/engines/wintermute/BRenderer.cpp b/engines/wintermute/BRenderer.cpp
new file mode 100644
index 0000000000..aaaca902fa
--- /dev/null
+++ b/engines/wintermute/BRenderer.cpp
@@ -0,0 +1,259 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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; either version 2
+ * of the License, or (at your option) any later version.
+
+ * 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 for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on WME Lite.
+ * http://dead-code.org/redir.php?target=wmelite
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "dcgf.h"
+#include "BActiveRect.h"
+#include "BRenderer.h"
+#include "BSurface.h"
+#include "BSubFrame.h"
+#include "BRegion.h"
+#include "PlatformSDL.h"
+
+namespace WinterMute {
+
+//////////////////////////////////////////////////////////////////////
+CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) {
+ m_Instance = NULL;
+ m_Window = NULL;
+ m_ClipperWindow = NULL;
+ m_Active = false;
+ m_Ready = false;
+ m_Windowed = true;
+ m_ForceAlphaColor = 0x00;
+
+ m_Width = m_Height = m_BPP = 0;
+ CBPlatform::SetRectEmpty(&m_MonitorRect);
+
+ m_RealWidth = m_RealHeight = 0;
+ m_DrawOffsetX = m_DrawOffsetY = 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+CBRenderer::~CBRenderer() {
+ DeleteRectList();
+ UnclipCursor();
+}
+
+
+//////////////////////////////////////////////////////////////////////
+void CBRenderer::InitLoop() {
+ DeleteRectList();
+}
+
+
+//////////////////////////////////////////////////////////////////////
+CBObject *CBRenderer::GetObjectAt(int X, int Y) {
+ POINT point;
+ point.x = X;
+ point.y = Y;
+
+ for (int i = m_RectList.GetSize() - 1; i >= 0; i--) {
+ if (CBPlatform::PtInRect(&m_RectList[i]->m_Rect, point)) {
+ if (m_RectList[i]->m_Precise) {
+ // frame
+ if (m_RectList[i]->m_Frame) {
+ int XX = (int)((m_RectList[i]->m_Frame->m_Rect.left + X - m_RectList[i]->m_Rect.left + m_RectList[i]->m_OffsetX) / (float)((float)m_RectList[i]->m_ZoomX / (float)100));
+ int YY = (int)((m_RectList[i]->m_Frame->m_Rect.top + Y - m_RectList[i]->m_Rect.top + m_RectList[i]->m_OffsetY) / (float)((float)m_RectList[i]->m_ZoomY / (float)100));
+
+ if (m_RectList[i]->m_Frame->m_MirrorX) {
+ int Width = m_RectList[i]->m_Frame->m_Rect.right - m_RectList[i]->m_Frame->m_Rect.left;
+ XX = Width - XX;
+ }
+
+ if (m_RectList[i]->m_Frame->m_MirrorY) {
+ int Height = m_RectList[i]->m_Frame->m_Rect.bottom - m_RectList[i]->m_Frame->m_Rect.top;
+ YY = Height - YY;
+ }
+
+ if (!m_RectList[i]->m_Frame->m_Surface->IsTransparentAt(XX, YY)) return m_RectList[i]->m_Owner;
+ }
+ // region
+ else if (m_RectList[i]->m_Region) {
+ if (m_RectList[i]->m_Region->PointInRegion(X + m_RectList[i]->m_OffsetX, Y + m_RectList[i]->m_OffsetY)) return m_RectList[i]->m_Owner;
+ }
+ } else return m_RectList[i]->m_Owner;
+ }
+ }
+
+ return (CBObject *)NULL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+void CBRenderer::DeleteRectList() {
+ for (int i = 0; i < m_RectList.GetSize(); i++) {
+ delete m_RectList[i];
+ }
+ m_RectList.RemoveAll();
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::SwitchFullscreen() {
+ return E_FAIL;
+}
+
+//////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::Flip() {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::InitRenderer(int width, int height, bool windowed) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+void CBRenderer::OnWindowChange() {
+}
+
+
+//////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::Fill(byte r, byte g, byte b, RECT *rect) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::WindowedBlt() {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::Setup2D(bool Force) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::SetupLines() {
+ return E_FAIL;
+}
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::DrawLine(int X1, int Y1, int X2, int Y2, uint32 Color) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::DrawRect(int X1, int Y1, int X2, int Y2, uint32 Color, int Width) {
+ for (int i = 0; i < Width; i++) {
+ DrawLine(X1 + i, Y1 + i, X2 - i, Y1 + i, Color); // up
+ DrawLine(X1 + i, Y2 - i, X2 - i + 1, Y2 - i, Color); // down
+
+ DrawLine(X1 + i, Y1 + i, X1 + i, Y2 - i, Color); // left
+ DrawLine(X2 - i, Y1 + i, X2 - i, Y2 - i + 1, Color); // right
+ }
+ return S_OK;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::Fade(WORD Alpha) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::FadeToColor(uint32 Color, RECT *rect) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::SetViewport(int left, int top, int right, int bottom) {
+ return E_FAIL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::SetScreenViewport() {
+ return SetViewport(m_DrawOffsetX, m_DrawOffsetY, m_Width + m_DrawOffsetX, m_Height + m_DrawOffsetY);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::SetViewport(RECT *Rect) {
+ return SetViewport(Rect->left + m_DrawOffsetX,
+ Rect->top + m_DrawOffsetY,
+ Rect->right + m_DrawOffsetX,
+ Rect->bottom + m_DrawOffsetY);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+CBImage *CBRenderer::TakeScreenshot() {
+ return NULL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::ClipCursor() {
+ /*
+ if(!m_Windowed)
+ {
+ RECT rc;
+ GetWindowRect(m_Window, &rc);
+
+ // if "maintain aspect ratio" is in effect, lock mouse to visible area
+ rc.left = m_DrawOffsetX;
+ rc.top = m_DrawOffsetY;
+ rc.right = rc.left + m_Width;
+ rc.bottom = rc.top + m_Height;
+
+ ::ClipCursor(&rc);
+ }
+ */
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+HRESULT CBRenderer::UnclipCursor() {
+ /*
+ if(!m_Windowed) ::ClipCursor(NULL);
+ */
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool CBRenderer::PointInViewport(POINT *P) {
+ if (P->x < m_DrawOffsetX) return false;
+ if (P->y < m_DrawOffsetY) return false;
+ if (P->x > m_DrawOffsetX + m_Width) return false;
+ if (P->y > m_DrawOffsetY + m_Height) return false;
+
+ return true;
+}
+
+} // end of namespace WinterMute