Introduction to OpenGL: Part 2
|
|
- Aileen Marshall
- 6 years ago
- Views:
Transcription
1 Introduction to OpenGL: Part 2
2 Introduction to OpenGL: Part 2 A more complex example recursive refinement
3 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves?
4 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments.
5 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments. The following code draws a simple outline of a square, using 4 lines. The square is centered at the origin, and has a radius of 1. (It is a crude approximation to a circle.)
6 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments. The following code draws a simple outline of a square, using 4 lines. The square is centered at the origin, and has a radius of 1. (It is a crude approximation to a circle.) The program then recursively finds the center of each of the lines, and normalizes the distance from the origin to 1, making successively better approximations to a square.
7 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments. The following code draws a simple outline of a square, using 4 lines. The square is centered at the origin, and has a radius of 1. (It is a crude approximation to a circle.) The program then recursively finds the center of each of the lines, and normalizes the distance from the origin to 1, making successively better approximations to a square. The program also parses a simple command line argument (an integer) which it uses to set the level of recursion.
8 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments. The following code draws a simple outline of a square, using 4 lines. The square is centered at the origin, and has a radius of 1. (It is a crude approximation to a circle.) The program then recursively finds the center of each of the lines, and normalizes the distance from the origin to 1, making successively better approximations to a square. The program also parses a simple command line argument (an integer) which it uses to set the level of recursion. (The C language has I/O functions which are quite different from JAVA or C++.)
9 Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous curves? Yes, by segmenting the curve into a large number of straight-line segments. The following code draws a simple outline of a square, using 4 lines. The square is centered at the origin, and has a radius of 1. (It is a crude approximation to a circle.) The program then recursively finds the center of each of the lines, and normalizes the distance from the origin to 1, making successively better approximations to a square. The program also parses a simple command line argument (an integer) which it uses to set the level of recursion. (The C language has I/O functions which are quite different from JAVA or C++.) 1 1
10 /* recursive_circle.c * This is a simple, introductory OpenGL program. * It draws a circle on a white background by recursively * subdividing the sides of a square and renormalizing * the distance from the origin. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <GL/glut.h> int n=0; \\ the number of levels of recursion
11 /* recursive_circle.c * This is a simple, introductory OpenGL program. * It draws a circle on a white background by recursively * subdividing the sides of a square and renormalizing * the distance from the origin. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <GL/glut.h> int n=0; \\ the number of levels of recursion void init (void) { /* select clearing color as white */ glclearcolor (1.0, 1.0, 1.0, 0.0); /* initialize viewing values */ glmatrixmode(gl_projection); glloadidentity(); glortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); } 2
12 // the recursive function void drawside(float x0,float y0,float x1,float y1,int n) { float xm, ym, norm; if (n <= 0) { // the stopping condition glbegin(gl_lines); // drawing only done here glvertex3f(x0,y0,0.0); glvertex3f(x1,y1,0.0); glend(); }
13 // the recursive function void drawside(float x0,float y0,float x1,float y1,int n) { float xm, ym, norm; if (n <= 0) { glbegin(gl_lines); glvertex3f(x0,y0,0.0); glvertex3f(x1,y1,0.0); glend(); } else{ n--; xm = 0.5*(x0 + x1); ym = 0.5*(y0 + y1); // the stopping condition // drawing only done here // the recursion // decriment counter // calculate midpoints
14 // the recursive function void drawside(float x0,float y0,float x1,float y1,int n) { float xm, ym, norm; if (n <= 0) { glbegin(gl_lines); glvertex3f(x0,y0,0.0); glvertex3f(x1,y1,0.0); glend(); } else{ n--; xm = 0.5*(x0 + x1); ym = 0.5*(y0 + y1); norm = sqrt(xm*xm +ym*ym); xm = xm/norm; ym = ym/norm; // the stopping condition // drawing only done here // the recursion // decriment counter // calculate midpoints // normalize line
15 // the recursive function void drawside(float x0,float y0,float x1,float y1,int n) { float xm, ym, norm; if (n <= 0) { glbegin(gl_lines); glvertex3f(x0,y0,0.0); glvertex3f(x1,y1,0.0); glend(); } else{ } n--; xm = 0.5*(x0 + x1); ym = 0.5*(y0 + y1); norm = sqrt(xm*xm +ym*ym); xm = xm/norm; ym = ym/norm; drawside(x0,y0,xm,ym,n); drawside(xm,ym,x1,y1,n); } // the stopping condition // drawing only done here // the recursion // decriment counter // calculate midpoints // normalize line 3
16 void display(void) { \\ the new display function
17 void display(void) \\ the new display function { float x0, y0; /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0;
18 void display(void) { float x0, y0; /* clear all pixels */ /* glclear (GL_COLOR_BUFFER_BIT); \\ the new display function * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0; drawside(x0,y0,-x0,y0,n);
19 void display(void) { float x0, y0; /* clear all pixels */ /* glclear (GL_COLOR_BUFFER_BIT); \\ the new display function * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0; drawside(x0,y0,-x0,y0,n); drawside(-x0,y0,-x0,-y0,n);
20 void display(void) { float x0, y0; /* clear all pixels */ /* glclear (GL_COLOR_BUFFER_BIT); \\ the new display function * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0; drawside(x0,y0,-x0,y0,n); drawside(-x0,y0,-x0,-y0,n); drawside(-x0,-y0,x0,-y0,n);
21 void display(void) { float x0, y0; /* clear all pixels */ /* glclear (GL_COLOR_BUFFER_BIT); \\ the new display function * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0; drawside(x0,y0,-x0,y0,n); drawside(-x0,y0,-x0,-y0,n); drawside(-x0,-y0,x0,-y0,n); drawside(x0,-y0,x0,y0,n);
22 void display(void) { float x0, y0; /* clear all pixels */ /* glclear (GL_COLOR_BUFFER_BIT); \\ the new display function * set initial sides of square with unit "radius" * centered at (0.0, 0.0, 0.0). */ glcolor3f (1.0, 0.0, 0.0); x0 = 1.0/sqrt(2.0); y0 = x0; drawside(x0,y0,-x0,y0,n); drawside(-x0,y0,-x0,-y0,n); drawside(-x0,-y0,x0,-y0,n); drawside(x0,-y0,x0,y0,n); } glflush (); 4
23 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (single buffer and RGBA). * Open window with "circle" * in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ {
24 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (single buffer and RGBA). * Open window with "circle" * in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ { if (argc == 2) sscanf(argv[1],"%i",&n);
25 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (single buffer and RGBA). * Open window with "circle" * in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ { if (argc == 2) sscanf(argv[1],"%i",&n); } glutinit(&argc, argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize (400, 400); glutinitwindowposition (100, 100); glutcreatewindow ("circle"); init (); glutdisplayfunc(display); glutmainloop(); return 0; /* ANSI C requires main to return int. */ 5
26 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input.
27 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input. sscanf takes input from a character string and reads it according to the specified format.
28 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input. sscanf takes input from a character string and reads it according to the specified format. argv[1] is the character string corresponding to the first command line argument.
29 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input. sscanf takes input from a character string and reads it according to the specified format. argv[1] is the character string corresponding to the first command line argument. The constant character string "%i" is the format string, telling the function that the input string represents an integer.
30 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input. sscanf takes input from a character string and reads it according to the specified format. argv[1] is the character string corresponding to the first command line argument. The constant character string "%i" is the format string, telling the function that the input string represents an integer. The third argument, &n, is a pointer to the integer variable n which is the value of the integer which was read.
31 Consider the following line of code: if (argc == 2) sscanf(argv[1],"%i",&n); The function sscanf(...) is one of the C input functions. There are several, which do formatted input. sscanf takes input from a character string and reads it according to the specified format. argv[1] is the character string corresponding to the first command line argument. The constant character string "%i" is the format string, telling the function that the input string represents an integer. The third argument, &n, is a pointer to the integer variable n which is the value of the integer which was read. The man page for scanf gives descriptions of sscanf and related I/O functions. 6
32 Simple animation
33 Simple animation Animation is achieved by redrawing the screen repeatedly.
34 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory.
35 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped.
36 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped. Without double buffering the contents of the framebuffer can be changed while being copied to the screen. This can cause serious artefacts.
37 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped. Without double buffering the contents of the framebuffer can be changed while being copied to the screen. This can cause serious artefacts. Another animation-supporting feature of GLUT is glutpostdisplay a function which posts an event, causing the display to be redrawn.
38 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped. Without double buffering the contents of the framebuffer can be changed while being copied to the screen. This can cause serious artefacts. Another animation-supporting feature of GLUT is glutpostdisplay a function which posts an event, causing the display to be redrawn. The following additions to the display and main functions show a very simple animation of the previous example, in which the color of the square is changed randomly.
39 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped. Without double buffering the contents of the framebuffer can be changed while being copied to the screen. This can cause serious artefacts. Another animation-supporting feature of GLUT is glutpostdisplay a function which posts an event, causing the display to be redrawn. The following additions to the display and main functions show a very simple animation of the previous example, in which the color of the square is changed randomly. The random color change is accomplished with the following change to the function display():
40 Simple animation Animation is achieved by redrawing the screen repeatedly. The GLUT interface to OpenGL has features to assist in animation. One is to double buffer the display memory. With double buffering there are two separate framebuffers. One buffer is displayed while drawing operations are applied to the other buffer. After all drawing is complete, the buffers are simply swapped. Without double buffering the contents of the framebuffer can be changed while being copied to the screen. This can cause serious artefacts. Another animation-supporting feature of GLUT is glutpostdisplay a function which posts an event, causing the display to be redrawn. The following additions to the display and main functions show a very simple animation of the previous example, in which the color of the square is changed randomly. The random color change is accomplished with the following change to the function display(): glcolor3i (rand(), rand(), rand()); 7
41 The double buffering and the re-running of the display() function are effected by the following:
42 The double buffering and the re-running of the display() function are effected by the following: glutswapbuffers(); glutpostredisplay();
43 The double buffering and the re-running of the display() function are effected by the following: glutswapbuffers(); glutpostredisplay(); The C function
44 The double buffering and the re-running of the display() function are effected by the following: glutswapbuffers(); glutpostredisplay(); The C function usleep(100000);
45 The double buffering and the re-running of the display() function are effected by the following: glutswapbuffers(); glutpostredisplay(); The C function usleep(100000); suspends execution of the process for microseconds (0.1 seconds). 8
46 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */
47 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand());
48 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand()); glbegin(gl_polygon); glvertex3f (0.25, 0.25, 0.0); glvertex3f (0.75, 0.25, 0.0); glvertex3f (0.75, 0.75, 0.0); glvertex3f (0.25, 0.75, 0.0); glend(); /* start processing buffered OpenGL routines */
49 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand()); glbegin(gl_polygon); glvertex3f (0.25, 0.25, 0.0); glvertex3f (0.75, 0.25, 0.0); glvertex3f (0.75, 0.75, 0.0); glvertex3f (0.25, 0.75, 0.0); glend(); /* start processing buffered OpenGL routines */ glflush ();
50 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand()); glbegin(gl_polygon); glvertex3f (0.25, 0.25, 0.0); glvertex3f (0.75, 0.25, 0.0); glvertex3f (0.75, 0.75, 0.0); glvertex3f (0.25, 0.75, 0.0); glend(); /* start processing buffered OpenGL routines */ glflush (); glutswapbuffers();
51 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand()); glbegin(gl_polygon); glvertex3f (0.25, 0.25, 0.0); glvertex3f (0.75, 0.25, 0.0); glvertex3f (0.75, 0.75, 0.0); glvertex3f (0.25, 0.75, 0.0); glend(); /* start processing buffered OpenGL routines */ glflush (); glutswapbuffers(); usleep(100000);
52 void display(void) { /* clear all pixels */ glclear (GL_COLOR_BUFFER_BIT); /* draw random color rectangle with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */ glcolor3i (rand(), rand(), rand()); glbegin(gl_polygon); glvertex3f (0.25, 0.25, 0.0); glvertex3f (0.75, 0.25, 0.0); glvertex3f (0.75, 0.75, 0.0); glvertex3f (0.25, 0.75, 0.0); glend(); /* start processing buffered OpenGL routines */ glflush (); glutswapbuffers(); usleep(100000); glutpostredisplay(); } 9
53 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (double buffer and RGBA). * Open window with "new_hello" in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ { glutinit(&argc, argv);
54 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (double buffer and RGBA). * Open window with "new_hello" in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ { glutinit(&argc, argv); glutinitdisplaymode (GLUT DOUBLE GLUT RGB);
55 int main(int argc, char** argv) /* * Declare initial window size, position, and * display mode (double buffer and RGBA). * Open window with "new_hello" in its title bar. * Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ { glutinit(&argc, argv); glutinitdisplaymode (GLUT DOUBLE GLUT RGB); } glutinitwindowsize (250, 250); glutinitwindowposition (100, 100); glutcreatewindow ("new_hello"); init (); glutdisplayfunc(display); glutmainloop(); return 0; /* ANSI C requires main to return int. */ 10
C++ 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 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 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 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 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 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 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 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 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 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 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 informationBob s Concise Introduction to Doxygen
Bob s Concise Introduction to Doxygen by Robert S Laramee Visual and Interactive Computing Group Department of Computer Science Swansea University Swansea, Wales, UK 1 Comment Standard February 14, 2011
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 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 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 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 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 informationAbel 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 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 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 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 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 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 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 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 informationCOS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15
COS340A Assignment 1 I Pillemer Student# 3257 495 9 March 25 th 2007 p1/15 Assignment 1 I Pillemer Student#: 3257 495 9 COS340A Date submitted: March 25, 2007 Question 1... p2 3 Question 2... p4 Question
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 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 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 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. 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 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 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 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 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 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 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 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 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 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 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 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 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 informationCS Computer Graphics: OpenGL, Continued
CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.
More informationCS Computer Graphics: OpenGL, Continued
CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.
More information1/12/11. Basic Graphics Programming. What is OpenGL. OpenGL is cross-platform. How does OpenGL work. How does OpenGL work (continued) The result
CSCI 480 Computer raphics Lecture 2 asic raphics Programming What is OpenL A low- level graphics API for 2D and 3D interac
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 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 information2 Transformations and Homogeneous Coordinates
Brief solutions to Exam in Computer Graphics Time and place: 08:00 3:00 Tuesday March 7, 2009, Gimogatan 4, sal Grades TD388: 3: 20pts; 4: 26pts; 5: 34pts. Glossary API Application Programmer s Interface.
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 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 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 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 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 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 informationCS 432 Interactive Computer Graphics
CS 432 Interactive Computer Graphics Lecture 1 Part 3 Anatomy of OpenGL Programs Matt Burlick - Drexel University - CS 432 1 Reading Angel Chapter 2 Red Book Chapter 4 Matt Burlick - Drexel University
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 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 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 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 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 informationInput and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs.
Input and Interaction Chapter 3 Introduction: - We now turn to the development of interactive graphics programs. - Our discussion has three main parts First, we consider the variety of devices available
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 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 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 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 informationCS Computer Graphics: Intro to OpenGL
CS 543 - Computer Graphics: Intro to OpenGL by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) OpenGL Basics Last time: What is Computer Graphics? What is a graphics library What to expect
More informationCS Computer Graphics: Intro to OpenGL
CS 543 - Computer Graphics: Intro to OpenGL by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) OpenGL Basics Last time: What is Computer Graphics? What is a graphics library What to expect
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 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 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 informationFourier Series. Given a periodic function, x(t), (-T <t <T): + b n sin n t T. a n cos n t T. 2 a 0 + Z T. a n = 1 T. x(t) cos n t T. b n = 1 T.
x(t) = 1 1X 2 a 0 + Fourier Series Given a periodic function, x(t), (-T
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 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 informationOpenGL JOGL. OpenGL & JOGL. Shaoting Zhang, or Tony. September 12, 2007
September 12, 2007 1 Program 2 HW: Graphing in I m Program Cross-language (C, C++, C#, Java, Python, Delphi) Cross-platform (Linux, Windows, Unix, PS3) Low-level (provides only rendering func.) State machine
More informationFAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL
FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM 3213 - INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4 C++ - OpenGL Part 1- C++ - Texture Mapping 1. Download texture file and put it into your current folder
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 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 informationOverview of Graphics Systems Hearn & Baker Chapter 2. Some slides are taken from Robert Thomsons notes.
Overview of Graphics Systems Hearn & Baker Chapter 2 Some slides are taken from Robert Thomsons notes. OVERVIEW Video Display Devices Raster Scan Systems Graphics Workstations and Viewing Systems Input
More information(21) OpenGL GUI. OpenGL GUI 1 UNIX MAGAZINE UNIX. SGI (Silicon Graphics Inc.) Windows PC GUI. UNIX Windows GUI. Java. 1 prefposition() X X
(21) OpenGL GUI UNIX Windows Macintosh UNIX Windows PC SGI (Silicon Graphics Inc.) Windows PC GUI UNIX Windows GUI Java OpenGL OpenGL SGI 3 / GL GUI OpenGL GL OpenGL SGI 3 GL SGI 3 / 3 1 GL /* GL sample
More information1.2 Basic Graphics Programming
Fall 2018 CSCI 420: Computer Graphics 1.2 Basic Graphics Programming Hao Li http://cs420.hao-li.com 1 Last time Last Time Story Computer Graphics Image Last Time 3D Printing 3D Capture Animation Modeling
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 informationInput and Interaction
Input and Interaction Interactive program is something make CG look interesting Suriyong L., Computer Multimedia 1 Physical Input Devices 2 Types Pointing devices Locate or indicate position on screen
More informationCSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science
CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming GLUT 2 Events in OpenGL Event Example Keypress KeyDown KeyUp Mouse leftbuttondown leftbuttonup With mouse
More informationUlf Assarsson Department of Computer Engineering Chalmers University of Technology
Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1. I am located in room 4115 in EDIT-huset 2. Email: 3. Phone: 031-772 1775 (office) 4. Course assistant: Tomas Akenine-Mőller
More informationVR-programming tools (procedural) More VRML later in this course! (declarative)
Realtime 3D Computer Graphics & Virtual Reality OpenGL Introduction VR-programming Input and display devices are the main hardware interface to users Immersion embeds users through the generation of live-like
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 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 informationComputer Graphics (CS 543) Lecture 1 (Part 2): Introduction to OpenGL/GLUT (Part 1)
Computer Graphics (CS 543) Lecture 1 (Part 2): Introduction to OpenGL/GLUT (Part 1) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) OpenGL/GLUT Installation OpenGL: Specific
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 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 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 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 informationLectures Display List
Lectures Display List 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 it? What
More informationOpenGL Introduction Computer Graphics and Visualization
Fall 2009 2 OpenGL OpenGL System Interaction Portable Consistent visual display regardless of hardware, OS and windowing system Callable from Ada, C, C++, Fortran, Python, Perl and Java Runs on all major
More information... Print PROGRAMS\Final Project final\planes\planeshoot.c 1
... Print PROGRAMS\Final Project final\planes\planeshoot.c 1 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include
More informationChapter 13 Selection and Feedback
OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 13 Selection and Feedback Chapter Objectives After reading this chapter, you ll be able to do the following: Create applications that
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
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 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 information