Download presentation
Presentation is loading. Please wait.
Published byYanti Hartono Modified over 7 years ago
1
Imam Cholissodin| imam.cholissodin@gmail.com
03 |Primitives Imam Cholissodin|
2
Primitives : What’s Primitives Create Point Create Line
Create Line Strip Create Line Loop/ Polygon Create Triangle Create Rectangle Create Line Stipple Create Circle, Ellips, Cardioid, Treeleaf, Spiral and Limacon
3
What’s Primitives Titik Garis Segiempat Lingkaran
“Objek se-kompleks apapun, dapat dibuat dengan mengkombinasikan bentuk-bentuk primitif di atas.”
4
Create Point glColor3f(1.0,0.0,0.0); glPointSize(19);
glBegin(GL_POINTS); glVertex2f(80,20); glVertex2f(300,50); glVertex2f(180,200); glEnd(); glFlush(); =========================
5
Create Line glColor3f(1.0,0.0,1.0); glLineWidth(5); glBegin(GL_LINES);
glVertex2f(100,100); glVertex2f(210,300); glVertex2f(320,100); glEnd(); glFlush(); =========================
6
Vertex Array & Color Array
float array_vertex[]= { 150,10, //vertex 1 280,250, //vertex 2 20,250 //vertex 3 }; float array_color[]= 1,0,0, //red 0,1,0, //green 0,0,1 //blue
7
Create Lines GLfloat x1 = 2, y1 = 2 ; GLfloat x2= 100, y2 = 100 ; glBegin(GL_POINTS); glVertex2i(x1,y1); glVertex2i(x2,y2); // hitung nilai m GLfloat m = (y2-y1)/(x2-x1); for(float x=2;x<=10;x++){ GLfloat y = m*(x-x1)+y1; glVertex2i(x,y); } glEnd();
8
Create Circle GLfloat jari_jari=150; // Titik Pusat GLfloat a = 290, b = 250 ; GLfloat x=a+jari_jari, y=b; glLineWidth(7); glBegin(GL_LINE_LOOP); for(float teta=0;teta<=360;teta++){ GLfloat x_aksen = (x-a)*cos((teta/180)*(22/7)) - ((y-b)*sin((teta/180)*(22/7))) + a; GLfloat y_aksen = (x-a)*sin((teta/180)*(22/7)) - ((y-b)*cos((teta/180)*(22/7))) + b; glVertex2i(x_aksen,y_aksen); } glEnd();
9
Imam Cholissodin| imam.cholissodin@gmail.com
Selesai Imam Cholissodin|
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.