Shishu

Draw Star in Visual Basic

Feb 22nd, 2019
149
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_LOOP);
  20.       glVertex3f(-0.5,0.5,0);
  21.       glVertex3f(0.5,0.5,0);
  22.       glVertex3f(-0.3,-0.2,0);
  23.      glVertex3f(0.0,1,0.0);
  24.       glVertex3f(0.3,-0.2,0);
  25.        
  26.      
  27.  
  28.     /*glBegin(GL_POLYGON);
  29.     glColor3f(1, 0, 0);
  30.     glVertex3f(-0.6, -0.75, 0);
  31.     glColor3f(0, 1, 0);
  32.     glVertex3f(0.6, -0.75, 0);
  33.     glColor3f(0, 0, 1);
  34.     glVertex3f(0, 0.75, 0);*/
  35.  
  36.     /*glBegin(GL_TRIANGLES);
  37.     glColor3f(0.5, 0.5, 0.5);
  38.     glVertex3f(0, 0, 0);
  39.     glVertex3f(1, .2, 1);
  40.     glVertex3f(-.5, .5, 2);*/
  41.  
  42.  
  43.     /*glBegin(GL_QUADS);
  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.     glVertex3f(0.5, -0.5, 0.0);*/
  48.  
  49.     /*glBegin(GL_TRIANGLE_FAN);
  50.          glColor3f(1,0,0);
  51.          glVertex2f(0,0.5);
  52.          glVertex2f(-0.4,0);
  53.          glVertex2f(0.4,0);
  54.          glVertex2f(0,-0.5);
  55.     */
  56.  
  57.     glEnd();
  58. }
  59.  
  60. void display (void) {
  61.  
  62.     // clearing the window with black color, 1st 3 parameter are for R,G,B. last one for opacity
  63.     glClearColor (0.0,0.0,0.0,1.0);
  64.     glClear (GL_COLOR_BUFFER_BIT);
  65.     glLoadIdentity();  
  66.          //viewing transformation
  67.     //glulookat() positions the camera towards the object
  68.     //camera position, camera target, upvector
  69.     gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  70.     shapes();
  71.     glFlush();
  72. }
  73.  
  74. void reshape (int w, int h) {
  75.  
  76.     // 1st 2 parameters for lower left corner of the viewport rectangle. the default is 0,0
  77.     // the next coordinates are width and hight of the viewport
  78. //Set the viewport to be the entire window
  79.     glViewport (0, 0, (GLsizei)w, (GLsizei)h);
  80.  
  81.     // setting the camera
  82.     glMatrixMode (GL_PROJECTION);
  83.     glLoadIdentity ();  
  84.  
  85.     //perspective transform
  86.     //gluPerspective (30, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
  87.     gluPerspective (30, 1, 1.0, 100.0);
  88.     glMatrixMode (GL_MODELVIEW); //switch back the the model editing mode.
  89.  
  90. }
  91.  
  92. int main (int argc, char **argv) {
  93.     glutInit (&argc, argv);
  94.     glutInitDisplayMode (GLUT_SINGLE); // single buffering.. (double buffering for animation)
  95.     // full screen is 1000,1000
  96.     // this 0,0 or 1000,1000 are world co ordinates
  97.     glutInitWindowSize (700, 700);
  98.     glutInitWindowPosition (100, 100);
  99.     glutCreateWindow ("A basic OpenGL Window");
  100.     // registering callback functions
  101.     glutDisplayFunc (display);  
  102.     glutReshapeFunc (reshape);
  103.    
  104.     glutMainLoop ();
  105.     return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment