现在的位置: 首页 > 综合 > 正文

cocos2d-x加入控制台程序代码

2017年09月16日 ⁄ 综合 ⁄ 共 707字 ⁄ 字号 评论关闭
#include "main.h"
#include "AppDelegate.h"
#include "CCEGLView.h"

USING_NS_CC;  
#define USE_WIN32_CONSOLE  //这里是控制台开关,是否打开控制台

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef USE_WIN32_CONSOLE
	AllocConsole();   //创建一个控制台
	freopen("CONIN$","r",stdin);    //将标准输入输出流定位到这个控制台
	freopen("CONOUT$","w",stdout);
	freopen("CONOUT$","w",stderr);
#endif
    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName("NetWorkTest");
    eglView->setFrameSize(480, 320);
	int ret=CCApplication::sharedApplication()->run();

#ifdef USE_WIN32_CONSOLE
	FreeConsole();    //删除控制台
#endif

	return ret;
}

抱歉!评论已关闭.