GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, February 27, 2011

OpenGL - Points

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void setup(){
    // backgrouning the screen
    glClearColor(0.0, 0.0, 0.0, 1.0);
    // make the coord width and height 20 in scale
    gluOrtho2D(-10.0, 10.0, -10.0, 10.0);
}

void display(){
    // clearing the buffer screen in memory
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(0.0, 1.0, 0.1);
    glPointSize(5.0);        // make the point 5 in width

    glBegin(GL_POINTS);
        glVertex2f(1.0, 1.0);
        glVertex2f(2.0, 2.0);
        glVertex2f(3.0, 3.0);
        glVertex2f(4.0, 4.0);
        glVertex2f(5.0, 5.0);
    glEnd();

    glFlush();
}

int main(int argc, char *argv[]){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowPosition(200, 100);
    glutInitWindowSize(400, 300);
    glutCreateWindow("Hello World");
    glutDisplayFunc(display);

    setup();
    glutMainLoop();

    return 0;

}


Share/Bookmark

Saturday, February 26, 2011

OpenGL - Draw Rectangle

Here's a code on how to make backgrouning color:

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void setup(){
   glClearColor(1.0f, 0.0f, 0.0f, 0.0f);    // backgrouning
}

void display(){

   glClear(GL_COLOR_BUFFER_BIT);
   glColor3f(0.0f, 0.0f, 0.0f);    // coloring rect
   glRectf(-0.75f, 0.75f, 0.75f, -0.75f);  // draw rect
   glFlush();
   glutSwapBuffers();
}

int main(int argc, char *argv[]){

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(400, 300);    // horizontal, vertical
    glutInitWindowPosition(200, 100);    // horizontal, vertical
    glutCreateWindow("Hello World");    // title of the window

    glutDisplayFunc(display);
    glutMainLoop();

    return 0;
}



Share/Bookmark

OpenGL - Backgrouning

Here's a code on how to make backgrouning color:

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void setup(){
   glClearColor(1.0f, 0.0f, 0.0f, 0.0f);    // backgrouning
}

void display(){

   glClear(GL_COLOR_BUFFER_BIT);
   glutWireTeapot(0.5);
   glFlush();
}

int main(int argc, char *argv[]){

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(400, 300);    // horizontal, vertical
    glutInitWindowPosition(200, 100);    // horizontal, vertical
    glutCreateWindow("Hello World");    // title of the window

    glutDisplayFunc(display);
    glutMainLoop();

    return 0;
}

You can get learning from this link: Wikibooks or cs.uccs
Share/Bookmark

Starting OpenGL

Here's a code on how to start your hello world in openGL:

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void display(){

   glClear(GL_COLOR_BUFFER_BIT);
   glutWireTeapot(0.5);
   glFlush();
}

int main(int argc, char *argv[]){

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(400, 300);    // horizontal, vertical
    glutInitWindowPosition(200, 100);    // horizontal, vertical
    glutCreateWindow("Hello World");    // title of the window

    glutDisplayFunc(display);
    glutMainLoop();

    return 0;
}

You can get learning from this link: Wikibooks or cs.uccs
Share/Bookmark

Elegan Box Style

<div id="zero">
    <div id="satu">
        <p>Holla for the one of the other</p>
    </div>
</div>

<style>
#zero { width: 500px; padding: 20 20 60px; border: 1px solid #ccc;
        -moz-box-shadow: 0 0 4px #ccc; -moz-border-radius: 4px;}
#satu { border: 1px solid #ccc; -moz-box-shadow: 0 0 4px #ccc; 
        -moz-border-radius: 4px;}
#satu p { margin: 1px; padding: 15px; -moz-border-radius: 4px;
        background: #eee; border: 1px solid #eee; font: 12px sans-serif;
        color: #444; }
</style>

Share/Bookmark

Friday, February 25, 2011

Handling Zip File Using Python

To start import the needed module
>>> import zipfile
Then get your file handle
>>> file = zipfile.ZipFile("d:/luna/me.zip", "r")
>>> for name in file.namelist():
            print name


If you want more informations, please do like this one
>>> for info in infolist():
           print info.filename, info.date_time, info.file_size

Share/Bookmark

MD5 In Python

To use md5 service, import it firstly
>>> import md5
Then make new instance
>>> m = md5.new()
Then supply the resources
>>> m.update("From Barack Obama")
>>> m.update("To Barack Obama")
Then process it
>>> m.digest()

You want to more condese? Do like this one
>>> md5.new("From Barack Obama To Barack Obama").digest()

It's the same
>>> m.update("Me")
>>> m.update("You")
with
>>> m.update("MeYou")
Share/Bookmark