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;
}
Saturday, March 22, 2014
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)
The following is the way to turn it off.
1. Press the
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)
Wednesday, March 19, 2014
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);
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
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);
}
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
https://stackoverflow.com/questions/12677093/invalid-project-description-when-importing-project-into-eclipse
Subscribe to:
Posts (Atom)