From 7a655528e4861c16facb031d79d9ca35881b2208 Mon Sep 17 00:00:00 2001
From: Jonas Kulla <Nyocurio@gmail.com>
Date: Fri, 15 Aug 2014 22:55:55 +0200
Subject: [PATCH] Viewport: Add zero arg constructor (RGSS3) and bind in MRI

---
 binding-mri/viewport-binding.cpp |  7 +++++++
 src/viewport.cpp                 | 13 +++++++++++++
 src/viewport.h                   |  5 +++++
 3 files changed, 25 insertions(+)

diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp
index 75f447e..1c0a389 100644
--- a/binding-mri/viewport-binding.cpp
+++ b/binding-mri/viewport-binding.cpp
@@ -32,6 +32,13 @@ RB_METHOD(viewportInitialize)
 {
 	Viewport *v;
 
+#ifdef RGSS3
+	if (argc == 0)
+	{
+		v = new Viewport();
+	}
+	else
+#endif
 	if (argc == 1)
 	{
 		/* The rect arg is only used to init the viewport,
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 114924b..f0395b2 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -26,6 +26,7 @@
 #include "util.h"
 #include "quad.h"
 #include "glstate.h"
+#include "graphics.h"
 
 #include <SDL_rect.h>
 
@@ -112,6 +113,18 @@ Viewport::Viewport(Rect *rect)
 	initViewport(rect->x, rect->y, rect->width, rect->height);
 }
 
+#ifdef RGSS3
+
+Viewport::Viewport()
+    : SceneElement(*shState->screen()),
+      sceneLink(this)
+{
+	const Graphics &graphics = shState->graphics();
+	initViewport(0, 0, graphics.width(), graphics.height());
+}
+
+#endif
+
 void Viewport::initViewport(int x, int y, int width, int height)
 {
 	p = new ViewportPrivate(x, y, width, height, this);
diff --git a/src/viewport.h b/src/viewport.h
index 4c60cbb..6fea1b3 100644
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -34,6 +34,11 @@ class Viewport : public Scene, public SceneElement, public Flashable, public Dis
 public:
 	Viewport(int x, int y, int width, int height);
 	Viewport(Rect *rect);
+
+#ifdef RGSS3
+	Viewport();
+#endif
+
 	~Viewport();
 
 	DECL_ATTR( Rect,  Rect*  )