diff --git a/cocos2dx/platform/airplay/CCEGLView_airplay.cpp b/cocos2dx/platform/airplay/CCEGLView_airplay.cpp index cba94ee819..84ff4deed8 100644 --- a/cocos2dx/platform/airplay/CCEGLView_airplay.cpp +++ b/cocos2dx/platform/airplay/CCEGLView_airplay.cpp @@ -231,6 +231,26 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) (GLint)h); } } + +void CCEGLView::setScissorInPoints(float x, float y, float w, float h) +{ + if (m_bNotHVGA) + { + float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); + glScissor((GLint)(x * factor) + m_rcViewPort.origin.x, + (GLint)(y * factor) + m_rcViewPort.origin.y, + (GLint)(w * factor), + (GLint)(h * factor)); + } + else + { + glScissor((GLint)x, + (GLint)y, + (GLint)w, + (GLint)h); + } +} + CCEGLView& CCEGLView::sharedOpenGLView() { static CCEGLView instance; diff --git a/cocos2dx/platform/airplay/CCEGLView_airplay.h b/cocos2dx/platform/airplay/CCEGLView_airplay.h index 4238787b14..a4a9a95fb5 100644 --- a/cocos2dx/platform/airplay/CCEGLView_airplay.h +++ b/cocos2dx/platform/airplay/CCEGLView_airplay.h @@ -62,6 +62,7 @@ public: bool canSetContentScaleFactor(); void setContentScaleFactor(float contentScaleFactor); void setViewPortInPoints(float x, float y, float w, float h); + void setScissorInPoints(float x, float y, float w, float h); CCRect getViewPort(); float getScreenScaleFactor(); diff --git a/cocos2dx/platform/android/CCEGLView_android.cpp b/cocos2dx/platform/android/CCEGLView_android.cpp index 4f9c17ff82..535c3d22d8 100644 --- a/cocos2dx/platform/android/CCEGLView_android.cpp +++ b/cocos2dx/platform/android/CCEGLView_android.cpp @@ -145,6 +145,25 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) } } +void CCEGLView::setScissorInPoints(float x, float y, float w, float h) +{ + if (m_bNotHVGA) + { + float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); + glScissor((GLint)(x * factor) + m_rcViewPort.origin.x, + (GLint)(y * factor) + m_rcViewPort.origin.y, + (GLint)(w * factor), + (GLint)(h * factor)); + } + else + { + glScissor((GLint)x, + (GLint)y, + (GLint)w, + (GLint)h); + } +} + CCEGLView& CCEGLView::sharedOpenGLView() { static CCEGLView instance; diff --git a/cocos2dx/platform/android/CCEGLView_android.h b/cocos2dx/platform/android/CCEGLView_android.h index 40b4f4a066..9578a17ee8 100644 --- a/cocos2dx/platform/android/CCEGLView_android.h +++ b/cocos2dx/platform/android/CCEGLView_android.h @@ -58,6 +58,7 @@ public: bool canSetContentScaleFactor(); void setContentScaleFactor(float contentScaleFactor); void setViewPortInPoints(float x, float y, float w, float h); + void setScissorInPoints(float x, float y, float w, float h); CCRect getViewPort(); float getScreenScaleFactor(); void setIMEKeyboardState(bool bOpen); diff --git a/cocos2dx/platform/ios/CCEGLView_ios.h b/cocos2dx/platform/ios/CCEGLView_ios.h index 0115a5f745..6af1eda194 100644 --- a/cocos2dx/platform/ios/CCEGLView_ios.h +++ b/cocos2dx/platform/ios/CCEGLView_ios.h @@ -49,7 +49,8 @@ public: void setTouchDelegate(EGLTouchDelegate * pDelegate); void swapBuffers(); void setViewPortInPoints(float x, float y, float w, float h); - + void setScissorInPoints(float x, float y, float w, float h); + void touchesBegan(CCSet *set); void touchesMoved(CCSet *set); void touchesEnded(CCSet *set); diff --git a/cocos2dx/platform/ios/CCEGLView_ios.mm b/cocos2dx/platform/ios/CCEGLView_ios.mm index bee08fc2cb..c9f801976b 100644 --- a/cocos2dx/platform/ios/CCEGLView_ios.mm +++ b/cocos2dx/platform/ios/CCEGLView_ios.mm @@ -116,6 +116,11 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) glViewport((GLint)x, (GLint)y, (GLint)w, (GLint)h); } +void CCEGLView::setScissorInPoints(float x, float y, float w, float h) +{ + glScissor((GLint)x, (GLint)y, (GLint)w, (GLint)h); +} + void CCEGLView::setIMEKeyboardState(bool bOpen) { if (bOpen) diff --git a/cocos2dx/platform/win32/CCEGLView_win32.cpp b/cocos2dx/platform/win32/CCEGLView_win32.cpp index 21f76cfeab..23244e0c81 100644 --- a/cocos2dx/platform/win32/CCEGLView_win32.cpp +++ b/cocos2dx/platform/win32/CCEGLView_win32.cpp @@ -444,6 +444,18 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) } } +void CCEGLView::setScissorInPoints(float x, float y, float w, float h) +{ + if (m_pEGL) + { + float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); + glScissor((GLint)(x * factor) + m_rcViewPort.left, + (GLint)(y * factor) + m_rcViewPort.top, + (GLint)(w * factor), + (GLint)(h * factor)); + } +} + void CCEGLView::setIMEKeyboardState(bool /*bOpen*/) { } diff --git a/cocos2dx/platform/win32/CCEGLView_win32.h b/cocos2dx/platform/win32/CCEGLView_win32.h index 37914b1b93..c3ca1e5e29 100644 --- a/cocos2dx/platform/win32/CCEGLView_win32.h +++ b/cocos2dx/platform/win32/CCEGLView_win32.h @@ -58,6 +58,7 @@ public: int setDeviceOrientation(int eOritation); void setViewPortInPoints(float x, float y, float w, float h); + void setScissorInPoints(float x, float y, float w, float h); void setIMEKeyboardState(bool bOpen); diff --git a/cocos2dx/platform/wophone/CCEGLView_wophone.cpp b/cocos2dx/platform/wophone/CCEGLView_wophone.cpp index d6a7d9a509..a66bd3b4b1 100644 --- a/cocos2dx/platform/wophone/CCEGLView_wophone.cpp +++ b/cocos2dx/platform/wophone/CCEGLView_wophone.cpp @@ -658,6 +658,18 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) } } +void CCEGLView::setScissorInPoints(float x, float y, float w, float h) +{ + if (m_pEGL) + { + float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); + glScissor((GLint)(x * factor) + m_rcViewPort.X(), + (GLint)(y * factor) + m_rcViewPort.Y(), + (GLint)(w * factor), + (GLint)(h * factor)); + } +} + void CCEGLView::setIMEKeyboardState(bool bOpen) { do diff --git a/cocos2dx/platform/wophone/CCEGLView_wophone.h b/cocos2dx/platform/wophone/CCEGLView_wophone.h index ce3a08f1d3..19bbe3cb4f 100644 --- a/cocos2dx/platform/wophone/CCEGLView_wophone.h +++ b/cocos2dx/platform/wophone/CCEGLView_wophone.h @@ -61,6 +61,7 @@ public: void setContentScaleFactor(float contentScaleFactor); void setAnimationInterval(double interval) {}; void setViewPortInPoints(float x, float y, float w, float h); + void setScissorInPoints(float x, float y, float w, float h); void setIMEKeyboardState(bool bOpen); // static function /**