Posts

GL_POINTS In OpenGl

#include <GL/glut.h> void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPointSize(3.0); glBegin(GL_POINTS); glColor3f(1.0,1.0,0.0); glVertex2f(-0.5, -0.5); glColor3f(1.0,0.0,0.0); glVertex2f(-0.5, 0.5); glColor3f(0.0,0.0,1.0); glVertex2f(0.5, 0.5); glColor3f(0.0,1.0,0.0); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } void init(){} int main(int argc, char** argv) { glutCreateWindow("simple"); glutDisplayFunc(display); init(); glutMainLoop(); }

Line drawing with mouse click event in OpenGl

#include <GL/glut.h>  int ww = 600, wh = 400; int first = 0; int xi, yi, xf, yf; void drawLine(int x1, int y1, int x2, int y2) { glClear(GL_COLOR_BUFFER_BIT); glLineWidth(5.0); glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); glEnd(); glFlush(); } void display() { glClearColor(1.0, 1.0, 0.0, 1.0); glColor3f(1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glFlush(); } void mouse(int btn, int state, int x, int y) { if(btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) { switch(first) { case 0: xi = x; yi = (wh-y); first = 1; break; case 1: xf = x; yf = (wh-y); drawLine(xi,yi,xf,yf); first = 0; break; } } } void myinit() { glViewport(0,0,ww,wh); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,(GLdouble)ww,0.0,(GLdouble)wh); glMatrixMode(GL_MODELVIEW); } int main(int argc, char** argv) { glutInit(&argc,argv); glutInitDisplayMode (GLU...

Restore mongoDb data

Image

Dump MongoDB Data

Image

Delete collection in mongodb

Image

Update document in mongodb

Image
Basic syntax of update() method is as follows db.COLLECTION_NAME.update (SELECTIOIN_CRITERIA, UPDATED_DATA)

Insert And Find In MongoDb

Image
To insert data into MongoDB collection, you need to use MongoDB's insert() or save()method. Basic syntax of insert() command is as follows: db.COLLECTION_NAME.insert(document) To query data from MongoDB collection, you need to use MongoDB's find() method. Basic syntax of find() method is as follows db.COLLECTION_NAME.find() To display the results in a pretty way, you can use pretty() method. SYNTAX: db.mycol.find().pretty() Apart from find() method there is findOne() method, that reruns only one document.