SlideShare a Scribd company logo
OpenGL
Code review
Sanuri Karunarathna
Example 1
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);
glBegin(GL_POLYGON);
glVertex2f(100,500);
glVertex2f(100,100);
glVertex2f(200,100);
glVertex2f(200,300);
glEnd();
glFlush();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(512,512);
glutCreateWindow("");
glutDisplayFunc(display);
gluOrtho2D(0,640,0,640);
glClearColor(0.5,0.7,0.5,0);
glutMainLoop();
return 0;
}
Output – OpenGL
include <GL/glut.h>
void display(){
glClear(GL_COLOR_BUFFER_BIT);
Adding required libraries to the project
Define a method to display
glClear — clear buffers to preset values
3 values :
• GL_COLOR_BUFFER_BIT- Indicates the buffers currently
enabled for color writing.
• GL_DEPTH_BUFFER_BIT- Indicates the depth buffer.
• GL_STENCIL_BUFFER_BIT - Indicates the stencil buffer.
glColor — set the current color
glColor3f(1,0,0);
glBegin(GL_POLYGON); glBegin — delimit the vertices of a primitive or a group of
like primitives
Code review cont…
glVertex2f(100,500);
glVertex2f(100,100);
glVertex2f(200,100);
glVertex2f(200,300);
glVertex — specify a vertex
C specifications
Code review cont…
glEnd(); glBegin and glEnd delimit the vertices that define a primitive
or a group of like primitives.
glFlush — force execution of GL commands in finite timeglFlush();
glutSwapBuffers(); glutSwapBuffers- swaps the buffers of the current window
if double buffered.
} End of Display function
Code review cont…
main function
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(512,512);
glutCreateWindow("");
glutDisplayFunc(display);
gluOrtho2D(0,640,0,640);
glClearColor(0.5,0.7,0.5,0);
glutMainLoop();
return 0;
}
main()
The entry point into any console application. As you delve into graphics
development, you'll notice that it isn't always this. However, to keep
things simple, let's just stick with main on its own.
int argc;
Stands for argument count. In other words, how many things are being
passed into the program.
char **argv; or char *argv[];
Both do the exact same thing. Short for argument vector, or in other
words, this is a multidimensional array that will store all arguments
being passed to the function.
is used to initialize the GLUT library.glutInit(&argc, argv);
glutInitDisplayMode - sets the initial display mode.glutInitDisplayMode(GLUT_RGBA);
Code review cont…
Code review cont…
glutInitWindowSize(512,512); glutInitWindowPosition and glutInitWindowSize set the initial
window position and size respectively.
glutCreateWindow creates a top-level window.
glutCreateWindow("");
glutDisplayFunc sets the display callback for the current window.
glutDisplayFunc(display);
Code review cont…
gluOrtho2D(0,640,0,640); gluOrtho2D — define a 2D orthographic projection matrix
glClearColor(0.5,0.7,0.5,0); glClearColor — specify clear values for the color buffers
Code review cont…
glutMainLoop(); glutMainLoop enters the GLUT event processing loop.
return 0;
}
Return 0 and end of the main function
Open gl polygon code review

More Related Content

What's hot

Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
Andres Almiray
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilder
Andres Almiray
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDB
Jim Chang
 
MFC Cosinus
MFC CosinusMFC Cosinus
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being LazyNagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
Owen Hsu
 
Svcc Java2D And Groovy
Svcc Java2D And GroovySvcc Java2D And Groovy
Svcc Java2D And Groovy
Andres Almiray
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
Zohaib Ahmed
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
khasmanjalali
 
The Big Three
The Big ThreeThe Big Three
The Big Three
Roman Okolovich
 
Programming using opengl in visual c++
Programming   using opengl in visual c++Programming   using opengl in visual c++
Programming using opengl in visual c++
Ta Nam
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
James Titcumb
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?
PVS-Studio
 
GvaScript Library
GvaScript LibraryGvaScript Library
GvaScript Library
Mona Remlawi
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
경주 전
 
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
Michel Alves
 
C++ programs
C++ programsC++ programs
C++ programs
Mukund Gandrakota
 
Checking Notepad++: five years later
Checking Notepad++: five years laterChecking Notepad++: five years later
Checking Notepad++: five years later
PVS-Studio
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
Alipay
 

What's hot (20)

Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilder
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDB
 
MFC Cosinus
MFC CosinusMFC Cosinus
MFC Cosinus
 
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being LazyNagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
Svcc Java2D And Groovy
Svcc Java2D And GroovySvcc Java2D And Groovy
Svcc Java2D And Groovy
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
The Big Three
The Big ThreeThe Big Three
The Big Three
 
Programming using opengl in visual c++
Programming   using opengl in visual c++Programming   using opengl in visual c++
Programming using opengl in visual c++
 
Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)Diving into HHVM Extensions (Brno PHP Conference 2015)
Diving into HHVM Extensions (Brno PHP Conference 2015)
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?Of complicacy of programming, or won't C# save us?
Of complicacy of programming, or won't C# save us?
 
GvaScript Library
GvaScript LibraryGvaScript Library
GvaScript Library
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
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
 
C++ programs
C++ programsC++ programs
C++ programs
 
Checking Notepad++: five years later
Checking Notepad++: five years laterChecking Notepad++: five years later
Checking Notepad++: five years later
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
 

Similar to Open gl polygon code review

01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
EngrZamaan
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
Subiksha57
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
adil104135
 
computer graphics at openGL
computer graphics at openGLcomputer graphics at openGL
computer graphics at openGL
Yasir Khan
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
Bijoy679
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
René Domínguez
 
Open gl
Open glOpen gl
Open gl
ch samaram
 
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 at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)
Yasir Khan
 
The Ring programming language version 1.5.1 book - Part 52 of 180
The Ring programming language version 1.5.1 book - Part 52 of 180The Ring programming language version 1.5.1 book - Part 52 of 180
The Ring programming language version 1.5.1 book - Part 52 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 60 of 202
The Ring programming language version 1.8 book - Part 60 of 202The Ring programming language version 1.8 book - Part 60 of 202
The Ring programming language version 1.8 book - Part 60 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 56 of 189
The Ring programming language version 1.6 book - Part 56 of 189The Ring programming language version 1.6 book - Part 56 of 189
The Ring programming language version 1.6 book - Part 56 of 189
Mahmoud Samir Fayed
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
ch samaram
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
Girish Ghate
 
The Ring programming language version 1.5.2 book - Part 53 of 181
The Ring programming language version 1.5.2 book - Part 53 of 181The Ring programming language version 1.5.2 book - Part 53 of 181
The Ring programming language version 1.5.2 book - Part 53 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196
Mahmoud Samir Fayed
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
Matt Hirsch - MIT Media Lab
 
The Ring programming language version 1.10 book - Part 65 of 212
The Ring programming language version 1.10 book - Part 65 of 212The Ring programming language version 1.10 book - Part 65 of 212
The Ring programming language version 1.10 book - Part 65 of 212
Mahmoud Samir Fayed
 
All things that are not code
All things that are not codeAll things that are not code
All things that are not code
Mobile Delivery Days
 
Richard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL ModuleRichard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL Module
Axway Appcelerator
 

Similar to Open gl polygon code review (20)

01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
 
computer graphics at openGL
computer graphics at openGLcomputer graphics at openGL
computer graphics at openGL
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
Open gl
Open glOpen gl
Open gl
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
computer graphics at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)
 
The Ring programming language version 1.5.1 book - Part 52 of 180
The Ring programming language version 1.5.1 book - Part 52 of 180The Ring programming language version 1.5.1 book - Part 52 of 180
The Ring programming language version 1.5.1 book - Part 52 of 180
 
The Ring programming language version 1.8 book - Part 60 of 202
The Ring programming language version 1.8 book - Part 60 of 202The Ring programming language version 1.8 book - Part 60 of 202
The Ring programming language version 1.8 book - Part 60 of 202
 
The Ring programming language version 1.6 book - Part 56 of 189
The Ring programming language version 1.6 book - Part 56 of 189The Ring programming language version 1.6 book - Part 56 of 189
The Ring programming language version 1.6 book - Part 56 of 189
 
Opengl (1)
Opengl (1)Opengl (1)
Opengl (1)
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
The Ring programming language version 1.5.2 book - Part 53 of 181
The Ring programming language version 1.5.2 book - Part 53 of 181The Ring programming language version 1.5.2 book - Part 53 of 181
The Ring programming language version 1.5.2 book - Part 53 of 181
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
 
The Ring programming language version 1.10 book - Part 65 of 212
The Ring programming language version 1.10 book - Part 65 of 212The Ring programming language version 1.10 book - Part 65 of 212
The Ring programming language version 1.10 book - Part 65 of 212
 
All things that are not code
All things that are not codeAll things that are not code
All things that are not code
 
Richard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL ModuleRichard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL Module
 

Recently uploaded

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
Codeigniter VS Cakephp Which is Better for Web Development.pdf
Codeigniter VS Cakephp Which is Better for Web Development.pdfCodeigniter VS Cakephp Which is Better for Web Development.pdf
Codeigniter VS Cakephp Which is Better for Web Development.pdf
Semiosis Software Private Limited
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 

Recently uploaded (20)

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
Codeigniter VS Cakephp Which is Better for Web Development.pdf
Codeigniter VS Cakephp Which is Better for Web Development.pdfCodeigniter VS Cakephp Which is Better for Web Development.pdf
Codeigniter VS Cakephp Which is Better for Web Development.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 

Open gl polygon code review

  • 2. Example 1 #include <GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1,0,0); glBegin(GL_POLYGON); glVertex2f(100,500); glVertex2f(100,100); glVertex2f(200,100); glVertex2f(200,300); glEnd(); glFlush(); glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(512,512); glutCreateWindow(""); glutDisplayFunc(display); gluOrtho2D(0,640,0,640); glClearColor(0.5,0.7,0.5,0); glutMainLoop(); return 0; }
  • 4. include <GL/glut.h> void display(){ glClear(GL_COLOR_BUFFER_BIT); Adding required libraries to the project Define a method to display glClear — clear buffers to preset values 3 values : • GL_COLOR_BUFFER_BIT- Indicates the buffers currently enabled for color writing. • GL_DEPTH_BUFFER_BIT- Indicates the depth buffer. • GL_STENCIL_BUFFER_BIT - Indicates the stencil buffer. glColor — set the current color glColor3f(1,0,0);
  • 5. glBegin(GL_POLYGON); glBegin — delimit the vertices of a primitive or a group of like primitives Code review cont…
  • 7. glEnd(); glBegin and glEnd delimit the vertices that define a primitive or a group of like primitives. glFlush — force execution of GL commands in finite timeglFlush(); glutSwapBuffers(); glutSwapBuffers- swaps the buffers of the current window if double buffered. } End of Display function Code review cont…
  • 8. main function int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(512,512); glutCreateWindow(""); glutDisplayFunc(display); gluOrtho2D(0,640,0,640); glClearColor(0.5,0.7,0.5,0); glutMainLoop(); return 0; } main() The entry point into any console application. As you delve into graphics development, you'll notice that it isn't always this. However, to keep things simple, let's just stick with main on its own. int argc; Stands for argument count. In other words, how many things are being passed into the program. char **argv; or char *argv[]; Both do the exact same thing. Short for argument vector, or in other words, this is a multidimensional array that will store all arguments being passed to the function.
  • 9. is used to initialize the GLUT library.glutInit(&argc, argv); glutInitDisplayMode - sets the initial display mode.glutInitDisplayMode(GLUT_RGBA); Code review cont…
  • 10. Code review cont… glutInitWindowSize(512,512); glutInitWindowPosition and glutInitWindowSize set the initial window position and size respectively. glutCreateWindow creates a top-level window. glutCreateWindow(""); glutDisplayFunc sets the display callback for the current window. glutDisplayFunc(display);
  • 11. Code review cont… gluOrtho2D(0,640,0,640); gluOrtho2D — define a 2D orthographic projection matrix glClearColor(0.5,0.7,0.5,0); glClearColor — specify clear values for the color buffers
  • 12. Code review cont… glutMainLoop(); glutMainLoop enters the GLUT event processing loop. return 0; } Return 0 and end of the main function