Skip to content

Commit

Permalink
Merge pull request cocos2d#970 from dumganhar/gles20
Browse files Browse the repository at this point in the history
fixed cocos2d#1301: CCEGLView::sharedOpenGLView().setScissorInPoints() should apply scissor in points.
  • Loading branch information
James Chen committed Jun 6, 2012
2 parents 35f9169 + 99c7326 commit abca93b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions HelloWorld/proj.win32/HelloWorld.win32.vcproj
Expand Up @@ -61,7 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcocos2d.lib"
AdditionalDependencies="opengl32.lib glew32.lib libcocos2d.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
LinkIncremental="2"
AdditionalLibraryDirectories="$(OutDir)"
Expand Down Expand Up @@ -138,7 +138,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcocos2d.lib"
AdditionalDependencies="opengl32.lib glew32.lib libcocos2d.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="$(OutDir)"
Expand Down
3 changes: 1 addition & 2 deletions cocos2dx/CCDirector.cpp
Expand Up @@ -336,10 +336,9 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
CCSize size = m_obWinSizeInPixels;
CCSize sizePoint = m_obWinSizeInPoints;

//glViewport(0, 0, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() );
if (m_pobOpenGLView)
{
m_pobOpenGLView->setViewPortInPoints(0, 0, size.width, size.height);
m_pobOpenGLView->setViewPortInPoints(0, 0, sizePoint.width, sizePoint.height);
}

switch (kProjection)
Expand Down
22 changes: 14 additions & 8 deletions cocos2dx/platform/CCEGLViewProtocol.cpp
Expand Up @@ -97,6 +97,8 @@ CCSize CCEGLViewProtocol::getSize()
CCSize size;
if (m_bNeedScale)
{
// retina and scale mode can't be opened at the same time
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!");
size.setSize(m_sSizeInPoint.width, m_sSizeInPoint.height);
}
else
Expand Down Expand Up @@ -135,6 +137,7 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float
{
if (m_bNeedScale)
{
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!");
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glViewport((GLint)(x * factor + m_rcViewPort.origin.x),
(GLint)(y * factor + m_rcViewPort.origin.y),
Expand All @@ -143,17 +146,19 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float
}
else
{
glViewport((GLint)x,
(GLint)y,
(GLsizei)w,
(GLsizei)h);
glViewport(
(GLint)(x*CC_CONTENT_SCALE_FACTOR()),
(GLint)(y*CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(w*CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(h*CC_CONTENT_SCALE_FACTOR()));
}
}

void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h)
{
if (m_bNeedScale)
{
CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!");
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glScissor((GLint)(x * factor + m_rcViewPort.origin.x),
(GLint)(y * factor + m_rcViewPort.origin.y),
Expand All @@ -162,10 +167,11 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h
}
else
{
glScissor((GLint)x,
(GLint)y,
(GLsizei)w,
(GLsizei)h);
glScissor(
(GLint)(x * CC_CONTENT_SCALE_FACTOR()),
(GLint)(y * CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(w * CC_CONTENT_SCALE_FACTOR()),
(GLsizei)(h * CC_CONTENT_SCALE_FACTOR()));
}
}

Expand Down

0 comments on commit abca93b

Please sign in to comment.