Wednesday, April 1, 2015

Cocos2d-x wide screen 해상도 설정하기

Cocos2d-x의 기본 해상도는 960x640이다. 이것은 아이폰4S의 해상도이다.

그런데 이것을 안드로이드 폰의 와이드 해상도인 800x480 (WVGA)이나 1280x720 (HD)으로 15:9/16:9 해상도를 맞추려고 하면 해상도 자체의 aspect ratio를 변경해야 한다.

그래서 기존에 아이폰간의 멀티 해상도를 지원하기 위해서 setDesignResolution, setContentScaleFactor를 조절하라고 되어 있는 함수를 쓰면 안된다.

아래와 같이 GLViewImpl::create대신에 GLViewImpl::createWithRect로 glview의 FrameSize를 변경시켜야 한다.

bool AppDelegate::applicationDidFinishLaunching() {
...
        glview = GLViewImpl::createWithRect("My Game", Rect(0, 0, 800, 480));
...

Android ADT bundle download link

이제는 Android Studio 때문에 지원이 중단되었지만, 아직은 쓸만한 Eclipse와 ADT bundle 팩

linux 64 bit vm: http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20140702.zip
linux 32 bit vm: http://dl.google.com/android/adt/adt-bundle-linux-x86-20140702.zip
mac: http://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip
win32: http://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.zip
win64: http://dl.google.com/android/adt/adt-bundle-windows-x86_64-20140702.zip


Android RenderScript 내장함수 위치

내장함수 있는곳:
/android-sdk/platform-tools/renderscript/include/*.rsh

rs_cl.rsh
rs_graphics.rsh
rs_object.rsh
rs_time.rsh
rs_types.rsh
rs_core.rsh
rs_math.rsh
rs_quaternion.rsh
rs_debug.rsh
rs_matrix.rsh
rs_allocation.rsh

Android 4.1에서 RenderScript 변경점

Android-16에서 변경점:
구버전:
1. RSSurfaceView는 GLSurfaceView와 유사한 동작을 하며 GLRenderer를 set한다.
2. RenderScriptGL이라는 객체를 사용하며, GLSL shader program을 지원한다.
3. 2번과 연동되어 rsg_graphics.rsh를 지원하며 void main()대신에 int main()을 사용한다.

신버전:
1. RSSurfaceView, RenderScriptGL을 사용하지 않는다.
2. 따라서 GLSL을 사용하지 못하고 독자적으로 .rs에서 내장함수를 사용한다.
3. rsg_graphics.rsh를 사용할수 없다. int main()을 RenderScriptGL을 사용하지 않고는 call할 방법이 없다.