fixed #526 Wrap glScissor in CCEGLVIew::setScissorInPoints.

This commit is contained in:
yangws 2011-06-27 10:55:45 +08:00
parent bf99245dbb
commit 59f37ddb5d
10 changed files with 74 additions and 1 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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*/)
{
}

View File

@ -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);

View File

@ -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

View File

@ -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
/**