cocos2d-x  3.3
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GLView Class Referenceabstract

#include <CCGLView.h>

Inheritance diagram for GLView:
Ref GLViewImpl GLViewImpl GLViewImpl GLViewImpl GLViewImpl GLViewImpl

Public Member Functions

 GLView ()
virtual ~GLView ()
virtual void end ()=0
 Force destroying EGL view, subclass must implement this method. More...
 
virtual bool isOpenGLReady ()=0
 Get whether opengl render system is ready, subclass must implement this method. More...
 
virtual void swapBuffers ()=0
 Exchanges the front and back buffers, subclass must implement this method. More...
 
virtual void setIMEKeyboardState (bool open)=0
 Open or close IME keyboard , subclass must implement this method. More...
 
virtual void setIMEKeyboardState (bool open, std::string str)=0
virtual bool windowShouldClose ()
virtual void pollInputEvents ()
 Polls input events. More...
 
virtual void pollEvents ()
virtual const SizegetFrameSize () const
 Get the frame size of EGL view. More...
 
virtual void setFrameSize (float width, float height)
 Set the frame size of EGL view. More...
 
virtual void setFrameZoomFactor (float zoomFactor)
 Set and get zoom factor for frame. More...
 
virtual float getFrameZoomFactor () const
virtual int getRetinaFactor () const
 Get retina factor. More...
 
virtual bool setContentScaleFactor (float scaleFactor)
 only works on ios platform More...
 
virtual float getContentScaleFactor () const
virtual bool isRetinaDisplay () const
 returns whether or not the view is in Retina Display mode More...
 
virtual void * getEAGLView () const
virtual Size getRenerTargetSize () const =0
virtual const Mat4getOrientationMatrix () const =0
virtual const Mat4getReverseOrientationMatrix () const =0
virtual Size getVisibleSize () const
 Get the visible area size of opengl viewport. More...
 
virtual Vec2 getVisibleOrigin () const
 Get the visible origin point of opengl viewport. More...
 
virtual Rect getVisibleRect () const
 Get the visible rectangle of opengl viewport. More...
 
virtual void setDesignResolutionSize (float width, float height, ResolutionPolicy resolutionPolicy)
 Set the design resolution size. More...
 
virtual const SizegetDesignResolutionSize () const
 Get design resolution size. More...
 
virtual void setViewPortInPoints (float x, float y, float w, float h)
 Set opengl view port rectangle with points. More...
 
virtual void setScissorInPoints (float x, float y, float w, float h)
 Set Scissor rectangle with points. More...
 
virtual bool isScissorEnabled ()
 Get whether GL_SCISSOR_TEST is enable. More...
 
virtual Rect getScissorRect () const
 Get the current scissor rectangle. More...
 
virtual void setViewName (const std::string &viewname)
const std::string & getViewName () const
virtual void handleTouchesBegin (int num, intptr_t ids[], float xs[], float ys[])
 Touch events are handled by default; if you want to customize your handlers, please override these functions: More...
 
virtual void handleTouchesMove (int num, intptr_t ids[], float xs[], float ys[])
virtual void handleTouchesEnd (int num, intptr_t ids[], float xs[], float ys[])
virtual void handleTouchesCancel (int num, intptr_t ids[], float xs[], float ys[])
const RectgetViewPortRect () const
 Get the opengl view port rectangle. More...
 
std::vector< Touch * > getAllTouches () const
 Get list of all active touches. More...
 
float getScaleX () const
 Get scale factor of the horizontal direction. More...
 
float getScaleY () const
 Get scale factor of the vertical direction. More...
 
ResolutionPolicy getResolutionPolicy () const
 returns the current Resolution policy More...
 
virtual HWND getWin32Window ()=0
virtual id getCocoaWindow ()=0
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Static Public Member Functions

static void setGLContextAttrs (GLContextAttrs &glContextAttrs)
static GLContextAttrs getGLContextAttrs ()

Static Public Attributes

static GLContextAttrs _glContextAttrs

Protected Member Functions

void updateDesignResolutionSize ()
void handleTouchesOfEndOrCancel (EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[])
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Protected Attributes

Size _screenSize
Size _designResolutionSize
Rect _viewPortRect
std::string _viewName
float _scaleX
float _scaleY
ResolutionPolicy _resolutionPolicy
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Constructor & Destructor Documentation

GLView ( )
virtual ~GLView ( )
virtual

Member Function Documentation

virtual void end ( )
pure virtual

Force destroying EGL view, subclass must implement this method.

Implemented in GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, and GLViewImpl.

std::vector<Touch*> getAllTouches ( ) const

Get list of all active touches.

virtual id getCocoaWindow ( )
pure virtual

Implemented in GLViewImpl.

virtual float getContentScaleFactor ( ) const
inlinevirtual

Reimplemented in GLViewImpl.

virtual const Size&
getDesignResolutionSize
( ) const
virtual

Get design resolution size.

Default resolution size is the same as 'getFrameSize'.

virtual void* getEAGLView ( ) const
inlinevirtual

Reimplemented in GLViewImpl.

virtual const Size& getFrameSize ( ) const
virtual

Get the frame size of EGL view.

In general, it returns the screen size since the EGL view is a fullscreen view.

virtual float getFrameZoomFactor ( ) const
inlinevirtual

Reimplemented in GLViewImpl.

static GLContextAttrs
getGLContextAttrs
( )
static
virtual const Mat4&
getOrientationMatrix
( ) const
pure virtual

Implemented in GLViewImpl.

virtual Size getRenerTargetSize ( ) const
pure virtual

Implemented in GLViewImpl, and GLViewImpl.

ResolutionPolicy
getResolutionPolicy
( ) const
inline

returns the current Resolution policy

virtual int getRetinaFactor ( ) const
inlinevirtual

Get retina factor.

Reimplemented in GLViewImpl.

virtual const Mat4&
getReverseOrientationMatrix
( ) const
pure virtual

Implemented in GLViewImpl.

float getScaleX ( ) const

Get scale factor of the horizontal direction.

float getScaleY ( ) const

Get scale factor of the vertical direction.

virtual Rect getScissorRect ( ) const
virtual

Get the current scissor rectangle.

const std::string& getViewName ( ) const
const Rect& getViewPortRect ( ) const

Get the opengl view port rectangle.

virtual Vec2 getVisibleOrigin ( ) const
virtual

Get the visible origin point of opengl viewport.

virtual Rect getVisibleRect ( ) const
virtual

Get the visible rectangle of opengl viewport.

virtual Size getVisibleSize ( ) const
virtual

Get the visible area size of opengl viewport.

virtual HWND getWin32Window ( )
pure virtual

Implemented in GLViewImpl.

virtual void handleTouchesBegin ( int  num,
intptr_t  ids[],
float  xs[],
float  ys[] 
)
virtual

Touch events are handled by default; if you want to customize your handlers, please override these functions:

virtual void handleTouchesCancel ( int  num,
intptr_t  ids[],
float  xs[],
float  ys[] 
)
virtual
virtual void handleTouchesEnd ( int  num,
intptr_t  ids[],
float  xs[],
float  ys[] 
)
virtual
virtual void handleTouchesMove ( int  num,
intptr_t  ids[],
float  xs[],
float  ys[] 
)
virtual
void handleTouchesOfEndOrCancel ( EventTouch::EventCode  eventCode,
int  num,
intptr_t  ids[],
float  xs[],
float  ys[] 
)
protected
virtual bool isOpenGLReady ( )
pure virtual

Get whether opengl render system is ready, subclass must implement this method.

Implemented in GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, and GLViewImpl.

virtual bool isRetinaDisplay ( ) const
inlinevirtual

returns whether or not the view is in Retina Display mode

Reimplemented in GLViewImpl.

virtual bool isScissorEnabled ( )
virtual

Get whether GL_SCISSOR_TEST is enable.

virtual void pollEvents ( )
virtual

Reimplemented in GLViewImpl.

virtual void pollInputEvents ( )
virtual

Polls input events.

Subclass must implement methods if platform does not provide event callbacks.

virtual bool setContentScaleFactor ( float  scaleFactor)
inlinevirtual

only works on ios platform

Reimplemented in GLViewImpl.

virtual void
setDesignResolutionSize
( float  width,
float  height,
ResolutionPolicy  resolutionPolicy 
)
virtual

Set the design resolution size.

Parameters
widthDesign resolution width.
heightDesign resolution height.
resolutionPolicyThe resolution policy desired, you may choose: [1] EXACT_FIT 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] NO_BORDER 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] SHOW_ALL 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 setFrameSize ( float  width,
float  height 
)
virtual

Set the frame size of EGL view.

Reimplemented in GLViewImpl, and GLViewImpl.

virtual void setFrameZoomFactor ( float  zoomFactor)
inlinevirtual

Set and get zoom factor for frame.

This two methods are for debugging big resolution (e.g.new ipad) app on desktop.

Reimplemented in GLViewImpl, GLViewImpl, GLViewImpl, and GLViewImpl.

static void setGLContextAttrs ( GLContextAttrs glContextAttrs)
static
virtual void setIMEKeyboardState ( bool  open)
pure virtual

Open or close IME keyboard , subclass must implement this method.

Implemented in GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, and GLViewImpl.

virtual void setIMEKeyboardState ( bool  open,
std::string  str 
)
pure virtual

Implemented in GLViewImpl, and GLViewImpl.

virtual void setScissorInPoints ( float  x,
float  y,
float  w,
float  h 
)
virtual

Set Scissor rectangle with points.

Reimplemented in GLViewImpl, GLViewImpl, and GLViewImpl.

virtual void setViewName ( const std::string &  viewname)
virtual
virtual void setViewPortInPoints ( float  x,
float  y,
float  w,
float  h 
)
virtual

Set opengl view port rectangle with points.

Reimplemented in GLViewImpl, GLViewImpl, and GLViewImpl.

virtual void swapBuffers ( )
pure virtual

Exchanges the front and back buffers, subclass must implement this method.

Implemented in GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, GLViewImpl, and GLViewImpl.

void updateDesignResolutionSize ( )
protected
virtual bool windowShouldClose ( )
inlinevirtual

Reimplemented in GLViewImpl.

Member Data Documentation

Size _designResolutionSize
protected
GLContextAttrs _glContextAttrs
static
ResolutionPolicy _resolutionPolicy
protected
float _scaleX
protected
float _scaleY
protected
Size _screenSize
protected
std::string _viewName
protected
Rect _viewPortRect
protected

The documentation for this class was generated from the following file: