00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #include "cinder/app/App.h"
00026 #include "cinder/Display.h"
00027
00028 #if defined( CINDER_MAC )
00029 #include <OpenGL/CGLTypes.h>
00030 #ifdef __OBJC__
00031 @class AppImplCocoaBasic;
00032 #else
00033 class AppImplCocoaBasic;
00034 #endif
00035 #endif
00036
00037
00038 namespace cinder { namespace app {
00039
00040 class AppBasic : public App {
00041 public:
00042 class Settings : public App::Settings {
00043 public:
00044 Settings();
00045
00046 void setShouldQuit ( bool aShouldQuit = true );
00047 void setFullScreenSize( int aFullScreenSizeX, int aFullScreenSizeY );
00048 void setFullScreen( bool aFullScreen = true );
00049 void setResizable( bool aResizable = true );
00050
00051 int getFullScreenWidth() const { return mFullScreenSizeX; }
00052 int getFullScreenHeight() const { return mFullScreenSizeY; }
00053
00055 Display* getDisplay() const { return mDisplay; }
00056 void setDisplay( shared_ptr<Display> aDisplay );
00057 private:
00058 int mFullScreenSizeX, mFullScreenSizeY;
00059 Display *mDisplay;
00060 };
00061
00062 public:
00063 AppBasic();
00064 virtual ~AppBasic();
00065
00066 virtual void prepareSettings( Settings *settings ) {}
00067
00069 virtual int getWindowWidth() const;
00071 void setWindowWidth( int windowWidth );
00073 virtual int getWindowHeight() const;
00075 void setWindowHeight( int windowHeight );
00077 void setWindowSize( int windowWidth, int windowHeight );
00078
00080 virtual float getFrameRate() const;
00082 virtual void setFrameRate( float frameRate );
00084 virtual bool isFullScreen() const;
00086 virtual void setFullScreen( bool fullScreen );
00087
00089 Vec2i getMousePos() const;
00091 void hideCursor();
00093 void showCursor();
00094
00095 const Settings& getSettings() const { return mSettings; }
00096 const Display& getDisplay();
00097
00099 virtual void quit();
00100
00102 virtual std::string getAppPath();
00103
00104 #if defined( CINDER_MAC )
00105 void privateSetImpl__( AppImplCocoaBasic *aImpl );
00106 #elif defined( CINDER_MSW )
00107 virtual bool getsWindowsPaintEvents() { return true; }
00108 #endif
00109
00111 static AppBasic* get() { return sInstance; }
00112
00114
00115 static void prepareLaunch() { App::prepareLaunch(); }
00116 static void executeLaunch( AppBasic *app, class Renderer *renderer, const char *title, int argc, char * const argv[] ) { sInstance = app; App::executeLaunch( app, renderer, title, argc, argv ); }
00117 static void cleanupLaunch() { App::cleanupLaunch(); }
00118
00119 virtual void launch( const char *title, int argc, char * const argv[] );
00121
00123 virtual void privateResize__( int width, int height );
00125
00126 private:
00127
00128 static AppBasic* sInstance;
00129
00130 #if defined( CINDER_MAC )
00131 AppImplCocoaBasic *mImpl;
00132 #elif defined( CINDER_MSW )
00133 class AppImplMswBasic *mImpl;
00134 friend class AppImplMswBasic;
00135 #endif
00136
00137 Settings mSettings;
00138 };
00139
00140 } }
00141
00142
00143
00144 #if defined( CINDER_MAC )
00145 #define CINDER_APP_BASIC( APP, RENDERER ) \
00146 int main( int argc, char * const argv[] ) { \
00147 cinder::app::AppBasic::prepareLaunch(); \
00148 cinder::app::AppBasic *app = new APP; \
00149 cinder::app::Renderer *ren = new RENDERER; \
00150 cinder::app::AppBasic::executeLaunch( app, ren, #APP, argc, argv ); \
00151 cinder::app::AppBasic::cleanupLaunch(); \
00152 return 0; \
00153 }
00154 #elif defined( CINDER_MSW )
00155 #define CINDER_APP_BASIC( APP, RENDERER ) \
00156 int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { \
00157 cinder::app::AppBasic::prepareLaunch(); \
00158 cinder::app::AppBasic *app = new APP; \
00159 cinder::app::Renderer *ren = new RENDERER; \
00160 cinder::app::AppBasic::executeLaunch( app, ren, #APP, -1, 0 ); \
00161 cinder::app::AppBasic::cleanupLaunch(); \
00162 return 0; \
00163 }
00164 #endif