SlideShare a Scribd company logo
1 of 14
MyTricksLab.com (Computer Science & Tech Tutorials)




      PRACTICING OPENGL-
      PRIMITIVES
OPENGL OUTPUT PRIMITIVES




 Each geometric object is described by a set of vertices and the type of primitive to be
 drawn. Whether and how the vertices are connected is determined by the primitive
 type.
OPENGL PRIMITIVES- GL_POINTS
 Lab Activity (1): Add the following code to display() method.

         glPointSize(4.0);              /* specify point to be 4 pixels thick */
         glBegin(GL_POINTS);
             glVertex2f(0.0f, 2.0f);    //note 2D form
             glVertex2f(1.0f, 2.0f);
             glVertex2f(0.0f, -2.0f);
             glVertex2f(-1.0f, 0.0f);
         glEnd();
OPENGL PRIMITIVES- LINES
   Three different line primitives can be created:


GL_LINES: glColor3f(0.0,0.0,0.0);
          glLineWidth(5.0);

                 glBegin(GL_LINES);
                         glVertex2f (-20.0, -20.0);
                         glVertex2f (20.0, 20.0);

                            glColor3f(1.0,1.0,0.0);
                            glVertex2f (10.0, -20.0);
                            glVertex2f (10.0, 20.0);
                 glEnd();
OPENGL PRIMITIVES- LINES
GL_LINE_STRIP:       Draws a connected set of line segments from the first vertex to the
 last.
         glColor3f(0.5,0.6,0.0);
         glLineWidth(4);
         glBegin(GL_LINE_STRIP);
             glVertex2f (5.0, 10.0);
             glVertex2f (10.0, 10.0);
             glVertex2f (10.0, 0.0);
             glVertex2f (5.0, 0.0);
         glEnd();
OPENGL PRIMITIVES- LINES
GL_LINE_LOOP:
        glColor3f(0.9,0.8,0.0);
        glLineWidth(4);
        glBegin(GL_LINE_LOOP);
                 glVertex2f (-10.0, 9.0);
                 glVertex2f (5.0, 9.0);
                 glVertex2f (5.0, -1.0);
                 glVertex2f (-10.0, -1.0);
        glEnd();
OPENGL PRIMITIVES –GL_TRIANGES
glColor3f(1.0,0.0,1.0);
glLineWidth(4);                  -The default is GL_FILL for both front-and back-facing
                                 polygons.
glBegin(GL_TRIANGLES);
        glVertex2f (-10.0, -10.0);
        glVertex2f (-5.0, -10.0);
        glVertex2f (-5.0, -5.0);
glEnd();

   Insert this command before glLineWidth, and note the effect.
                      glPolygonMode(GL_FRONT, GL_LINE);

                                 GL_BACK                                GL_POINT
                                  or                                     or
                         GL_FRONT_AND_BACK                              GL_FILL
OPENGL PRIMITIVES –
GL_TRIANGLE_STRIP
glColor3f(0.0,1.0,0.0);
glLineWidth(4);
glPolygonMode(GL_FRONT, GL_LINE);
glBegin(GL_TRIANGLE_STRIP);
    glVertex2f (-10.0, -10.0);
    glVertex2f (-19.0, -10.0);
    glVertex2f (-10.0, -20.0);
         glVertex2f (-18.0,-19.0);      //create 2ndtriangle
         glVertex2f (-5.0, -25.0);     //create 3rd triangle
         glVertex2f (-20.0, -29.0);   //create 4th triangle
glEnd();

 Note:
 • Order of points does matter!
 • If the vertices are defined clockwise, the front of the polygon will
 be shown. Otherwise, the back of the polygon will be shown.
OPENGL PRIMITIVES –
GL_TRIANGLE_FAN
Draws a connected set of triangles. One triangle is defined for each vertex
  presented after the first two vertices.
Note: Order of points does matter!
                        glColor3f(0.0,0.0,1.0);
                        glLineWidth(4);

                       /* draw only the outline of polygon */
                       glPolygonMode(GL_FRONT, GL_LINE);

                       glBegin( GL_TRIANGLE_FAN);
                           glVertex2f (12.0, -30.0);
                           glVertex2f(30.0, -30.0);
                           glVertex2f (30.0, -20.0);
                           glVertex2f (22.0, -15.0);
                           glVertex2f (12.0, -12.0);
                       glEnd();
OPENGL PRIMITIVES –GL_QUADS
Note: Order of points does matter!
            /* creating 2 quadrilaterals */
            glColor3f(0.0,0.0,0.0);
            glPolygonMode(GL_FRONT, GL_LINE);
            glLineWidth(4);
            glBegin( GL_QUADS );
                 glVertex2f (-28.0, 25.0);
                 glVertex2f (-28.0, 10.0);
                 glVertex2f (-20.0, 10.0);
                 glVertex2f (-20.0, 20.0);

                glVertex2f (-15.0, 20.0);
                glVertex2f (-2.0, 20.0);
                glVertex2f (-2.0, 28.0);
                glVertex2f (-15.0, 28.0);
            glEnd();
OPENGL PRIMITIVES –
GL_QUAD_STRIP
/* creating 2 quadrilaterals using GL_QUAD_STRIP */
glColor3f(0.0,1.0,1.0);
glPolygonMode(GL_FRONT, GL_LINE);
glLineWidth(4);
glBegin( GL_QUAD_STRIP);
    glVertex2f (20.0, 10.0);
    glVertex2f (29.0, 13.0);
    glVertex2f (18.0, 20.0);
    glVertex2f (26.0, 20.0);



    glVertex2f (22.0, 25.0);
    glVertex2f (30.0, 25.0);

    glVertex2f (15.0, 30.0);
    glVertex2f (35.0, 30.0);
glEnd();
OPENGL PRIMITIVES –
GL_POLYGON
glBegin(GL_POLYGON);
  glVertex2f(2.0,1.0);
  glVertex2f(12.0,1.0);
  glVertex2f(14.0,3.0);
  glVertex2f(1.0,3.0);
glEnd();
CREATIVE DRAWING USING OPENGL
PRIMITIVES
LAB EXERCISE: TIME TO SHOW YOUR
CREATIVITY
                    “Sample 2D Scenary are given Lab folder”

1.   Show your best to Design your virtual World (2D Scene) onto graph
     paper.
           With Well defined coordinates Points of each object in Scene.

           Also Define Color of each Object Of Your Scene


1.   Use Open GL built in primitives to Implement your
     Designed virtual world (2D Scene).


       MyTricksLab.com (Computer Science & Tech Tutorials)

More Related Content

What's hot

The Ring programming language version 1.7 book - Part 155 of 196
The Ring programming language version 1.7 book - Part 155 of 196The Ring programming language version 1.7 book - Part 155 of 196
The Ring programming language version 1.7 book - Part 155 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 174 of 212
The Ring programming language version 1.10 book - Part 174 of 212The Ring programming language version 1.10 book - Part 174 of 212
The Ring programming language version 1.10 book - Part 174 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 186 of 210
The Ring programming language version 1.9 book - Part 186 of 210The Ring programming language version 1.9 book - Part 186 of 210
The Ring programming language version 1.9 book - Part 186 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 129 of 184
The Ring programming language version 1.5.3 book - Part 129 of 184The Ring programming language version 1.5.3 book - Part 129 of 184
The Ring programming language version 1.5.3 book - Part 129 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 177 of 210
The Ring programming language version 1.9 book - Part 177 of 210The Ring programming language version 1.9 book - Part 177 of 210
The Ring programming language version 1.9 book - Part 177 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 133 of 184
The Ring programming language version 1.5.3 book - Part 133 of 184The Ring programming language version 1.5.3 book - Part 133 of 184
The Ring programming language version 1.5.3 book - Part 133 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 127 of 189
The Ring programming language version 1.6 book - Part 127 of 189The Ring programming language version 1.6 book - Part 127 of 189
The Ring programming language version 1.6 book - Part 127 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 135 of 181
The Ring programming language version 1.5.2 book - Part 135 of 181The Ring programming language version 1.5.2 book - Part 135 of 181
The Ring programming language version 1.5.2 book - Part 135 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 143 of 184
The Ring programming language version 1.5.3 book - Part 143 of 184The Ring programming language version 1.5.3 book - Part 143 of 184
The Ring programming language version 1.5.3 book - Part 143 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 167 of 210
The Ring programming language version 1.9 book - Part 167 of 210 The Ring programming language version 1.9 book - Part 167 of 210
The Ring programming language version 1.9 book - Part 167 of 210 Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 169 of 196
The Ring programming language version 1.7 book - Part 169 of 196The Ring programming language version 1.7 book - Part 169 of 196
The Ring programming language version 1.7 book - Part 169 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 196 of 210
The Ring programming language version 1.9 book - Part 196 of 210The Ring programming language version 1.9 book - Part 196 of 210
The Ring programming language version 1.9 book - Part 196 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 162 of 194
The Ring programming language version 1.5.3 book - Part 162 of 194The Ring programming language version 1.5.3 book - Part 162 of 194
The Ring programming language version 1.5.3 book - Part 162 of 194Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 148 of 180
The Ring programming language version 1.5.1 book - Part 148 of 180 The Ring programming language version 1.5.1 book - Part 148 of 180
The Ring programming language version 1.5.1 book - Part 148 of 180 Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 152 of 194
The Ring programming language version 1.5.3 book - Part 152 of 194The Ring programming language version 1.5.3 book - Part 152 of 194
The Ring programming language version 1.5.3 book - Part 152 of 194Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 165 of 202
The Ring programming language version 1.8 book - Part 165 of 202The Ring programming language version 1.8 book - Part 165 of 202
The Ring programming language version 1.8 book - Part 165 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 159 of 202
The Ring programming language version 1.8 book - Part 159 of 202The Ring programming language version 1.8 book - Part 159 of 202
The Ring programming language version 1.8 book - Part 159 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 188 of 196
The Ring programming language version 1.7 book - Part 188 of 196The Ring programming language version 1.7 book - Part 188 of 196
The Ring programming language version 1.7 book - Part 188 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 166 of 194
The Ring programming language version 1.5.3 book - Part 166 of 194The Ring programming language version 1.5.3 book - Part 166 of 194
The Ring programming language version 1.5.3 book - Part 166 of 194Mahmoud Samir Fayed
 

What's hot (20)

The Ring programming language version 1.7 book - Part 155 of 196
The Ring programming language version 1.7 book - Part 155 of 196The Ring programming language version 1.7 book - Part 155 of 196
The Ring programming language version 1.7 book - Part 155 of 196
 
The Ring programming language version 1.10 book - Part 174 of 212
The Ring programming language version 1.10 book - Part 174 of 212The Ring programming language version 1.10 book - Part 174 of 212
The Ring programming language version 1.10 book - Part 174 of 212
 
The Ring programming language version 1.9 book - Part 186 of 210
The Ring programming language version 1.9 book - Part 186 of 210The Ring programming language version 1.9 book - Part 186 of 210
The Ring programming language version 1.9 book - Part 186 of 210
 
The Ring programming language version 1.5.3 book - Part 129 of 184
The Ring programming language version 1.5.3 book - Part 129 of 184The Ring programming language version 1.5.3 book - Part 129 of 184
The Ring programming language version 1.5.3 book - Part 129 of 184
 
The Ring programming language version 1.9 book - Part 177 of 210
The Ring programming language version 1.9 book - Part 177 of 210The Ring programming language version 1.9 book - Part 177 of 210
The Ring programming language version 1.9 book - Part 177 of 210
 
The Ring programming language version 1.5.3 book - Part 133 of 184
The Ring programming language version 1.5.3 book - Part 133 of 184The Ring programming language version 1.5.3 book - Part 133 of 184
The Ring programming language version 1.5.3 book - Part 133 of 184
 
The Ring programming language version 1.6 book - Part 127 of 189
The Ring programming language version 1.6 book - Part 127 of 189The Ring programming language version 1.6 book - Part 127 of 189
The Ring programming language version 1.6 book - Part 127 of 189
 
The Ring programming language version 1.5.2 book - Part 135 of 181
The Ring programming language version 1.5.2 book - Part 135 of 181The Ring programming language version 1.5.2 book - Part 135 of 181
The Ring programming language version 1.5.2 book - Part 135 of 181
 
The Ring programming language version 1.5.3 book - Part 143 of 184
The Ring programming language version 1.5.3 book - Part 143 of 184The Ring programming language version 1.5.3 book - Part 143 of 184
The Ring programming language version 1.5.3 book - Part 143 of 184
 
The Ring programming language version 1.9 book - Part 167 of 210
The Ring programming language version 1.9 book - Part 167 of 210 The Ring programming language version 1.9 book - Part 167 of 210
The Ring programming language version 1.9 book - Part 167 of 210
 
The Ring programming language version 1.7 book - Part 169 of 196
The Ring programming language version 1.7 book - Part 169 of 196The Ring programming language version 1.7 book - Part 169 of 196
The Ring programming language version 1.7 book - Part 169 of 196
 
The Ring programming language version 1.9 book - Part 196 of 210
The Ring programming language version 1.9 book - Part 196 of 210The Ring programming language version 1.9 book - Part 196 of 210
The Ring programming language version 1.9 book - Part 196 of 210
 
The Ring programming language version 1.5.3 book - Part 162 of 194
The Ring programming language version 1.5.3 book - Part 162 of 194The Ring programming language version 1.5.3 book - Part 162 of 194
The Ring programming language version 1.5.3 book - Part 162 of 194
 
The Ring programming language version 1.5.1 book - Part 148 of 180
The Ring programming language version 1.5.1 book - Part 148 of 180 The Ring programming language version 1.5.1 book - Part 148 of 180
The Ring programming language version 1.5.1 book - Part 148 of 180
 
The Ring programming language version 1.5.3 book - Part 152 of 194
The Ring programming language version 1.5.3 book - Part 152 of 194The Ring programming language version 1.5.3 book - Part 152 of 194
The Ring programming language version 1.5.3 book - Part 152 of 194
 
The Ring programming language version 1.8 book - Part 165 of 202
The Ring programming language version 1.8 book - Part 165 of 202The Ring programming language version 1.8 book - Part 165 of 202
The Ring programming language version 1.8 book - Part 165 of 202
 
The Ring programming language version 1.8 book - Part 159 of 202
The Ring programming language version 1.8 book - Part 159 of 202The Ring programming language version 1.8 book - Part 159 of 202
The Ring programming language version 1.8 book - Part 159 of 202
 
The Ring programming language version 1.7 book - Part 188 of 196
The Ring programming language version 1.7 book - Part 188 of 196The Ring programming language version 1.7 book - Part 188 of 196
The Ring programming language version 1.7 book - Part 188 of 196
 
The Ring programming language version 1.5.3 book - Part 166 of 194
The Ring programming language version 1.5.3 book - Part 166 of 194The Ring programming language version 1.5.3 book - Part 166 of 194
The Ring programming language version 1.5.3 book - Part 166 of 194
 
Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0
 

Viewers also liked

Viewers also liked (6)

Setting up your first open gl program
Setting up your first open gl programSetting up your first open gl program
Setting up your first open gl program
 
Ooad sequence diagram lecture
Ooad sequence diagram lectureOoad sequence diagram lecture
Ooad sequence diagram lecture
 
Windows and viewport
Windows and viewportWindows and viewport
Windows and viewport
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 

Similar to Practicing 2d drawing primitives

Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Robi Parvez
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flagRobi Parvez
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wireRené Domínguez
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Aila Gema Safitri
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportBijoy679
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Jannat Jamshed
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Jannat Jamshed
 
The Ring programming language version 1.5.4 book - Part 58 of 185
The Ring programming language version 1.5.4 book - Part 58 of 185The Ring programming language version 1.5.4 book - Part 58 of 185
The Ring programming language version 1.5.4 book - Part 58 of 185Mahmoud Samir Fayed
 
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docxajoy21
 
FLTK Summer Course - Part VIII - Eighth Impact - Exercises
FLTK Summer Course - Part VIII - Eighth Impact - ExercisesFLTK Summer Course - Part VIII - Eighth Impact - Exercises
FLTK Summer Course - Part VIII - Eighth Impact - ExercisesMichel Alves
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp OpenMikeEly930
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184Mahmoud Samir Fayed
 

Similar to Practicing 2d drawing primitives (20)

Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
 
2D Drawing
2D Drawing2D Drawing
2D Drawing
 
Practica
PracticaPractica
Practica
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
 
Development with OpenGL and Qt
Development with OpenGL and QtDevelopment with OpenGL and Qt
Development with OpenGL and Qt
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
Komputer Grafik
Komputer GrafikKomputer Grafik
Komputer Grafik
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
The Ring programming language version 1.5.4 book - Part 58 of 185
The Ring programming language version 1.5.4 book - Part 58 of 185The Ring programming language version 1.5.4 book - Part 58 of 185
The Ring programming language version 1.5.4 book - Part 58 of 185
 
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
 
FLTK Summer Course - Part VIII - Eighth Impact - Exercises
FLTK Summer Course - Part VIII - Eighth Impact - ExercisesFLTK Summer Course - Part VIII - Eighth Impact - Exercises
FLTK Summer Course - Part VIII - Eighth Impact - Exercises
 
Manual
ManualManual
Manual
 
Grafika komputer 2
Grafika komputer 2Grafika komputer 2
Grafika komputer 2
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp Open
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
 

Recently uploaded

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Recently uploaded (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 

Practicing 2d drawing primitives

  • 1. MyTricksLab.com (Computer Science & Tech Tutorials) PRACTICING OPENGL- PRIMITIVES
  • 2. OPENGL OUTPUT PRIMITIVES Each geometric object is described by a set of vertices and the type of primitive to be drawn. Whether and how the vertices are connected is determined by the primitive type.
  • 3. OPENGL PRIMITIVES- GL_POINTS Lab Activity (1): Add the following code to display() method. glPointSize(4.0); /* specify point to be 4 pixels thick */ glBegin(GL_POINTS); glVertex2f(0.0f, 2.0f); //note 2D form glVertex2f(1.0f, 2.0f); glVertex2f(0.0f, -2.0f); glVertex2f(-1.0f, 0.0f); glEnd();
  • 4. OPENGL PRIMITIVES- LINES  Three different line primitives can be created: GL_LINES: glColor3f(0.0,0.0,0.0); glLineWidth(5.0); glBegin(GL_LINES); glVertex2f (-20.0, -20.0); glVertex2f (20.0, 20.0); glColor3f(1.0,1.0,0.0); glVertex2f (10.0, -20.0); glVertex2f (10.0, 20.0); glEnd();
  • 5. OPENGL PRIMITIVES- LINES GL_LINE_STRIP: Draws a connected set of line segments from the first vertex to the last. glColor3f(0.5,0.6,0.0); glLineWidth(4); glBegin(GL_LINE_STRIP); glVertex2f (5.0, 10.0); glVertex2f (10.0, 10.0); glVertex2f (10.0, 0.0); glVertex2f (5.0, 0.0); glEnd();
  • 6. OPENGL PRIMITIVES- LINES GL_LINE_LOOP: glColor3f(0.9,0.8,0.0); glLineWidth(4); glBegin(GL_LINE_LOOP); glVertex2f (-10.0, 9.0); glVertex2f (5.0, 9.0); glVertex2f (5.0, -1.0); glVertex2f (-10.0, -1.0); glEnd();
  • 7. OPENGL PRIMITIVES –GL_TRIANGES glColor3f(1.0,0.0,1.0); glLineWidth(4); -The default is GL_FILL for both front-and back-facing polygons. glBegin(GL_TRIANGLES); glVertex2f (-10.0, -10.0); glVertex2f (-5.0, -10.0); glVertex2f (-5.0, -5.0); glEnd();  Insert this command before glLineWidth, and note the effect. glPolygonMode(GL_FRONT, GL_LINE); GL_BACK GL_POINT or or GL_FRONT_AND_BACK GL_FILL
  • 8. OPENGL PRIMITIVES – GL_TRIANGLE_STRIP glColor3f(0.0,1.0,0.0); glLineWidth(4); glPolygonMode(GL_FRONT, GL_LINE); glBegin(GL_TRIANGLE_STRIP); glVertex2f (-10.0, -10.0); glVertex2f (-19.0, -10.0); glVertex2f (-10.0, -20.0); glVertex2f (-18.0,-19.0); //create 2ndtriangle glVertex2f (-5.0, -25.0); //create 3rd triangle glVertex2f (-20.0, -29.0); //create 4th triangle glEnd(); Note: • Order of points does matter! • If the vertices are defined clockwise, the front of the polygon will be shown. Otherwise, the back of the polygon will be shown.
  • 9. OPENGL PRIMITIVES – GL_TRIANGLE_FAN Draws a connected set of triangles. One triangle is defined for each vertex presented after the first two vertices. Note: Order of points does matter! glColor3f(0.0,0.0,1.0); glLineWidth(4); /* draw only the outline of polygon */ glPolygonMode(GL_FRONT, GL_LINE); glBegin( GL_TRIANGLE_FAN); glVertex2f (12.0, -30.0); glVertex2f(30.0, -30.0); glVertex2f (30.0, -20.0); glVertex2f (22.0, -15.0); glVertex2f (12.0, -12.0); glEnd();
  • 10. OPENGL PRIMITIVES –GL_QUADS Note: Order of points does matter! /* creating 2 quadrilaterals */ glColor3f(0.0,0.0,0.0); glPolygonMode(GL_FRONT, GL_LINE); glLineWidth(4); glBegin( GL_QUADS ); glVertex2f (-28.0, 25.0); glVertex2f (-28.0, 10.0); glVertex2f (-20.0, 10.0); glVertex2f (-20.0, 20.0); glVertex2f (-15.0, 20.0); glVertex2f (-2.0, 20.0); glVertex2f (-2.0, 28.0); glVertex2f (-15.0, 28.0); glEnd();
  • 11. OPENGL PRIMITIVES – GL_QUAD_STRIP /* creating 2 quadrilaterals using GL_QUAD_STRIP */ glColor3f(0.0,1.0,1.0); glPolygonMode(GL_FRONT, GL_LINE); glLineWidth(4); glBegin( GL_QUAD_STRIP); glVertex2f (20.0, 10.0); glVertex2f (29.0, 13.0); glVertex2f (18.0, 20.0); glVertex2f (26.0, 20.0); glVertex2f (22.0, 25.0); glVertex2f (30.0, 25.0); glVertex2f (15.0, 30.0); glVertex2f (35.0, 30.0); glEnd();
  • 12. OPENGL PRIMITIVES – GL_POLYGON glBegin(GL_POLYGON); glVertex2f(2.0,1.0); glVertex2f(12.0,1.0); glVertex2f(14.0,3.0); glVertex2f(1.0,3.0); glEnd();
  • 13. CREATIVE DRAWING USING OPENGL PRIMITIVES
  • 14. LAB EXERCISE: TIME TO SHOW YOUR CREATIVITY “Sample 2D Scenary are given Lab folder” 1. Show your best to Design your virtual World (2D Scene) onto graph paper.  With Well defined coordinates Points of each object in Scene.  Also Define Color of each Object Of Your Scene 1. Use Open GL built in primitives to Implement your Designed virtual world (2D Scene). MyTricksLab.com (Computer Science & Tech Tutorials)