1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib

Size: px
Start display at page:

Download "1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib"

Transcription

1 1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib 11 opencv_highgui240d.lib 12 opencv_video240d.lib 13 - > - > - > 14 ( ) 15 PATH=C:\opencv\build\x86\vc10\bin;C:\opencv\build\common\tbb\ia32\vc10;%PATH% 16 */ 17 #include <stdio.h> 18 #include <opencv2/opencv.hpp > int main(void) 21 { 22 // image 23 IplImage *image = cvcreateimage(cvsize(640,480), IPL_DEPTH_8U, 3); // p i c t u r e "sample.jpg" 26 IplImage *picture = cvloadimage("sample.jpg", CV_LOAD_IMAGE_COLOR); // p i c t u r e c I m a g e R e s u l t 29 cvresize(picture, image, CV_INTER_LINEAR); // "My Window" 32 cvnamedwindow ("My Window", CV_WINDOW_AUTOSIZE); cvshowimage("my Window", image); // image "My Window" cvwaitkey (0); // cvdestroyallwindows (); // return 0; 41 } 1

2 2. Program 2 (OpenGL Sample012) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib 11 opencv_highgui240d.lib 12 opencv_video240d.lib 13 - > - > - > 14 ( ) 15 PATH=C:\opencv\build\x86\vc10\bin;C:\opencv\build\common\tbb\ia32\vc10;%PATH% 16 */ 17 #include <stdio.h> #include <opencv2/opencv.hpp > #include <GL/glut.h> #define SQUARE_TEXTURE 1 24 #define SPHERE_TEXTURE // 27 static int MouseX = 0; // X 28 static int MouseY = 0; // Y 29 static float SpinX = 0; // X 30 static float SpinY = 0; // Y 31 static float Scale = 1.0; // static int MouseLB_ON=0; // 34 static int MouseRB_ON=0; // void mouse(int button, int state, int x, int y) 37 { 38 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN){ 39 MouseLB_ON = 1; printf("(%3d,%3d) \ n", x, y); 40 }else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP){ 41 MouseLB_ON = 0; printf("(%3d,%3d) \ n", x, y); 42 }else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN){ 43 MouseRB_ON = 1; printf("(%3d,%3d) \ n", x, y); 44 }else if (button == GLUT_RIGHT_BUTTON && state == GLUT_UP){ 45 MouseRB_ON = 0; printf("(%3d,%3d) \ n", x, y); 46 } 47 } void dragmotion(int x, int y) 50 { 51 if (MouseLB_ON == 1){ 52 printf("(%3d,%3d)...\ n", x, y); 53 // 54 SpinX += x - MouseX; 55 SpinY += y - MouseY; 56 // 57 MouseX = x; 58 MouseY = y; 59 glutpostredisplay (); 60 } 61 else if (MouseRB_ON == 1){ 62 printf("(%3d,%3d)...\ n", x, y); 63 // 64 Scale += (float)(y - MouseY )/100; 65 // 66 MouseX = x; 67 MouseY = y; 68 glutpostredisplay (); 69 } 70 } void reshape(int w, int h) // R e s h a p e 73 { 74 glviewport(0, 0, w, h); glmatrixmode(gl_projection); 77 glloadidentity (); 78 gluperspective (30.0, (double)w/h, 1.0, 100.0); // glmatrixmode(gl_modelview); 81 glloadidentity (); 82 glulookat(5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); // 83 } 84 2

3 85 void display(void) // D i s p l a y 86 { 87 glclearcolor(0.0, 0.0, 0.0, 1.0); // 88 glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // 89 glenable(gl_depth_test); // // 92 glpushmatrix(); 93 glrotatef(spinx, 1.0, 0.0, 0.0); // X S p i n X 94 glrotatef(spiny, 0.0, 1.0, 0.0); // Y S p i n Y 95 glscalef(scale, Scale, Scale); // S c a l e glcalllist(square_texture); // A 98 //glcalllist(sphere_texture); // B 99 glpopmatrix(); // 102 glpushmatrix(); // X 103 GLfloat mat1diff[] = { 0.6, 0.2, 0.2, 1.0 }; // 104 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat1diff); 105 glnormal3f(0.0, 1.0, 0.0); // 106 glbegin(gl_lines); 107 glvertex3f (0.0f, 0.0f, 0.0f); 108 glvertex3f (2.0f, 0.0f, 0.0f); 109 glend(); 110 glpopmatrix(); 111 glpushmatrix(); // Y 112 GLfloat mat2diff[] = { 0.2, 0.6, 0.2, 1.0 }; // 113 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat2diff); 114 glnormal3f(0.0, 1.0, 0.0); // 115 glbegin(gl_lines); 116 glvertex3f (0.0f, 0.0f, 0.0f); 117 glvertex3f (0.0f, 2.0f, 0.0f); 118 glend(); 119 glpopmatrix(); 120 glpushmatrix(); // Z 121 GLfloat mat3diff[] = { 0.2, 0.2, 0.6, 1.0 }; // 122 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat3diff); 123 glnormal3f(0.0, 1.0, 0.0); // 124 glbegin(gl_lines); 125 glvertex3f (0.0f, 0.0f, 0.0f); 126 glvertex3f (0.0f, 0.0f, 2.0f); 127 glend(); 128 glpopmatrix(); glutswapbuffers (); // 131 } void lightinit(void) // ( ) 134 { 135 glenable(gl_lighting); // 136 glenable(gl_light0); //0 (8 ) 137 glenable(gl_normalize); // GLfloat light0pos[] = { 0.0, 5.0, 0.0, 1.0 }; 140 gllightfv(gl_light0, GL_POSITION, light0pos); // GLfloat light0ambi[] = { 0.2, 0.2, 0.2, 1.0 }; 143 gllightfv(gl_light0, GL_AMBIENT, light0ambi); // GLfloat light0diff[] = { 0.8, 0.8, 0.8, 1.0 }; 145 gllightfv(gl_light0, GL_DIFFUSE, light0diff); // GLfloat light0spec[] = { 0.5, 0.5, 0.5, 1.0 }; 147 gllightfv(gl_light0, GL_SPECULAR, light0spec); // glshademodel(gl_smooth); // 150 } // A( ) 153 void makemodela(unsigned char *image, int size_x, int size_y) 154 { 155 GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; // GLuint texture; 158 glgentextures(1, &texture); // 159 glbindtexture(gl_texture_2d, texture); // ( ) gltexparameteri(gl_texture_2d,gl_texture_mag_filter,gl_linear); // ( ) 162 gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear); // ( ) 163 // 164 glubuild2dmipmaps(gl_texture_2d, 3, size_x, size_y, GL_RGB, GL_UNSIGNED_BYTE, image); /* ( ) */ 167 glnewlist(square_texture, GL_COMPILE); 168 glpushmatrix(); 169 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, white); 170 glenable(gl_texture_2d); 171 glbegin(gl_polygon); 172 glnormal3f(0.0, 1.0, 0.0); // 3

4 173 gltexcoord2f(0.0, 1.0); glvertex3f( 1.0, 0.0, 1.0); 174 gltexcoord2f(0.0, 0.0); glvertex3f(-1.0, 0.0, 1.0); 175 gltexcoord2f(1.0, 0.0); glvertex3f(-1.0, 0.0,-1.0); 176 gltexcoord2f(1.0, 1.0); glvertex3f( 1.0, 0.0,-1.0); 177 glend(); 178 gldisable(gl_texture_2d); 179 glpopmatrix(); 180 glendlist(); return; 183 } // B 186 void makemodelb(unsigned char *image, int size_x, int size_y) 187 { 188 GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; // GLuint texture; 191 glgentextures(1, &texture); // 192 glbindtexture(gl_texture_2d, texture); // ( ) gltexparameteri(gl_texture_2d,gl_texture_mag_filter,gl_linear); // ( ) 195 gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear); // ( ) 196 // 197 glubuild2dmipmaps(gl_texture_2d, 3, size_x, size_y, GL_RGB, GL_UNSIGNED_BYTE, image); GLUquadricObj* sphere; 200 sphere = glunewquadric (); 201 gluquadricdrawstyle(sphere, GLU_FILL); 202 gluquadricnormals(sphere, GLU_SMOOTH); 203 gluquadrictexture(sphere, GL_TRUE); /* ( ) */ 206 glnewlist(sphere_texture, GL_COMPILE); 207 glpushmatrix(); 208 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, white); 209 glenable(gl_texture_2d); 210 glusphere(sphere, 1.0, 32, 32); 211 gldisable(gl_texture_2d); 212 glpopmatrix(); 213 glendlist(); return; 216 } int main(int argc, char *argv[]) 219 { 220 // OpenCV Initialize 221 // 222 IplImage *teximage = cvloadimage("texture.bmp",1); 223 unsigned char image [128][128][3]; 224 for(int x=0;x<128;x++){ 225 for(int y=0;y<128;y++){ 226 image[x][y][2]=teximage ->imagedata [128*y*3+x*3+0];/* B */ 227 image[x][y][1]=teximage ->imagedata [128*y*3+x*3+1];/* G */ 228 image[x][y][0]=teximage ->imagedata [128*y*3+x*3+2];/* R */ 229 } } // 232 cvnamedwindow("opencv Window", CV_WINDOW_AUTOSIZE ); 233 cvshowimage("opencv Window", teximage); 234 cvwaitkey (1); // OpenGL Initialize 237 glutinit(&argc, argv); // G L U T 238 glutinitdisplaymode(glut_rgba GLUT_DOUBLE GLUT_DEPTH); 239 glutinitwindowsize(640, 480); // 240 glutcreatewindow("window"); // 241 glutreshapefunc(reshape); // R e s h a p e 242 glutdisplayfunc(display); // D i s p l a y glutmousefunc(mouse); // 245 glutmotionfunc(dragmotion); // lightinit(); // ( ) makemodela((unsigned char *)image, 128, 128); // C G 250 makemodelb((unsigned char *)image, 128, 128); // C G // ( g l u t m y I d l e ) 253 glutmainloop(); // // OpenCV Finalize 256 cvdestroywindow( "OpenCV Window" ); return 0; 259 } 4

5 Program 3 (OpenGL Sample013) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib 11 opencv_highgui240d.lib 12 opencv_video240d.lib 13 - > - > - > 14 ( ) 15 PATH=C:\opencv\build\x86\vc10\bin;C:\opencv\build\common\tbb\ia32\vc10;%PATH% 16 */ 17 #include <stdio.h> #include <opencv2/opencv.hpp > #include <GL/glut.h> // ID 24 #define TEXTURE_STARS #define TEXTURE_EARTH // ID 28 #define SQUARE_TEXTURE 1 29 #define SPHERE_TEXTURE // 32 static int MouseX = 0; // X 33 static int MouseY = 0; // Y 34 static float SpinX = 0; // X 35 static float SpinY = 0; // Y 36 static float Scale = 1.0; // static int MouseLB_ON=0; // 39 static int MouseRB_ON=0; // void mouse(int button, int state, int x, int y) 42 { 43 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN){ 44 MouseLB_ON = 1; printf("(%3d,%3d) \ n", x, y); 45 }else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP){ 46 MouseLB_ON = 0; printf("(%3d,%3d) \ n", x, y); 47 }else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN){ 48 MouseRB_ON = 1; printf("(%3d,%3d) \ n", x, y); 49 }else if (button == GLUT_RIGHT_BUTTON && state == GLUT_UP){ 50 MouseRB_ON = 0; printf("(%3d,%3d) \ n", x, y); 51 } 52 } void dragmotion(int x, int y) 55 { 56 if (MouseLB_ON == 1){ 57 printf("(%3d,%3d)...\ n", x, y); 58 // 59 SpinX += x - MouseX; 60 SpinY += y - MouseY; 61 // 62 MouseX = x; 63 MouseY = y; 64 glutpostredisplay (); 65 } 66 else if (MouseRB_ON == 1){ 67 printf("(%3d,%3d)...\ n", x, y); 68 // 69 Scale += (float)(y - MouseY )/100; 70 // 71 MouseX = x; 72 MouseY = y; 73 glutpostredisplay (); 74 } 75 } void reshape(int w, int h) // R e s h a p e 78 { 79 glviewport(0, 0, w, h); 80 glmatrixmode(gl_projection); 81 glloadidentity (); 82 gluperspective (30.0, (double)w/h, 1.0, 100.0); // glmatrixmode(gl_modelview); 85 glloadidentity (); 86 glulookat(5.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); // 87 } 5

6 88 89 void display(void) // D i s p l a y 90 { 91 glclearcolor(0.0, 0.0, 0.0, 1.0); // 92 glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // 93 glenable(gl_depth_test); // // 96 glpushmatrix(); 97 gltranslatef(-1.0,0.0, -1.0); 98 glrotatef(45.0, 0.0, 1.0, 0.0); // Y S p i n Y 99 glscalef(3.0, 3.0, 3.0); // S c a l e 100 glbindtexture(gl_texture_2d, TEXTURE_STARS); // ( ) 101 glcalllist(square_texture); // A 102 glpopmatrix(); // 105 glpushmatrix(); 106 glrotatef(spinx, 1.0, 0.0, 0.0); // X S p i n X 107 glrotatef(spiny, 0.0, 1.0, 0.0); // Y S p i n Y 108 glscalef(scale, Scale, Scale); // S c a l e 109 glbindtexture(gl_texture_2d, TEXTURE_EARTH); // ( ) 110 glcalllist(sphere_texture); // B 111 glpopmatrix(); // 114 glpushmatrix(); // X 115 GLfloat mat1diff[] = { 0.6, 0.2, 0.2, 1.0 }; // 116 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat1diff); 117 glnormal3f(0.0, 1.0, 0.0); // 118 glbegin(gl_lines); 119 glvertex3f (0.0f, 0.0f, 0.0f); 120 glvertex3f (2.0f, 0.0f, 0.0f); 121 glend(); 122 glpopmatrix(); 123 glpushmatrix(); // Y 124 GLfloat mat2diff[] = { 0.2, 0.6, 0.2, 1.0 }; // 125 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat2diff); 126 glnormal3f(0.0, 1.0, 0.0); // 127 glbegin(gl_lines); 128 glvertex3f (0.0f, 0.0f, 0.0f); 129 glvertex3f (0.0f, 2.0f, 0.0f); 130 glend(); 131 glpopmatrix(); 132 glpushmatrix(); // Z 133 GLfloat mat3diff[] = { 0.2, 0.2, 0.6, 1.0 }; // 134 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, mat3diff); 135 glnormal3f(0.0, 1.0, 0.0); // 136 glbegin(gl_lines); 137 glvertex3f (0.0f, 0.0f, 0.0f); 138 glvertex3f (0.0f, 0.0f, 2.0f); 139 glend(); 140 glpopmatrix(); glutswapbuffers (); // 143 } void lightinit(void) // ( ) 146 { 147 glenable(gl_lighting); // 148 glenable(gl_light0); //0 (8 ) 149 glenable(gl_normalize); // GLfloat light0pos[] = { 0.0, 5.0, 0.0, 1.0 }; 152 gllightfv(gl_light0, GL_POSITION, light0pos); // GLfloat light0ambi[] = { 0.2, 0.2, 0.2, 1.0 }; 155 gllightfv(gl_light0, GL_AMBIENT, light0ambi); // GLfloat light0diff[] = { 0.8, 0.8, 0.8, 1.0 }; 157 gllightfv(gl_light0, GL_DIFFUSE, light0diff); // GLfloat light0spec[] = { 0.5, 0.5, 0.5, 1.0 }; 159 gllightfv(gl_light0, GL_SPECULAR, light0spec); // glshademodel(gl_smooth); // 162 } void loadtexture(void) 165 { 166 // O p e n C V 167 // 168 IplImage *_teximage1 = cvloadimage("texture1.jpg", 1); 169 // (( n )*( n ) ) 170 IplImage *teximage1 = cvcreateimage(cvsize(768,512), IPL_DEPTH_8U,3); 171 cvresize(_teximage1, teximage1); 172 cvflip(teximage1, teximage1, 0);// 173 cvcvtcolor(teximage1, teximage1, CV_BGR2RGB); // B G R R G B 174 cvnamedwindow("opencv Window 1", CV_WINDOW_AUTOSIZE ); 175 cvshowimage("opencv Window 1", _teximage1); cvwaitkey (1); 6

7 176 // 177 glbindtexture(gl_texture_2d, TEXTURE_STARS); // 178 gltexparameteri(gl_texture_2d,gl_texture_mag_filter,gl_linear); // ( ) 179 gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear); // ( ) 180 // 181 glubuild2dmipmaps(gl_texture_2d, 3, 768, 512, GL_RGB, GL_UNSIGNED_BYTE, teximage1 ->imagedata); 182 // 183 cvreleaseimage(&teximage1); // 186 IplImage *_teximage2 = cvloadimage("texture2.jpg", 1); 187 // (( n )*( n ) ) 188 IplImage *teximage2 = cvcreateimage(cvsize(1024,512), IPL_DEPTH_8U,3); 189 cvresize(_teximage2, teximage2); 190 cvflip(teximage2, teximage2, 0); // 191 cvcvtcolor(teximage2, teximage2, CV_BGR2RGB); // B G R R G B 192 cvnamedwindow("opencv Window 2", CV_WINDOW_AUTOSIZE ); 193 cvshowimage("opencv Window 2", _teximage2); cvwaitkey (1); 194 // 195 glbindtexture(gl_texture_2d, TEXTURE_EARTH); // 196 gltexparameteri(gl_texture_2d,gl_texture_mag_filter,gl_linear); // ( ) 197 gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear); // ( ) 198 // 199 glubuild2dmipmaps(gl_texture_2d, 3, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, teximage2 ->imagedata); 200 // 201 cvreleaseimage(&teximage2); return; 204 } // A( ) 207 void makemodela(void) 208 { 209 GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; // /* ( ) */ 212 glnewlist(square_texture, GL_COMPILE); 213 glpushmatrix(); 214 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, white); 215 glenable(gl_texture_2d); 216 glbegin(gl_polygon); 217 glnormal3f(0.0, 1.0, 0.0); // 218 gltexcoord2f(1.0, 1.0); glvertex3f( 1.0, 1.0, 0.0); 219 gltexcoord2f(0.0, 1.0); glvertex3f(-1.0, 1.0, 0.0); 220 gltexcoord2f(0.0, 0.0); glvertex3f(-1.0, -1.0,0.0); 221 gltexcoord2f(1.0, 0.0); glvertex3f( 1.0, -1.0,0.0); 222 glend(); 223 gldisable(gl_texture_2d); 224 glpopmatrix(); 225 glendlist(); return; 228 } // B 231 void makemodelb(void) 232 { 233 GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; // GLUquadricObj* sphere; 236 sphere = glunewquadric (); 237 gluquadricdrawstyle(sphere, GLU_FILL); 238 gluquadricnormals(sphere, GLU_SMOOTH); 239 gluquadrictexture(sphere, GL_TRUE); /* ( ) */ 242 glnewlist(sphere_texture, GL_COMPILE); 243 glpushmatrix(); 244 glmaterialfv(gl_front_and_back, GL_AMBIENT_AND_DIFFUSE, white); 245 glenable(gl_texture_2d); 246 glusphere(sphere, 1.0, 32, 32); 247 gldisable(gl_texture_2d); 248 glpopmatrix(); 249 glendlist(); return; 252 } int main(int argc, char *argv[]) 255 { //************************************************************* 258 // OpenGL Initialize 259 //************************************************************* 260 glutinit(&argc, argv); // G L U T 261 glutinitdisplaymode(glut_rgba GLUT_DOUBLE GLUT_DEPTH); 262 glutinitwindowsize(640, 480); // 263 glutcreatewindow("window"); // 7

8 264 glutreshapefunc(reshape); // R e s h a p e 265 glutdisplayfunc(display); // D i s p l a y glutmousefunc(mouse); // 268 glutmotionfunc(dragmotion); // lightinit(); // ( ) loadtexture(); // 273 makemodela(); // C G 274 makemodelb(); // C G //************************************************************* 277 // ( g l u t m y I d l e ) 278 //************************************************************* 279 glutmainloop(); // 280 // //************************************************************* 283 // OpenCV Finalize 284 //************************************************************* 285 cvdestroyallwindows (); return 0; 288 } 8

20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:

20 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 information

OpenGL for dummies hello.c #include int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize (250, 250); glutinitwindowposition

More information

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

FAKULTI 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 information

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

// 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 information

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process Outline 433-380 Graphics and Computation Introduction to OpenGL OpenGL Background and History Other Graphics Technology Drawing Viewing and Transformation Lighting GLUT Resources Some images in these slides

More information

Graphics and Computation Introduction to OpenGL

Graphics and Computation Introduction to OpenGL 433-380 Graphics and Computation Introduction to OpenGL Some images in these slides are taken from The OpenGL Programming Manual, which is copyright Addison Wesley and the OpenGL Architecture Review Board.

More information

Computer graphics MN1

Computer 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 information

Introduction to OpenGL

Introduction 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 information

Computer graphics MN1

Computer 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 information

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

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 information

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

CS559: 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 information

Introduction to OpenGL

Introduction 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 information

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Books, 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 information

1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Andrew Yenalavitch CSE520 Winter 2015 Quiz 2 Report 1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Use the following provided image for the texture:

More information

Computer graphics MN1

Computer 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 information

C OMPUTER G RAPHICS Thursday

C 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 information

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

To 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 information

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Books, 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 information

1) Here is the various stages of the tetrahedron:

1) Here is the various stages of the tetrahedron: Andrew Yenalavitch Homework 3 CSE 520 - Winter 2015 1) ( 20 points ) Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape.

More information

Order of Transformations

Order of Transformations Order of Transformations Because the same transformation is applied to many vertices, the cost of forming a matrix M=ABCD is not significant compared to the cost of computing Mp for many vertices p Note

More information

Philip Calderon CSE 520 Lab 3 Color Shader

Philip Calderon CSE 520 Lab 3 Color Shader Philip Calderon CSE 520 Lab 3 Color Shader Summary: The purpose of lab 4 is to produce a pyramid tetrahedron that we are able to rotate it when clicked. Part 1: Color Tetrahedron Part 2: Rotation to show

More information

Using OpenGL with CUDA

Using 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 information

Pearce Outline. OpenGL Background and History. Other Graphics Technology. Platform Specifics. The Drawing Process

Pearce Outline. OpenGL Background and History. Other Graphics Technology. Platform Specifics. The Drawing Process Outline 433-380 Graphics and Computation Introduction to OpenGL OpenGL Background and History Other Graphics Technology Drawing Viewing and Transformation Lighting JOGL and GLUT Resources Some images in

More information

Scientific Visualization Basics

Scientific Visualization Basics Scientific Visualization Basics Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Dept. of Computer Science, Dept. of Physics & Astronomy, Dept. of Chemical Engineering & Materials Science,

More information

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Modeling 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 information

Lecture 3. Understanding of OPenGL programming

Lecture 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 information

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Duc 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 information

Erik Anchondo cse 520 lab 4

Erik Anchondo cse 520 lab 4 Erik Anchondo 2-6-19 cse 520 lab 4 1. Wrote a glsl program that displays a colored tetrahedron. The tetrahedron starts to rotate on the x axis when the mouse button is clicked once. If the mouse button

More information

COMPSCI 373 S1 C - Assignment 2 Sample Solution

COMPSCI 373 S1 C - Assignment 2 Sample Solution COMPSCI 373 S1 C Assignment 2 Sample Solution 1 of 17 Computer Science COMPSCI 373 S1 C - Assignment 2 Sample Solution This assignment is worth 8.3333% of your final grade. 1. 3D Modelling and Texture

More information

Programming Graphic Processing Units with CUDA. Paolo Burgio

Programming Graphic Processing Units with CUDA. Paolo Burgio Programming Graphic Processing Units with CUDA Paolo Burgio paolo.burgio@unimore.it Graphics Processing Units (Co-)processor devoted to graphics Built as "monolithical" chip Integrated as co-processor

More information

Interaction Computer Graphics I Lecture 3

Interaction 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 information

Rendering Pipeline/ OpenGL

Rendering Pipeline/ OpenGL Chapter 2 Basics of Computer Graphics: Your tasks for the weekend Piazza Discussion Group: Register Post review questions by Mon noon Use private option, rev1 tag Start Assignment 1 Test programming environment

More information

IntMu.Lab5. Download all the files available from

IntMu.Lab5. Download all the files available from IntMu.Lab5 0. Download all the files available from http://www.dee.isep.ipp.pt/~jml/intmu/lab5: wget http://www.dee.isep.ipp.pt/~jml/intmu/lab5/makefile make getall Analyze the program windmill.c. Compile

More information

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero.

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero. REGULATIONS Due date: 19.11.2009 Thursday 23:59 Late Submission: Late submission is not allowed. Submission: Use the COW system to submit your homework file. The homework should be done and submitted individually.

More information

Display Lists in OpenGL

Display 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 information

Lighting. Chapter 5. Chapter Objectives. After reading this chapter, you'll be able to do the following:

Lighting. Chapter 5. Chapter Objectives. After reading this chapter, you'll be able to do the following: Chapter 5 Lighting Chapter Objectives After reading this chapter, you'll be able to do the following: Understand how real-world lighting conditions are approximated by OpenGL Render illuminated objects

More information

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

Cameras (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 information

compatibility mode core mode

compatibility mode core mode Using the GLUT This document provides a more detailed description of the minimum steps necessary to write build and execute an OpenGL 3D application that runs on the three desktop platforms Windows, OSX

More information

OpenGL and X, Column 1: An OpenGL Toolkit

OpenGL and X, Column 1: An OpenGL Toolkit Copyright c 1994 Mark J. Kilgard. All rights reserved. PUBLISHED IN THE NOVEMBER/DECEMBER 1994 ISSUE OF The X Journal. OpenGL and X, Column 1: An OpenGL Toolkit Mark J. Kilgard Silicon Graphics Inc. November

More information

Transformation, Input and Interaction. Hanyang University

Transformation, 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 information

OPENGL TM AND X, COLUMN 1: AN OPENGL TOOLKIT

OPENGL TM AND X, COLUMN 1: AN OPENGL TOOLKIT Copyright c1994 Mark J. Kilgard. All rights reserved. PUBLISHED IN THE NOVEMBER/DECEMBER 1994 ISSUE OF The X Journal. OPENGL TM AND X, COLUMN 1: AN OPENGL TOOLKIT Mark J. Kilgard Silicon Graphics Inc.

More information

Chapter 7 Display Lists

Chapter 7 Display Lists OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 7 Display Lists Chapter Objectives After reading this chapter, you ll be able to do the following: Understand how display lists can

More information

Understand how real-world lighting conditions are approximated by OpenGL

Understand how real-world lighting conditions are approximated by OpenGL OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 5 Lighting Chapter Objectives After reading this chapter, you ll be able to do the following: Understand how real-world lighting conditions

More information

Chapter 13 Selection and Feedback

Chapter 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 information

Precept 2 Aleksey Boyko February 18, 2011

Precept 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 information

CS 4204 Computer Graphics

CS 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 information

Interaction. CSCI 480 Computer Graphics Lecture 3

Interaction. 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 information

2a. The triangles scale increases (expands) when the 'e' key is pressed and decreases (contracts) when the 'c' key is pressed.

2a. The triangles scale increases (expands) when the 'e' key is pressed and decreases (contracts) when the 'c' key is pressed. Erik Anchondo 1-29-19 cse 520 lab 3 1. Wrote a shader program to display three colored triangles, with one of each triangle being red, green, and blue. The colors change which triangle they are applied

More information

UNIT 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 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 information

CSC 470 Computer Graphics

CSC 470 Computer Graphics CSC 470 Computer Graphics Transformations of Objects CSC 470 Computer Graphics, Dr.N. Georgieva, CSI/CUNY 1 Transformations of objects - 2D CSC 470 Computer Graphics, Dr.N. Georgieva, CSI/CUNY 2 Using

More information

yahoo.com

yahoo.com What is the workshop about? We use software such as AutoCAD, 3D Studio, Maya and many others for a host of applications ranging from Technical Drawings to Machine Design to Game Making to Special Effects

More information

Hierarchical 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: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks, Hierarchical Modeling Hofstra University 1 Modeling complex objects/motion Decompose object hierarchically

More information

Introduction to OpenGL: Part 2

Introduction 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 information

Source code: #include <iostream>

Source 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 information

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC Assignment #6 2D Vector Field Visualization Arrow Plot and LIC Due Oct.15th before midnight Goal: In this assignment, you will be asked to implement two visualization techniques for 2D steady (time independent)

More information

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

GL_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 information

Programming with OpenGL Part 3: Three Dimensions

Programming 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 information

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

CS559: 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 information

1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back.

1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back. Karl Zachary Maier CSE 520 Homework 1 1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back. /* morph.cpp */ #include #include #include

More information

Computer Graphics Introduction to OpenGL

Computer 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 information

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010) Lecture 5: Viewing CSE 40166 Computer Graphics (Fall 2010) Review: from 3D world to 2D pixels 1. Transformations are represented by matrix multiplication. o Modeling o Viewing o Projection 2. Clipping

More information

Lectures OpenGL Introduction

Lectures 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

USHTRIME NGA GRAFIKA KOMPJUTERIKE

USHTRIME NGA GRAFIKA KOMPJUTERIKE Detyra 1. // lab01.c #include #include #include GLint gjeresiadritares, lartesiadritares, N=10; void boshtet(void) int i; glcolor3f(0.198,.04,.740); glbegin(gl_lines);

More information

Visualizing Molecular Dynamics

Visualizing Molecular Dynamics Visualizing Molecular Dynamics Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Department of Computer Science Department of Physics & Astronomy Department of Chemical Engineering & Materials

More information

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections

Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections University of Liège Department of Aerospace and Mechanical engineering Computer graphics Labs: OpenGL (1/3) Geometric transformations and projections Exercise 1: Geometric transformations (Folder transf

More information

This Lecture. Why OpenGL? Introduction to OpenGL. Programmer s View

This Lecture. Why OpenGL? Introduction to OpenGL. Programmer s View Foundations of Computer Graphics Overview and Motivation This Lecture Introduction to OpenGL and simple demo code mytest1.cpp ; you compiled mytest3.cpp for HW 0 I am going to show (and write) actual code

More information

Drawing Primitives. OpenGL basics

Drawing 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 information

Computer Graphics Primitive Attributes

Computer 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 information

Lectures Display List

Lectures 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 information

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

2/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 information

Computer Graphics Course 2005

Computer 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 information

... Print PROGRAMS\Final Project final\planes\planeshoot.c 1

... 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 information

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI) Computer Graphics (CS 47) Lecture : Implementing Transformations Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Objectives Learn how to implement transformations in OpenGL

More information

Interaction. CSCI 420 Computer Graphics Lecture 3

Interaction. 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 information

Introduction to Computer Graphics with OpenGL/GLUT

Introduction 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 information

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

Computer Graphics. Transformations. CSC 470 Computer Graphics 1 Computer Graphics Transformations CSC 47 Computer Graphics 1 Today s Lecture Transformations How to: Rotate Scale and Translate 2 Introduction An important concept in computer graphics is Affine Transformations.

More information

Yazhuo Liu Homework 3

Yazhuo Liu Homework 3 Yazhuo Liu Homework 3 Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape. While it is shrinking and expanding, the color

More information

Graphics Pipeline & APIs

Graphics 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 information

To Do. Demo: Surreal (HW 3) This Lecture. Introduction to OpenGL. Outline. Foundations of Computer Graphics (Spring 2012)

To Do. Demo: Surreal (HW 3) This Lecture. Introduction to OpenGL. Outline. Foundations of Computer Graphics (Spring 2012) Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 6: OpenGL 1 http://inst.eecs.berkeley.edu/~cs184 To Do HW 1 due on Thu Must find partners for HW 2 (if problems, speak to TAs during section).

More information

Basic Graphics Programming

Basic 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 information

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Graphics 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 information

Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or

Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or Part of a Texture Image One Dimensional Textures Using

More information

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL OpenGL OpenGL OpenGL Is a mechanism to create images in a frame buffer Is an API to access that mechanism Is well specified OpenGL Is not a window system Is not a user interface Is not a display mechanism

More information

GLUT 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, 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 information

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

OpenGL 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 information

Graphics Pipeline & APIs

Graphics Pipeline & APIs 3 2 4 Graphics Pipeline & APIs CPU Vertex Processing Rasterization Processing glclear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glpushmatrix (); gltranslatef (-0.15, -0.15, solidz); glmaterialfv(gl_front,

More information

Lattice Gas Cellular Automaton Model for Fluid Flow

Lattice Gas Cellular Automaton Model for Fluid Flow Lattice Gas Cellular Automaton Model for Fluid Flow lgca.cpp // Lattice Gas Cellular Automaton Model for Fluid Flow 1 #include 3 #include 4 #include 5 using namespace std;

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. 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 information

CS D Transformation. Junqiao Zhao 赵君峤

CS D Transformation. Junqiao Zhao 赵君峤 CS10101001 3D Transformation Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University Review Translation Linear transformation

More information

CSC 240 Computer Graphics. Fall 2015 Smith College

CSC 240 Computer Graphics. Fall 2015 Smith College CSC 240 Computer Graphics Fall 2015 Smith College Outline: 11/9 Stacks revisited Shading (using normal vectors) Texture Mapping Final quiz If time: robot with two arms White background slides from Eitan

More information

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI) Computer Graphics (CS 47) Lecture : Implementing Transformations Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Objectives Learn how to implement transformations in OpenGL

More information

6. Make use of glviewport() to display two sine curves on the same screen, one on the

6. 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 information

DONALD HOUSE: CPSC 8170, FALL 2018 DESIGN OF A REAL-TIME ANIMATION PROGRAM

DONALD HOUSE: CPSC 8170, FALL 2018 DESIGN OF A REAL-TIME ANIMATION PROGRAM DONALD HOUSE: CPSC 8170, FALL 2018 DESIGN OF A REAL-TIME ANIMATION PROGRAM DEMO MODEL-VIEW-CONTROLLER DESIGN canonical.cpp The main program canonical.cpp acts as the controller, directing Model and actions

More information

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

API 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 information

Computer graphic -- Programming with OpenGL 2

Computer graphic -- Programming with OpenGL 2 Computer graphic -- Programming with OpenGL 2 OpenGL OpenGL (Open Graphics Library) a cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is typically used to interact

More information

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin Intro to OpenGL III Don Fussell Computer Science Department The University of Texas at Austin University of Texas at Austin CS354 - Computer Graphics Don Fussell Where are we? Continuing the OpenGL basic

More information

Computer Graphics Introduction to OpenGL

Computer 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 information

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf 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 information

2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-

2. 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 information