MercuryWindow.h

Go to the documentation of this file.
00001 #ifndef MERCURYWINDOW_H
00002 #define MERCURYWINDOW_H
00003 
00004 #include "MercuryTimer.h"
00005 #include "MercuryString.h"
00006 #include "MercuryMessages.h"
00007 
00008 enum RendererType
00009 {
00010     RT_NONE,
00011     RT_OGL,
00012     RT_D3D,
00013     RT_SW,
00014 };
00015 
00016 class MercuryWindow : public MercuryMessageHandler {
00017 public:
00018     virtual ~MercuryWindow();
00019     MercuryWindow(int width, int height, bool fullscreenflag);
00020     virtual bool MakeWindow(const char* title, int width, int height, int bits, bool fullscreenflag) = 0;
00021     void SetDemensions(int width, int height);
00022     inline void SetFullscreen(bool fullscreen) { m_fullscreen = fullscreen; }
00023     inline bool IsMinimized() const { return m_minimized; }
00024 
00025     virtual void DestroyWindow() = 0;
00026     virtual bool RestoreDevice() = 0;
00027 
00028     virtual bool MakeRenderCurrent() = 0;
00029     virtual bool MakeRender(const char* title, int width, int height, int bits, bool fullscreenflag, RendererType brt ) = 0;
00030     virtual void DestroyWindowAndRender() = 0;
00031     void SwapBuffers();
00032 
00033     inline int GetWidth() { return m_width; }
00034     inline int GetHeight() { return m_height; }
00035     virtual bool Update(const float dTime) = 0;
00036     void SetTitle(const char* title);
00037     inline char* GetTitle() { return m_title; }
00038     virtual bool HasFocus() { return true; }
00039 
00040     virtual void Message( int Message, PStack & data, const MString & name );
00041     virtual unsigned char * GetBackDirectBuffer() { return NULL; }  //For use only with SW renderer
00042 
00043     //Whatever device specific handle you want to use.
00044     void * m_hWnd;
00045 protected:
00046     virtual void SwapBuffersInternal() = 0;
00047 
00048     int m_width;
00049     int m_height;
00050     double m_aspect;
00051     bool m_fullscreen;
00052     bool m_minimized;
00053     int m_bits;
00054     unsigned int m_pixelFormat;
00055 
00056     bool m_alt_held;
00057 
00058     MercuryTimer m_lastSwap_t;
00059 private:
00060     void ClearTitle();
00061     char* m_title;
00062 
00063     MercuryTimer m_tFrameTimer;
00064     bool    m_bEnableFrameTimer;
00065     float   m_fSimFramerate;
00066 
00067 };
00068 
00069 #endif
00070 
00071 /* 
00072  * Copyright (c) 2005-2006, Joshua Allen
00073  * All rights reserved.
00074  *
00075  * Redistribution and use in source and binary forms, with or
00076  * without modification, are permitted provided that the following
00077  * conditions are met:
00078  *  -   Redistributions of source code must retain the above
00079  *      copyright notice, this list of conditions and the following disclaimer.
00080  *  -   Redistributions in binary form must reproduce the above copyright
00081  *      notice, this list of conditions and the following disclaimer in
00082  *      the documentation and/or other materials provided with the distribution.
00083  *  -   Neither the name of the Mercury Engine nor the names of its
00084  *      contributors may be used to endorse or promote products derived from
00085  *      this software without specific prior written permission.
00086  *
00087  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00088  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00089  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00090  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00091  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00092  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00093  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00094  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00095  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00096  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00097  */

Hosted by SourceForge.net Logo