LAB 5 Drawing Objects Lab 5 Drawing Objects.

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

OPENGL.
3D Game Programming Geometric Transformations
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Part 3: Three Dimensions.
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
Drawing 3D Scenes in OpenGL We want to transform objects in order to orient and position them as desired in a 3D scene. OpenGL provides the necessary functions.
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
OpenGL and Projections
1 CSC461 Lecture 7: 3D Programming in OpenGL Objectives: Develop 2D and 3D examples -- Sierpinski gasket: a fractal Develop 2D and 3D examples -- Sierpinski.
Ellipses Using OpenGL.
Sierpinski Gasket Program
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
CS 470 Introduction to Computer Graphics Basic 3D in OpenGL.
Geometric Objects and Transformations Chapter 4. Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey.
Chapter 4 10 February Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.
Geometric Primitives Used in Open GL Polygons Polygon is : Flat shape with three or more straight sides. It could be either : convex or concave.
Write a Simple Program with OpenGL & GLUT. Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
Modeling with OpenGL Practice with OpenGL transformations.
1 Programming with OpenGL Part 3: Three Dimensions Yuanfeng Zhou Shandong University.
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
3D Programming and Viewing Week 3 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
1 Chapter 2 Graphics Programming. 2 Using OpenGL in Visual C++ – 1/3 Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib and glu32.lib.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
NoufNaief.net 1 TA: Nouf Al-Harbi.
Chap 3 Viewing and Transformation
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
Chap 2 Write a Simple OpenGL Program. Preparing 1/2 environment : Microsoft Visual C 、 Microsoft Visual C++.Net Also need : GLUT
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
OpenGL & OpenSceneGraph Graphics Programming Katia Oleinik:
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Implement of transformation,projection, viewing Hanyang University Jungsik Park.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Chapter 8 Three-dimensional Object Representations PART I
CSC Graphics Programming
Introduction of OpenGL - 3D Graphic and Animation
Curves and Surfaces in OpenGL
Introduction to OpenGL
Chapter 5.6 Transformations of Objects © 2007, Prentice Hall
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Reference1. [OpenGL course slides by Rasmus Stenholt]
Course code:10CS65 | Computer Graphics and Visualization
Programming with OpenGL Part 2: Complete Programs
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Programming with OpenGL Part 3: Three Dimensions
Rendering Geometric Primitives Reading: HB4, HB8-1 to HB8-6, HK9.7, 11
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Lighting and Shading Lab 8:.
CSC461: Lecture 24 Lighting and Shading in OpenGL
Programming with OpenGL Part 3: Three Dimensions
Introduction to OpenGL
LAB 5 Drawing Objects Lab 5 Drawing Objects.
OPENGL.
Lecture 12: OpenGL Li Zhang Spring 2008
Programming with OpenGL Part 2: Complete Programs
Lighting and Shading Lab 8:.
Programming with OpenGL Part 3: Three Dimensions
Chapter 4 15 March 2006 EventPro Strategies is looking for a part-time programmer (any language) who knows SQL. For more info, contact Ryan Taylor,
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Introduction to OpenGL Programming
Presentation transcript:

LAB 5 Drawing Objects Lab 5 Drawing Objects

 Example to draw circle  Drawing Objects:  Sphere  Cube  Torus  Icosahedron  Octahedron  Tetrahedron  Dodecahedron  Cone  Teapot  practices

glutCreateWindow("draw circle"); glClearColor(0.95, 0.90, 0.85, 0.0); #include <windows.h> #include <gl\glut.h> #include <math.h> void main(void) #define PI 3.14159265 } int numPoints= 500; int Radius =50; void draw(void) glutInitDisplayMode(GLUT_RGB); glutInitWindowPosition(100,100); glutInitWindowSize(200,200); } glutCreateWindow("draw circle"); glClearColor(0.95, 0.90, 0.85, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0,0.6,0.6); glutDisplayFunc(draw); glBegin(GL_POLYGON); for (int i=0; i<numPoints; i++) gluOrtho2D(-100.0, 100.0, -100.0, 100.0); } glutMainLoop(); float angle = i * (2.0*PI/numPoints); float x = cos(angle)*Radius; { float y = sin(angle)*Radius; glVertex2f(x , y); { glEnd(); glFlush(); {

 The GLUT library provides several objects that are rather tedious to build. These objects are fully defined, with normal, and they are useful for experimenting with lighting. A “wire” object displays as a wire frame. A “solid” object looks like a solid, but you should define its material properties yourself.

GLUT provides functions for the 3D objects:  Sphere  Cube  Torus  Icosahedron  Octahedron  Tetrahedron  Dodecahedron  Cone  Teapot

 void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);  void glutWireSphere(GLdouble radius, GLint slices, GLint stacks); Where:  radius : The radius of the sphere.  slices : The number of subdivisions around the Z axis (similar to lines of longitude).  stacks : The number of subdivisions along the Z axis (similar to lines of latitude).

 glutSolidSphere(15,10,70);  glutWireSphere(15,10,70);

GLdouble outerRadius, GLint nsides, GLint rings); Where:  void glutSolidTorus(Gldouble innerRadius ,GLdouble outerRadius, GLint nsides, GLint rings);  void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint nsides, GLint rings); Where:  innerRadius : Inner radius of the torus.  outerRadius : Outer radius of the torus.  nsides : Number of sides for each radial section.  rings : Number of radial divisions for the torus.

 glutSolidTorus(5,10,15,50);

void glutSolidCube(GLdouble size); void glutWireCube(GLdouble size);

 GlutSolidCube(20);  glutWireCube(20);

 void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);  void glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); Where:  base : The radius of the base of the cone.  height :The height of the cone.  slices : The number of subdivisions around the Z axis.  stacks :The number of subdivisions along the Z axis.

 glutSolidCone(5,2,70,10);

 void glutSolidTeapot(GLdouble size);  void glutWireTeapot(GLdouble size); Where:  size :Relative size of the teapot. Example: glutSolidTeapot(10);

 void glutSolidIcosahedron(void); Example: glutSolidIcosahedron();  void glutWireIcosahedron(void); Example: glutWireIcosahedron();

 void glutSolidOctahedron(void); Example: glutSolidOctahedron ();  void glutWireOctahedron(void); Example: glutWireOctahedron ();

 void glutSolidTetrahedron(void); Example: glutSolidTetrahedron();  void glutWireTetrahedron(void); Example: glutWireTetrahedron();

 void glutSolidDodecahedron(void); Example: glutSolidDodecahedron();  void glutWireDodecahedron(void); Example: glutWireDodecahedron();

#include <windows.h> #include <GL/glut.h> void draw(void) } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glEnable(GL_DEPTH_TEST); //glEnable(GL_LIGHTING); //glEnable(GL_LIGHT0); //glDisable(GL_CULL_FACE); //glEnable(GL_COLOR_MATERIAL); glColor3ub (204,0,102); glutSolidTeapot(10); glFlush(); {

void main() } glutInitWindowSize(200,200); glutInitDisplayMode(GLUT_DEPTH); glutCreateWindow("Teapot"); glutDisplayFunc(draw); glClearColor(0.95, 0.90, 0.85, 0.0); //glMatrixMode(GL_PROJECTION); //glLoadIdentity(); glOrtho(-21.0, 21.0, -21.0, 21.0, -20.0, 20.0); //glMatrixMode(GL_MODELVIEW); //glLoadIdentity(); glutMainLoop(); {

Draw the following shapes: Solid Sphere glutSolidSphere (0.4, 16, 16) 1) Solid Cube glutSolidCube (1.0) 2) Solid cone glutSolidCone (1.0, 2.0, 3, 4); 3) Redraw the previous objects as a wire frame.