Wednesday, 13 February 2013

Python and Ubuntu

I just removed Python2.7 from my Ubuntu. Initially, I needed to remove some Python packages but they locate in many folders. So, I used command "apt-get remove python2.7". The consequence was vital that all GUIs on desktop were deleted as well. Please be careful don't uninstall your Python desktop.

However, if you accidentally remove Python, here is a short solution. First, reinstall Python and desktop interfacing by following commands.
"apt-get install pythoin2.7"
"apt-get install ubuntu-desktop"

Monday, 21 January 2013

OpenGL:


I'm using OpenGL and QT creator in Ubuntu environment. I will constantly make short notes about problems and solutions in programming.

Adding OpenGL Library


To add external library, right click on the project or .pro file then click >>Add new library >>External library >>Browse "usr/lib/libGLEW.so"

Or edit the *.pro file by adding "LIBS += -L$$PWD/../../../../../../usr/lib/ -lglut -lGLEW"

A good OpenGL tutorial can be found here or here.

Create a simple project

1. Firstly, open QT Creator and create a empty project.
2. Add libraries (see above). After adding two libraries you can see the "-lglut -lGLEW" in the *.pro file.
3. Add the main source file (main.cpp)
4. Finally build and execute the project.

------------------------------------main.cpp----------------------------------------
#include <GL/glut.h>
void display(){
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0.5, 0.5);
    glVertex2f(0.5, -0.5);
    glEnd();
    glFlush();
}
void init(){
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glColor3f(1.0, 1.0, 1.0);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    glOrtho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
}
int main(int argc, char** argv){
    glutInit(&argc,argv);
    glutCreateWindow("simple");
    glutDisplayFunc(display);
    init();
    glutMainLoop();
}
-------------------------------------------------------------------------------------- 


Another useful material click here.

Ubuntu tips

Set LAN speed in Ubuntu
1. install ethtool "$sudo apt-get ethtool"
2. Add command to the start-up script "./etc/rc.local". Add command "/sbin/ethtool -s eth0 speed 100 duplex full".


Monday, 22 August 2011

First blog!!

I've done so many things in last week. I've used Google calendar for the first time and feel it quite useful. And I set the calendar as my home page. Any update will be add soon.