Wednesday, December 31, 2014

Put you app on jailbreak iOS devices.

It is not necessary, but I want to save $100 for now and pay it same time later.

I followed method 2 this tutorial.
http://iphonedevwiki.net/index.php/Xcode

Note:
ldid, in its git repo, does not contain some head files. I found them in "https://github.com/linusyang/opencl-test-ios". Remember update the SDK version. For me, they are xcode 6 and iOS 8.1.

game dev solution(incompleted)

I am focusing on cross-platform game dev, majorly mobile.

Graphics engine

Ogre3d.
Ogre3d is promising. It is a commercial standard lib with MIT license. There exist successful game like torchlight based on it. It starts from desktops and officially supports main stream mobile platforms. I verified android and iOS. The performance are good enough on built in samples. On my One Plus phone, everything is 60 fps. On iPad mini2, samples with 20000 triangles run at around 27 fps, while simpler samples can hit the 30 fps cap easily. Ogre 3d is the best free graphics solution so far.

You might also check irrlicht. It supports mobile in dev branch.


Physics

Input

Network

To be updated.

Wednesday, December 3, 2014

MyGUI mit now

It was LGPL. Now there is one more option other than librocket.

Wednesday, November 19, 2014

Sunday, November 9, 2014

blender video editor, adding without scaling

blender video editor will try to scale and fit the output size default. To turn this off, chose image offset or image crop in strip input.

Saturday, November 8, 2014

hostname got overridden

My hostname got overridden by dhclient on archlinux. The hostname might cause some Xauthority fail. NetworkManager wiki on arch explains how to setup static host name. However, it does not work for me. keyfile setting, dhclient conf, switching to dhcpd. Nth worked. Finally I added post script in /etc/NetworkManager/dispatcher.d/ to reset my hostname manually.

Friday, October 31, 2014

hp chromebook 14 and archlinux

1. Replace a larger ssd. (It is complicated. You have to remove everything under hood to replace the ssd.)

2. Install archlinux by following the wiki.

3. 3G sim card work out of box with networkmanager its plugins.

4. Use tlp and acpid for power management.

5. Disable power button in systemd.

6. Closing lid suspends it but opening lid does not resume some usb devices with default usb auto suspend setting. Removing xhci_hcd and re-modprobing it solves the problem for me. (I added these to handler.sh of acpid but it crashed my machine. I removed them then and re-add module manually.)

Monday, August 11, 2014

mibox install/uninstall apps

./adb install <-r> blablabla

./adb shell
pm list packages|grep <your app keyword>

./adb shell am start -a android.intent.action.DELETE -d package:<your package name>

Sunday, August 3, 2014

msysgit ssh mintty hang when password required

It works find in windows cmd, but not in mintty. I change the following config.
git config --global core.askpass "git-gui--askpass"

This workaround makes git-gui prompt.

Tuesday, July 15, 2014

google play services kill battery

Setting -> privacy -> privacy guard -> setting -> show built-in apps -> long press google play services -> deny keep awake

It saves my battery.

evo 3d cdma switch between stock and custom roms

Assume you have your phone  unlocked and s-off on it.

Back to stock

Get imgs here, http://forum.xda-developers.com/showthread.php?t=1447839.

(hboot 1.40 one is broken, won't unzip, 1.58 one works fine)

relock your phone.(you need driver in window. I just use linux as everything works out of box)

adb reboot bootloader
fastboot oem lock
adb reboot bootloader (shows relocked)
put your PG86IMG.zip at the root of your sd card. Let it update.
adb reboot bootloader
fastboot flash unlocktoken Unlock_code.bin

stock kernel needs hboot 1.58, custom ones need hboot <= 1.4.

flash custom roms
flash hboot first, using PG86IMG.zip with hboot only in it.
reboot to recovery, flash roms.

kindle fire hd 7 custom recovery

1 root "Root_with_Restore_by_Bin4ry_v33"
2 flash recovery with  "Fire Flash"

No factory cable required, but you might need it in case.

google now launcher on kindle fire hd 7 with cm11

I installed google now launcher from play. It kept asking for newer version of google search, but my search is up to date. Googled a lot, and found a work around. Some steps may not be necessary, but they worked for me.

remove google search apk form system, uninstall google now launch, install nova, uninstall cm11 default txxxxx launcher

reboot

install google now launcher

reboot

install google search

reboot

load google now launcher, ask for newer search again. load google search. uninstall google now launcher. re-install google now launch.

Then, it works.

Monday, June 23, 2014

VTK python object garbage collection

VTK use smart pointer to handle objects in c++. It is garbage collection in python. All the objects will be unavailable out of scope unless you keep ref count on them.

I return those objects in functions. So far, it works for me.

All the regular objects in vtk module work. But I also use vtk.util.numpy_support for the conversion between numpy data and vtk data. I have to use deep = True to make a deep copy. Otherwise, numpy arrays are garbage collected out of the scope.

Saturday, June 21, 2014

Add f-curve to video editing in blender

Adding f-curve in video editing it anti-intuitive. There is no direct solution when I google. Finally I found a clue.

You must point at the properties, such as scale and rotation,first. Then use your short cut "I" to insert the current key frame. Everything works the same as it does in 3D the editor.

Wednesday, June 11, 2014

auto suspend with xautolock

xautolock -time 20 -corners -000 -detectsleep -locker "systemctl suspend"&

This cmd will put the computer suspended after 20 min or move you mouse to left-up corner for a while.

You can put this cmd in some setup script.

Saturday, March 22, 2014

Shader debugging

It is for ES 2.0, maybe also works for desktop GL.Replace LOG_PRINT with your own log printing API.

glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &stat);
if (stat == GL_FALSE)
{
   LOG_PRINT("SDL_LOG", "Error: Vertex shader compiling\n");
   GLsizei iLength, slen = 0;
   glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &iLength);
   GLchar* compiler_log = new GLchar[iLength];
   glGetShaderInfoLog(vertexShader, iLength, &slen, compiler_log);
   LOG_PRINT("SDL_LOG", "%s\n", compiler_log);
   delete[] compiler_log;
}


High cpu usage when idle, win 8

If you find your fan is noisy while idle, M$ may run its famous auto maintenance without your permission. This auto maintenance may be turned on "automatically" during the system update. I do not know why M$ likes it so much.


The following is the way to turn it off.



1. Press the + R keys to open the Run dialog, type taskschd.msc, and click/tap on OK.

2. In the left pane of Task Scheduler, click/tap on to expand Task Scheduler Library, Microsoft, Windows, and TaskScheduler. (see screenshots below)

3. In the middle pane of TaskScheduler, either right click on or select the Regular Maintenance task, and do step 4 or 5 below for what you would like to do. (see screenshots below)

Tuesday, March 18, 2014

android NDK file io with SDL2

The resource management of NDK is ****** unfriendly. The files in the asset fold will be zipped, can not be accessed by NDK directly. Fortunately, SDL2 has file io wrapper. Here is a sample to read a file. Note that, the root path is asset.

SDL_RWops *file = SDL_RWFromFile("yourfile.txt", "r");
size_t len;
len = SDL_RWseek(file, 0, SEEK_END);
SDL_RWseek(file, 0, SEEK_SET);
char * fileChar = new char[len + 1];
SDL_RWread(file,  fileChar, sizeof(char), len);
fileChar[len] = '\0';
SDL_RWclose(file);

Monday, March 17, 2014

Kernel headers for version 3.x-xxxx were not found. If you installed them

One time, I updated my kernel, I could not use vmware 9. It always showed "Kernel headers for version 3.x-xxxx were not found. If you installed them". Archlinux wiki can not solve this.

I found the solution in a post. The kernel version.h file is relocated to some where else since some version. vmware can not find it.

ln -s /usr/lib/modules/3.13.6-1-ck/build/include/generated/uapi/linux/version.h /usr/lib/modules/3.13.6-1-ck/build/include/linux/version.h

Sunday, March 16, 2014

HUD/GUI with pure opengl calls

I am tired looking for good cross-platform gui libs. So far none of existing libs satisfies me.

cocos2d-x (MIT): Perfect for 2D , but I have to figure out how to draw 3D there.
librocket (MIT): Works with existing projects, but stops updating.
MyGUI-es2 (MIT): Have not tried.

I decide to reinvent the wheels.I could do GUI or HUD with only opengl calls. The basic ideal is that, draw 3D first normally, then disable depth related features and draw 2D stuff on the top. I tested with triangles, it seems working. Here is the pseudo-code.

//set your perspective matrix
glUniformMatrix4fv(u_matrix, 1, GL_FALSE, pers_view_mat.data());

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

{
    //3D draw
}
//set your orthogonal matrix
glUniformMatrix4fv(u_matrix, 1, GL_FALSE, orthoMat.data());
{
   glDisable(GL_DEPTH_TEST);
   glDepthMask(GL_FALSE);

   //2D draw

   glEnable(GL_DEPTH_TEST);
   glDepthMask(GL_TRUE);
}

Saturday, March 15, 2014

Importing android project into eclipse gets "Invalid project description"

It could have something to do with git. Moving the whole folder to a sub folder solves the problem.

https://stackoverflow.com/questions/12677093/invalid-project-description-when-importing-project-into-eclipse

Wednesday, March 12, 2014

cocos2d-x with custom gl es 2.0 code

cocos2d-x is a great 2D engine. It is based on ES 2.0. cocos2d-x has its own 2D wrappers on top of ES 2.0 to make it across platform. As long as there is already an EGL context, it is possible to add your own opengl code, or even other 3D engine.

The straight forward way is to override the draw function of a layer class and attach it to the scene. Just put all your gl code into function draw, such as shaders, VBO, and so on. It works. I just tested with a simple triangle though. Howerver, there problem is that my layer overrides everything. The original sprites and fonts are all covered. This is not what I need. I plan to re-use those GUI on top of my own 3D layer.

There is also a post in their forum talking about embedding horde3d to cocos2d-x.

Monday, March 10, 2014

flann 1.8.4 fails on win x64

I tried all I could, but failed.

mingw-64bit, vs 2012, vs 2013, with/without CUDA. 1.8.4 release or latest git. All failed.

Maybe I have to roll back to 1.7 on windows.

Saturday, March 8, 2014

run bat file in msys

I tried to run android.bat from the android-sdk for windows within msys shell. But the windows bat syntax is not working. I found a way after googleing. The following commands work.

cmd /c "your.bat [args,...]"


cocos2d-x ant debug error

If I follow the cocos2d-x tutorial, I receive an error while doing ant debug to generate the apk.

Setting the android sdk dir fixes it.

ant debug -Dsdk.dir= %ANDROID_SDK_ROOT%
or
ant debug -Dsdk.dir= $ANDROID_SDK_ROOT


Friday, February 14, 2014

Using chrome/firefox with nvidia gpu on optimus

"https://superuser.com/questions/645918/how-to-run-google-chrome-with-nvidia-card-optimus" gives the answser.


chrome disable nvidia gpu on optimus by default. The workaround in the post works for me too. Create hard links for browsers, and run it with nvidia by right clicking. At least I can see the it in the GPU monitor. It should work, as I tested it with webgl and saw the fps difference.


Here is the command for chrome.
C:\Program Files (x86)\Google\Chrome\Application>mklink /H gpu-chrome.exe chrome.exe
Hardlink created for gpu-chrome.exe <<===>> chrome.exe

This trick also works on firefox.

Thursday, February 6, 2014

android sdl static link

Follow the readme of android, it should work, but there is two tricks I have to mention.

1. You can put SDL folder anywhere but not in jni, otherwise you will get redefine error of NDK as "Trying to define local module".
2. You have to define main as "int main(int argc, char *argv[])".  "char **argv" will not work, and leads to undefined SDL_main linking error.

Tuesday, January 28, 2014

opengl es 2.0/opengl4 porting

ES 2.0 is a subset of GL 3/4. We know there is no geometry shader in ES. When I tried to porting my GL4 code to ES 2.0. I found another problem. There is no glVertexAttribIPointer or glVertexAttribLPointer to pass integer buffer to the vertex shaders. All the vertex buffers have to be passed with glVertexAttribPointer with different types. In my code, ivec3/ivec4 will not get correct values from glVertexAttribPointer. I have to use vec3/vec4 to get buffers. And then, cast them to int to use, like int(foo[0]). So far, it works fine, but I am not sure if there is any performance overhead while type casting from float to int, or there is any better solution.

understanding clang cross-compiing

I try to unify the dev environment to clang as I might work on IOS where gcc might not available. So far, clang works for most of my porting. Usually, libs work with gcc by default. clang can replace gcc in most of cases of native compiling, with some minor patches some times. However, crossing compie with clang is not trivial.

I dug into the android-cmake log to find the way of cross-compiling. The procedure seems that clang compile the source code to some bitcode, and then ndk/gcc/as compiles the bitcode to arm binary. clang can not work along to get arm binary.

Maybe I just use gcc for everything to save my live, as I might not work on IOS in a short time.

Update:
I try to manually compile arm binary on x86_64 with following commands:

clang -target armv7a-none-eabi -mcpu=cortex-a8 --sysroot=/opt/android-ndk/platforms/android-19/arch-arm/ -S hello.c

/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 hello.s -o hello.o

/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld hello.o -o hello -L $ANDROID_NDK/platforms/android-19/arch-arm/usr/lib/ -lc -lm

I got an arm binary, but I can not test it, as my tablet does not allow binary to run natively.

Sunday, January 26, 2014

porting freetype to android

UPDATE: 2.5.3 works with r9d clang4.4 out of box.


//=============Deprecated=======================

I need freetype as libRocket depends on it. The problem is freetype does not compile with clang3.3 in ndk-r9c.

I got these errors:
  "/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/as" -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 -o CMakeFiles/freetype.dir/src/autofit/autofit.c.o /tmp/autofit-tnCFeA.s
/tmp/autofit-tnCFeA.s: Assembler messages:
/tmp/autofit-tnCFeA.s:1145: Error: width suffixes are invalid in ARM mode -- `add.w r5,r5,#0x8000'

4.8 and 4.6 work fine. However it works with x86_64 clang on my PC. I hold it will with clang in IOS.

Update
uncomment the following line in "freetype-2.5.2/devel/ftoption.h" and "freetype-2.5.2/include/config/ftoption.h",
#define FT_CONFIG_OPTION_NO_ASSEMBLER

clang will compile, both freetype and libRocket then. I have to test if there is any running risks.

Monday, January 20, 2014

archlinux on android/arm, ssh normal user chroot

I tried chroot to use archlinux on an android tablet. The normal user will get socket error while using ssh, but root works fine. In order to use ssh, add a grp and add your user into it.

groupadd -g 3003 aid_inet
gpasswd -a $USER aid_inet

Wednesday, January 15, 2014

c++ log libs

I am considering port a c++ log lib to android ndk. On linux and windows, I use log4cxx in my projects. It works fine. However porting it to android is not trivial. Then, I also searched for some other options.

boost.log
log4cxx, BSD, configure/make, not for android
log4cplus, BSD/MIT, cmake, android setting
google glog, BSD, configure/make, no android
muduo, BSD, cmake, not sure on android
pantheios, BSD, configure, not ready for android

The options might be log4cplus and muduo so far. I have not started trying. My second thought is it is worth porting, as it take time to port and learn the api.

I just leave a note here, and use dummy i/o for logging in my dummy project. Maybe I am back some time.


Sunday, January 12, 2014

android emulator with opengl es 2.0

I googled around, and found a perfect emulator, "Genymotion". It emulates arm android on your windows/mac/linux. You can even install google play on it. I tried angry birds with nvidia 420m (integrated graphics card is slow), and it worked flawless. Then I tested my own arm projects, and they ran again. It is so far a perfect emulator.

PS
Before I found Genymotion, I tried stock emulator, which is said to support es 2.0 on x86 images. But, I can not got it work. Even if I could, it will be x86 with poor performance. I have to re-set up my projects. Android-x86 is another choice, but it is said there is no es 2.0.

Saturday, January 11, 2014

There exists no unified memory access for GPU so far.

I heard that, embedded systems like arm have only one memory pool. CPU and GPU share it. I though there might be some unified memory access there. But I am wrong. Arm (android/ios) GPUs work in the same way as integrated graphic cards in PC. RAM and VRAM are still separated logically. At least there is not such an API to let GPU access main memory directly. Data copying is still required.

AMD kaveri APU seems to break this rules on Jan 14 2014. Let us see.

Friday, January 10, 2014

android-cmake windows

android-cmake is a great solution to build existing libraries, e.g. libpng, for android. In my linux, it works flawlessly. I compiled assimp, libpng, libz, and bullet so far. And then, I can add them to my project in the android.mk, which I attached it to the end.

android-cmake works out-of-box in Linux. In window, there is no softlink, make install will fail. I just copy those target files, such as *.so, *.a, and bin files, to the build folder, and then make install works.

"Could not find any working toolchain in the NDK. Probably your Android NDK is broken" drove me to nut. I got this problem on one PC, but another one works perfectly. I finally found out, android-cmake works only with cmake 2.8.12.2. I updated the old one. Everything works now.

In order to link your prebuilt libs, you have to define your own LOCAL_MODULE and put them in the LOCAL_STATIC_LIBRARIES list



android.mk

LOCAL_PATH := $(call my-dir)

#assimp
include $(CLEAR_VARS)
LOCAL_MODULE := assimp
LOCAL_SRC_FILES := $(ANDROID_TOOLCHAIN)/lib/libassimp.a
LOCAL_EXPORT_C_INCLUDES := $(ANDROID_TOOLCHAIN)/include/assimp
include $(PREBUILT_STATIC_LIBRARY)

#libpng
include $(CLEAR_VARS)
LOCAL_MODULE := libpng
LOCAL_SRC_FILES := $(ANDROID_TOOLCHAIN)/lib/libpng.a
LOCAL_EXPORT_C_INCLUDES := $(ANDROID_TOOLCHAIN)/include/
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := game
LOCAL_C_INCLUDES += $(ANDROID_TOOLCHAIN)/include/eigen3/
LOCAL_SRC_FILES := ../../common/game.cpp jni.cpp assets_file_io.cpp
LOCAL_STATIC_LIBRARIES := assimp libpng
LOCAL_LDLIBS := -lz -lstdc++ -llog -lGLESv2 -lEGL -landroid
include $(BUILD_SHARED_LIBRARY)

Saturday, January 4, 2014

Multi-Player games notes

It is NOT well organized and NO game is made yet.

I just wanna keep a note about my thoughts about a pipeline for creating a multiplayer game. It is not specific to a single game but more a frame work or work flow. I hate reinventing the wheel so I prefer choosing existing tools.

I focus on the pure game itself so far. The external elements, such as log in UI or database, are not discussed here. I wanna describe my demands with keywords. Working along, low budget or no budget, indie, multi-player, real-time,  and cross-platforms.

I would like to have these steps: graphic modeling, logic, and network.

I am using blender and 3ds max for modeling. I used blender at the beginning. It is free, and incredible powerful. It is perfect for all my modeling tasks. When I found out I can get 3ds max and all the related Autodesk software for free as a student, I gave it a try as it is a kind of industry standard and a lot of models online are in max format. And, it should be better somewhere and have better compatibility with other software as it is sold thousands of dollars. However I found out, so far, it is a little better. I still need some work to import max models into unity 3d. On current stage, I would stay on blender for a while, because I am more familiar with it now. Probably I will move to 3ds max.

There are also plenty of game engines, such as blender, unity 3d, unreal,cocos-2dx, and panda 3d. I am using all of those above. unity 3d and unreal is the best in terms of performance, cross-platforms and network support.If you just need a offline game, they are the best to go. blender is good for tiny prototypes on pc. It is still powerful and easy to use, at least to myself. However, I have never seen any serious games out of it, except some demos. For cocos-2dx or panda 3d, there is no GUI, generally speaking. You need to implement your world from sketch.

Networking is kind of new to gaming, as I have not find any game engine has network embedded for dummy users. In other words, you need to program anyway if you need online games. I am not sure if unity or unreal handles server-client either. As on the server side, you probably do not need any rendering but just logic.

To conclude so far. Offline games, go unity 3D or unreal. Online games, any one is ok, and implement your own server.

Wednesday, January 1, 2014

windows/linux/osx,intel/amd,desktop/laptop/pad

I am interested in different platforms. Thus, I spent a day on googleing related information. In order not to waste such time, I decide to write these down.

windows/linux/osx

windows is best optimized on the same hardwares.

I can finish all the same tasks on those OS. They are transparent in terms of software to me. So I am more interesting hardware optimizations, especially on graphics. I thought osx has some magic on optimizations so that they can be overpriced. But, I can not find any evidence to support my hypothesis. In stead, main stream games are optimized for windows at the first place. Although osx versions may catch up years later, they will not do better. Based on my own experience, my windows works smoother than my linux on the same laptop. Even on science computation, windows versions are a little faster, at least no worse. So far, I would say, windows are optimized best, based on the hardwares(based on hackintosh or the same level mac).

intel/amd

amd is never a good solution on desktops, for price, power consuming, or performance. Maybe it is good for laptop in terms of price.

I have no amd chips to test, so all the following comparisons are from google. Cpu of amd seems really sucks nowadays.A saying is that, A10 can only reach i3 for daily use. GPU is better, maybe A10 can match 630. As a result, A10 ($130 bundle) seems a better solution than i3 ($180 bundle) + 630. However, i3+630 level is not for gamers. I would like go i5/i7($250 bundle) + 650ti ($130) at least. A10 can crossfire with 6xxx cards. Higher level cards work better standalone. Also A10 is said to consume more power.

For laptops, the story is a little difference.If you focus on battery life, go macbooks. Nothing can bit them so far. If you pursuit performance, you will get a big box, as heavy as a desktop, with twice of its prices. Neither of them is my target. I am think about a cheap laptop which can handle basic games like WoW. CPU is never my bottle neck. core 2 duo can handle such games without any problems.We assume A10 = i3 + 630m in laptops. A laptop with 630m or above will cost $700 usually and will not consume any less power. A10 ones might cost $400. Also, the coming Kaveri A10 will have unified memory for GPU and CPU, which will benefit GPU computing. If you have a tight budget, A10 laptop may be good choice.

desktop/laptop/pad

powerful desktop + light laptop/pad

Desktops are much powerful than laptops. It is proved by data and my feeling. You will pay a lot to make the performance of a laptop to match that of a desktop. Even if you match the performance, you probably get a large, heavy, and hot laptop, and you need pay more to improve the mobility. My ideal solution is, getting a powerful desktop (if I really need one), and carrying a very light laptop, like yoga2 or air, or even a pad with bluetooth keyboard.