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);