Download presentation
Presentation is loading. Please wait.
Published byHector Gilmore Modified over 6 years ago
1
Computer Graphics Prof. Muhammad Saeed Dept. of Computer Science & IT
Federal Urdu University of Arts, Sciences and Technology
2
Computer Graphics Prof. Muhammad Saeed Dept. of Computer Science & IT
Federal Urdu University of Arts, Sciences and Technology
3
using Tao Framework in C#
Computer Graphics 3. OpenGL using Tao Framework in C# FUUAST Dept. of Comp. Sc.& IT
4
1. C# Wrapper (Tao Framework) i. Introduction to ‘Tao framework’
OpenGL Computer Graphics Introduction 1. C# Wrapper (Tao Framework) i. Introduction to ‘Tao framework’ ii. The installation and use in C# 2. Two Dimensional i. Functions’ structure a. end characters: i, f, d and v b. next to end:2, 3,4 ii. 2D window and viewport a. gluOrtho2D(left,right,bottom,right); b. glViewport(x,y,width,height); iii. Projection Matrix Mode a. glMatrixMode(GL_PROJECTION) b. glLoadIdentity() FUUAST Dept. of Comp. Sc.& IT
5
iv. Drawing primitives OpenGL Computer Graphics a. Points:
glBegin(GL_POINTS); glVertex2d(x,y); …… ; glEnd(); b. Lines: glBegin(GL_LINES); glVertex2d(x,y); glVertex2d(x,y); ……. ;glEnd(); glBegin(GL_LINE_STRIP); …….. ; glEnd(); glBegin(GL_LINE_LOOP); ……. ;glEnd(); c. Triangles: glBegin(GL_TRIANGLES); ……. ; glEnd(); glBegin(GL_TRIANGLE_STRIP); ……. ; glEnd(); glBegin(GL_TRIANGLE_FAN); ……. ; glEnd(); d. Quads: glBegin(GL_QUADS); ……….. ; glEnd(); glBegin(GL_QUAD_STRIP); ……. glEnd(); e. Polygons: glBegin(GL_POLYGON); …….. ; glEnd(); , FUUAST Dept. of Comp. Sc.& IT
6
glClear(GL_COLOR_BUFFER_BIT);
OpenGL Computer Graphics v. Colors: a. Drawing color: glColor3d(red, green, blue); b. Background Color: glClearColor(red, green, blue, alpha); c. Clear Screen(Frame Buffer): glClear(GL_COLOR_BUFFER_BIT); d. Color Gradient: Every vertex with different color. 2. Three Dimensional Initials i. Viewing Systems : a. 2D b. Orthographic c. Perspective. FUUAST Dept. of Comp. Sc.& IT
7
Orthographic Viewing System
Computer Graphics Orthographic Viewing System y top Near Plane Far Plane left x bottom right N z F FUUAST Dept. of Comp. Sc.& IT
8
Projection Matrix and Orthographic Viewing
Computer Graphics Projection Matrix and Orthographic Viewing a. Orthographic: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-x, x,-y, y, near far); FUUAST Dept. of Comp. Sc.& IT
9
Perspective Viewing System
Computer Graphics Perspective Viewing System top, left N d F right, bottom FUUAST Dept. of Comp. Sc.& IT
10
Projection Matrix and Perspective viewing
Computer Graphics Projection Matrix and Perspective viewing b. Perspective: glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(view angle, aspect ratio, near, far); FUUAST Dept. of Comp. Sc.& IT
11
Camera Analogy Viewing Model OpenGL Computer Graphics Setting Model
Focus Photograph Viewing Modeling Projection Viewport Model Modeling Projection Focus Viewport Photograph FUUAST Dept. of Comp. Sc.& IT
12
OpenGL Computer Graphics
ii. Camera Setting: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( x1, y1, z1, x2, y2, z2, x, y, z); iii. Lights: Ambient, Diffuse and Specular. ( Defs. and Discussion ) a. Position glLightfv(GL_LIGHT0, GL_POSITION, pos); b. Ambient Light: glLightfv(GL_LIGHT0, GL_AMBIENT, amb); c. Diffuse: glLightfv(GL_LIGHT0, GL_DIFFUSE, diff); d. Specular: glLightfv(GL_LIGHT0, GL_SPECULAR, spec); Pos, amb, diff, spec are arrays of size 4. containing respective position and color values. FUUAST Dept. of Comp. Sc.& IT
13
OpenGL Computer Graphics
e. Enabling of light: glEnable(GL_LIGHTING); glEnable(GL_LIGHT0) ; iv. Shading Model: a. 1) Gouraud Shading 2) Phong Shading b. 1) glShadeModel(GL_SMOOTH); 2) glShadeModel(GL_FLAT); v. Buffers: a) Double Buffer b) Frame Buffer c) Accummulation Buffer vi. Hidden Surface Removal Depth Buffer (Z-Buffer) glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); FUUAST Dept. of Comp. Sc.& IT
14
i. 3D implicit and parametric curves (list given)
OpenGL Computer Graphics 3. 3D Mathematics 1. Vectors i. component representation ii. Addition, dot product and cross product iii. Unit, parallel and normal vector on a plane iv. Equation of a plane and normal vector 2. 3D Curves i. 3D implicit and parametric curves (list given) ii. Bezier Curves and B-Splines 4. Meshes and surfaces 1. Meshes i. meshes by curve equations, Sine curve, and sphere etc. ii. Meshes by rotation and translation FUUAST Dept. of Comp. Sc.& IT
15
1. 3D Objects and Transformations
OpenGL Computer Graphics 5. Solid Modeling 1. 3D Objects and Transformations i. Material colors, emission color and shininess glMaterialfv(GL_FRONT, GL_AMBIENT, materialAmbient); glMaterialfv(GL_FRONT, GL_DIFFUSE, materialAmbient); glMaterialfv(GL_FRONT, GL_SPECULAR, materialSpecular); glMaterialfv(GL_FRONT, GL_EMISSION, materialEmission); glMaterialf(GL_FRONT, GL_SHININESS, materialShininess); glColorMaterial(GL_FRONT, GL_DIFFUSE); ii. Drawing sphere, cylinder, cone, disk, partial disk GLUquadric quad = gluNewQuadric(); gluQuadricDrawStyle(quad, GLU_FILL); //GLU_POINT,GLU_LINE,GLU_SILHOUETTE gluQuadricNormals(quad, GLU_SMOOTH); //GLU_FLAT, GLU_NONE gluQuadricOrientation(quad, GLU_INSIDE); //GLU_OUTSIDE gluSphere(quad, radius, slices, stacks); FUUAST Dept. of Comp. Sc.& IT
16
i. vertices, edges and surfaces
OpenGL Computer Graphics iii. Rotation, translation and scaling of 3D objects glRotated(angle, x, y, z); glTranslated(dx, dy, dz); glScaled(s, s, s); iv. User-defined matrices and OpenGL stacks, shearing matrix glLoadMatrixf(array[16]); glMultMatrixf( array[16]); Surfaces and solids i. vertices, edges and surfaces ii. Platonic solids ii. Constructing Cube, Sphere, Tetrahedron etc. 3. Surfaces of rotation surfaces of sine curve, Bezier curve FUUAST Dept. of Comp. Sc.& IT
17
Structure-deforming Transformations
OpenGL Computer Graphics 2. Deformations Structure-deforming Transformations Tapering Twisting Bending Dept. of Comp. Sc. & IT FUUAST
18
i. Tapering: OpenGL Computer Graphics Tapered along Z-axis
Original Object Transformation Equations: X2 = r * X1 Y2 = r * Y1 Z2 = Z1 r = f(Z1) Matrix Form: = Dept. of Comp. Sc. & IT FUUAST
19
ii. Twisting: OpenGL Computer Graphics Original Object
Twisted along Z-axis Transformation Equations: Matrix Form: X2 = X1*cos() – Y1*sin() Y2 = X1*sin() + Y1*cos() Z2 = Z1 = f(Z1) = Dept. of Comp. Sc. & IT FUUAST
20
iii. Bending (Composite Transformation):
OpenGL Computer Graphics iii. Bending (Composite Transformation): Original Object Bent Transformation Equations: x = X y = Z = Bend Region is along Y axis Ymin≤ Y ≤ Ymax Center of the Bend is at Y = Y0 Radius of Curvature = 1/k Bending angle is: = k( - Y0) Where: = Dept. of Comp. Sc. & IT FUUAST
21
int num=glGenerateLists(1);
OpenGL Computer Graphics Display Lists int num=glGenerateLists(1); glNewList(num, GL_COMPILE); //GL_COMPILE_AND_EXECUTE ………. glEndList(); glCallList(num); Fog glEnable(GL_FOG); float[] fogColor ={ 0.1f, 0.1f, 0.15f, 1.0f }; glFogi(GL_FOG_MODE, GL_EXP); //GL_EXP2;//GL_LINEAR;//GL_EXP; glFogfv(GL_FOG_COLOR, fogColor); glFogf(GL_FOG_DENSITY, 0.2f); glHint(GL_FOG_HINT, GL_NICEST); //GL_FASTEST);//GL_DONT_CARE);//GL_NICEST glFogf(GL_FOG_START, 3.5f); glFogf(GL_FOG_END, 5.0f); FUUAST Dept. of Comp. Sc.& IT
22
6. Spot Lights Blending glEnable(GL_BLEND); OpenGL Computer Graphics
glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, 30);//20 glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 1.5f); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0f); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.2f); glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.1f); Blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glBlendEquation(GL_FUNC_ADD); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); FUUAST Dept. of Comp. Sc.& IT
23
Quad trees, Octree and BSP trees Bitmap
OpenGL Computer Graphics Ray Tracing Quad trees, Octree and BSP trees Bitmap Color picColor; Bitmap bitmap = (Bitmap)Bitmap.FromFile(file); //bitmap = new Bitmap(file); bitmapHeight = bitmap.Height; bitmapWidth = bitmap.Width; picColor = bitmap.GetPixel(i, j); bitmap.SetPixel(i, j, picColor); 10. Zooming, Panning, Segmentation and Extruding 11. Texture Mapping 12. Animation FUUAST Dept. of Comp. Sc.& IT
24
END
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.