플밍

visual studio 에서 CCLog 출력하기 본문

프로그래밍/cocos2d-x

visual studio 에서 CCLog 출력하기

너구리안주 2013. 9. 16. 11:41

Visual Studio 에서 CCLog 출력하기

Visual Studio 에서 디폴트로 만들어지는 프로젝트로 CCLog를 실행하면 출력되지 않는다.

왜냐하면 CCLog는 printf 함수를 사용해 콘솔창에 결과를 찍는 함수인데 main.cpp의 진입함수가 윈도우즈의 _tWinMain() 함수로 되어 있어 콘솔창이 나타나지 않고 실행되기 때문이다.

아래처럼 main.cpp 의 내용을 바꾸어 준다.

#ads_1

#include "main.h"
#include "AppDelegate.h"
#include "CCEGLView.h"

USING_NS_CC;

// uncomment below line, open debug console
// #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->setFrameSize(480, 320);

    int ret = CCApplication::sharedApplication()->run();

#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
}
*/

// 콘솔용 메인으로 바꾼다
int main(){
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setFrameSize(480, 320);

    return CCApplication::sharedApplication()->run();
}

그리고 나서

프로젝트 속성 -> 링커 -> 하위시스템 항목을 

콘솔 (/SUBSYSTEM:CONSOLE)

이렇게 바꾸어 주고 실행해보자

#ads_1

Comments