USHTRIME NGA GRAFIKA KOMPJUTERIKE
|
|
- Brice Lawrence
- 6 years ago
- Views:
Transcription
1 Detyra 1. // lab01.c #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> GLint gjeresiadritares, lartesiadritares, N=10; void boshtet(void) int i; glcolor3f(0.198,.04,.740); glbegin(gl_lines); for(i=1; i<n; i++) glvertex2i(i*gjeresiadritares/n, 0); glvertex2i(i*gjeresiadritares/n, lartesiadritares); glvertex2i(0, i*lartesiadritares/n); glvertex2i(gjeresiadritares, i*lartesiadritares/n); void vizatimi(void) glcolor3f(0.60,.40,.170); glbegin(gl_polygon); glvertex2i(5*gjeresiadritares/n, 5*lartesiadritares/N); glvertex2i(7*gjeresiadritares/n, 5*lartesiadritares/N); glvertex2i(7*gjeresiadritares/n, 8*lartesiadritares/N); glvertex2i(5*gjeresiadritares/n, 8*lartesiadritares/N); void mydisplay() glclear(gl_color_buffer_bit); boshtet(); vizatimi(); glflush(); void myreshape(int gjeresia, int lartesia) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,0.5*gjeresia,0.5*lartesia); glmatrixmode(gl_projection);
2 glortho(0, gjeresia,0, lartesia, 1, 1); gjeresiadritares=gjeresia; lartesiadritares=lartesia; glmatrixmode(gl_modelview); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize(800,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi1"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmainloop(); Detyra 2. #include <Windows.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> #define X_AXIS 0 #define Y_AXIS 1 #define Z_AXIS 2 GLfloat m=4.0; GLint N=8, translateaxis=0; GLfloat xtranslate=0.0, ytranslate=0.0, ztranslate=0.0; GLfloat translatedelta=0.1; void vizatimi(void) glcolor3f(0.160,.40,.70); glbegin(gl_polygon); glvertex2f(0.5, 0.5); glvertex2f(1.0, 0.5); glvertex2f(1.0, 1.0); glvertex2f(0.5, 1.); void boshtet(void) int i;
3 glcolor3f(0.98,.04,.70); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( m+2.0*i*m/n, m); glvertex2f( m+2.0*i*m/n, m); glvertex2f( m, m+2.0*i*m/n); glvertex2f(m, m+2.0*i*m/n); glcolor3f(.25,.25,.25); glbegin(gl_lines); glvertex2f(0, m); glvertex2f(0, m); glvertex2f( m, 0); glvertex2f(m, 0); void mydisplay(void) glclear(gl_color_buffer_bit); boshtet(); gltranslatef(xtranslate, ytranslate, ztranslate); vizatimi(); glflush(); glutswapbuffers(); void myreshape(int width, int height) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,width,height); glmatrixmode(gl_projection); glortho( 2*m, 2*m, 2*m, 2*m, m, m); glmatrixmode(gl_modelview); void mymouse(int btn, int state, int x, int y) if(btn==glut_left_button && state == GLUT_DOWN) if(translateaxis==x_axis) xtranslate =translatedelta; else if(translateaxis == Y_AXIS) ytranslate =translatedelta; else ztranslate =translatedelta; else if(btn==glut_right_button &&
4 state == GLUT_DOWN) if(translateaxis == X_AXIS) xtranslate+=translatedelta; else if(translateaxis == Y_AXIS) ytranslate+=translatedelta; else ztranslate+=translatedelta; else if(btn==glut_middle_button && state == GLUT_DOWN) translateaxis++; if(translateaxis==3) translateaxis=0; else return; mydisplay(); void main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(300,300); glutinitwindowposition(10,0); glutcreatewindow("ushtrimi 1"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmousefunc(mymouse); glutmainloop(); Detyra 3. #include <math.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> GLint N=6; GLfloat x=30.0; void boshtet(void) int i; glcolor3f(.98,.04,.70); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( x+2.0*i*x/n, x); glvertex2f( x+2.0*i*x/n, x); glvertex2f( x, x+2.0*i*x/n);
5 glvertex2f(x, x+2.0*i*x/n); glcolor3f(.25,.25,.25); glbegin(gl_lines); glvertex2f(0, x); glvertex2f(0, x); glvertex2f( x, 0); glvertex2f(x, 0); void trekendeshi(void) glbegin(gl_polygon); glcolor3f(.0,.0, 1.0); glvertex3f( 5., 5., 0.); glcolor3f(.0,.0, 1.0); glvertex3f(5., 5., 0.); glcolor3f(1.0,.0,.0); glvertex3f(0., 5., 0.); void mydisplay(void) glclear(gl_color_buffer_bit); boshtet(); gltranslatef(0.0, 0.0, 0.0); glrotatef(0.0, 0.0, 0.0, 1.0); trekendeshi(); glflush(); glutswapbuffers(); void myreshape(int width, int height) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,width,height); glmatrixmode(gl_projection); glortho( x, x, x, x, x, x); glmatrixmode(gl_modelview); int main(int argc, char** argv) glutinit(&argc,argv);
6 glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi3"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmainloop(); Detyra 4. #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> GLfloat x=2.0; GLint N=8; GLfloat shkallax=1.0; void boshtet(void) int i; glcolor3f(0.98,.04,.70); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( x+2.0*i*x/n, x); glvertex2f( x+2.0*i*x/n, x); glvertex2f( x, x+2.0*i*x/n); glvertex2f(x, x+2.0*i*x/n); glcolor3f(0.25,.24,.25); glbegin(gl_lines); glvertex2f(0, x); glvertex2f(0, x); glvertex2f( x, 0); glvertex2f(x, 0); void vizatimi(void) glcolor3f(0.60,.40,.70); glbegin(gl_polygon); glvertex2f(0., 0.); glvertex2f(1., 0.);
7 glvertex2f(1., 1.); glvertex2f(0., 1.); void mydisplay(void) glclear(gl_color_buffer_bit); boshtet(); glscalef(shkallax, 1.0, 1.0); gltranslatef(0.0, 0.1, 0.0); glrotatef(45.0, 0.0, 0.0, 1.0); vizatimi(); glflush(); glutswapbuffers(); void myreshape(int gjeresia, int lartesia) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,gjeresia,lartesia); glmatrixmode(gl_projection); glortho( x, x, x, x, x, x); glmatrixmode(gl_modelview); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi4"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmainloop(); Detyra 5. /*Tw vizatohet katrorw me dimenzione 0,5. katrori tw zhvendoset nw 3 pozita tjera, ashtu qw cdonjwra prej tjetrws tw zhvendoset nga 2 njwsi nw drejtim tw boshtit x dhe 2 njwsi nw drejtim tw y. */
8 #include <Windows.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> GLint N=6; GLfloat x=3.0; void boshtet(void) int i; glcolor3f(.9,.04,.70); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( x+2.0*i*x/n, x); glvertex2f( x+2.0*i*x/n, x); glvertex2f( x, x+2.0*i*x/n); glvertex2f(x, x+2.0*i*x/n); glcolor3f(.25,.25,.25); glbegin(gl_lines); glvertex2f(0, x); glvertex2f(0, x); glvertex2f( x, 0); glvertex2f(x, 0); void vizatimi(void) glbegin(gl_polygon); glvertex3f(0., 0., 0.); glvertex3f(1., 0., 0.); glvertex3f(1., 0.5, 0.); glvertex3f(0.5, 1.0, 0.0); glvertex3f(0., 0.5, 0.); /* , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.);
9 glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( , , 0.); glvertex3f( 3., 8., 0.)*/ void mydisplay(void) int j=1; glclear(gl_color_buffer_bit); boshtet(); glcolor3f(.25,.25,.12); vizatimi(); glcolor3f(.98,.625,.12); for(j=0; j<5; j++) gltranslatef(1.0+j, 1.0+j, 0.0); vizatimi(); glflush(); glutswapbuffers(); void myreshape(int lart, int gjer) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,lart,gjer); glmatrixmode(gl_projection); glortho( 2*x, 2*x, 2*x, 2*x, x, x); glmatrixmode(gl_modelview); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi5"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmainloop();
10 Detyra 6. // Rrotullimi i katrorit #include <windows.h> #include <GL/glut.h> #include <GL/glu.h> #include <GL/gl.h> static GLfloat kendi = 0.0; void init(void) glclearcolor (0, 0, 0, 0); // Pastrimi i ekranit ne te zeze glshademodel (GL_FLAT); void display(void) glclear(gl_color_buffer_bit); // Pastron bufferin glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glpushmatrix(); glscalef(1.3, 1.3, 1.3); //Madhesia e figures levizese glrotatef(kendi, 0.0, 0.0, 1.0); // x, y, z kendi i rotullimit glcolor3f(1.0, 1.0, 1.0); // glrectf( 25, 25, 25, 25); // vizatimi i katrorit glbegin ( GL_LINE_LOOP ); // metode tjeter e vizatimit glvertex2i ( 25, 25); glcolor3f(1.0, 0.0, 0.0); glvertex2i (25, 25); glcolor3f(0.0, 1.0, 0.0); glvertex2i (25,25); glcolor3f(0.0, 0.0, 1.0); glvertex2i ( 25,25); glend (); glpopmatrix(); glflush(); glutswapbuffers(); void rotullimi(void)
11 // kendi = kendi + 1.0; // fast rotation kendi = kendi + 0.1; // slow rotation if (kendi > 360) kendi = kendi 360; void reshape(int w, int h) glviewport(0, 0, (GLsizei) w, (GLsizei) h); glmatrixmode(gl_projection); glortho( 50,50, 50,50, 1,1); glmatrixmode(gl_modelview); void mouse(int button, int state, int x, int y) switch (button) case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glutidlefunc(rotullimi); if (state == GLUT_UP) glutidlefunc(null); default:
12 int main(int argc, char **argv) glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB); glutinitwindowposition(100, 100); glutinitwindowsize(200, 200); glutcreatewindow("rrotullimi i katrorit");//krijon dritare me emrin "Rrotullimi i katrorit" init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmousefunc(mouse); // glutkeyboardfunc(keyboard); // registers keyboard event callback function glutmainloop(); return 0; Detyra 7. #include <Windows.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> GLint N=4; GLint mousex = 0; GLint mousey = 0; GLint mousestate = 0; GLint mousebutton = 0; GLint shape=1, model=1 ; GLfloat size=2.0; GLfloat xtheta=0., ytheta=0., ztheta=0., GLfloat scale=1.0, scaledelta=1.01; thetadelta=.25;
13 void myaxis(void) int i; glcolor3f(0.98,.4,.070); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( size+2.0*i*size/n, size); glvertex2f( size+2.0*i*size/n, size); glvertex2f( size, size+2.0*i*size/n); glvertex2f(size, size+2.0*i*size/n); glcolor3f(0.25,0.25,0.25); glbegin(gl_lines); glvertex2f( size, 0); glvertex2f(size, 0); glvertex2f(0, size); glvertex2f(0, size); void mydraw(void) glcolor3f(.25,.25,.22); if(model==5) glutwireteapot(1.0); else if(model==6) glutsolidteapot(1.0); else if(model==1) glutwirecube(1.0); else if(model==2) glutsolidcube(1.0); else if(model==3) glutwiresphere(1.0, 6, 20); else if(model==4) glutsolidsphere(1.0, 10, 10); // else if(model==5) glutwireteapot(1.0); //else if(model==6) glutsolidteapot(1.0); void mydisplay(void) static int i=0; glclear(gl_color_buffer_bit); myaxis(); glrotatef(xtheta, 1.0, 0.0, 0.0); glrotatef(ytheta, 0.0, 1.0, 0.0); glrotatef(ztheta, 0.0, 0.0, 1.0); glscalef(scale, scale, scale); mydraw(); glflush(); glutswapbuffers();
14 void myreshape(int width, int height) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,width,height); glmatrixmode(gl_projection); glortho( size, size, size, size, size, size); glmatrixmode(gl_modelview); void glutmouse(int btn, int state, int x, int y) if(btn==glut_right_button && state == GLUT_DOWN) mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_right_button && state == GLUT_UP) mousestate= 1; else if(btn==glut_middle_button && state == GLUT_DOWN) mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_middle_button && state == GLUT_UP) mousestate= 1; else return; void glutmotion(int x, int y) if(mousebutton == GLUT_LEFT_BUTTON && mousestate == GLUT_DOWN) ytheta = ( mousex x)/10.; xtheta = (mousey y)/10.; /* else if(mousebutton == GLUT_MIDDLE_BUTTON && mousestate == GLUT_DOWN) if(mousey!=y) scale = scale * pow(double (scaledelta), int (mousey y)/10.);
15 */ else return; mousex = x; mousey = y; void mymenu(int id) if(id == 7) exit(1); else model = id; int main(int argc, char** argv) int shape_submenu; glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi 8"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmousefunc(glutmouse); glutmotionfunc(glutmotion); glutcreatemenu(mymenu); glutaddmenuentry("wirekubi", 1); glutaddmenuentry("solidcube", 2); glutaddmenuentry("wiresphere", 3); glutaddmenuentry("solidsphere", 4); glutaddmenuentry("wireteapot", 5); glutaddmenuentry("solidteapot", 6); glutaddmenuentry("quit", 7); glutattachmenu(glut_right_button); glutmainloop(); Detyra 8. #include <windows.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> #include <GL/glu.h> GLint N=6;
16 GLfloat size=3.0; GLfloat ztheta=0.; void myaxis(void) int i; glcolor3f(0.198,.04,.70); glbegin(gl_lines); for(i=1; i<n; i++) glvertex2f( size+2.0*i*size/n, size); glvertex2f( size+2.0*i*size/n, size); glvertex2f( size, size+2.0*i*size/n); glvertex2f(size, size+2.0*i*size/n); void mydraw(void) glcolor3f(0.198,.04,.70); glbegin(gl_polygon); glvertex3f(0., 0., 0.); glvertex3f(0.5, 0., 0.); glvertex3f(0.5, 0.5, 0.); glvertex3f(0., 0.5, 0.); glcolor3f(1., 0., 0.); glbegin(gl_line_loop); glvertex3f(0., 0., 0.); glvertex3f(0., 1., 0.); glvertex3f(0., 1., 1.); glvertex3f(0., 0., 1.); glcolor3f(0., 1., 0.); glbegin(gl_line_loop); glvertex3f(1., 0., 0.); glvertex3f(1., 1., 0.); glvertex3f(1., 1., 1.); glvertex3f(1., 0., 1.); glcolor3f(0., 0., 1.); glbegin(gl_line_loop); glvertex3f(0., 0., 0.); glvertex3f(1., 0., 0.); glvertex3f(1., 0., 1.); glvertex3f(0., 0., 1.); glcolor3f(1., 1., 0.); glbegin(gl_line_loop);
17 glvertex3f(0., 1., 0.); glvertex3f(1., 1., 0.); glvertex3f(1., 1., 1.); glvertex3f(0., 1., 1.); GLfloat xtheta=0., ytheta=0., thetadelta=6.0; void mydisplay(void) glclear(gl_color_buffer_bit); myaxis(); glrotatef(xtheta, 1.0, 0.0, 0.0); glrotatef(ytheta, 0.0, 1.0, 0.0); glrotatef(ztheta, 0.0, 0.0, 1.0); mydraw(); glflush(); glutswapbuffers(); void mykeyboard(unsigned char thekey, int x, int y) switch (thekey) case 'x' : xtheta = thetadelta; case 'X' : xtheta += thetadelta; case 'y' : ytheta = thetadelta; case 'Y' : ytheta += thetadelta; case 'z' : ztheta = thetadelta; case 'Z' : ztheta += thetadelta; case 27: exit( 1); // esc key mydisplay(); void myreshape(int width, int height) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,width,height);
18 glmatrixmode(gl_projection); glortho( size, size, size, size, size, size); glmatrixmode(gl_modelview); int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi9"); glutreshapefunc(myreshape); glutkeyboardfunc(mykeyboard); // in main(); glutdisplayfunc(mydisplay); glutmainloop(); Detyra 9. #include <math.h> #include <stdio.h> #include <windows.h> #include <gl/glut.h> typedef float vec3_t[3]; vec3_t cube[] = 1, 1, 1, 1,1, 1, 1,1, 1, 1, 1, 1, 1,1,1, 1,1, 1, 1,1, 1, 1,1,1, 1, 1,1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1,1,1, 1,1, 1, 1, 1, 1, 1, 1,1,
19 1,1,1, 1, 1,1, 1, 1, 1, 1,1, 1, 1, 1,1, 1, 1,1, 1,1,1, 1,1,1 ; vec3_t color[] = 1.0f,.0f,.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,.25f,.25f,.25f,.60f,.40f,.70f,.98f,.625f,.12f,.98f,.04f,.70f,.75f,.75f,.75f,.60f,.40f,.12f ; vec3_t rot = 0.,0.,0.; vec3_t eye = 0.,5., 5.; vec3_t center = 0.,0.,10.; //red //green //blue //yellow //magenta //cyan //white //dark gray //barney purple //pumpkin orange //pastel pink //light gray //brown float float float float float float size=3.; theta=.0; thetadelta=.125; eyedelta=.125; scale=1.0; scaledelta=1.125; int mousex = 0; int mousey = 0; int mousestate = 0; int mousebutton = 0; int projection = 0; int anion = 0; int depthon = 1; int openon = 0; int fillon = 0; int windowwidth, windowheight;
20 void drawcube (void) int i; for(i = 0; i < 20+openOn*4; i ++) if(fillon) glbegin(gl_polygon); else glbegin(gl_line_loop); glcolor3fv(color[i%13]); glvertex3fv(cube[i]); if((i+1)%4 == 0) void mydisplay (void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); if(!projection) gltranslatef(eye[0], eye[1], eye[2]); glrotatef(rot[0], 1.0f, 0.0f, 0.0f); glrotatef(rot[1], 0.0f, 1.0f, 0.0f); glrotatef(rot[2], 0.0f, 0.0f, 1.0f); glscalef(scale, scale, scale); drawcube(); glcolor3fv(color[6]); glutwireteapot(.5); glflush(); glutswapbuffers(); void myresize (int width, int height) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glviewport(0, 0, width, height); glmatrixmode(gl_projection); if(projection) glortho( size, size, size, size, size, size); else gluperspective(150., (float)width/height,.1, 100.); glenable(gl_depth_test); windowwidth=width; windowheight=height; void mykeyboard (unsigned char key, int x, int y) switch (key) case 'o': openon =!openon;
21 case 'f': fillon =!fillon; case 'p': projection =!projection; myresize(windowwidth, windowheight); case 'd': depthon =!depthon; if(depthon) glenable(gl_depth_test); else gldisable(gl_depth_test); case 'z': scale*=scaledelta; case 'x': scale/=scaledelta; void mymouse(int btn, int state, int x, int y) if(btn==glut_left_button && state == GLUT_DOWN) mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_left_button && state == mousestate= 1; else return; GLUT_UP) void mymotion(int x, int y) if(mousebutton == GLUT_LEFT_BUTTON && mousestate == GLUT_DOWN) rot[1] = (mousex x)/5.; rot[0] = (mousey y)/5.; mousex=x; mousey=y; int main (void)
22 glutinitdisplaymode(glut_rgb GLUT_DOUBLE glutinitwindowsize(500,500); glutcreatewindow("lab07"); glutdisplayfunc(mydisplay); glutreshapefunc(myresize); glutkeyboardfunc(mykeyboard); glutmousefunc(mymouse); glutmotionfunc(mymotion); glutmainloop(); GLUT_DEPTH); Detyra 10. #include <math.h> #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> #include <cmath> GLint N=6, idleflag = 1; GLint mousex = 0; GLint mousey = 0; GLint mousestate = 0; GLint mousebutton = 0; GLfloat size=30.0, theta=0.0; GLfloat z; GLfloat xtheta=0., ytheta=0., ztheta=0., GLfloat scale=1.0, scaledelta=1.01; thetadelta=.125; void myaxis(void) int i; glcolor3f(.98,.04,.70); glutwirecube(size*2.0); glbegin(gl_lines); for(i=0; i<=n; i++) glvertex2f( size+2.0*i*size/n, size); glvertex2f( size+2.0*i*size/n, size); glvertex2f( size, size+2.0*i*size/n); glvertex2f(size, size+2.0*i*size/n); glcolor3f(.25,.25,.25); glbegin(gl_lines); glvertex2f(0, size); glvertex2f(0, size);
23 glvertex2f( size, 0); glvertex2f(size, 0); void mydisplay(void) glclear(gl_color_buffer_bit); glrotatef(xtheta, 1.0, 0.0, 0.0); glrotatef(ytheta, 0.0, 1.0, 0.0); glrotatef(ztheta, 0.0, 0.0, 1.0); glscalef(scale, scale, scale); myaxis(); glcolor3f(.98,.625,.12); glutwiresphere(3.0, 10, 10); glpushmatrix(); glrotatef(0.1*theta, 0., 0., 1.); gltranslatef(20., 0., 0.); glutwiresphere(1.0, 10, 10); glrotatef(0.2*theta, 0., 0., 1.); gltranslatef(5., 0., 0.); glutwiresphere(.5, 10, 10); glpopmatrix(); glrotatef(0.5*theta, 0., 0., 1.); gltranslatef( 5., 0., 0.); glutwiresphere(.5, 10, 10); glflush(); glutswapbuffers(); void myreshape(int width, int height) glclearcolor (.75,.75,.75, 0.0); glviewport(0,0,width,height); glmatrixmode(gl_projection); glortho( size, size, size, size, size, size); glmatrixmode(gl_modelview); void myidle(void) theta+=0.1;
24 void mymouse(int btn, int state, int x, int y) if(btn==glut_left_button && state ==GLUT_DOWN) mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_left_button && state == GLUT_UP) mousestate= 1; else if(btn==glut_right_button && state == GLUT_DOWN) mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_right_button && state == GLUT_UP) mousestate= 1; else if(btn==glut_middle_button && state == GLUT_DOWN) xtheta=ytheta=ztheta=0.; scale=1.0; else return; if(idleflag && state==glut_down) glutidlefunc(null); else if(idleflag && state==glut_up) glutidlefunc(myidle); void mymotion(int x, int y) //z=pow(scaledelta, (mousey y)/1.); if(mousebutton == GLUT_LEFT_BUTTON && mousestate == GLUT_DOWN) ytheta = (mousex x)/10.; xtheta = (mousey y)/10.;
25 else if(mousebutton == GLUT_RIGHT_BUTTON && mousestate == GLUT_DOWN) if(mousey!=y) scale = scale*scaledelta; //*pow(scaledelta, (mousey y)/1.); else return; mousex = x; mousey = y; void mykeyboard(unsigned char thekey, int x, int y) switch (thekey) case ' ' : idleflag=!idleflag; if(idleflag) glutidlefunc(myidle); else glutidlefunc(null); case 27: exit( 1); // esc key int main(int argc, char** argv) glutinit(&argc,argv); glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB); glutinitwindowsize(500,500); glutinitwindowposition(0,0); glutcreatewindow("ushtrimi10"); glutreshapefunc(myreshape); glutdisplayfunc(mydisplay); glutmousefunc(mymouse); glutmotionfunc(mymotion); glutkeyboardfunc(mykeyboard); glutmainloop(); Detyra 11. /*katrori bazw tw duket me kwtw shkallw: (3,2;3,2;0,5). mbi cilindrin e gjelber nw vend tw 4 tw rrotullohen 2 cilindra nw kahje pozitive me reze 0.4, njwri me ngjyrw tw kuqe dhe tjetri me tw kaltwr. syri i kamerws tw jwtw nw largwsi 8. nw vend tw cilindrit tw zi vizato cilindwr tw kaltwr me baza 0,2 dhe lartwsi 0,6.mbi sferwn e sipwrme vizato cilindwr me reze 0.01 dhe 0.5 dhe lartwsi 0.6 pastaj mbi cilindrin e siperm vizato 8 sfera me reze 0.1 i twrw sistemi tw rrotullohet nw kahje pozitive */ #include <math.h>
26 #include <stdio.h> #include <windows.h> #include <gl/glut.h> typedef float vec3_t[3]; vec3_t cube[] = 1, 1, 1, 1,1, 1, 1,1, 1, 1, 1, 1, 1,1,1, 1,1, 1, 1,1, 1, 1,1,1, 1, 1,1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1,1,1, 1,1, 1, 1, 1, 1, 1, 1,1, 1,1,1, 1, 1,1, 1, 1, 1, 1,1, 1, 1, 1,1, 1, 1,1, 1,1,1, 1,1,1 ; vec3_t color[] = 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,.25f,.25f,.25f,.60f,.40f,.70f,.98f,.625f,.12f,.98f,.04f,.70f,.75f,.75f,.75f,.60f,.40f,.12f ; vec3_t rot = 0.,0.,0.; vec3_t eye = 0.,0., 5.; vec3_t center = 0.,0.,0.; //red //green //blue //yellow //magenta //cyan //white //dark gray //barney purple //pumpkin orange //pastel pink //light gray //brown
27 float float float float float float size=3.; theta=.0; thetadelta=.125; eyedelta=.125; scale=1.0; scaledelta=1.125; float anitheta=.0; float anithetadelta=.125; GLUquadricObj *c; int mousex = 0; int mousey = 0; int mousestate = 0; int mousebutton = 0; int projection = 0; int anion = 0; int depthon = 1; int openon = 0; int fillon = 0; int windowwidth, windowheight; void drawcube (void) int i; for(i = 0; i < 20+openOn*4; i ++) if(fillon) glbegin(gl_polygon); else glbegin(gl_line_loop); glcolor3fv(color[i%12]); glvertex3fv(cube[i]); if((i+1)%4 == 0) void mydisplay (void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); if(!projection) glulookat(eye[0], eye[1], eye[2], center[0], center[2], 0, 1, 0); glrotatef(rot[0], 1.0f, 0.0f, 0.0f); glrotatef(rot[1], 0.0f, 1.0f, 0.0f); glrotatef(rot[2], 0.0f, 0.0f, 1.0f); glscalef(scale, scale, scale); glrotatef( 45., 1., 0., 0.); glpushmatrix(); glscalef(3., 3., 0.1); center[1],
28 glcolor3fv(color[0]); if(fillon) glutsolidcube(1.0); else glutwirecube(1.0); glpopmatrix(); gltranslatef(0., 0.,.1); glrotatef( anitheta, 0., 0., 1.); glcolor3fv(color[1]); glucylinder(c, 1., 1.,.5, 15, 5); gltranslatef(0., 0.,.5); glpushmatrix(); gltranslatef(.5, 0., 0.); glrotatef( anitheta*5, 0., 0., 1.); glcolor3fv(color[2]); glucylinder(c,.25,.25,.25, 12, 10); glpopmatrix(); glpushmatrix(); gltranslatef(0.,.5, 0.); glrotatef( anitheta*5, 0., 0., 1.); glcolor3fv(color[3]); glucylinder(c,.25,.25,.25, 12, 10); glpopmatrix(); glpushmatrix(); gltranslatef(0.,.5, 0.); glrotatef( anitheta*5, 0., 0., 1.); glcolor3fv(color[4]); glucylinder(c,.25,.25,.25, 12, 10); glpopmatrix(); glpushmatrix(); gltranslatef(.5, 0., 0.); glrotatef( anitheta*2, 0., 0., 1.); glcolor3fv(color[5]); glucylinder(c,.25,.25,.25, 12, 10); glpopmatrix(); // gltranslatef(0., 0.,.25); glrotatef(anitheta*2, 0., 0., 1.); glcolor3fv(color[6]); glucylinder(c,.5,.1,.25, 12, 10); gltranslatef(0., 0.,.25);//?????? glcolor3fv(color[0]); glucylinder(c,.1,.1,.5, 12, 10); gltranslatef(0., 0.,.75); glcolor3fv(color[8]); if(fillon) glutsolidsphere(.25, 10, 10);
29 else glutwiresphere(.25, 10, 10); glpushmatrix(); gltranslatef(0., 0.,.25); glrotatef(anitheta, 0., 0., 1.); glcolor3fv(color[6]); glucylinder(c,.05,.5,.25, 12, 10); glpopmatrix(); gltranslatef(0.0,.0, 0.6); glpushmatrix(); gltranslatef(0.5,.0, 0.0); glrotatef(anitheta, 0., 0., 1.); glcolor3fv(color[3]); glutwiresphere(.1, 10, 10); glpopmatrix(); glpopmatrix(); glpushmatrix(); gltranslatef( 0.5,.0, 0.0); glrotatef(anitheta, 0., 0., 1.); glcolor3fv(color[4]); glutwiresphere(.1, 10, 10); glflush(); glutswapbuffers(); void mylookat(int key) if(key == GLUT_KEY_UP) eye[2] = eye[2] cos(theta)*eyedelta; eye[0] = eye[0]+sin(theta)*eyedelta; else if(key == GLUT_KEY_DOWN) eye[2] = eye[2]+cos(theta)*eyedelta; eye[0] = eye[0] sin(theta)*eyedelta; center[2] = eye[2] cos(theta); center[0] = eye[0]+sin(theta); void myidle() anitheta += anithetadelta;
30 void myresize (int width, int height) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glviewport(0, 0, width, height); glmatrixmode(gl_projection); if(projection) glortho(( size), size, ( size), size, size, size); eye[2] = 0.; else gluperspective(60., (float)width/height,.21, 100.); eye[2] = 4.; mylookat(0); glenable(gl_depth_test); windowwidth=width; windowheight=height; void mykeyboard (unsigned char key, int x, int y) switch (key) case ' ': anion =!anion; if(anion) glutidlefunc(myidle); else glutidlefunc(null); case 'o': openon =!openon; case 'f': fillon =!fillon; if(fillon) gluquadricdrawstyle(c, GLU_FILL); else gluquadricdrawstyle(c, GLU_LINE); case 'p': projection =!projection; myresize(windowwidth, windowheight); case 'd': depthon =!depthon; if(depthon) glenable(gl_depth_test); else gldisable(gl_depth_test); case 'z': scale*=scaledelta; case 'x':
31 scale/=scaledelta; void myskeyboard (int key, int x, int y) switch (key) case GLUT_KEY_UP : case GLUT_KEY_DOWN : case GLUT_KEY_LEFT : theta =thetadelta; case GLUT_KEY_RIGHT : theta+=thetadelta; default : return; mylookat(key); void mymouse(int btn, int state, int x, int y) if(btn==glut_left_button && state == GLUT_DOWN) if(anion) glutidlefunc(null); mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_left_button && state == GLUT_UP) mousestate= 1; if(anion) glutidlefunc(myidle); else return; void myinit() c=glunewquadric(); gluquadricdrawstyle(c, GLU_LINE); void mymotion(int x, int y)
32 if(mousebutton == GLUT_LEFT_BUTTON && mousestate == GLUT_DOWN) rot[1] = (mousex x)/5.; rot[0] = (mousey y)/5.; mousex=x; mousey=y; int main (void) myinit(); glutinitdisplaymode(glut_rgb GLUT_DOUBLE glutinitwindowsize(800,600); glutcreatewindow("ushtrimi 12"); glutdisplayfunc(mydisplay); glutreshapefunc(myresize); glutkeyboardfunc(mykeyboard); glutspecialfunc(myskeyboard); glutmousefunc(mymouse); glutmotionfunc(mymotion); glutidlefunc(myidle); glutmainloop(); GLUT_DEPTH); Detyra 12. /*madhwsia e drejtkwndwshit tw jetw 2,sipwrfaqje e hapur tw ngel sipwrfaqja nw pjeswn e poshtme (fundi), gjatwsia e frustumit tw jetw 95*/ #include <math.h> #include <stdio.h> #include <windows.h> #include <gl/glut.h> typedef float vec3_t[3]; float size=0.; float theta=.0; float thetadelta=.125; float eyedelta=.125; float scale=1.0; float scaledelta=1.125; int mousex = 0; int mousey = 0; int mousestate = 0; int mousebutton = 0; int projection = 0;
33 int anion = 0; int depthon = 1; int openon = 0; int fillon = 1; int frontface = 0; int cullface = 0; int windowwidth; int windowheight; vec3_t rot = 0.,0.,0.; vec3_t eye = 0.,0., 5.; vec3_t center = 0.,0.,0.; vec3_t color[] = 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,.25f,.25f,.25f,.60f,.40f,.70f,.98f,.625f,.12f,.98f,.04f,.70f,.75f,.75f,.75f,.60f,.40f,.12f ; //red //green //blue //yellow //magenta //cyan //white //dark gray //barney purple //pumpkin orange //pastel pink //light gray //brown GLfloat Vertices[8][3] = 0.0, 0.0, 0.0, // vertex 0 1.0, 0.0, 0.0, // vertex 1 1.0, 0.0, 1.0, // vertex 2 0.0, 0.0, 1.0, // vertex 3 0.0, 1.0, 0.0, // vertex 4 1.0, 1.0, 0.0, // vertex 5 1.0, 1.0, 1.0, // vertex 6 0.0, 1.0, 1.0 ; // vertex 7 GLfloat Normals[5][3] = 0.0,1.0, 0.0, // face 0 0.0, 1.0, 0.0, // face 1 0.0, 0.0, 1.0, // face 2 1.0, 0.0, 0.0, // face 3 0.0, 0.0,1.0 ; // face 4 GLint Faces[5][4] = 0, 1, 2, 3, // face 0 4, 7, 6, 5, // face 1 2, 6, 7, 3, // face 2 3, 7, 4, 0, // face 3
34 4, 5, 1, 0 ; // face 4 void drawmesh(glfloat vertices[][3], GLfloat normalvectors[][3], GLint faces[][4], GLint nfaces) int j; for(j=0; j<nfaces; j++) glcolor3fv(color[j%12]); glbegin(gl_quads); glnormal3fv(normalvectors[j]); glvertex3fv(vertices[faces[j][0]]); glvertex3fv(vertices[faces[j][1]]); glvertex3fv(vertices[faces[j][2]]); glvertex3fv(vertices[faces[j][3]]); void mydisplay (void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); if(!projection) glulookat(eye[0], eye[1], eye[2], center[0], center[2], 0, 1, 0); glrotatef(rot[0], 1.0f, 0.0f, 0.0f); glrotatef(rot[1], 0.0f, 1.0f, 0.0f); glrotatef(rot[2], 0.0f, 0.0f, 1.0f); glscalef(scale, scale, scale); drawmesh(vertices, Normals, Faces, 5); glflush(); glutswapbuffers(); void mylookat(int key) if(key == GLUT_KEY_UP) eye[2] = eye[2] cos(theta)*eyedelta; eye[0] = eye[0]+sin(theta)*eyedelta; else if(key == GLUT_KEY_DOWN) eye[2] = eye[2]+cos(theta)*eyedelta; eye[0] = eye[0] sin(theta)*eyedelta; center[2] = eye[2] cos(theta); center[0] = eye[0]+sin(theta); void myresize (int width, int height) center[1],
35 glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glviewport(0, 0, width, height); glmatrixmode(gl_projection); if(projection) glortho( size, size, size, size, size, size); eye[2] = 0.; else gluperspective(80., (float)width/height,.1, 100.); eye[2] = 5.; mylookat(0); glenable(gl_depth_test); glcullface(gl_back); glpolygonmode(gl_back, GL_LINE); glpolygonmode(gl_front, GL_FILL); windowwidth=width; windowheight=height; void myskeyboard (int key, int x, int y) switch (key) case GLUT_KEY_UP : case GLUT_KEY_DOWN : case GLUT_KEY_LEFT : theta =thetadelta; case GLUT_KEY_RIGHT : theta+=thetadelta; default : return; mylookat(key); void mykeyboard (unsigned char key, int x, int y) switch (key) case 'p': projection =!projection; myresize(windowwidth, windowheight); case 'd': depthon =!depthon;
36 if(depthon) glenable(gl_depth_test); else gldisable(gl_depth_test); case 'f': frontface =!frontface; if(frontface) glfrontface(gl_cw); else glfrontface(gl_ccw); case 'c': cullface =!cullface; if(cullface) glenable(gl_cull_face); else gldisable(gl_cull_face); case 'z': scale*=scaledelta; case 'x': scale/=scaledelta; void mymouse(int btn, int state, int x, int y) if(btn==glut_left_button && state == GLUT_DOWN) glutidlefunc(null); mousestate=state; mousebutton=btn; mousex=x; mousey=y; else if(btn==glut_left_button && state == GLUT_UP) mousestate= 1; else return; void mymotion(int x, int y) if(mousebutton == GLUT_LEFT_BUTTON && mousestate == GLUT_DOWN) rot[1] = (mousex x)/5.; rot[0] = (mousey y)/5.; mousex=x;
37 mousey=y; int main (void) glutinitdisplaymode(glut_rgb GLUT_DOUBLE GLUT_DEPTH); glutinitwindowsize(500,500); glutcreatewindow("ushtrimi12"); glutdisplayfunc(mydisplay); glutreshapefunc(myresize); glutkeyboardfunc(mykeyboard); glutspecialfunc(myskeyboard); glutmousefunc(mymouse); glutmotionfunc(mymotion); glutmainloop();
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 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 information20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:
1 1. 1 #include 2 #include 3 Program 1 (OpenGL Sample016) 4 // 5 static int MouseX = 0; // X 6 static int MouseY = 0; // Y 7 static float SpinX = 0; // X 8 static float SpinY = 0;
More informationC++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson
C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson Syllabus 1) First program and introduction to data types and control structures with applications for games learning how to use the programming
More 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 information1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib
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
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 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 informationTransformation, Input and Interaction. Hanyang University
Transformation, Input and Interaction Hanyang University Transformation, projection, viewing Pipeline of transformations Standard sequence of transforms Cornell CS4620 Fall 2008 Lecture 8 3 2008 Steve
More 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 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 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 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 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 informationProject Sketchpad. Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics:
Project Sketchpad Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics: User sees an object on the display User points to (picks) the object
More informationComp 410/510 Computer Graphics Spring Input & Interaction
Comp 410/510 Computer Graphics Spring 2018 Input & Interaction Objectives Introduce the basic input devices - Physical Devices - Logical Devices Event-driven input Input Modes Programming event input with
More informationModeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益
Modeling Transform Chapter 4 Geometric Transformations 李同益 Specify transformation for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene
More informationComputer Graphics. OpenGL
Computer Graphics OpenGL What is OpenGL? OpenGL (Open Graphics Library) is a library for computer graphics It consists of several procedures and functions that allow a programmer to specify the objects
More informationIntroduction to 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 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 informationGraphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++
Computer Graphics Graphics Programming August 31, 2005 Contents Our Goal in This Chapter Programming of the Sierpinski gasket How To? Programming with OpenGL and C/C++ OpenGL API (Application Programmer
More informationComputer Graphics. 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 informationLecture 3 Advanced Computer Graphics (CS & SE )
Lecture 3 Advanced Computer Graphics (CS & SE 233.420) Programming with OpenGL Program Structure Primitives Attributes and States Programming in three dimensions Inputs and Interaction Working with Callbacks
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 informationOrder 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 informationWorking with Callbacks
Working with Callbacks 1 Objectives Learn to build interactive programs using GLUT callbacks Mouse Keyboard Reshape Introduce menus in GLUT 2 The mouse callback glutmousefunc(mymouse) void mymouse(glint
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 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 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 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 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 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 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 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 informationSource code: #include <iostream>
Andrew Yenalavitch Homework 4 CSE 520 - Winter 2015 1. ( 10 points ) Write a program that finds the knot vector ( u 0,..., u n-1 ) of a B-spline. It asks for 'number of control points' and 'degree of spline'
More 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 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 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 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 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 informationInput, Interaction and Animation Week 2
CS 432/637 INTERACTIVE COMPUTER GRAPHICS Input, Interaction and Animation Week 2 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico Objectives
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 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 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 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 informationPhilip 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 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 informationLecture 4. Interaction / Graphical Devices. CS 354 Computer Graphics Sunday, January 20, 13
Lecture 4 Interaction / Graphical Devices Graphical Input Devices can be described either by - Physical properties Mouse Keyboard Trackball - Logical Properties What is returned to program via API A position
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 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 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 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 informationCSC 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 informationComputer Graphics Anatomy of GUI. Computer Graphics CSC470 1
Computer Graphics Anatomy of GUI 1 Anatomy of GLUT keyboard mouse OpenGL Application if (key == f key == F ) { glutfullscreen(); } else if(key == w key == W ) { glutreshapewindow(640,480); } display reshape
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 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 informationErik 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 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 information1) Program to display a set of values {fij} as a rectangular mesh. #include<gl/glut.h> #define maxx 20. #define maxy 20. #define dx 15.
1) Program to display a set of values fij as a rectangular mesh. #include #define maxx 20 #define maxy 20 #define dx 15 #define dy 20 GLfloat x[maxx]=0.0,y[maxy]=0.0; GLfloat x0=50,y01=50; GLint
More 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 informationComputer Graphics Introduction to OpenGL
Computer Graphics 2013 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2013-09-16 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines start
More 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 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 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 informationCS621 Lab 1 Name: Ihab Zbib
CS621 Lab 1 Name: Ihab Zbib 1) The program draw.cpp draws two rectangles and two triangles. The program compiles and executes successfully. What follows are the snap shots of the output. Illustration 1:
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 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 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 informationOpenGL Tutorial. Ceng 477 Introduction to Computer Graphics
OpenGL Tutorial Ceng 477 Introduction to Computer Graphics Adapted from: http://www.cs.princeton.edu/courses/archive/spr06/cos426/assn3/opengl_tutorial.ppt OpenGL IS an API OpenGL IS nothing more than
More informationComputer Graphics (CS 543) Lecture 2b: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)
Computer Graphics (CS 543) Lecture 2b: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Announcements All code
More informationIntroduction to OpenGL: Part 2
Introduction to OpenGL: Part 2 Introduction to OpenGL: Part 2 A more complex example recursive refinement Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous
More 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 informationInput and Interaction. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science
Input and Interaction CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science E. Angel and D. Shreiner : Interactive Computer Graphics 6E Addison-Wesley 2012 1 Objectives
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 informationCMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013
CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013 Reading: See any standard reference on OpenGL or GLUT. Basic Drawing: In the previous lecture, we showed how to create a window in GLUT,
More informationLecture 11: Callbacks. CITS 3003 Graphics & Animation
Lecture 11: Callbacks CITS 3003 Graphics & Animation Slides: E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Learn to build interactive programs using GLUT callbacks
More information2a. 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 informationComputer graphics MN1
Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? HowdoI useit? Rendering pipeline Points, vertices, lines, polygons Matrices and transformations Lighting and shading Code examples
More informationComputer Graphics Introduction to OpenGL
! Computer Graphics 2014! 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2014-09-29! ! 2. 2D Graphics Algorithms (cont.) Rasterization Scan converting lines
More informationComputer Graphics Introduction to OpenGL
Computer Graphics 2016 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2016-10-10 2. 2D Graphics Algorithms (cont.) 3 Rasterization Computer Graphics @ ZJU 4 5 6 7
More information1. 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 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 informationChapter 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 informationOutline. 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 informationGraphics 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 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 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 informationLAB MANUAL. Computer Graphics using OpenGL Department of CSE & IT, JUIT. Chief Course Coordinator: Dr Rajesh Siddavatam Associate Professor, CSE& IT
LAB MANUAL Computer Graphics using OpenGL Department of CSE & IT, JUIT. Chief Course Coordinator: Dr Rajesh Siddavatam Associate Professor, CSE& IT Lab Co-ordinators: Ms Meenakshi S Arya, Mr Ravikant Verma
More informationIntroduction to OpenGL and 3D Graphics
Introduction to OpenGL and 3D Graphics Categories Introduction to graphics The History of 3D Graphics How 3D Graphics work Drawing Points, Lines and Polygons in OpenGL Transformations and Perspective Introduction
More informationRendering 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 informationComputer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations
Computer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Objectives Learn how to implement transformations
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 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 informationINDEX. 5. WAP to show various OpenGL primitives with the help of 8-19 menu e.g. GL_POINTS, GL_LINES, GL_LINE_STRIP,GL_LINE_LOOP GL_TRIANGLES
P a g e 1 S.NO TOPICS INDEX PAGE NO. 1. Write the steps to Setting up the VC++ environment for Open GL. 2. Briefly describe architecture of OpenGL. 3-4 3. Describe the features supported by GLUT (OpenGL
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 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 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 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 information