Advertisement
Shishu

house in Visual Basic

Feb 22nd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glut.h>
  2.  
  3. void shapes (void) {
  4.  
  5.     /*glColor3f(1.0, 1.0, 1.0); //this will set a color of the square.
  6.     glBegin(GL_LINES); // write shape u want to create
  7.     glVertex3f(-0.5, -0.5, 0.0);
  8.     glVertex3f(-0.5, 0.5, 0.0);
  9.     glVertex3f(0.5, 0.5, 0.0);
  10.     glVertex3f(0.5, -0.5, 0.0);*/
  11.  
  12.     /*glBegin(GL_POINTS);
  13.     glVertex3f(.5,.5,0);
  14.     glVertex3f(-.5,-.5,0);
  15.     glVertex3f(0,.5,0);
  16.     glVertex3f(.5,0,0);
  17.     glVertex3f(0,0,0);*/
  18.  
  19.     /*glBegin(GL_LINE_STRIP);
  20.       glVertex3f(0,0,0);
  21.       glVertex3f(-.5,0,0);  
  22.       glVertex3f(.5,.5,0);
  23.       glVertex3f(-.5,.5,0);
  24.       glVertex3f(.5,0,0);*/
  25.  
  26.     /*glBegin(GL_POLYGON);
  27.     glColor3f(1, 0, 0);
  28.     glVertex3f(-0.6, -0.75, 0);
  29.     glColor3f(0, 1, 0);
  30.     glVertex3f(0.6, -0.75, 0);
  31.     glColor3f(0, 0, 1);
  32.     glVertex3f(0, 0.75, 0);*/
  33.  
  34.     glBegin(GL_TRIANGLES);
  35.     glColor3f(0.0, 1.0, 0.0);
  36.     glVertex3f(-0.5,0.5,0.0);
  37.     glVertex3f(0, 1, 0);
  38.     glVertex3f(0.5,0.5,0);
  39.     glEnd();
  40.  
  41.     glBegin(GL_QUADS);
  42.     glColor3f(1,1, 1);
  43.     glVertex3f(-0.5, -0.5, 0.0);
  44.     glVertex3f(-0.5, 0.5, 0.0);
  45.     glVertex3f(0.5, 0.5, 0.0);
  46.     glVertex3f(0.5, -0.5, 0.0);
  47.     glEnd();
  48.  
  49.  
  50.     glBegin(GL_QUADS);
  51.     glColor3f(1,0, 0);
  52.     glVertex3f(-0.2,-0.5,0.0);
  53.     glVertex3f(-0.2,0.3,0.0);
  54.     glVertex3f(0.2,0.3,0.0);
  55.     glVertex3f(0.2,-0.5,0.0);
  56.     glEnd();
  57.  
  58.  
  59.     glBegin(GL_QUADS);
  60.     glColor3f(1,0, 0);
  61.     glVertex3f(-0.4,-0.1,0.0);
  62.     glVertex3f(-0.4,0.1,0.0);
  63.     glVertex3f(-0.3,0.1,0.0);
  64.     glVertex3f(-0.3,-0.1,0.0);
  65.     glEnd();
  66.  
  67.     glBegin(GL_QUADS);
  68.     glColor3f(1,0, 0);
  69.     glVertex3f(0.4,-0.1,0.0);
  70.     glVertex3f(0.4,0.1,0.0);
  71.     glVertex3f(0.3,0.1,0.0);
  72.     glVertex3f(0.3,-0.1,0.0);
  73.     glEnd();
  74.     /*glBegin(GL_TRIANGLE_FAN);
  75.          glColor3f(1,0,0);
  76.          glVertex2f(0,0.5);
  77.          glVertex2f(-0.4,0);
  78.          glVertex2f(0.4,0);
  79.          glVertex2f(0,-0.5);
  80.     */
  81.  
  82.     glEnd();
  83. }
  84.  
  85. void display (void) {
  86.  
  87.     // clearing the window with black color, 1st 3 parameter are for R,G,B. last one for opacity
  88.     glClearColor (0.0,0.0,0.0,1.0);
  89.     glClear (GL_COLOR_BUFFER_BIT);
  90.     glLoadIdentity();  
  91.          //viewing transformation
  92.     //glulookat() positions the camera towards the object
  93.     //camera position, camera target, upvector
  94.     gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  95.     shapes();
  96.     glFlush();
  97. }
  98.  
  99. void reshape (int w, int h) {
  100.  
  101.     // 1st 2 parameters for lower left corner of the viewport rectangle. the default is 0,0
  102.     // the next coordinates are width and hight of the viewport
  103. //Set the viewport to be the entire window
  104.     glViewport (0, 0, (GLsizei)w, (GLsizei)h);
  105.  
  106.     // setting the camera
  107.     glMatrixMode (GL_PROJECTION);
  108.     glLoadIdentity ();  
  109.  
  110.     //perspective transform
  111.     //gluPerspective (30, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
  112.     gluPerspective (30, 1, 1.0, 100.0);
  113.     glMatrixMode (GL_MODELVIEW); //switch back the the model editing mode.
  114.  
  115. }
  116.  
  117. int main (int argc, char **argv) {
  118.     glutInit (&argc, argv);
  119.     glutInitDisplayMode (GLUT_SINGLE); // single buffering.. (double buffering for animation)
  120.     // full screen is 1000,1000
  121.     // this 0,0 or 1000,1000 are world co ordinates
  122.     glutInitWindowSize (700, 700);
  123.     glutInitWindowPosition (100, 100);
  124.     glutCreateWindow ("A basic OpenGL Window");
  125.     // registering callback functions
  126.     glutDisplayFunc (display);  
  127.     glutReshapeFunc (reshape);
  128.    
  129.     glutMainLoop ();
  130.     return 0;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement