axmol/cocos2dx/platform/CCEGLViewProtocol.h

171 lines
5.7 KiB
C
Raw Normal View History

#ifndef __CCEGLVIEWPROTOCOL_H__
#define __CCEGLVIEWPROTOCOL_H__
#include "ccTypes.h"
enum ResolutionPolicy
{
// 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.
kResolutionExactFit,
// The entire application fills the specified area, without distortion but possibly with some cropping,
// while maintaining the original aspect ratio of the application.
kResolutionNoBorder,
// 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.
kResolutionShowAll,
// The application takes the height of the design resolution size and modifies the width of the internal
// canvas so that it fits the aspect ratio of the device
// no distortion will occur however you must make sure your application works on different
// aspect ratios
kResolutionFixedHeight,
// The application takes the width of the design resolution size and modifies the height of the internal
// canvas so that it fits the aspect ratio of the device
// no distortion will occur however you must make sure your application works on different
// aspect ratios
kResolutionFixedWidth,
2012-08-07 14:29:46 +08:00
kResolutionUnKnown,
};
NS_CC_BEGIN
#define CC_MAX_TOUCHES 5
class EGLTouchDelegate;
class CCSet;
2012-06-20 18:09:11 +08:00
/**
* @addtogroup platform
* @{
*/
class CC_DLL CCEGLViewProtocol
{
public:
CCEGLViewProtocol();
virtual ~CCEGLViewProtocol();
/** Force destroying EGL view, subclass must implement this method. */
virtual void end() = 0;
/** Get whether opengl render system is ready, subclass must implement this method. */
virtual bool isOpenGLReady() = 0;
/** Exchanges the front and back buffers, subclass must implement this method. */
virtual void swapBuffers() = 0;
/** Open or close IME keyboard , subclass must implement this method. */
virtual void setIMEKeyboardState(bool bOpen) = 0;
/**
* 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.
*/
2012-10-09 00:38:04 +08:00
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;
/**
* Set the design resolution size.
* @param width Design resolution width.
* @param height Design resolution height.
* @param resolutionPolicy The resolution policy desired, you may choose:
* [1] kResolutionExactFit 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] kResolutionNoBorder 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] kResolutionShowAll 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.
*/
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
/** Get design resolution size.
2012-10-23 14:01:48 +08:00
* Default resolution size is the same as 'getFrameSize'.
*/
virtual const CCSize& getDesignResolutionSize() const;
/** Set touch delegate */
virtual void setTouchDelegate(EGLTouchDelegate * pDelegate);
/**
* 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);
2013-03-29 17:21:29 +08:00
/**
* Get whether GL_SCISSOR_TEST is enable
*/
virtual bool isScissorEnabled();
2013-03-29 17:21:29 +08:00
/**
* Get the current scissor rectangle
*/
virtual CCRect getScissorRect();
virtual void setViewName(const char* pszViewName);
const char* getViewName();
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
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[]);
/**
* Get the opengl view port rectangle.
*/
const CCRect& getViewPortRect() const;
/**
* Get scale factor of the horizontal direction.
*/
float getScaleX() const;
/**
* Get scale factor of the vertical direction.
*/
float getScaleY() const;
private:
void getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[], float xs[], float ys[]);
protected:
EGLTouchDelegate* _delegate;
// real screen size
CCSize _screenSize;
// resolution size, it is the size appropriate for the app resources.
CCSize _designResolutionSize;
// the view port size
CCRect _viewPortRect;
// the view name
char _viewName[50];
float _scaleX;
float _scaleY;
ResolutionPolicy _resolutionPolicy;
};
2012-06-20 18:09:11 +08:00
// end of platform group
/// @}
NS_CC_END
#endif /* __CCEGLVIEWPROTOCOL_H__ */