Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[win32] fix window size after restart #2129

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions cocos/platform/win32/CCApplication-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,17 @@ namespace
RegCloseKey(hKey);
}

int g_width = 0;
int g_height = 0;
bool setCanvasCallback(se::Object* global)
{
auto viewSize = cocos2d::Application::getInstance()->getViewSize();
se::ScriptEngine* se = se::ScriptEngine::getInstance();
uint8_t devicePixelRatio = cocos2d::Application::getInstance()->getDevicePixelRatio();
char commandBuf[200] = {0};
sprintf(commandBuf, "window.innerWidth = %d; window.innerHeight = %d;",
(int)(g_width / devicePixelRatio),
(int)(g_height / devicePixelRatio));
(int)(viewSize.x / devicePixelRatio),
(int)(viewSize.y / devicePixelRatio));
se->evalString(commandBuf);
cocos2d::ccViewport(0, 0, g_width, g_height);
cocos2d::ccViewport(0, 0, viewSize.x, viewSize.y);
glDepthMask(GL_TRUE);
return true;
}
Expand Down Expand Up @@ -426,9 +425,6 @@ void Application::createView(const std::string& name, int width, int height)
multisamplingCount);

_view = new GLView(this, name, 0, 0, width, height, pixelformat, depthFormat, multisamplingCount);

g_width = width;
g_height = height;
}

std::string Application::getSystemVersion()
Expand Down