Pages

Saturday, November 21, 2009

OpenGL GL_Select problems with ATI, NVidia

  • Các giải thích về cách install và uninstall các ATI drivers. See here
select and pick object up

The 1st explaination: see here. Bên dưới là một copy của giải thích.
Beware that a BIG drop in performance will exist in ATI or NVIDIA GPUs

The hardware acceleration for GL_Select is only in full power on the high end graphics cards specially for graphics workstation.

The Bad Thing, that's only a matter of drivers, (some folks have hacked the drivers) but not a good solution.

So, if u have lots of objects to pick (like i have , > 10000) it's better that you don't rely on that method for object picking.
The 2nd explaination: see here. Bên dưới là một phiên bản copy lại
As mentioned above, this is very easy to implement.But there's a big drawback,namely the maximum size of the Name Stack.Every OpenGL implementation must at least offer a Name Stack size of 64 names (My GeForce4 Ti4400 with NVidia's Detonator 28.80 offers a Name Stack depth of 128 names).This is not enough,especially for complex scenes.If you need to retrieve information on more objects than your Name Stack is deep,then you'll have to use another method like casting a ray on where your mousecursor is.
The 3nd explaination: see here. Bên dưới là một copy lại

I've started noticing a dramatic drop in the performance of OpenGL rendering in SELECT mode. That is, after a call glRenderMode(GL_SELECT);. GL_SELECT is meant to be faster than regular rendering, because it only needs to render the geometry, and not shading or textures but recent drivers (since July 2007) have started slowing this operation down dramatically.

So far, it only appears to affect ATI graphics drivers. I haven't tested any HD cards -- if you have one, please consider contributing some numbers, using the test program below. Also, the numbers below indicate that GL_RENDER performance may very well also be affected -- by half!. Clearly something has screwed up.

....

Nvidia drivers seem to be unaffected -- if they were doing it too, I might be lead to believe a:

Conspiracy Theory

There's a chance that ATI/AMD (and nvidia) are deliberately disabling this feature of their graphics cards. Games often get by without using it, while high-end graphics workstation applications like Maya depend on it heavily. There's a chance the card manufacturers want you to shell out for a workstation card, like Quadro, if you want to use this feature. But, clearly, the cards can support it just fine!

The 4th explaination: See here.

Those are very clear for us to stop testing on Francois's computer.

Sunday, November 8, 2009

Dual boot Linux and Vista (or XP)

Sau gần vài tiếng đồng hồ thử nghiệm và cấu hình, cuối cùng tôi cùng tìm ra được cách edit GRUB để có thể cài một lúc Ubuntu và Vista (hoặc XP) trên cùng một máy tính.

Cách 1: Chỉnh sửa GRUB bootloader trong Ubuntu.
Cho dù bạn cài Vista hoặc Ubuntu trước, cách này đều hiệu quả.
Dùng đĩa Ubuntu Live CD (nói dễ hiểu là đĩa cài đặt Ubuntu và dĩ nhiên nó phải có tính tự boot được, tiếng anh là bootable) để khởi động hệ thống. Trên menu điều khiển, chọn Try install Ubuntu without.... để chạy trực tiếp Ubuntu trên đĩa CD mà không cần cài đặt. Khi đó, bạn chỉ cần chỉnh sửa GRUB theo bước sau:
  1. Từ Terminal, gõ lệnh: sudo -i để không cần phải gõ lại sudo (vì tất cả các thao tác này đều liên quan đến hệ thống, phải có quyền tương đương với root mới có thể thực hiện được)
  2. Dùng lệnh: fdisk -l để xem danh sách các phân vùng (partitions), xem phân vùng nào cài đặt Ubuntu, phân vùng nào cài đặt Windows (lệnh này chỉ test, không quan trọng).
  3. Gõ: grub
  4. find /boot/grub/stage1 để tìm phân vùng cài đặt Ubuntu, kết quả sẽ là một dòng dạng: hd?,? --> dấu ? thứ nhất là số hiệu của ổ đĩa, nếu máy tính của chúng ta chỉ có duy nhất một ổ đĩa cứng thì dấu hỏi này là số 0, nếu có hai ổ đĩa, mà Ubuntu được cài đặt trên ổ đĩa thứ 2 thì dấu hỏi này là số 1. Nói chung là, dấu ? thứ nhất cho biết ổ đĩa nào cài đặt Ubuntu.
    Dấu hỏi thứ 2 là số hiệu của phân vùng trên một ổ cứng, số hiệu đánh dấu từ 1 trở đi. Nên nếu: hd0,6 nghĩa là Ubuntu đang cài đặt trên ổ đĩa cứng đầu tiên, ở phân vùng thứ 6.
  5. Gõ lệnh: root (hd0,6)
  6. Gõ lệnh: setup (hd0)
  7. Thoát grub: quit, sau đó khởi động lại máy tính bằng lệnh reboot kế tiếp.
Sau đó, hệ thống sẽ hiển thị một menu để bạn chọn lựa hệ điều hành cần khởi động. Và thường theo cách này thì dòng thông báo hệ điều hành Windows Vista sẽ nằm cuối cùng. Chúng ta có thể chỉnh sửa thêm một vài thông số trong file cấu hình này.
Cũng từ Terminal, chúng ta dùng lệnh: gksudo gedit /boot/grub/menu.lst. File menu.lst chứa các thông số để khởi động Ubuntu và Vista.

Cách 2: Chỉnh sửa bootinit.h trong Vista

Saturday, November 7, 2009

How to print multiple pages in a sheet

Tôi biết có nhiều người muốn in nhiều trang soạn thảo văn bản trong Microsoft Word trên một mặt giấy A4 (vì muốn tiết kiệm giấy). Chức năng này đã có trong Page Setup... khi chúng ta soạn thảo văn bản nhưng đôi khi không thực hiện vì một lý do nào đó. Thường thì máy in có support tính năng này không. Theo tôi tìm hiểu, có 2 cách để thực hiện điều này:
  1. Một số máy in đời mới có hỗ trợ thì việc này dễ như trở bàn tay.
  2. Nếu không, bạn sẽ dùng một số tiện ích khác nhằm làm một việc thủ công trước khi in. Trong Linux, bạn dùng pdfnup hoặc psnup. Có thể xem thêm link ở đây http://ubuntuforums.org/showthread.php?t=138981.

Mọi thứ về Latex

TẠO PRESENTATION VỚI LATEX

Gói thường sử dụng nhiều nhất là beamer.


References và citations được quản lý theo một thống nhất trong Latex bằng cách sử dụng BibTeX. Với cách này, chúng ta đưa tất cả các thông tin liên quan đến tài liệu tham khảo vào trong một file có phần mở rộng là .bib. mà không cần quan tâm đến thứ tự của chúng (Xem file mẫu myrefs.bib).

(See the sample file myrefs.bib, below.) Then you let BibTeX format all citations and reference entries according to the chosen bibliographic style, and you don't have to sweat all the font and punctuation and ordering details yourself.
The reference/bibliography section usually appears at the end of an publication. In your LaTeX file, these two commands insert the reference section:
\bibliographystyle{xxx}
 \bibliography{yyy}
The ``xxx'' is a style name -- plain or abbrv or siam or alpha or any of dozens of other available styles, many listed below. The ``yyy'' is the name of the bib file (yyy.bib) containing the reference database.
For example, the command \bibliography{myrefs} would call on file ``myrefs.bib''.
Below find the following:

Chinh sua de in code cho dep:
http://stackoverflow.com/questions/741985/latex-source-code-listing-like-in-professional-books

Friday, November 6, 2009

Bioinformatic Textbooks

http://search.barnesandnoble.com/Bioinformatics/David-W-Mount/e/9780879697129
http://compbio.ucdenver.edu/hunter/cpbs7711/textbooks.html
http://kdpnw.kdp-baptist.louisville.edu/proteomelab/bookbio.html
http://www.google.com/Top/Science/Biology/Bioinformatics/Education/Courses/
http://www.bioinformaticscourses.com/bioinform/2003q3/lecture1_2003q4.html

Thursday, October 29, 2009

Clustering

jClust: A tool for clustering analysis

CircularLayout - Giai thich mot ty ve Clustered Graph

Compression and Decompression in Ubuntu

This is a presentation of tar:
Linux: File Compression and Archiving with gzip, zip, rar, tar, unzip...

Các file lưu trữ (đôi khi gọi là file nén) trên hệ thống UNIX/Linux (thường phần mở rộng là tar.gz hoặc .tgz) có thể được trích xuất (bung nén - extract) bằng một lệnh đơn giản.

Ví dụ: Để bung một file lưu trữ nén tên là target.tar.gz vào thư mục hiện hành, ta dùng lệnh:

gzip -dc target.tar.gz | tar xf -
tar xvzf target.tar.gz

Nếu file được nén với chuẩn bzip2 (i.e., .tar.bz2), chúng ta có thể thay thế gzip bằng lệnh bzip2.

Nếu file nén với lệnh nén của UNIX (phần mở rộng là .z) thì chúng ta dùng lệnh sau:

zcat target.tar.Z | tar xf -

Nếu nén ở dạng *.tar.xz thì:
tar Jxf *.tar.xz hoặc dùng unxz -z: để nén, và -d để giải nén.
Hy vọng với tóm tắt này sẽ là nơi để tham khảo quý báu.

Q. How do I extract tar.gz file under Linux / UNIX like operating systems?

A. tar.gz is nothing but compressed tar archive.
The tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use Tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored.
Initially, tar archives were used to store files conveniently on magnetic tape. The name "Tar" comes from this use; it stands for tape archiver. Despite the utility's name, Tar can direct its output to available devices, files, or other programs (using pipes), it can even access remote devices or files (as archives).

Extract tr.gz. file

To extract one or more members from an archive, enter:
tar -zxvf {file.tar.gz}
If your tarball name is backup.tar.gz, enter the following at a shell prompt:
tar -zxvf backup.tar.gz

Extracting an Entire Archive

To extract an entire archive, specify the archive file name only, with no individual file names as arguments.
tar -zxvf backup.tar.gz

tar xjvf cornbread.tar.bz2

Nếu chỉ là .bz2 thôi thì:
bunzip2 spankythefish.bz2

Chuẩn nén 7z
Cài đặt: sudo apt-get install p7zip
Bung nén: p7zip -d filename.7z

Chuẩn nén rar
Dùng rar hoặc unrar

Chuẩn nén zip
zip và unzip

Cycle in Metabolic Network

Citrate cycle (TCA cycle) - Leishmania major







http://en.wikipedia.org/wiki/File:Citric_acid_cycle_with_aconitate_2.svg



Interactive animations: The Citric Acid Cycle

TCA Cycle

How to install FFmpeg with MP3 and AMR support

Mot bai viet hay ve dieu nay:
http://www.mattiouz.com/blog/2007/07/02/how-to-install-ffmpeg-with-mp3-and-amr-support
Va tren ubuntuforums
http://ubuntuforums.org/showthread.php?t=178455

Wednesday, October 28, 2009

Quản lý phiên bản phần mềm và source code (SVN)

Một vài lệnh căn bản:
svn ci -m "Updated the project": Cap nhat len respority
svn checkout+ssh
http://linux.byexamples.com/archives/255/svn-command-line-tutorial-for-beginners-1/
http://code.google.com/p/svnx/

Monday, October 26, 2009

Using gluUnProject

One introductory tutorial can be shared here.

Thursday, October 8, 2009

Drawing arrow in OpenGL

We have two points A and B in 3D. The problem is to find the way to draw a line that the started point is A and the later is B. We also want to have a little arrow at B.

One guy posted the guide in gamedev.net
Say: A = [x1, y1, z1] (start)
and B = [x2, y2, z2] (end)
and C = [x3, y3, z3] (arrow tip at one side)
and D = [x4, y4, z4] (tip at the other side)

if((z1-z2) != 0) {
first we make a normal vector:
x3 = 1
y3 = 1
z3 = (-(x1-x2)-(y1-y2))/(z1-z2)

adjusting the distance from the arrow axis to one fourth of the arrows lenght:
adj = sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)) / (4 * sqrt((x3^2)+(y3^2)+(z3^2)));
x3 *= adj
y3 *= adj
z3 *= adj

setting the other side:
x4 = -x3
y4 = -y3
z4 = -z3

gettin the point:
x3 = x1 + (3/4)*(x1-x2) + x3
y3 = y1 + (3/4)*(y1-y2) + y3
z3 = z1 + (3/4)*(z1-z2) + z3

x4 = x1 + (3/4)*(x1-x2) + x4
y4 = y1 + (3/4)*(y1-y2) + y4
z4 = z1 + (3/4)*(z1-z2) + z4
}

OK, I didn't double check this, but the clue is the "first we make a normal vector:" -section, the rest is fairly straight out. Oh and if you use float or double values, they rarely become zero, but if (z1-z2) should happen to be zero, then find the normal setting z3 = 1, y3 = 1, and x3 = (-(y1-y2)-(z1-z2))/(x1-x2), that should work work as well, and if (x1-x2) also is zero, just base it on y the same way.
Well, as I said, I didn't double check this, but I know it works, there might be simpler ways also, be sure to tell me if I made some stupid mistakes here.


I appreciate this explanation.

Saturday, October 3, 2009

Installing PHP5, MySQL and Apache on Ubuntu

Để lập trình web sử dụng PHP và MySQL trên Ubuntu, chúng ta nên sử dụng XAMPP. Xem trên trang này, chúng ta sẽ biết cách cài đặt. Khá đơn giản vì chúng ta chỉ cần cài gói XAMPP dành cho Linux nên việc cấu hình còn lại chỉ là sử dụng xampp như thế nào cho đúng.

Tuy nhiên, ngoài những bước kiểm tra như trong các trang cài đặt, chúng ta cần kiểm tra thêm một vài thứ như sau:

Rõ ràng, nếu chúng ta đã cài đặt XAMPP thì không cần thiết phải cài đặt riêng từng gói như PHP, MySQL hay Apache... Vì thế, từ bất kỳ vị trí nào ngoài /opt/lampp/bin, chúng ta gõ mysql -u root -p (sau đó yêu cầu password) thì có nghĩa là trên máy bạn đã có mysql.

Có vấn đề tôi gặp phải là:

  1. Tôi cài và dùng MySQL Query Browser và MySQL Administrator, mỗi khi khởi đội một trong hai chương trình này đều yêu cầu cung cấp Username và Password.
  2. Cấu hình phpmyadmin: mỗi lần đăng nhập hay hỏi mật khẩu. Lỗi cũng giống như trường hợp 3.
  3. Chạy mysql từ console, không cho root đăng nhập. Lỗi: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Các tình huống lỗi hay gặp:
Lỗi 01:
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’
Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!


Xem cách giải quyết tình huống 1
Lỗi 02:
honey@honey:~$ mysqladmin create test
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘honey’@'localhost’ (using password: NO)’






Xem cách giải quyết tình huống 2,3






Giải quyết tình huống 1:
Hay báo lỗi là không khởi động được file mysqld.sock. Thế thì:
- Tạo thư mục mysqld: sudo mkdir /var/run/mysqld
- Chuyển đến thư mục trên: cd /var/run/mysqld
- Tạo một shortcut: sudo ln -s /opt/lampp/var/mysql/mysql.sock mysqld.sock

Giải quyết tình huống 2:
Cứ theo hướng dẫn và chỉnh sửa như sau:
This is What I did, assuming mysql server is already running 
and setup ok. 









edited the file /etc/my.cnf 
at the [mysqld] section
added this line: 
skip-grant-tables 
and restarted the server .... 
That worked great!!!
Giải quyết tình huống 3:
Nếu đã giải quyết tình huống 2 xong thì 3 ok. Hướng dẫn đầy đủ nhất xem trên trang này.
+================================================================+
SAU ĐÂY LÀ CÁC LỆNH ĐẦU TIÊN DÙNG TRÊN MYSQL
1. Tạo database:
a. Dùng: mysqladmin create Tên_CSDL
b. Đăng nhập vào mysql: mysql -u root (hoặc user khác có quyền tạo database) -p --> enter, sau đó nhập mật khẩu.
mysql>create database tasks;
Query OK, 1 row affected (0.00 sec)
2. Sửa mật khẩu user: xem trang này đầy đủ hơn.
===================================================================
Tham khảo:

Shared via AddThis

Thursday, September 24, 2009

References to do report

Graph Editor - a brief discussion about node, edge, selection and move tools.
Tutorials - Raw J3D - discusses on the principal 3D graphics in Java

Interaction with Mouse in OpenGL (Part 2)

In fact, transformations are relative to the object. You need to keep track of your transforms and move things as appropriate for the current state of the model view matrix. Everything is relative, so it doesn't really make sense to talk about absolute position in this way. You can try glPushMatrix(), glLoadIdentity(), glTranslatef(0.1f0, 0.2f0, 0.0f0), draw-gl-scene, and glPopMatrix(), which may or may not be what you actually want to do.

Moving selected objects in OpenGL
What you need to do is check whenever the mouse is moved AND if the player is holding the button you use to move objects. You also need to check if the user has already clicked on an object to move and is then holding the mouse to move it.

Here's the steps:
1. User mouse clicks down on object
2. Call function with mouse down
3. User keeps mouse held down and moves mouse
4. Call function with mouse motion
5. User stops holding mouse down
6. Call function with mouse up

void reshape(int w, int h) {
glViewport(0, 0, (GLint) w, (GLint) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if ( h==0 )
gluPerspective(45, (GLdouble)w, 1.0, 2000.0);
else
gluPerspective(45, (GLdouble)w/ (GLdouble)h, 1.0, 2000.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void mouse ( int button, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
moving = 1;
startx = x;
starty = y;
}
if ( button == GLUT_LEFT_BUTTON && state == GLUT_UP )
moving = 0;

if ( button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN )
{
moving = 2;
starty = y;
}
if ( button == GLUT_RIGHT_BUTTON && state == GLUT_UP )
moving = 0;
}

void motion ( int x, int y )
{
if ( moving == 1 )
{
angle = angle + ( x - startx );
angle2 = angle2 + ( y - starty );
startx = x;
starty = y;
glutPostRedisplay ( );
}
if ( moving == 2 )
{
zoom = zoom + ( y - starty );
starty = y;
glutPostRedisplay ( );
}
}

And make sure you call
glutMouseFunc ( mouse );
glutMotionFunc ( motion );

after init() in your main loop

And needed global variables

float angle, angle2, cloud_rot;
float zoom = -25.50;

int moving, startx, starty;

See more here

Drag Mouse to move Objects
According to the docs, the mouse state has to be checkd like this:
Uint8 ms;
ms = SDL_GetMouseState(&x, &y);
if(ms & SDL_BUTTON(SDL_BUTTON_LEFT))
{
MouseButtonUp(x,y,LEFT);
}
else if (ms & SDL_BUTTON(SDL_BUTTON_RIGHT))
{
MouseButtonUp(x,y,RIGHT);
}
else if (ms & SDL_BUTTON(SDL_BUTTON_MIDDLE))
{
MouseButtonUp(x,y,MIDDLE);
}

// my mouse event code cut from my game engine.
// All the game events go thru here
while ( SDL_PollEvent(&event) )
{
// Send Keyboard events to the keyboard handler
done = HandleKeys(event);

// Mouse events
int x,y;
switch (event.type)
{
// A button on the mouse was pressed
case SDL_MOUSEBUTTONDOWN:
switch(SDL_GetMouseState(&x,&y))
{
case SDL_BUTTON(SDL_BUTTON_LEFT):
MouseButtonDown(x, y, LEFT);
break;
case SDL_BUTTON(SDL_BUTTON_RIGHT):
MouseButtonDown(x, y, RIGHT);
break;
case SDL_BUTTON(SDL_BUTTON_MIDDLE):
MouseButtonDown(x, y, MIDDLE);
break;
default:
break;
}
break;

// It was realeased
case SDL_MOUSEBUTTONUP:
switch(SDL_GetMouseState(&x, &y))
{
case SDL_BUTTON(SDL_BUTTON_LEFT):
MouseButtonUp(x, y, LEFT);
break;
case SDL_BUTTON(SDL_BUTTON_RIGHT):
MouseButtonUp(x, y, RIGHT);
break;
case SDL_BUTTON(SDL_BUTTON_MIDDLE):
MouseButtonUp(x, y, MIDDLE);
break;
default:
break;
}
break;

// Mouse is on the move.
case SDL_MOUSEMOTION:
SDL_GetMouseState(&x, &y);
MouseMove(x, y);
break;

}

http://www.gamedev.net/community/forums/topic.asp?topic_id=400975

Getting mouse button and/or keyboard events
Hi all,
I have a Windows program I am using for an experiment - I am recording people's reaction times in various situations, and to control the duration of the displays people see, I increase the priority of the current process and the current thread using the Windows functions SetPriorityClass(hProcess,
HIGH_PRIORITY_CLASS) and SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST),
respectively. Raising the priority of the current thread locks out other
Windows processes (so they don't affect the timing of my displays), but it also
appears to lock out the keyboard and mouse, so I can't use SDL_PollEvent() to
get mouse button presses or key presses. I'm wondering if there is another
function that will allow me to directly poll the mouse or check for specific key
presses that would not be affected by changing the priority of the thread. I
realize that this might be beyond the scope of the forum, but any information
would be helpful and appreciated. (I also realize that recording reaction times
with a mouse or keyboard event is likely to have some built-in variability; I'm
just trying to minimize that variability as much as possible). Thank you in
advance.

Chris Dickinson
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-October/066952.html
Maybe:
Uint8* keystates = SDL_GetKeyState(0);
...
if(keystates[SDLK_SPACE])
{
// do stuff
}

and... (from docs)
SDL_PumpEvents();
if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1))
printf("Mouse Button 1(left) is pressed.\n");


Jonny D


basically, if you're just wanting a ray in the direction of the mouse click, then its pretty simple using gluUnProject.
below is a simple usage to get the ray

GLdouble ray_x, ray_y, ray_z;
GLint viewport[4];
GLdouble proj[16];
GLdouble modelview[16];

// we query OpenGL for the necessary matrices etc.
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_PROJECTION_MATRIX, proj);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);

// assuming you have mouse coordinates as mouseX and mouseY
// gluUnproject assumes coordinates are measured from bottom of screen
// so we invert the mouseY you got from glut or SDL or watever
GLdouble _mouseY = viewport[3] - mouseY;

// using 1.0 for winZ gives u a ray
gluUnProject(mouseX, _mouseY, 1.0f, modelview, proj, viewport, &ray_x, &ray_y, &ray_z);


and there you have the ray direction coords... it isn't normalized tho fyi.

i think you can actually get the z coordinate of the object you clicked.. but i haven't needed that yet... then you'd pass in something else as winZ, getting it from the Z-buffer... but not too sure.

hope that helped.
----------------
If you just want the 3d coordinates of the point in space the mouse is over, the following code will give you just that:

GLdouble model_view[16];
glGetDoublev(GL_MODELVIEW_MATRIX, model_view);
GLdouble projection[16];
glGetDoublev(GL_PROJECTION_MATRIX, projection);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
double dx; double dy; double dz;
GLfloat depth[2];
glReadPixels (x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
gluUnProject(x, y, depth[0], model_view, projection, viewport, &dx, &dy, &dz);
x3d = float(dx);
y3d = float(dy);
z3d = float(dz);

Zoom in and out a large surface
There are 2 common ways to zoom in 3D:
  • by scaling
  • by manipulating the projection matrix
Scaling just involves calling glScalef with the correct scaling factor before rendering the zoomed object. Unfortunately, you will still run into problems with the clipping planes.

The correct way to zoom is to modify the projection matrix. If you are using an orthographic projection, just scale the width and height arguments to glOrtho. If you are using a perspective projection, try modifying the field of view (narrow field of view is more zoomed).

glTranslate is not a very good way to zoom. You are basically moving the object closer of further away from the camera, which will sort of work in perspective projection, but eventually you will translate past the a clipping plane.

I was recently doing this by changing glViewPort function and increasing the number (from both sides)
See more here

Friday, September 11, 2009

Some notes working with Common Lisp

1. When using multiple-value-bind, there are some values that we don't need. We can ignore the warning "The variable x, y,... is never used...". Below is an example:
(defun my-round (x)
(round (+ x 0.5)))

(defun next-power-of-two (x)
(let ((log-base2 (/ (log x) (log 2))))
(multiple-value-bind (y z)
(my-round (expt 2 (ceiling log-base2)))
(declare (ignorable z))
y)))
Because the my-round functions returns two values, but I only use the first one. When I apply this function inside the next-power-of-two function, I also need the first.

2. In order to use the hexadecimal values in Common Lisp, we can use "#x" or "x16r" to represent them.

Saturday, September 5, 2009

Interaction with Mouse in OpenGL (Part 1)

Cytoscape
Selection Objects (www.3dkingdoms.com)
BioLayout Express 3D, click here to get more details of BioLayoutJava
Interactive Graph Drawing is an open source for drawing interactive graph drawing on the WWW, inspired by Arthur van Hoff's early GraphLayout Java demonstration applet. He implemented how to select and move nodes on the graph.
VisAnt is an Integrative Visual Analysis Tool for Biological Networks and Pathways. Currently, there is not available source code.

/* Function prototypes */
/*
* Retrieve the current state of the mouse.
* The current button state is returned as a button bitmask, which can
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
* current mouse cursor position.  You can pass NULL for either x or y.
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);

With:
/* Used as a mask when testing buttons in buttonstate
Button 1: Left mouse button
Button 2: Middle mouse button
Button 3: Right mouse button
Button 4: Mouse wheel up  (may also be a real button)
Button 5: Mouse wheel down (may also be a real button)
*/
#define SDL_BUTTON(X)  (1 << ((X)-1))
#define SDL_BUTTON_LEFT  1
#define SDL_BUTTON_MIDDLE 2
#define SDL_BUTTON_RIGHT 3
#define SDL_BUTTON_WHEELUP 4
#define SDL_BUTTON_WHEELDOWN 5
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)


Thursday, September 3, 2009

Technology terms in Graphics Processing

Rasterization or Rasterisation is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (pixels or dots) for output on a video display or printer, or for storage in a bitmap file format.

Wednesday, September 2, 2009

NewLisp

newLISP Fan Club: http://www.alh.net/newlisp/phpbb/index.php?sid=86dab258338cbad37c81adeee447cb6d

OpenGL Programming with GLFW

OpenGL: Overview from Answers.com: http://www.answers.com/topic/opengl
GLFW: An OpenGL Library: http://glfw.sourceforge.net/index.html
Introduction to OpenGL: http://opengl.joudoki.com/
Get GLFW at SourceForge.net: http://sourceforge.net/projects/glfw/
Forums for GLFW: http://sourceforge.net/forum/?group_id=72569

Saturday, August 29, 2009

GLX - GLU - DRI

GLX is used on Unix OpenGL implementation to manage interaction with the X Window System and to encode OpenGL onto the X protocol stream for remote rendering.

GLU stands for OpenGL Utility library. This is a set of functions to create texture mipmaps from a base image, map coordinates between screen and object space, and draw quadric surfaces and NURBS.

DRI stands for Direct Rendering Infrastructure. In simple terms, it enables hardware-accelerated 3D graphics on Linux. More specifically, it's a software architecture for coordinating the Linux kernel, X Window system, 3D graphics hardware and an OpenGL-based rendering engine.

(More http://www.opengl.org/resources/libraries/glx/)

Thursday, August 27, 2009

IT Communities, Forums and Groups

DaniWeb IT Discussion Community (Software Engineering, Web Development...
Genesim Software - Powerful applications (A lot of good things)

Draw in OpenGL

How to compile a program written in OpenGL

g++ -Wall -O my-program.cpp -lglut -o my-program
In which:
  • -Wall: is a way of saying the compiler that it should output all the warnings
  • -O: says the compiler to use some optimization techniques
  • -l is a linker option stating to include the library followed the -l. Here is glut.

    There is a little extra advantage when using GLUT, if you were developing an OpenGL application you should include the header files gl.h and glu.h (glu is the OpenGL Utility Library) but when you are including glut.h, glut.h guarantees the inclusion of gl.h and glu.h. So when we start and OpenGL application we start by writing:

    #include
  • -o: says the compiler that it should produce a binary file whose name is my-program
An Efficient Way to Draw Approximate Circles in OpenGL
An introduction of GLUT (Understand easily)


Draw Text
Faster Text in OpenGL
Drawing Text

Tuesday, August 18, 2009

Download videos from YouTube.com in Linux

youtube-dl is a small command-line program to download videos from YouTube.com.

Install youtube-dl in Ubuntu

sudo aptitude install youtube-dl

This will complete the installation.

Using youtube-dl

Usage instructions are easy. Use youtube-dl followed by a video URL or identifier.

youtube-dl Example

youtube-dl “http://www.youtube.com/watch?v=foobar”

The video will be saved to the file foobar.flv in that example. As YouTube.com videos are in Flash Video format, their extension should be flv.Check this simple guide to convert .flv files to .mpg

More usage tips

You can change the file name of the video using the -o option, like in

youtube-dl -o vid.flv “http://www.youtube.com/watch?v=foobar”.

Some videos require an account to be downloaded, mostly because they’re flagged as mature content. You can pass the program a username and password for a YouTube.com account with the -u and -p options, like

youtube-dl -u myusername -p mypassword “http://www.youtube.com/watch?v=foobar”.

The account data can also be read from the user .netrc file by indicating the -n or --netrc option. The machine name is youtube in that case.

The simulate mode (activated with -s or --simulate) can be used to just get the real video URL and use it with a download manager if you prefer that option.

The quiet mode (activated with -q or --quiet) can be used to supress all output messages. This allows, in systems featuring /dev/stdout and other similar special files, outputting the video data to standard output in order to pipe it to another program without interferences.

The program can be told to simply print the final video URL to standard output using the -g or --get-url option.

Friday, August 14, 2009

Works have done in this week (10/08-14/08)

  1. Coded the Kosaraju's algorithm to find the strongly connected components
  2. Coded Graph's operations
  3. Understood the Becker's et al paper


A path with no repeated vertices is called a simple path, and cycle with no repeated vertices aside from the start/end vertex is a simple cycle. In modern graph theory, most often "simple" is implied; i.e., "cycle" means "simple cycle" and "path" means "simple path", but this convention is not always observed, especially in applied graph theory. Some authors (e.g. Bondy and Murty 1976) use the term "walk" for a path in which vertices or edges may be repeated, and reserve the term "path" for what is here called a simple path.

A path such that no graph edges connect two nonconsecutive path vertices is called an induced path.

A simple cycle that includes every vertex of the graph is known as a Hamiltonian cycle.

Wednesday, August 5, 2009

Solutions for moving selected objects in OpenGL

Moving selected objects in OpenGL
Nehe - Lesson 30
From lisp hacker
Mouse event handlers

Research algorithms to optimize the placements

1. Find the longest cycle in the graph
2. Find all pairs shortest path Algorithm

* Sample Code: http://www.codeguru.com/cpp/cpp/algorithms/article.php/c5119
* Shortest Path Algorithms: http://www.umich.edu/~me558/manuals/LEDA/shortest_path.html

3. Detect a cycle in the graph

* Extending the shortest-path swarm algorithm to cycle detection: http://ieeexplore.ieee.org/Xplore/login.jsp?url=http%3A%2F%2Fieeexplore.ieee.org%2Fiel5%2F10622%2F33557%2F01594255.pdf%3Farnumber%3D1594255&authDecision=-203

Websites should discovery

Good coders code, greate reuse
Dreamsongs
Everything
So Jakes Say

Swarm Programming

Swarm Computing

Friday, July 17, 2009

Python Programming for Beginners

To start with Python Programming, have a look at glance at the article from Linux journal Python Programming for Beginners

Some other resources can help us to learn Python as follows:
Dive in Python - From novice to pro
Thinking in Python - One of the famous series of books
Python Documentation
How to Think Like a Computer Scientist: Learning with Python v2nd Edition documentation

OpenGL Programming in Linux: GLX and Xlib

Xlib is a library which provides functions for applications running under the X Window System (also referred to as X). This includes window management as well as event handling. X is a network orientated system: An application which is running on computer A can send its graphical output to computer B, which is located somewhere else in the network (the network can be a LAN as well as the internet), and can receive events like keyboard or mouse input from computer B. This requires that a program called the "X-Server" is running on both computers. In Linux, the X-server is started with the command startx. You will most probably not have to start the X-server manually, because most Linux Distributions will set up the system to automatically start X after booting.

In the following, a small program framework will be developed, which uses the GLX extension to the X windows system. Only little knowledge of X will be needed; for a comprehensive introduction to X the "Xlib Programming Manual" by Adrian Nye can be recommended.

The program starts with the inclusion of the header files:
More...

Another tutorial about OpenGL Programming in Linux is here

Drawing simple shapes with perspective

Drawing simple shapes with perspective

Shared via AddThis

How To Start With Cpp In Linux

http://www.socher.org/index.php/Main/HowToStartWithCppInLinux

OpenGL Programming

Introduction

freeglut vs OpenGlut
freeglut and OpenGlut are open sources to the OpenGL Utility Toolkit (GLUT) library. OpenGL is a sibling of freeglut which belongs to some members of freeglut team.

freeglut vs GLUT
GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windowing application programming interface (API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides a portable API so you can write a single OpenGL program that works across all PC and workstation OS platforms.

freeglut is a completely OpenSourced alternative to the OpenGL Utility Toolkit (GLUT) library. GLUT was originally written by Mark Kilgard to support the sample programs in the second edition OpenGL 'RedBook'. Since then, GLUT has been used in a wide variety of practical applications because it is simple, widely available and highly portable.

GLUT was originally to get a window open as fast as possible with least amount of code possible (for quick OpenGL programs) and for simple keyboard interface.

GLUT (and hence freeglut) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions.

freeglut is released under the X-Consortium license.

SDL
SDL is also super-portable and very commonly used. SDL has a working fullscreen mode. SDL on the other hand is designed to be used more extensively

(More detailed: http://archives.seul.org/linuxgames/Jun-2002/msg00019.html)
These are useful links
  1. OpenGL, SDL, graphics, games
  2. Beginning Game Programming
  3. Computer Graphics (A course of Computer Graphics from MIT OpenCourseWare)

  4. OpenGL with Java and here is Tutorials

Unable to create direct context rendering for window

When we run a OpenGL program in Ubuntu, there is an error below:
"freeglut (./a.out): Unable to create direct context rendering for window ''
This may hurt performance."
The solution is: to install dri and drivers correct for computer

Thursday, March 26, 2009

User guest

1. Open the Local Security Policy console in the Administrative Tools folder.

2. Browse down to: Security Settings\Local Policies\Security Options.

3. Double-click on the Network Access: Sharing And Security Model For Local
Accounts.

4. Change the settings from Guest Only to Classic. This feature is, by default,

set to Classic when Windows XP Professional is joined to a domain.

User guest

Local Policies:
Network: Sharing resource: Classic

Wednesday, March 18, 2009

Tìm hiểu XML - Phần 1

XML là một dạng ngôn ngữ dùng để biểu diễn dữ liệu. Nếu HTML thiên về cách trình bày (định dạng) dữ liệu thì XML thiên về cách thức lưu trữ chúng.

Trang này là một giới thiệu ngắn và dễ học: XML Tutorial.