INDEX. 5. WAP to show various OpenGL primitives with the help of 8-19 menu e.g. GL_POINTS, GL_LINES, GL_LINE_STRIP,GL_LINE_LOOP GL_TRIANGLES
|
|
- Garey Henry
- 6 years ago
- Views:
Transcription
1 P a g e 1 S.NO TOPICS INDEX PAGE NO. 1. Write the steps to Setting up the VC++ environment for Open GL. 2. Briefly describe architecture of OpenGL Describe the features supported by GLUT (OpenGL Utility 5 Toolkit). 4. WAP to draw a Red Triangle on a Blue background WAP to show various OpenGL primitives with the help of 8-19 menu e.g. GL_POINTS, GL_LINES, GL_LINE_STRIP,GL_LINE_LOOP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP. (use glutcreatemenu Function). 6. Write a program to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this purpose, use the GL_POINTS primitive. 7. Rewrite the previous program in order to draw a house. The house consists of two figures: a square and a triangle. The first four points given above define the square, while the last three points define the triangle. For this purpose, use the GL_QUADS and GL_TRIANGLES primitives. Afterwards construct two windows and the door of the house. 8. WAP to create multiple viewport on screen WAP to draw line using DDA line drawing algorithm WAP to draw line using Bresenham Line drawing algorithm WAP to draw circle using Mid-point circle drawing algorithm Write a program to draw the Sin and Cos curve using menu Write a program to draw a circle centered at (cx,cy) with a given radius r, whose points are given by the following equations 47-49
2 P a g e 2 x=cx+r.cos(θ) y=cy+r.sin(θ) 14. WAP Program to implement basic transformations ( Translation, scaling, rotation) using Menu driven program WAP to show 3D shapes available in OpenGL WAP to draw the chess board WAP to perform point and line clipping in OpenGL
3 P a g e 3 #1.Write the steps to Setting up the VC++ environment for Open GL. Setting up OpenGL environment for Microsoft Visual C++ Before starting the setting up OpenGL environment, please do the following first: 1. Install Microsoft Visual C (Comes with Ms Visual Studio 6.0) 2. Download the file called opengl95.exe and glutdlls.zip from internet. [Just open browser-> navigatehttp:// -> type upper mentioned file name and search -> you will definitely find the appropriate link to download.] 3. Run opengl95.exe file and it will be extracted and will be generated some files. Copy those files and 4. Extract the file glutdlls.zip and it will also generate some more files. 5. Now, combine all extracted files from two sources (opengl95.exe and glutdlls.zip) and place in one location. Setting up OpenGL environment for Microsoft Visual C++ With any system, you can start with a C\C++ compiler and install appropriate OpenGL header files (.h) and libraries. Three libraries associated with header files are required for the use of OpenGL: OpenGL (The basic API tool) GLU (the OpenGL Utility Library) GLUT (the OpenGL utility Toolkit) Typically, files are associated with each library are: Header Files (.h) Library Files: Static Library Files (.lib) and Dynamic Linked Library (.dll). Adding Header Files: We can place (add) the three header files: Gl.h, Glu.h, Glut.h in a subdirectory of the include directory of your compiler. Thus, in each application program we may write the following include statements: #include<gl/gl.h> #include<gl/glu.h> #include<gl/glut.h>
4 P a g e 4 Adding Library Files: Now, you have to add the appropriate OpenGL library (.lib and.dll) files to your project so that the linker can find them, in order to run your program successfully. Ms. Visual C++ (5.0 or later) is a suitable environment for using OpenGL. If you are working with Ms Visual C++ i.e., win32 console application, there is no need to build a Graphical User Interface (GUI): as the input from the keyboard and output of text take place through the separate console window. When upper mentioned files have been downloaded, copy all extracted files and place those into following: 1. C:\Program files\microsoft Visual Studio\VC98\lib\ 2. C:\Windows\System32\ Now, Restart your pc. NOW CREATING A PROJECT IN VC AND EXECUTE AN OPENGL APPLICATION: Steps: Open Ms. Visual C Choose: File -> New In the project tab choose: Win32 Console Application Enter a unique project name eg. Myfirstopengl Click on ok Now Choose option An empty project Click finish then Ok. Now, go to Project menu -> Settings Go to Link tab menu. In the Object/ Library modules enter the names of the three.lib files as Glu32.lib glut32.lib opengl32.lib Press Ok Now, go to File -> New. Choose C++ Source File Name it. Eg. Firstgl Press Ok
5 P a g e 5 Write your code Press F7 to built Press Ctrl+f5 to run Another Simple method for Setting up the VC++ environment for Open GL. 1. Check whether VC++ (Microsoft Visual Studio 6.0) is setup on your machine/system. 2. Open the glut folder from the server. 3. Copy glut.dll, glu32.dll and glut32.dll into C:\WINDOWS\system Copy glut32.lib,glut.lib into C:\Program Files\Microsoft Visual Studio\VC98\ into the lib folder. 5. Copy glut.h into C:\Program Files\Microsoft Visual Studio\VC98\ into the INCLUDE folder. #2.Briefly describe architecture of OpenGL. It is a window system independent, operating system independent graphics rendering API which is capable of rendering high-quality color images composed of geometric and image primitives. OpenGL is a library for doing computer graphics. By using it, you can create interactive applications which render high-quality color images composed of 3D geometric objects and images. As OpenGL is window and operating system independent. As such, the part of your application which does rendering is platform independent. However, in order for OpenGL to be able to render, it needs a window to draw into. Generally, this is controlled by the windowing system on whatever platform you re working on. Summarizing the above discussion, we can say OpenGL is a software API to graphics hardware. Designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms.
6 P a g e 6 Procedural interface. No windowing commands. No high-level commands.
7 P a g e 7 #3.Describe the features supported by GLUT (OpenGL Utility Toolkit). GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windowing application programming interface (API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides a portable API so you can write a single OpenGL program that works across all PC and workstation OS platforms. GLUT is designed for constructing small to medium SizedOpenGL programs. While GLUT is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated user interfaces are better off using native window system toolkits. GLUT is simple, easy, and small. The GLUT library has both C, C++ (same as C), FORTRAN, and Ada programming bindings. The GLUT source code distribution is portable to nearly all OpenGL implementations and platforms. The current version is 3.7. Additional releases of the library are not anticipated. GLUT is not open source. Mark Kilgard maintains the copyright. There are a number of newer and open source alternatives. The current version of the GLUT API is 3. The current source code distribution is GLUT 3.7. The toolkit supports: Multiple windows for OpenGL rendering Callback driven event processing Sophisticated input devices An 'idle' routine and timers A simple, cascading pop-up menu facility Utility routines to generate various solid and wire frame objects Support for bitmap and stroke fonts Miscellaneous window management functions.
8 P a g e 8 #4.WAP to draw a Red Triangle on a Blue background. #include <windows.h> // for MS Windows #include <GL/glut.h> // GLUT, include glu.h and gl.h /* Handler for window-repaint event. Call back when the window first appears and whenever the window needs to be re-painted. */ void display() glclearcolor(0.0f, 0.0f, 1.0f, 1.0f); // Set background color to blue glclear(gl_color_buffer_bit); (background) // Clear the color buffer // Draw a Red 1x1 triangle centered at origin glbegin(gl_triangles); glcolor3f(1.0f,0.0f,0.0f); glvertex3f( 1.0f, 0.0f, 0.0f); glcolor3f(1.0f,0.0f,0.0f); glvertex3f(0.0f,1.0f, 0.0f); glcolor3f(1.0f,0.0f,0.0f); glvertex3f( 0.0f,0.0f, 1.0f); glend(); glflush(); // Render now
9 P a g e 9 /* Main function: GLUT runs as a console application starting at main() */ int main(int argc, char** argv) glutinit(&argc, argv); // Initialize GLUT glutcreatewindow("opengl Setup Test"); // Create a window with the given title glutinitwindowsize(320, 320); // Set the window's initial width & height glutinitwindowposition(50, 50); // Position the window's initial top-leftcorner glutdisplayfunc(display); // Register display callback handler for window repaint glutmainloop(); // Enter the event-processing loop return 0; OUTPUT:
10 P a g e 10 #5.WAP to show various OpenGL primitives with the help of menu e.g.gl_points,gl_lines,gl_line_strip,gl_line_loo P,GL_TRIANGLES,GL_TRIANGLE_STRIP,GL_TRIANGLE_ FAN, GL_QUADS, GL_QUAD_STRIP. (use glutcreatemenu Function). #include <GL/glut.h> # include <iostream.h> # include<stdlib.h> void display() /* clear window */ glclear(gl_color_buffer_bit); glflush(); void OptionsMenu (GLint selectedopt) switch (selectedopt) case 1: /* draw unit square polygon */ glclear(gl_color_buffer_bit); glbegin(gl_polygon); glvertex2f(-0.5, -0.5);
11 P a g e 11 glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.5, -0.5); glend(); /* flush GL buffers */ glflush(); break; case 2: glclear(gl_color_buffer_bit); glbegin(gl_lines); glvertex2f(0.75,0.25); glvertex2f(0.75,0.75); glend(); /* flush GL buffers */ glflush(); break; case 3: glclear(gl_color_buffer_bit); glpointsize(6); glbegin(gl_points); glvertex2f(0.25,0.25); glvertex2f(0.75,0.25); glvertex2f(0.75,0.75);
12 P a g e 12 glvertex2f(0.25,0.50); glvertex2f(0.50,0.75); glend(); /* flush GL buffers */ glflush(); break; case 4: glclear(gl_color_buffer_bit); glbegin(gl_line_strip); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glend(); /* flush GL buffers */ glflush(); break; case 5: glclear(gl_color_buffer_bit); glbegin(gl_line_loop); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.25,0.25); glvertex2f(0.75,0.25); glvertex2f(0.75,0.75); glvertex2f(0.25,0.50);
13 P a g e 13 glvertex2f(0.50,0.75); glend(); /* flush GL buffers */ glflush(); break; case 6: glclear(gl_color_buffer_bit); glbegin(gl_triangles); glvertex2f(0.25,0.25); glvertex2f(0.75,0.25); glvertex2f(0.75,0.75); glvertex2f(0.25,0.50); glvertex2f(0.50,0.75); glend(); /* flush GL buffers */ glflush(); break; case 7: glclear(gl_color_buffer_bit); glbegin(gl_triangle_strip); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glcolor3f(0.50, 0.25,0.70);
14 P a g e 14 glvertex2f(0.25,0.25); glvertex2f(0.75,0.25); glvertex2f(0.75,0.75); glcolor3f(0.0, 0.25,0.0); glvertex2f(0.25,0.50); glvertex2f(0.50,0.75); glend(); /* flush GL buffers */ glflush(); break; case 8: glclear(gl_color_buffer_bit); glbegin(gl_triangle_fan); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.25,0.25); glvertex2f(0.75,0.25); glend(); /* flush GL buffers */ glflush(); break; case 9:
15 P a g e 15 glclear(gl_color_buffer_bit); glbegin(gl_quads); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.5, -0.5); glend(); /* flush GL buffers */ glflush(); break; case 10: glclear(gl_color_buffer_bit); glbegin(gl_quad_strip); glvertex2f(-0.5, -0.5); glvertex2f(-0.5, 0.5); glvertex2f(0.5, 0.5); glvertex2f(0.5, -0.5); glend(); /* flush GL buffers */ glflush(); break; default: break; //glutpostredisplay();
16 P a g e 16 void init() /* set clear color to black */ glclearcolor(1.0, 0.0, 1.0, 1.50); /* set fill color to white */ glcolor3f(0.25, 0.25,0.50); void main() /* Initialize mode and open a window in upper left corner of /* screen */ /* Window title is name of program (arg[0]) */ //glutinit(&argc,argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500, 500); glutinitwindowposition(20, 20); glutcreatewindow("different primitives"); init(); glutdisplayfunc(display); glutcreatemenu (OptionsMenu); glutaddmenuentry("polygon ",1);
17 P a g e 17 glutaddmenuentry("line ",2); glutaddmenuentry("point ",3); glutaddmenuentry("linestrip ",4); glutaddmenuentry("lineloop ",5); glutaddmenuentry("triangle ",6); glutaddmenuentry("trianglestrip",7); glutaddmenuentry("trianglefan",8); glutaddmenuentry("quard ",9); glutaddmenuentry("quardstrip",10); glutattachmenu (GLUT_RIGHT_BUTTON); glutmainloop();
18 P a g e 18 OUTPUT:
19 P a g e 19
20 P a g e 20
21 P a g e 21
22 P a g e 22 #6.Write a program to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this purpose, use the GL_POINTS primitive. #include <GL/glut.h> #include <stdlib.h> void draw() glclear ( GL_COLOR_BUFFER_BIT ); glcolor3f(1,0,0); glbegin(gl_points); glvertex2f(0.0f,0.0f); glvertex2f(20.0,0.0); glvertex2f(20.0,20.0); glvertex2f(0.0,20.0); glvertex2f(10.0,25.50); glend(); glflush(); void initialize () glmatrixmode(gl_projection); glloadidentity(); glclearcolor(0.0, 0.0, 1.0, 0.0);
23 P a g e 23 glpointsize(5); gluortho2d(0,500,0,500); int main() glutinitdisplaymode( GLUT_RGB GLUT_SINGLE); glutinitwindowsize(500,500); glutinitwindowposition(0, 0); glutcreatewindow("program to draw Points"); initialize(); glutdisplayfunc(draw); glutmainloop(); return 0;
24 P a g e 24 OUTPUT:
25 P a g e 25 #7.Rewrite the previous program in order to draw a house. The house consists of two figures: a square and a triangle. The first four points given above define the square, while the last three points define the triangle. For this purpose, use the GL_QUADS and GL_TRIANGLES primitives. Afterwards construct two windows and the door of the house. #include <GL/glut.h> # include <iostream.h> # include<stdlib.h> void display() glclear(gl_color_buffer_bit); glbegin(gl_quads); glvertex2f(-0.5, -0.5); glvertex2f(-0.45, -0.5); glvertex2f(-0.45, 0.5); glvertex2f(-0.5, 0.5); glend(); glbegin(gl_quads); glvertex2f(-0.5, -0.5); glvertex2f(0.5,-0.5); glvertex2f(0.5, -0.45); glvertex2f(-0.5, -0.45); glbegin(gl_quads); glvertex2f(0.45,-0.5); glvertex2f(0.45,0.5); glvertex2f(0.5,0.5); glvertex2f(0.5,-0.5); glend(); glbegin(gl_quads); glvertex2f(0,0.9); glvertex2f(0.05,0.85); glvertex2f(-0.45,0.45); glvertex2f(-0.5,0.5);
26 P a g e 26 glend(); glbegin(gl_quads); glvertex2f(0,0.9); glvertex2f(-0.05,0.85); glvertex2f(0.45,0.45); glvertex2f(0.5,0.5); glend(); glbegin(gl_quads); glvertex2f(-0.3,0.8); glvertex2f(-0.35,0.8); glvertex2f(-0.35,0.6); glvertex2f(-0.3,0.65); glend(); glbegin(gl_quads); glvertex2f(0,0.2); glvertex2f(0.3,0.2); glvertex2f(0.3,0.5); glvertex2f(0,0.5); glend(); glbegin(gl_quads); glvertex2f(0,0); glvertex2f(-0.3,0); glvertex2f(-0.3,-0.5); glvertex2f(0,-0.5); glend(); glflush(); void init() glclearcolor(0.0, 0.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); void main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500, 500); glutinitwindowposition(0, 0);
27 P a g e 27 glutcreatewindow( "HUT.cpp" ); glutdisplayfunc(display); init(); glutmainloop(); OUTPUT:
28 P a g e 28 #8.WAP to create multiple viewport on screen. #include <GL/glut.h> //Header File ForTheOpenGLLibrary //#include <GL/glu.h> # include <iostream.h> //#include <gl/ glut.h> #include <stdlib.h> void draw() // Make background colour yellow glclearcolor(100,100,100,0); glclear(gl_color_buffer_bit); //Sets upfirstviewportspanningtheleft-bottomquarterof the interface window glviewport(0,0,250,250); // Sets up the PROJECTION matrix glmatrixmode (GL_PROJECTION); glloadidentity (); //gluortho2d(0.0,50.0,-10.0,70.0); //also sets up worldwindow // Draw BLUE rectangle glcolor3f(0,0,1); glrectf(0.0,0.0,10.0,30.0); //Sets up SECOND viewport spanning the right-top quarter of the interface window glviewport(250,0,250,250);
29 P a g e 29 //Sets up the PROJECTION matrix glmatrixmode(gl_projection); glloadidentity(); //gluortho2d(0.0,60.0,-10.0,40.0); //also sets up world window // Draw RED rectangle glcolor3f(1,0,0); glrectf(0.0,0.0,10.0,30.0); //displayrectangles glviewport(0,250,250,250); glmatrixmode(gl_projection); glloadidentity(); //gluortho2d(0.0,60.0,-10.0,40.0); //also sets up world window // Draw RED rectangle glcolor3f(0,1,0); glrectf(0.0,0.0,10.0,30.0); glutswapbuffers(); //Keyboard method to allow ESC key to quit void keyboard( unsigned char key,int x, int y) if (key== 27)
30 P a g e 30 exit(0); int main( int argc, char ** argv ) glutinit(&argc, argv); //DoubleBuffered RGB display glutinitdisplaymode (GLUT_RGB GLUT_DOUBLE); //Set window size glutinitwindowsize( 500, 500); glutcreatewindow("three viewports spanning the left-bottom and right-top quarters"); //Declare the display and keyboard functions glutdisplayfunc(draw); /*glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0,0.0,-50); glrotatef(90.0,1.0,0.0,0.0); glutdisplayfunc(draw);*/ glutkeyboardfunc(keyboard); //Start the Main Loop glutmainloop(); return 0 ;
31 P a g e 31 OUTPUT:
32 P a g e 32 #9. Program on Digital Differential Analyzer Algorithm #include<stdio.h> #include<math.h> #include<gl/glut.h> void init(void) glclearcolor(1.0,1.0,1.0,0.0); glmatrixmode(gl_projection); gluortho2d(0.0,300.0,0.0,300.0); void setpixel(int xcoordinate, int ycoordinate) // glenable(gl_line_smooth); glbegin(gl_points); glvertex2i(xcoordinate,ycoordinate); glend(); glflush(); void drawline(int x1, int y1, int x2, int y2) int dx=x2-x1; int dy=y2-y1; int steps=0;
33 P a g e 33 if (abs(dy) > abs(dx)) steps= dy; else steps= dx; float xx= dx/(float)steps; float yy= dy/(float)steps; float x= x1; float y= y1; setpixel (int(x+0.5), int(y+0.5)); for (int j=0;j<steps;j++) x=x+xx; y=y+yy; setpixel (int(x+0.5), int(y+0.5)); void display(void) glclear(gl_color_buffer_bit);
34 P a g e 34 glcolor3f(1.0,0.0,0.0); glpointsize(5.0); int x1 = 50; int y1 = 20; int x2 = 80; int y2 = 200; drawline(x1,y1,x2,y2); void main() glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("program on Digital Differential Analyzer Algorithm"); init(); glutdisplayfunc(display); glutmainloop(); OUTPUT:
35 P a g e 35
36 P a g e 36 #10. Program on Bresenham Line drawing Algorithm #include<stdio.h> #include<math.h> #include<gl/glut.h> void init(void) glclearcolor(1.0,1.0,1.0,0.0); glmatrixmode(gl_projection); gluortho2d(0.0,300.0,0.0,300.0); void setpixel(int xcoordinate, int ycoordinate) glenable(gl_line_smooth); glbegin(gl_points); glvertex2i(xcoordinate,ycoordinate); glend(); glflush(); void drawlinebres(int x1, int y1, int x2, int y2) int dx=x2-x1; int dy=y2-y1; int p=2*dy-dx;
37 P a g e 37 int x,y; x = x1; y=y1; setpixel(x,y); for(;x<=x2;) if (p<0) p+=2*dy; else p+=2*dy-2*dx; y++; x++; setpixel(x,y); void display(void)
38 P a g e 38 glclear(gl_color_buffer_bit); glcolor3f(1.0,0.0,0.0); glpointsize(4.0); int x1 = 100; int y1 = 70; int x2 = 160; int y2 = 100; drawlinebres(x1,y1,x2,y2); void main() glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("program on Bresenham Line drawing Algorithm"); init(); glutdisplayfunc(display); glutmainloop(); OUTPUT:
39 P a g e 39
40 P a g e 40 #11.WAP to draw circle using Mid-point circle drawing algorithm. #include<stdio.h> #include<math.h> #include<gl/glut.h> void init(void) glclearcolor(1.0,1.0,1.0,0.0); glmatrixmode(gl_projection); gluortho2d(0.0,300.0,0.0,300.0); void setpixel(int xcoordinate, int ycoordinate) glenable(gl_line_smooth); glbegin(gl_points); glvertex2i(xcoordinate,ycoordinate); glend(); glflush(); void symmetry_points(int xc,int yc,int x,int y) setpixel (xc+x, yc+y); glcolor3f(0.5,0.0,0.0); setpixel (xc-x, yc+y);
41 P a g e 41 glcolor3f(1.0,0.8,0.3); setpixel (xc-x, yc-y); glcolor3f(0.3,0.1,0.2); setpixel (xc+x, yc-y); glcolor3f(0.0,0.0,0.0); setpixel (xc+y, yc+x); glcolor3f(0.4,0.5,0.6); setpixel (xc-y, yc+x); glcolor3f(0.4,0.3,0.1); setpixel (xc-y, yc-x); glcolor3f(1.0,0.0,0.0); setpixel (xc+y, yc-x); void drawcirbres(int xc, int yc, int r) int p=1-r; int x=0; int y=r; symmetry_points(xc,yc,x,y); while (x<y) if (p<=0) x++;
42 P a g e 42 p=p+2*x +1; else x++; y--; p=p + 2*x - 2*y +1; symmetry_points(xc,yc,x,y); void display(void) glclear(gl_color_buffer_bit); glcolor3f(1.0,0.0,0.0); glpointsize(4.0); int x1 = 220; int y1 = 180; int r = 70; drawcirbres(x1,y1,r); void main() glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500,500);
43 P a g e 43 glutinitwindowposition(0,0); glutcreatewindow("program on Bresenham Line drawing Algorithm"); init(); glutdisplayfunc(display); glutmainloop(); OUTPUT:
44 P a g e 44 #12.Write a program to draw the Sin and Cos curve using menu. #include <GL/glut.h> # include <iostream.h> # include<stdlib.h> #include<math.h> void display() /* clear window */ glclear(gl_color_buffer_bit); glflush(); void OptionsMenu (GLint selectedopt) int i; switch (selectedopt) case 1: //cos curve glcolor3f(1.0,0.0,0.0); glbegin(gl_points); for(i=0;i<361;i=i+5) float x = (float)i; float y = 60.0 * cos(i *(6.284/360.0));
45 P a g e 45 glvertex2f(x,y); glend(); /* flush GL buffers */ glflush(); break; case 2: // sine curve glcolor3f(1.0,0.0,0.0); glbegin(gl_points); for(i=0;i<361;i=i+5) float x = (float)i; float y = * sin(i *(6.284/360.0)); glvertex2f(x,y); glend(); glflush();/* flush GL buffers */ break; default: break; void init() glclearcolor(0.0, 0.0, 0.0, 1.0); // clear background with black
46 P a g e 46 glclear(gl_color_buffer_bit); glmatrixmode( GL_PROJECTION ); glloadidentity(); double w = glutget( GLUT_WINDOW_WIDTH ); double h = glutget( GLUT_WINDOW_HEIGHT ); double ar = w / h; glortho( -360 * ar, 360 * ar, -120, 120, -1, 1 ); glmatrixmode( GL_MODELVIEW ); glloadidentity(); glpointsize(5); void main() glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500, 500); glutinitwindowposition(20, 20); glutcreatewindow("menu for sine cos"); init(); glutdisplayfunc(display); glutcreatemenu (OptionsMenu); glutaddmenuentry("cos curve ",1); glutaddmenuentry("sine curve ",2); glutattachmenu (GLUT_RIGHT_BUTTON); glutmainloop();
47 P a g e 47 OUTPUT:
48 P a g e 48
49 P a g e 49 #13.Write a program to draw a circle centered at (cx,cy) with a given radius r, whose points are given by the following equations x=cx+r.cos(θ) y=cy+r.sin(θ) #include <GL/glut.h> #include <stdlib.h> #include <math.h> void draw() int xc=250, int yc=200, int r=50; glclear ( GL_COLOR_BUFFER_BIT ); glcolor3f(1,0,0); glbegin(gl_points); for(int i= 0; i < 360; i++) float theta = 2.0 * * float(i) / float(360); float x = r * cos (theta); float y = r * sin (theta); glvertex2f(float(xc) + x, y + float(yc)); glend(); glflush();
50 P a g e 50 void initialize () glmatrixmode(gl_projection); glloadidentity(); glclearcolor(1.0, 1.0, 1.0, 0.0); glpointsize(5); gluortho2d(0,500,0,500); //MAIN FUNCTION int main() glutinitdisplaymode( GLUT_RGB GLUT_SINGLE); glutinitwindowsize(500,500); glutinitwindowposition(0, 0); glutcreatewindow("program to draw Points"); initialize(); glutdisplayfunc(draw); glutmainloop(); return 0;
51 P a g e 51 OUTPUT:
52 P a g e 52 #14.WAP Program to implement basic transformations ( Translation, scaling, rotation) using Menu driven program #include <GL/glut.h> # include <iostream.h> # include<stdlib.h> #include<math.h> void display() glclear(gl_color_buffer_bit); glflush(); void OptionsMenu (GLint selectedopt) int i; switch (selectedopt) case 1: //translation glbegin(gl_quads); // Each set of 4 vertices form a quad glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex2f(-0.3f, -0.3f); order glvertex2f( 0.3f, -0.3f); // Define vertices in counter-clockwise (CCW) // so that the normal (front-face) is facing you glvertex2f( 0.3f, 0.3f); glvertex2f(-0.3f, 0.3f); glend();
53 P a g e 53 gltranslatef(0.1f, -0.7f, 0.0f); // Translate right and down glbegin(gl_quads); // Each set of 4 vertices form a quad glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex2f(-0.3f, -0.3f); glvertex2f( 0.3f, -0.3f); glvertex2f( 0.3f, 0.3f); glvertex2f(-0.3f, 0.3f); glend(); glflush(); break; case 2: //rotation glbegin(gl_triangles); // Each set of 3 vertices form a triangle glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex2f(-0.3f, -0.2f); glvertex2f( 0.3f, -0.2f); glvertex2f( 0.0f, 0.3f); glend(); gltranslatef(0.2f, -0.3f, 0.0f); // Translate right and down glrotatef(180.0f, 0.0f, 0.0f, 1.0f); // Rotate 180 degree glbegin(gl_triangles); triangle // Each set of 3 vertices form a glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex2f(-0.3f, -0.2f); glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex2f( 0.3f, -0.2f);
54 P a g e 54 glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex2f( 0.0f, 0.3f); glend(); glflush(); break; case 3: //scaling glbegin(gl_triangles); // Each set of 3 vertices form a triangle glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex2f(-0.3f, -0.2f); glvertex2f( 0.3f, -0.2f); glvertex2f( 0.0f, 0.3f); glend(); gltranslatef(0.2f, -0.3f, 0.0f); // Translate right and down glscaled(0.5f,0.5f,1.0f); // Rotate 180 degree glbegin(gl_triangles); triangle // Each set of 3 vertices form a glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex2f(-0.3f, -0.2f); glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex2f( 0.3f, -0.2f); glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex2f( 0.0f, 0.3f); glend(); glflush(); break;
55 P a g e 55 default: break; void init() glclearcolor(0.0, 0.0, 0.0, 1.0); // clear background with black glclear(gl_color_buffer_bit); glmatrixmode( GL_PROJECTION ); glloadidentity(); glmatrixmode( GL_MODELVIEW ); glloadidentity(); glpointsize(5); void main() glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(700, 700); // Set the window's initial width & height - non-square glutinitwindowposition(50, 50); // Position the window's initial top-left corner glutcreatewindow("menu for transformation"); init(); glutdisplayfunc(display); glutcreatemenu (OptionsMenu); glutaddmenuentry("translation ",1);
56 P a g e 56 glutaddmenuentry("rotation ",2); glutaddmenuentry("scaling ",3); glutattachmenu (GLUT_RIGHT_BUTTON); glutmainloop(); OUTPUT:
57 P a g e 57
58 P a g e 58
59 P a g e 59 #15.WAP to show 3D shapes available in OpenGL #include <stdio.h> #include <windows.h> #include <GL/gl.h> #include <GL/glut.h> // Standard header for MS Windows applications // Open Graphics Library (OpenGL) header // The GL Utility Toolkit (GLUT) Header #define KEY_ESCAPE 27 typedef struct int width; int height; char* title; float field_of_view_angle; float z_near; float z_far; glutwindow; glutwindow win; float Rotation; void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // Clear Screen and Depth Buffer glloadidentity();
60 P a g e 60 glulookat( 10,3,0, 0,0,0, 0,1,0); // Define a viewing transformation glpushmatrix(); // Push the current matrix stack glcolor3f(1,0,0); gltranslatef(0,0,-2); // Multiply the current matrix by a translation matrix glrotatef(rotation,0,1,0); // Multiply the current matrix by a rotation matrix glrotatef(90,0,1,0); // Multiply the current matrix by a rotation matrix glutwireteapot(1); // render a wire frame teapot respectively. glpopmatrix(); // Pop the current matrix stack glpushmatrix(); // Push the current matrix stack glcolor3f(0,1,0); gltranslatef(0,0,2); // Multiply the current matrix by a translation matrix glrotatef(rotation,0,1,0); glrotatef(90,0,1,0); glutsolidteapot(1); glpopmatrix(); // Pop the current matrix stack
61 P a g e 61 glpushmatrix(); // Push the current matrix stack glcolor3f(0,0,1); glrotatef(-rotation,0,1,0); glrotatef(90,0,1,0); // Multiply the current matrix by a rotation matrix gltranslatef(0,2,0); // Multiply the current matrix by a translation matrix glutsolidcube (1.3); glpopmatrix(); // Pop the current matrix stack glpushmatrix(); // Push the current matrix stack glcolor3f(1,1,1); gltranslatef(0,-2.5,0); // Multiply the current matrix by a translation matrix glrotatef(-rotation,1,1,0); // Multiply the current matrix by a rotation matrix glrotatef(90,0,1,0); // Multiply the current matrix by a rotation matrix glutsolidsphere (1, 32, 32 ); glpopmatrix(); // Pop the current matrix stack Rotation+=15;
62 P a g e 62 glutswapbuffers(); void initialize () GLfloat aspect = (GLfloat) win.width / win.height; GLfloat amb_light[] = 0.1, 0.1, 0.1, 1.0 ; GLfloat diffuse[] = 0.6, 0.6, 0.6, 1 ; GLfloat specular[] = 0.7, 0.7, 0.3, 1 ; glmatrixmode(gl_projection); // select projection matrix glviewport(0, 0, win.width, win.height); // set the viewport glmatrixmode(gl_projection); // set matrix mode glloadidentity(); // reset projection matrix gluperspective(win.field_of_view_angle, aspect, win.z_near, win.z_far); // set up a perspective projection matrix glmatrixmode(gl_modelview); current matrix // specify which matrix is the glshademodel( GL_SMOOTH ); glcleardepth( 1.0f ); // specify the clear value for the depth buffer
63 P a g e 63 glenable( GL_DEPTH_TEST ); gldepthfunc( GL_LEQUAL ); glhint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); // specify implementation-specific hints gllightmodelfv( GL_LIGHT_MODEL_AMBIENT, amb_light ); gllightfv( GL_LIGHT0, GL_DIFFUSE, diffuse ); gllightfv( GL_LIGHT0, GL_SPECULAR, specular ); glenable( GL_LIGHT0 ); glenable( GL_COLOR_MATERIAL ); glshademodel( GL_SMOOTH ); gllightmodeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE ); gldepthfunc( GL_LEQUAL ); glenable( GL_DEPTH_TEST ); glenable(gl_lighting); glenable(gl_light0); glclearcolor(0.0, 0.0, 1.0, 1.0); void keyboard ( unsigned char key, int mousepositionx, int mousepositiony )
64 P a g e 64 switch ( key ) case KEY_ESCAPE: exit ( 0 ); break; default: break; int main(int argc, char **argv) // set window values win.width = 640; win.height = 480; win.title = "OpenGL/GLUT Window."; win.field_of_view_angle = 45; win.z_near = 1.0f; win.z_far = 500.0f; // initialize and run program glutinit(&argc, argv); // GLUT initialization glutinitdisplaymode(glut_rgb GLUT_DOUBLE GLUT_DEPTH ); // Display Mode
65 P a g e 65 glutinitwindowsize(win.width,win.height); // set window size glutcreatewindow(win.title); // create Window glutdisplayfunc(display); // register Display Function glutidlefunc( display ); // register Idle Function glutkeyboardfunc( keyboard ); // register Keyboard Handler initialize(); glutmainloop(); // run GLUT mainloop return 0;
66 P a g e 66 OUTPUT: OTHER SHAPES: #include <windows.h> // for MS Windows #include <GL/glut.h> // GLUT, include glu.h and gl.h /* Global variables */ char title[] = "3D Shapes with animation"; GLfloat anglepyramid = 0.0f; // Rotational angle for pyramid [NEW]
67 P a g e 67 GLfloat anglecube = 0.0f; // Rotational angle for cube [NEW] int refreshmills = 15; // refresh interval in milliseconds [NEW] /* Initialize OpenGL Graphics */ void initgl() glclearcolor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque glcleardepth(1.0f); // Set background depth to farthest glenable(gl_depth_test); // Enable depth testing for z-culling gldepthfunc(gl_lequal); // Set the type of depth-test glshademodel(gl_smooth); // Enable smooth shading glhint(gl_perspective_correction_hint, GL_NICEST); // Nice perspective corrections /* Handler for window-repaint event. Called back when the window first appears and whenever the window needs to be re-painted. */ void display() glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers glmatrixmode(gl_modelview); // To operate on model-view matrix // Render a color-cube consisting of 6 quads with different colors glloadidentity(); // Reset the model-view matrix gltranslatef(1.5f, 0.0f, -7.0f); // Move right and into the screen
68 P a g e 68 glrotatef(anglecube, 1.0f, 1.0f, 1.0f); // Rotate about (1,1,1)-axis [NEW] glbegin(gl_quads); // Begin drawing the color cube with 6 quads // Top face (y = 1.0f) // Define vertices in counter-clockwise (CCW) order with normal pointing out glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex3f( 1.0f, 1.0f, -1.0f); glvertex3f(-1.0f, 1.0f, -1.0f); glvertex3f(-1.0f, 1.0f, 1.0f); glvertex3f( 1.0f, 1.0f, 1.0f); // Bottom face (y = -1.0f) glcolor3f(1.0f, 0.5f, 0.0f); // Orange glvertex3f( 1.0f, -1.0f, 1.0f); glvertex3f(-1.0f, -1.0f, 1.0f); glvertex3f(-1.0f, -1.0f, -1.0f); glvertex3f( 1.0f, -1.0f, -1.0f); // Front face (z = 1.0f) glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex3f( 1.0f, 1.0f, 1.0f); glvertex3f(-1.0f, 1.0f, 1.0f); glvertex3f(-1.0f, -1.0f, 1.0f); glvertex3f( 1.0f, -1.0f, 1.0f);
69 P a g e 69 // Back face (z = -1.0f) glcolor3f(1.0f, 1.0f, 0.0f); // Yellow glvertex3f( 1.0f, -1.0f, -1.0f); glvertex3f(-1.0f, -1.0f, -1.0f); glvertex3f(-1.0f, 1.0f, -1.0f); glvertex3f( 1.0f, 1.0f, -1.0f); // Left face (x = -1.0f) glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex3f(-1.0f, 1.0f, 1.0f); glvertex3f(-1.0f, 1.0f, -1.0f); glvertex3f(-1.0f, -1.0f, -1.0f); glvertex3f(-1.0f, -1.0f, 1.0f); // Right face (x = 1.0f) glcolor3f(1.0f, 0.0f, 1.0f); // Magenta glvertex3f(1.0f, 1.0f, -1.0f); glvertex3f(1.0f, 1.0f, 1.0f); glvertex3f(1.0f, -1.0f, 1.0f); glvertex3f(1.0f, -1.0f, -1.0f); glend(); // End of drawing color-cube // Render a pyramid consists of 4 triangles
70 P a g e 70 glloadidentity(); // Reset the model-view matrix gltranslatef(-1.5f, 0.0f, -6.0f); // Move left and into the screen glrotatef(anglepyramid, 1.0f, 1.0f, 0.0f); // Rotate about the (1,1,0)-axis [NEW] glbegin(gl_triangles); // Begin drawing the pyramid with 4 triangles // Front glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex3f( 0.0f, 1.0f, 0.0f); glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex3f(-1.0f, -1.0f, 1.0f); glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex3f(1.0f, -1.0f, 1.0f); // Right glcolor3f(1.0f, 0.0f, 0.0f); // Red glvertex3f(0.0f, 1.0f, 0.0f); glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex3f(1.0f, -1.0f, 1.0f); glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex3f(1.0f, -1.0f, -1.0f); // Back glcolor3f(1.0f, 0.0f, 0.0f); // Red
71 P a g e 71 glvertex3f(0.0f, 1.0f, 0.0f); glcolor3f(0.0f, 1.0f, 0.0f); // Green glvertex3f(1.0f, -1.0f, -1.0f); glcolor3f(0.0f, 0.0f, 1.0f); // Blue glvertex3f(-1.0f, -1.0f, -1.0f); // Left glcolor3f(1.0f,0.0f,0.0f); // Red glvertex3f( 0.0f, 1.0f, 0.0f); glcolor3f(0.0f,0.0f,1.0f); // Blue glvertex3f(-1.0f,-1.0f,-1.0f); glcolor3f(0.0f,1.0f,0.0f); // Green glvertex3f(-1.0f,-1.0f, 1.0f); glend(); // Done drawing the pyramid glutswapbuffers(); // Swap the front and back frame buffers (double buffering) // Update the rotational angle after each refresh [NEW] anglepyramid += 0.2f; anglecube -= 0.15f; /* Called back when timer expired [NEW] */ void timer(int value)
72 P a g e 72 glutpostredisplay(); // Post re-paint request to activate display() gluttimerfunc(refreshmills, timer, 0); // next timer call milliseconds later /* Handler for window re-size event. Called back when the window first appears and whenever the window is re-sized with its new width and height */ void reshape(glsizei width, GLsizei height) // GLsizei for non-negative integer // Compute aspect ratio of the new window if (height == 0) height = 1; // To prevent divide by 0 GLfloat aspect = (GLfloat)width / (GLfloat)height; // Set the viewport to cover the new window glviewport(0, 0, width, height); // Set the aspect ratio of the clipping volume to match the viewport glmatrixmode(gl_projection); // To operate on the Projection matrix glloadidentity(); // Reset // Enable perspective projection with fovy, aspect, znear and zfar gluperspective(45.0f, aspect, 0.1f, 100.0f); /* Main function: GLUT runs as a console application starting at main() */ int main(int argc, char** argv)
73 P a g e 73 glutinit(&argc, argv); // Initialize GLUT glutinitdisplaymode(glut_double); // Enable double buffered mode glutinitwindowsize(640, 480); // Set the window's initial width & height glutinitwindowposition(50, 50); // Position the window's initial top-left corner glutcreatewindow(title); glutdisplayfunc(display); event glutreshapefunc(reshape); event // Create window with the given title // Register callback handler for window re-paint // Register callback handler for window re-size initgl(); // Our own OpenGL initialization gluttimerfunc(0, timer, 0); // First timer call immediately [NEW] glutmainloop(); // Enter the infinite event-processing loop return 0; OUTPUT:
74 P a g e 74
75 P a g e 75 #16.WAP to draw the chess board #include <gl/glut.h> #include <stdio.h> void init(void) glclearcolor(0.0,1.0,1.0,0.0); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0, 400,0,400); void draw_blackarea() int i,j,r,g,b; glcolor3f(1,0,0); for (j=1;j<=8;j++) for (i=1;i<=8;i++) if((j%2)==1) r=i%2; g=r; b=r;
76 P a g e 76 glcolor3f(r,g,b); glrecti((i-1)*50,(j-1)*50,(i)*50,j*50); else r=(i+1)%2; g=r; b=r; glcolor3f(r,g,b); glrecti((i-1)*50,(j-1)*50,(i)*50,j*50); glflush(); glutswapbuffers(); void display(void) glclear(gl_color_buffer_bit); glcolor3f(0, 0, 0);
77 P a g e 77 draw_blackarea(); int main() glutinitdisplaymode(glut_double GLUT_RGB); glutinitwindowsize(400,400); glutinitwindowposition(10,10); glutcreatewindow("triangle Drawing!"); init(); glutdisplayfunc(display); glutmainloop(); return 0;
78 P a g e 78 Output:
79 P a g e 79 #17.WAP to perform point and line clipping in OpenGL #include<stdio.h> #include<gl/glut.h> #define outcode int double xmin=50,ymin=50,xmax=100,ymax=100;// Windows boundaries double xvmin=200,yvmin =200, xvmax=300,yvmax=300; // Viewport boundaries const int RIGHT= 8; // bit codes for the right const int LEFT =2; //bit codes for the left const int TOP=4; // bit codes for the top const int BOTTOM=1; //bit codes for the bottom outcode ComputeOutCode(double x,double y); // used to compute bit codes of a point // Cohen -Sutherland clipping algorithm clips a line from // p0=(x0,y0) to p1 =(x1,y1) against a rectangle with. // diagonal from (xmin,ymin)to (xmax,ymax) void CohenSutherlandLineClipAnddraw(double x0,double y0,double x1,double y1) // OutCodes for P0,P1 and Whatever point(among P0 & P1) lies outside the
80 P a g e 80 // clip rectangle outcode outcode0,outcode1,outcodeout; int accept =0,done =0;// These are two bits to indicate trivial accept and/or // done with clipping //compute outcodes outcode0= ComputeOutCode(x0,y0); outcode1= ComputeOutCode(x1,y1); do if(!(outcode0 outcode1)) // logical or is 0 trivially accept and exit accept=1; done=1; else if(outcode0 & outcode1) // logical and is 0 trivially reject and exit done=1; else //failed both tests, so calculate the line segment clip; // from an outside point to an intersection with clip edge
81 P a g e 81 double x,y; // at least one endpoint is outside the clip rectangle ; pick it. outcodeout= outcode0?outcode0:outcode1; //now find the intersection point ; slope m= (y1-y0)/(x1-x0) // use formula /// y=y0+slope*(x-x0), //either x is xmin or xmax /// x=x0+(1/slope)*(y-y0) // y is ymin or ymax if(outcodeout & TOP) //point is above the clip rectangle x= x0+(x1-x0)*(ymax-y0)/(y1-y0); y=ymax; else if(outcodeout & BOTTOM) //point is below the clip rectangle x= x0+(x1-x0)*(ymin-y0)/(y1-y0); y=ymin; else if(outcodeout & RIGHT) //point is to the right of clip rectangle y= y0+(y1-y0)*(xmax-x0)/(x1-x0); x=xmax;
82 P a g e 82 else //point is to the left of the clip rectangle y= y0+(y1-y0)*(xmin-x0)/(x1-x0); x=xmin; // now we move outside point to intersection point to clip // and get ready for next pass. if(outcodeout == outcode0) // If the outside point was p0 update x0,y0 to x,y x0=x; // so x,y become the new x0,y0 y0=y; outcode0 = ComputeOutCode(x0,y0); //compute outcode of new endpoint else // If the outside point was p1 update x1,y1 to x,y // so x,y becomes the new x1,y1 x1=x; y1=y; outcode1 = ComputeOutCode(x1,y1); // compute outcode of new endpoint while(!done); if(accept) //If line was trivial reject no need to draw viewport
83 P a g e 83 // window to viewport mapping double sx=(xvmax-xvmin)/(xmax-xmin);// scale parameter in x direction double sy=(yvmax-yvmin)/(ymax-ymin);// scale parameter in y direction double vx0 = xvmin+(x0-xmin)*sx; double vy0 = yvmin+(y0-ymin)*sy; double vx1 = xvmin+(x1-xmin)*sx; double vy1 = yvmin+(y1-ymin)*sy; //draw a red color viewport glcolor3f(1.0,0.0,0.0); glbegin(gl_line_loop); glvertex2f(xvmin,yvmin); glvertex2f(xvmax,yvmin); glvertex2f(xvmax,yvmax); glvertex2f(xvmin,yvmax); glend(); glcolor3f(0.0,0.0,1.0); glbegin(gl_lines); glvertex2d(vx0,vy0); glvertex2d(vx1,vy1); glend(); // compute the bit code for a point (x,y) using the clip rectangle
84 P a g e 84 // bounded diagonally by (xmin,ymin) and (xmax,ymax) outcode ComputeOutCode(double x,double y) outcode code =0; if(y>ymax) //above the clip window code =TOP; if(y<ymin) //below the clip window code =BOTTOM; if(x>xmax) //to the right of the clip window code =RIGHT; if(x<xmin) //to the left of the clip window code =TOP; return code; void display() double x0=120,y0=10,x1=40,y1=130; glclear(gl_color_buffer_bit); glcolor3f(1.0,0.0,0.0); // draw red color lines glbegin(gl_lines); glvertex2d(x0,y0); glvertex2d(x1,y1); glvertex2d(60,20); glvertex2d(80,120);
85 P a g e 85 glend(); glcolor3f(0.0,0.0,1.0); // draw a blue colored window glbegin(gl_line_loop); glvertex2f(xmin,ymin); glvertex2f(xmax,ymin); glvertex2f(xmax,ymax); glvertex2f(xmin,ymax); glend(); CohenSutherlandLineClipAnddraw(x0,y0,x1,y1); CohenSutherlandLineClipAnddraw(60,20,80,120); glflush(); void myinit() glclearcolor(1.0,1.0,1.0,1.0); glcolor3f(1.0,0.0,0.0); glpointsize(1.0); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0,499.0,0.0,499.0); int main(int argc, char** argv) glutinit(&argc,argv);
86 P a g e 86 glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("cohen Sutherland line clipping algorithm"); glutdisplayfunc(display); myinit(); glutmainloop(); return 0; Output:
Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL
Visual Computing and Multimedia Abel J. P. Gomes 1. Getting Started 2. Installing Graphics Libraries: OpenGL and GLUT 3. Setting up an IDE to run graphics programs in OpenGL/GLUT 4. A First OpenGL/GLUT
More informationComputer Graphics. OpenGL
Computer Graphics OpenGL What is OpenGL? OpenGL (Open Graphics Library) is a library for computer graphics It consists of several procedures and functions that allow a programmer to specify the objects
More informationIntroduction to Computer Graphics with OpenGL/GLUT
Introduction to Computer Graphics with OpenGL/GLUT What is OpenGL? A software interface to graphics hardware Graphics rendering API (Low Level) High-quality color images composed of geometric and image
More informationPrecept 2 Aleksey Boyko February 18, 2011
Precept 2 Aleksey Boyko February 18, 2011 Getting started Initialization Drawing Transformations Cameras Animation Input Keyboard Mouse Joystick? Textures Lights Programmable pipeline elements (shaders)
More informationTeacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using
Teacher Assistant : Tamir Grossinger email: tamirgr@gmail.com Reception hours: by email - Building 37 / office -102 Assignments: 4 programing using C++ 1 theoretical You can find everything you need in
More informationGraphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++
Computer Graphics Graphics Programming August 31, 2005 Contents Our Goal in This Chapter Programming of the Sierpinski gasket How To? Programming with OpenGL and C/C++ OpenGL API (Application Programmer
More informationCOMPUTER GRAPHICS LAB # 3
COMPUTER GRAPHICS LAB # 3 Chapter 2: COMPUTER GRAPHICS by F.S HILLs. Initial steps in drawing figures (polygon, rectangle etc) Objective: Basic understanding of simple code in OpenGL and initial steps
More informationGraphics Programming
Graphics Programming 3 rd Week, 2011 OpenGL API (1) API (application programming interface) Interface between an application program and a graphics system Application Program OpenGL API Graphics Library
More informationRECITATION - 1. Ceng477 Fall
RECITATION - 1 Ceng477 Fall 2007-2008 2/ 53 Agenda General rules for the course General info on the libraries GLUT OpenGL GLUI Details about GLUT Functions Probably we will not cover this part 3/ 53 General
More informationGL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW
OpenGL Syntax Functions have prefix gl and initial capital letters for each word glclearcolor(), glenable(), glpushmatrix() glu for GLU functions glulookat(), gluperspective() constants begin with GL_,
More informationProgramming using OpenGL: A first Introduction
Programming using OpenGL: A first Introduction CMPT 361 Introduction to Computer Graphics Torsten Möller Machiraju/Zhang/Möller 1 Today Overview GL, GLU, GLUT, and GLUI First example OpenGL functions and
More informationCS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008
CS559: Computer Graphics Lecture 12: OpenGL Li Zhang Spring 2008 Reading Redbook Ch 1 & 2 So far: 3D Geometry Pipeline Model Space (Object Space) Rotation Translation Resizing World Space M Rotation Translation
More informationComputer graphics MN1
Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? How do I use it? Rendering pipeline Points, vertices, lines,, polygons Matrices and transformations Lighting and shading Code
More informationLectures OpenGL Introduction
Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is
More information// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations
#include int main(int argc, char** argv) { glutinit(&argc, argv); Typical OpenGL/GLUT Main Program // GLUT, GLU, and OpenGL defs // program arguments // initialize glut and gl // double buffering
More informationDuc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1
Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1 1. The endpoints of a given line are (0, 0) and (18, 6). Compute the first 4 values of y manually using Bresenham's Line Algorithm as x steps
More informationLecture 4 of 41. Lab 1a: OpenGL Basics
Lab 1a: OpenGL Basics William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/courses/cis636 Instructor
More informationBooks, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D
Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D CS334 Spring 2012 Daniel G. Aliaga Department of Computer Science Purdue University Computer Graphics Pipeline Geometric Primitives
More informationUNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M
UNIT 7 LIGHTING AND SHADING 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M Ans: Phong developed a simple model that can be computed rapidly It considers three
More informationC OMPUTER G RAPHICS Thursday
C OMPUTER G RAPHICS 2017.04.27 Thursday Professor s original PPT http://calab.hanyang.ac.kr/ Courses Computer Graphics practice3.pdf TA s current PPT not uploaded yet GRAPHICS PIPELINE What is Graphics
More informationCS 4204 Computer Graphics
CS 4204 Computer Graphics OpenGL Basics Yong Cao Virginia Tech References: 2001 Siggraph, An Interactive Introduction to OpenGL Programming, Dave Shreiner,Ed Angel, Vicki Shreiner Official Presentation
More informationOpenGL for dummies hello.c #include int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize (250, 250); glutinitwindowposition
More informationBasic Graphics Programming
15-462 Computer Graphics I Lecture 2 Basic Graphics Programming Graphics Pipeline OpenGL API Primitives: Lines, Polygons Attributes: Color Example January 17, 2002 [Angel Ch. 2] Frank Pfenning Carnegie
More informationComputer Graphics. Making Pictures. Computer Graphics CSC470 1
Computer Graphics Making Pictures Computer Graphics CSC470 1 Getting Started Making Pictures Graphics display: Entire screen (a); windows system (b); [both have usual screen coordinates, with y-axis y
More informationBOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR
COMPUTER GRAPHICS LECTURE 07 BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM /* * GL07BouncingBall.cpp: A ball bouncing inside the window */ #include // for MS Windows #include
More informationComputer Graphics Introduction to OpenGL
Computer Graphics 2015 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-09-28 2. 2D Graphics Algorithms (cont.) Rasterization Computer Graphics @ ZJU Hongxin Zhang,
More informationAssignment 1. Simple Graphics program using OpenGL
Assignment 1 Simple Graphics program using OpenGL In this assignment we will use basic OpenGL functions to draw some basic graphical figures. Example: Consider following program to draw a point on screen.
More informationComputer Graphics. Bing-Yu Chen National Taiwan University
Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering
More informationBooks, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt
Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt CS334 Fall 2015 Daniel G. Aliaga Department of Computer Science Purdue University Books (and by now means complete ) Interactive Computer
More informationDrawing Primitives. OpenGL basics
CSC 706 Computer Graphics / Dr. N. Gueorguieva 1 OpenGL Libraries Drawing Primitives OpenGL basics OpenGL core library OpenGL32 on Windows GL on most unix/linux systems (libgl.a) OpenGL Utility Library
More informationIntroduction to OpenGL
Introduction to OpenGL Tutorial 1: Create a window and draw a 2D square Introduction: The aim of the first tutorial is to introduce you to the magic world of graphics based on the OpenGL and GLUT APIs.
More informationUsing OpenGL with CUDA
Using OpenGL with CUDA Installing OpenGL and GLUT; compiling with nvcc Basics of OpenGL and GLUT in C Interoperability between OpenGL and CUDA OpenGL = Open Graphic Library creation of 3D graphic primitives
More informationC++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson
C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson Syllabus 1) First program and introduction to data types and control structures with applications for games learning how to use the programming
More informationTo Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)
Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1 http://www.cs.columbia.edu/~cs4160 To Do Start thinking (now) about HW 3. Milestones are due soon. Course Course 3D Graphics Pipeline 3D Graphics
More informationCSE4030 Introduction to Computer Graphics
CSE4030 Introduction to Computer Graphics Dongguk University Jeong-Mo Hong Week 2 The first step on a journey to the virtual world An introduction to computer graphics and interactive techniques How to
More informationAnnouncements OpenGL. Computer Graphics. Autumn 2009 CS4815
Computer Graphics Autumn 2009 Outline 1 Labs 2 Labs Outline 1 Labs 2 Labs Labs Week02 lab Marking 8 10 labs in total each lab worth 2 3% of overall grade marked on attendance and completion of lab completed
More informationComputer Graphics Primitive Attributes
Computer Graphics 2015 4. Primitive Attributes Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-10-12 Previous lessons - Rasterization - line - circle /ellipse? => homework - OpenGL and
More informationProgramming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall
Programming with OpenGL Part 2: Complete Programs 91.427 Computer Graphics I, Fall 2008 1 1 Objectives Refine first program Alter default values Introduce standard program structure Simple viewing 2-D
More informationAnnouncements OpenGL. Computer Graphics. Spring CS4815
Computer Graphics Spring 2017-2018 Outline 1 2 Tutes and Labs Tute02, vector review (see matrix) Week02 lab Lab Marking 10 labs in total each lab worth 3% of overall grade marked on attendance and completion
More informationComputer Graphics (Basic OpenGL)
Computer Graphics (Basic OpenGL) Thilo Kielmann Fall 2008 Vrije Universiteit, Amsterdam kielmann@cs.vu.nl http://www.cs.vu.nl/ graphics/ Computer Graphics (Basic OpenGL, Input and Interaction), ((57))
More informationCameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field
Cameras (and eye) Ideal Pinhole Real Pinhole Real + lens Depth of field 1 Z-buffer How do we draw objects? Polygon Based Fast Raytracing Ray/Object intersections Slow Copyright Pixar 2 Raytracing for each
More informationERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL
ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO SANTA BARBARA SANTA CRUZ EECS 104 Fundamentals of Computer Graphics OpenGL Slides courtesy of Dave Shreine, Ed Angel and Vicki Shreiner
More information6. Make use of glviewport() to display two sine curves on the same screen, one on the
Duc Nguyen CSE-420: Computer Graphics 10/17/18 1. Modify lines.cpp to display lines in the following patterns: a. a long dash and a dot, (.. ) b. two close dots followed by a distant dot (...... ) 2. Modify
More informationby modifying the glutinitwindowsize() function you can change the screen size to whatever you please.
Zoe Veale Lab 2 Draw2 part 1: I edited the glutinitwindowsize() function tom change the size of my screen window. int main(int argc, char** argv) glutinit(&argc, argv); //initialize toolkit glutinitdisplaymode
More informationLecture 3. Understanding of OPenGL programming
Lecture 3 Understanding of OPenGL programming What is OpenGL GL: stands for Graphic Library Software interface for rendering purposes for 2D or 3D geometric data objects. Various Pieces gl: The basic libraries.
More informationCS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008
CS559: Computer Graphics Lecture 2: OpenGL Transformation Li Zhang Spring 28 Today Transformation in OpenGL Reading Chapter 3 Last time Primitive Details glpolygonmode(glenum face, GLenum mode); face:
More informationIntroduction to OpenGL: Part 2
Introduction to OpenGL: Part 2 Introduction to OpenGL: Part 2 A more complex example recursive refinement Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous
More informationIntroduction to MS Visual C/C++
3/4/2002 Burkhard Wünsche Introduction to C/C++ Page 1 of 9 0. Introduction: Introduction to MS Visual C/C++ This tutorial gives a simple introduction to MS Visual C/C++ with an emphasis on OpenGL graphics
More informationBasic Graphics Programming
CSCI 480 Computer Graphics Lecture 2 Basic Graphics Programming January 11, 2012 Jernej Barbic University of Southern California http://www-bcf.usc.edu/~jbarbic/cs480-s12/ Graphics Pipeline OpenGL API
More informationLecture 2 2D transformations Introduction to OpenGL
Lecture 2 2D transformations Introduction to OpenGL OpenGL where it fits what it contains how you work with it OpenGL parts: GL = Graphics Library (core lib) GLU = GL Utilities (always present) GLX, AGL,
More information1) Program to display a set of values {fij} as a rectangular mesh. #include<gl/glut.h> #define maxx 20. #define maxy 20. #define dx 15.
1) Program to display a set of values fij as a rectangular mesh. #include #define maxx 20 #define maxy 20 #define dx 15 #define dy 20 GLfloat x[maxx]=0.0,y[maxy]=0.0; GLfloat x0=50,y01=50; GLint
More information11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)
CSCI 420 Computer Graphics Lecture 2 Basic Graphics Programming Teaching Assistant Yijing Li Office hours TBA Jernej Barbic University of Southern California Graphics Pipeline OpenGL API Primitives: Lines,
More informationExercise 1 Introduction to OpenGL
Exercise 1 Introduction to OpenGL What we are going to do OpenGL Glut Small Example using OpenGl and Glut Alexandra Junghans 2 What is OpenGL? OpenGL Two Parts most widely used and supported graphics API
More informationComputer Graphics 1 Computer Graphics 1
Projects: an example Developed by Nate Robbins Shapes Tutorial What is OpenGL? Graphics rendering API high-quality color images composed of geometric and image primitives window system independent operating
More informationGetting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.
Overview (1): Getting Started Setting up OpenGL/GLUT on Windows/Visual Studio COSC 4431/5331 Computer Graphics Thursday January 22, 2004 Overview Introduction Camera analogy Matrix operations and OpenGL
More informationIntroduction to OpenGL
Introduction to OpenGL Banafsheh Azari http://www.uni-weimar.de/cms/medien/cg.html What You ll See Today What is OpenGL? Related Libraries OpenGL Command Syntax B. Azari http://www.uni-weimar.de/cms/medien/cg.html
More informationComputer graphics MN1
Computer graphics MN1 Hierarchical modeling Transformations in OpenGL glmatrixmode(gl_modelview); glloadidentity(); // identity matrix gltranslatef(4.0, 5.0, 6.0); glrotatef(45.0, 1.0, 2.0, 3.0); gltranslatef(-4.0,
More informationCMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013
CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013 Reading: See any standard reference on OpenGL or GLUT. Basic Drawing: In the previous lecture, we showed how to create a window in GLUT,
More informationLecture 2 CISC440/640 Spring Department of Computer and Information Science
Lecture 2 CISC440/640 Spring 2015 Department of Computer and Information Science Today s Topic The secrets of Glut-tony 2 So let s do some graphics! For the next week or so this is your world: -1 1-1 1
More informationTransformation, Input and Interaction. Hanyang University
Transformation, Input and Interaction Hanyang University Transformation, projection, viewing Pipeline of transformations Standard sequence of transforms Cornell CS4620 Fall 2008 Lecture 8 3 2008 Steve
More information2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-
2.1 What is OpenGL? -23-2. OpenGL -I - Device-independent, application program interface (API) to graphics hardware - 3D-oriented - Event-driven Things OpenGL can do: - wireframe models - depth-cuing effect
More informationAPI for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3
OpenGL Introduction Introduction OpenGL OpenGL is an API for computer graphics. Hardware-independent Windowing or getting input is not included in the API Low-level Only knows about triangles (kind of,
More informationProgramming with OpenGL Part 1: Background
Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Objectives Development of the OpenGL API
More informationModeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益
Modeling Transform Chapter 4 Geometric Transformations 李同益 Specify transformation for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene
More informationInteraction Computer Graphics I Lecture 3
15-462 Computer Graphics I Lecture 3 Interaction Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations January 21, 2003 [Angel Ch. 3] Frank Pfenning Carnegie Mellon
More informationSource code: #include <iostream>
Andrew Yenalavitch Homework 4 CSE 520 - Winter 2015 1. ( 10 points ) Write a program that finds the knot vector ( u 0,..., u n-1 ) of a B-spline. It asks for 'number of control points' and 'degree of spline'
More informationInteraction. CSCI 480 Computer Graphics Lecture 3
CSCI 480 Computer Graphics Lecture 3 Interaction January 18, 2012 Jernej Barbic University of Southern California Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations
More informationOpenGL/GLUT Intro. Week 1, Fri Jan 12
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner OpenGL/GLUT Intro Week 1, Fri Jan 12 http://www.ugrad.cs.ubc.ca/~cs314/vjan2007 News Labs start next week Reminder:
More informationComputer graphics MN1
Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? HowdoI useit? Rendering pipeline Points, vertices, lines, polygons Matrices and transformations Lighting and shading Code examples
More informationProgramming with OpenGL Part 3: Three Dimensions
Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Objectives Develop a more sophisticated
More informationComputer Graphics Course 2005
Computer Graphics Course 2005 Introduction to GLUT, GLU and OpenGL Administrative Stuff Teaching Assistant: Rony Goldenthal Reception Hour: Wed. 18:00 19:00 Room 31 (Ross 1) Questions: E-mail: cg@cs Newsgroups:
More informationLAB MANUAL. Computer Graphics using OpenGL Department of CSE & IT, JUIT. Chief Course Coordinator: Dr Rajesh Siddavatam Associate Professor, CSE& IT
LAB MANUAL Computer Graphics using OpenGL Department of CSE & IT, JUIT. Chief Course Coordinator: Dr Rajesh Siddavatam Associate Professor, CSE& IT Lab Co-ordinators: Ms Meenakshi S Arya, Mr Ravikant Verma
More informationOpenGL Tutorial. Ceng 477 Introduction to Computer Graphics
OpenGL Tutorial Ceng 477 Introduction to Computer Graphics Adapted from: http://www.cs.princeton.edu/courses/archive/spr06/cos426/assn3/opengl_tutorial.ppt OpenGL IS an API OpenGL IS nothing more than
More informationComputer Graphics, Chapt 08
Computer Graphics, Chapt 08 Creating an Image Components, parts of a scene to be displayed Trees, terrain Furniture, walls Store fronts and street scenes Atoms and molecules Stars and galaxies Describe
More informationIntroduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou
Introduction to OpenGL Transformations, Viewing and Lighting Ali Bigdelou Modeling From Points to Polygonal Objects Vertices (points) are positioned in the virtual 3D scene Connect points to form polygons
More informationGraphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:
Graphics Programming Chapter 2 Introduction: - Our approach is programming oriented. - Therefore, we are going to introduce you to a simple but informative problem: the Sierpinski Gasket - The functionality
More informationLECTURE 02 OPENGL API
COMPUTER GRAPHICS LECTURE 02 OPENGL API Still from Pixar s Inside Out, 2015 IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM EARLY HISTORY OF APIS IFIPS (1973) formed two committees to come up with a
More informationCS 543 Lecture 1 (Part II): Intro to OpenGL and GLUT (Part I) Emmanuel Agu
CS 543 Lecture 1 (Part II): Intro to OpenGL and GLUT (Part I) Emmanuel Agu OpenGL Basics OpenGL s function Rendering Rendering? Convert geometric/mathematical object descriptions into images OpenGL can
More informationOpenGL refresher. Advanced Computer Graphics 2012
Advanced Computer Graphics 2012 What you will see today Outline General OpenGL introduction Setting up: GLUT and GLEW Elementary rendering Transformations in OpenGL Texture mapping Programmable shading
More informationCOMP 371/4 Computer Graphics Week 1
COMP 371/4 Computer Graphics Week 1 Course Overview Introduction to Computer Graphics: Definition, History, Graphics Pipeline, and Starting Your First OpenGL Program Ack: Slides from Prof. Fevens, Concordia
More informationCS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008
CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008 2008/2/3 Slide 2 I Am Your TA Name : Wei-Wen Wen Feng 4th Year Graduate Student in Graphics I will be Holding discussion/tutorial
More informationIntroduction to OpenGL Week 1
CS 432/680 INTERACTIVE COMPUTER GRAPHICS Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico Objectives
More informationObjectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1
CS 432/680 INTERACTIVE COMPUTER GRAPHICS Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Objectives Learn the basic design of a graphics system Introduce graphics
More informationCS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu
CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II Emmanuel Agu Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize toolkit, set display mode and create window glutinit(&argc,
More informationDisplay Lists in OpenGL
Display Lists in OpenGL Display lists are a mechanism for improving performance of interactive OpenGL applications. A display list is a group of OpenGL commands that have been stored for later execution.
More informationComputer Graphics Introduction to OpenGL
Computer Graphics 2013 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2013-09-16 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines start
More informationInformation Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)
11(40) Information Coding / Computer Graphics, ISY, LiTH OpenGL where it fits what it contains how you work with it 11(40) OpenGL The cross-platform graphics library Open = Open specification Runs everywhere
More informationGLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)
GLUT Tutorial John Tsiombikas (Nuclear / The Lab Demos) May 6, 2005 1 Introduction to GLUT (OpenGL Utility Toolkit) This is an introductory text, for those who are interested in using the OpenGL library
More informationPART-I: Lab for MCS-051 (Advanced Internet Technologies)
PART-I: Lab for MCS-051 (Advanced Internet Technologies) Q.1. Write a Program using Servlet and JDBC for developing online application for students attendance management for MCA V semester students of
More informationCS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)
Computer Graphics CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize
More information2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3
CSCI 420 Computer Graphics Lecture 3 Interaction Jernej Barbic University of Southern California [Angel Ch. 2] Triangles (Clarification) Can be any shape or size Well-shaped triangles have advantages for
More informationOpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University
OpenGL Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University Background Software interface to graphics hardware 250+ commands Objects (models) are built from geometric primitives
More information20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:
1 1. 1 #include 2 #include 3 Program 1 (OpenGL Sample016) 4 // 5 static int MouseX = 0; // X 6 static int MouseY = 0; // Y 7 static float SpinX = 0; // X 8 static float SpinY = 0;
More informationGraphics Pipeline & APIs
Graphics Pipeline & APIs CPU Vertex Processing Rasterization Fragment Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,
More informationAndrew Yenalavitch Homework 1 CSE Fall 2014
Andrew Yenalavitch Homework 1 CSE 420 - Fall 2014 1.) ( 20 points ) In the class, we have discussed how to draw a line given by y = m x + b using Besenham's algorithm with m 1. Extend the algorithm to
More informationInteraction. CSCI 420 Computer Graphics Lecture 3
CSCI 420 Computer Graphics Lecture 3 Interaction Jernej Barbic University of Southern California Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations [Angel Ch.
More information3D computer graphics: geometric modeling of objects in the computer and rendering them
SE313: Computer Graphics and Visual Programming Computer Graphics Notes Gazihan Alankus, Spring 2012 Computer Graphics 3D computer graphics: geometric modeling of objects in the computer and rendering
More informationHierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,
Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks, Hierarchical Modeling Hofstra University 1 Modeling complex objects/motion Decompose object hierarchically
More informationOpenGL Basics I. Seoul National University Graphics & Media Lab
OpenGL Basics I Seoul National University Graphics & Media Lab Contents Introduction to OpenGL OpenGL sample 01 OpenGL primitives OpenGL colors Introduction to OpenGL Evolution of Computers 4 Graphics
More informationComputer Graphics Introduction to OpenGL
! Computer Graphics 2014! 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2014-09-29! ! 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines
More information