Remove DummyWindowWrapper and implement default methods into WindowWrapper

This commit is contained in:
Alexander Bock
2015-12-23 16:26:24 -05:00
parent 1a4ea8763e
commit 465715f652
5 changed files with 67 additions and 139 deletions

View File

@@ -1,54 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __DUMMYWINDOWWRAPPER_H__
#define __DUMMYWINDOWWRAPPER_H__
#include <openspace/engine/wrapper/windowwrapper.h>
namespace openspace {
/**
* DummyWindowWrapper that can be used if no actual rendering output is required, such as
* for console applications. The window sizes and resolutions will all be set to
* <code>0</code> and all graphics operations will be <code>no-op</code>s.
*/
class DummyWindowWrapper : public WindowWrapper {
public:
void clearAllWindows(const glm::vec4& clearColor) override;
bool windowHasResized() const override;
double averageDeltaTime() const override;
uint32_t mouseButtons(int maxNumber = 8) const override;
glm::vec2 mousePosition() const override;
glm::ivec2 currentWindowSize() const override;
glm::mat4 viewProjectionMatrix() const override;
void setNearFarClippingPlane(float near, float far) override;
void takeScreenshot() const override;
};
} // namespace openspace
#endif // __DUMMYWINDOWWRAPPER_H__

View File

@@ -52,46 +52,53 @@ public:
/**
* This method clears all the rendering windows with the specified \p clearColor. In
* most OpenGL cases, this will end up with one or mode <code>glClear</code> calls.
* This method defaults to a no-op.
* \param clearColor The color with which to clear all windows
*/
virtual void clearAllWindows(const glm::vec4& clearColor) = 0;
virtual void clearAllWindows(const glm::vec4& clearColor);
/**
* Returns whether the current window has been resized recently.
* Returns whether the current window has been resized recently. On default, this
* method always returns <code>false</code>.
* \return <code>true</code> if the current window has been resized recently,
* <code>false</code> otherwise
*/
virtual bool windowHasResized() const = 0;
virtual bool windowHasResized() const;
/**
* Returns the average frametime in seconds.
* Returns the average frametime in seconds. On default, this method returns
* <code>0.0</code>.
* \return The average frametime in seconds
*/
virtual double averageDeltaTime() const = 0;
virtual double averageDeltaTime() const;
/**
* Returns the location of the mouse cursor in pixel screen coordinates.
* Returns the location of the mouse cursor in pixel screen coordinates. On default,
* this method returns <code>0,0</code>.
* \return The location of the mouse cursor in pixel screen coordinates
*/
virtual glm::vec2 mousePosition() const = 0;
virtual glm::vec2 mousePosition() const;
/**
* Returns a bitmask of the status of all available mouse buttons. Bit <code>i</code>
* is <code>1</code> if mouse button <code>i</code> is pressed down;
* <code>false</code> otherwise.
* <code>false</code> otherwise. On default, this method returns that none of the
* buttons is pressed.
* \param maxNumber The maximum number of mouse buttons that should be queried
* \return A bitmask showing the status of all mouse buttons (up to \p maxNumber)
*/
virtual uint32_t mouseButtons(int maxNumber = 8) const = 0;
virtual uint32_t mouseButtons(int maxNumber = 8) const;
/**
* Returns the size of the currently active window in pixel coordinates.
* Returns the size of the currently active window in pixel coordinates. On default,
* this method returns a window size of <code>0,0</code>.
* \return The size of the currently active window in pixel coordinates
*/
virtual glm::ivec2 currentWindowSize() const = 0;
virtual glm::ivec2 currentWindowSize() const;
/**
* Returns the resolution of the currently active window in pixel coordinates.
* Returns the resolution of the currently active window in pixel coordinates. On
* default, this method returns the same size as #currentWindowSize.
* \return The resolution of the currently active window in pixel coordinates
*/
virtual glm::ivec2 currentWindowResolution() const;
@@ -99,23 +106,26 @@ public:
/**
* Returns <code>true</code> if the current rendering method is regular, i.e., it is
* a flat projection without non-linear distortions. Returns <code>false</code> in
* other cases, for example fisheye projections.
* other cases, for example fisheye projections. On default, this method will return
* <code>true</code>.
* \return Whether the current rendering method is a regular method
*/
virtual bool isRegularRendering() const;
/**
* Returns the currently employed view-projection matrix.
* Returns the currently employed view-projection matrix. On default, this method will
* return the identity matrix.
* \return The currently employed view-projection matrix
*/
virtual glm::mat4 viewProjectionMatrix() const = 0;
virtual glm::mat4 viewProjectionMatrix() const;
/**
* Sets the near and far clipping planes of the rendering window.
* Sets the near and far clipping planes of the rendering window. This method defaults
* to a no-op.
* \param near The near clipping plane
* \param far The far clipping plane
*/
virtual void setNearFarClippingPlane(float near, float far) = 0;
virtual void setNearFarClippingPlane(float near, float far);
/**
* Returns the location and size of the current viewport (<code>x</code>,
@@ -128,29 +138,31 @@ public:
/**
* Returns <code>true</code> if there is an external control connected, i.e., an
* application that can receive control commands.
* application that can receive control commands. On default, this method will return
* <code>false</code>.
* \return If there is an external control connected
*/
virtual bool isExternalControlConnected() const;
/**
* Sends a \p message to an external control.
* Sends a \p message to an external control. This method defaults to a no-op.
* \param message The message to be sent
*/
virtual void sendMessageToExternalControl(const std::vector<char>& message) const;
/**
* Returns <code>true</code> if the rendering is a single viewport with an single
* window; <code>false</code> otherwise.
* window; <code>false</code> otherwise. On default, this method returns
* <code>true</code>
* \returns <code>true</code> if the rendering is a single viewport with an single
* widnow; <code>false</code> otherwise
*/
virtual bool isSimpleRendering() const;
/**
* Advises the windowing system to take a screenshot.
* Advises the windowing system to take a screenshot. This method defaults to a no-op.
*/
virtual void takeScreenshot() const = 0;
virtual void takeScreenshot() const;
};
} // namespace openspace