2012-04-23 14:30:38 +08:00
|
|
|
#ifndef __CCEGLVIEWPROTOCOL_H__
|
|
|
|
#define __CCEGLVIEWPROTOCOL_H__
|
|
|
|
|
|
|
|
#include "ccTypes.h"
|
|
|
|
|
2012-08-01 16:56:12 +08:00
|
|
|
enum ResolutionPolicy
|
|
|
|
{
|
2012-08-09 10:23:39 +08:00
|
|
|
// The entire application is visible in the specified area without trying to preserve the original aspect ratio.
|
|
|
|
// Distortion can occur, and the application may appear stretched or compressed.
|
2012-08-20 16:32:22 +08:00
|
|
|
kResolutionExactFit,
|
2012-08-09 10:23:39 +08:00
|
|
|
// The entire application fills the specified area, without distortion but possibly with some cropping,
|
|
|
|
// while maintaining the original aspect ratio of the application.
|
2012-08-20 16:32:22 +08:00
|
|
|
kResolutionNoBorder,
|
2012-08-09 10:23:39 +08:00
|
|
|
// The entire application is visible in the specified area without distortion while maintaining the original
|
|
|
|
// aspect ratio of the application. Borders can appear on two sides of the application.
|
2012-08-20 16:32:22 +08:00
|
|
|
kResolutionShowAll,
|
2012-08-07 14:29:46 +08:00
|
|
|
|
|
|
|
kResolutionUnKnown,
|
2012-08-01 16:56:12 +08:00
|
|
|
};
|
|
|
|
|
2012-04-23 14:30:38 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
#define CC_MAX_TOUCHES 5
|
|
|
|
|
|
|
|
class EGLTouchDelegate;
|
|
|
|
class CCSet;
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup platform
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-23 14:30:38 +08:00
|
|
|
class CC_DLL CCEGLViewProtocol
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCEGLViewProtocol();
|
|
|
|
virtual ~CCEGLViewProtocol();
|
|
|
|
|
2012-08-15 14:33:56 +08:00
|
|
|
/** Force destorying EGL view, subclass must implement this method. */
|
2012-04-23 14:30:38 +08:00
|
|
|
virtual void end() = 0;
|
2012-08-15 14:33:56 +08:00
|
|
|
|
|
|
|
/** Get whether opengl render system is ready, subclass must implement this method. */
|
2012-04-23 14:30:38 +08:00
|
|
|
virtual bool isOpenGLReady() = 0;
|
2012-08-15 14:33:56 +08:00
|
|
|
|
|
|
|
/** Exchanges the front and back buffers, subclass must implement this method. */
|
2012-04-23 14:30:38 +08:00
|
|
|
virtual void swapBuffers() = 0;
|
2012-08-15 14:33:56 +08:00
|
|
|
|
|
|
|
/** Open or close IME keyboard , subclass must implement this method. */
|
2012-04-23 14:30:38 +08:00
|
|
|
virtual void setIMEKeyboardState(bool bOpen) = 0;
|
|
|
|
|
2012-08-15 14:33:56 +08:00
|
|
|
/**
|
|
|
|
* Get design resolution size.
|
|
|
|
* If setDesignResolutionSize wasn't invoked, the result of this function return is the same as 'getFrameSize'
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual const CCSize& getSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the frame size of EGL view.
|
|
|
|
* In general, it returns the screen size since the EGL view is a fullscreen view.
|
|
|
|
*/
|
|
|
|
virtual const CCSize& getFrameSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the frame size of EGL view.
|
|
|
|
*/
|
|
|
|
virtual void setFrameSize(float width, float height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the visible area size of opengl viewport.
|
|
|
|
*/
|
|
|
|
virtual CCSize getVisibleSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the visible origin point of opengl viewport.
|
|
|
|
*/
|
|
|
|
virtual CCPoint getVisibleOrigin() const;
|
|
|
|
|
|
|
|
/**
|
2012-09-15 06:26:38 +08:00
|
|
|
* Set the design resolution size.
|
|
|
|
* Behavior undefined when enableRetina == true.
|
2012-08-15 14:33:56 +08:00
|
|
|
* @param width Design resolution width.
|
|
|
|
* @param height Design resolution height.
|
2012-09-15 06:26:38 +08:00
|
|
|
* @param resolutionPolicy The resolution policy desired, you may choose:
|
|
|
|
* [1] kCCResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
|
|
|
|
* [2] kCCResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
|
|
|
|
* [3] kCCResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
|
|
|
|
|
|
|
|
/** Set touch delegate */
|
|
|
|
virtual void setTouchDelegate(EGLTouchDelegate * pDelegate);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set content scale factor.
|
2012-09-15 06:41:42 +08:00
|
|
|
* @return If the return value is true, the platform supports retina display mode.
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
virtual bool setContentScaleFactor(float contentScaleFactor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set opengl view port rectangle with points.
|
|
|
|
*/
|
|
|
|
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Scissor rectangle with points.
|
|
|
|
*/
|
|
|
|
virtual void setScissorInPoints(float x , float y , float w , float h);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable retina mode.
|
|
|
|
* You can't use it with setDesignResolutionSize
|
|
|
|
*/
|
|
|
|
virtual bool enableRetina();
|
2012-05-02 17:50:26 +08:00
|
|
|
|
2012-09-15 06:26:38 +08:00
|
|
|
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
|
2012-08-15 14:33:56 +08:00
|
|
|
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
|
|
|
|
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]);
|
|
|
|
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]);
|
|
|
|
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]);
|
2012-04-23 14:30:38 +08:00
|
|
|
|
2012-08-15 14:33:56 +08:00
|
|
|
/**
|
2012-09-15 06:26:38 +08:00
|
|
|
* Get the opengl view port rectangle.
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
const CCRect& getViewPortRect() const;
|
|
|
|
|
|
|
|
/**
|
2012-09-15 06:26:38 +08:00
|
|
|
* Get scale factor of the horizontal direction.
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
float getScaleX() const;
|
|
|
|
|
|
|
|
/**
|
2012-09-15 06:26:38 +08:00
|
|
|
* Get scale factor of the vertical direction.
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
float getScaleY() const;
|
|
|
|
|
|
|
|
/**
|
2012-09-15 06:26:38 +08:00
|
|
|
* Get retina mode status (on if true).
|
2012-08-15 14:33:56 +08:00
|
|
|
*/
|
|
|
|
bool isRetinaEnabled() const;
|
2012-04-23 14:30:38 +08:00
|
|
|
private:
|
|
|
|
void getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[], float xs[], float ys[]);
|
2012-08-15 14:33:56 +08:00
|
|
|
|
2012-04-23 14:30:38 +08:00
|
|
|
protected:
|
|
|
|
EGLTouchDelegate* m_pDelegate;
|
2012-08-15 14:33:56 +08:00
|
|
|
|
2012-09-15 06:26:38 +08:00
|
|
|
// real screen size
|
2012-08-01 16:56:12 +08:00
|
|
|
CCSize m_obScreenSize;
|
2012-09-15 06:26:38 +08:00
|
|
|
// resolution size, it is the size appropriate for the app resources.
|
2012-08-01 16:56:12 +08:00
|
|
|
CCSize m_obDesignResolutionSize;
|
|
|
|
// the view port size
|
|
|
|
CCRect m_obViewPortRect;
|
2012-08-15 14:33:56 +08:00
|
|
|
// the view name
|
2012-08-01 16:56:12 +08:00
|
|
|
char m_szViewName[50];
|
2012-08-15 14:33:56 +08:00
|
|
|
|
|
|
|
float m_fScaleX;
|
|
|
|
float m_fScaleY;
|
2012-08-01 16:56:12 +08:00
|
|
|
ResolutionPolicy m_eResolutionPolicy;
|
2012-08-01 18:44:10 +08:00
|
|
|
bool m_bIsRetinaEnabled;
|
2012-04-23 14:30:38 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of platform group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-23 14:30:38 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /* __CCEGLVIEWPROTOCOL_H__ */
|