Download presentation
Presentation is loading. Please wait.
Published byPrimrose Ashlee Skinner Modified over 8 years ago
1
Computer Graphics -practical- Lecture 6
2
(visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft visual studio\vc98\include\GL 2)Glut32.dll C:\windows\system 3)Glut32.lib C:\program files\ Microsoft visual studio\ v098\lib After include these files start the visual C++ program.
3
Getting Started You’ll be using VC++ 2010 environment (Download)Download You should already have OpenGL libraries: glut32.dll glut32.lib glut.h GLUT files from the web (www.xmission.com/~nate/glut.html)www.xmission.com/~nate/glut.html
4
To draw the main shape (line, triangle, dot ……)the screen is divided to :
5
In open GL we need three functions to draw the main shapes : (program steps ) Open GL program structure: Header files Function to determine the type of the shape Function to determine the points of the shape Function to end of the points of the shape
6
Function that use to determine the type of the shapes: glBegin(NAME); NameDESCREPTION GL_POINTSDraw point GL_LINES Draw line GL_TRIANGLES To Draw triangle0lo GL_POLYGON To Draw polygon
8
Function that use to determine the points of the shapes:- two dimensional or 3 dimensional glVertex2F(X.Y); glVertex3F(X.Y); *Function to end the points of the shape glEnd();
9
#include
10
Write the VC++ program using open GL library to draw point. Open the VC++ to write the code Start --- visual C++2010 ----new Project :win 32 application Files: C++ source code Then write the program name Name: dpoint
11
#include void display() { glClear(GL_COLOR_BUFFER_BIT); glPointSize(8); glBegin(GL_POINTS); glVertex2f(0.0,0.0); glEnd(); glFlush(); }
12
int main(int argc, char **argv) { glutInit(&argc,argv); glutCreateWindow("draw point"); glutDisplayFunc(display); glutMainLoop(); return 0; }
13
#include #include //header file, define the opengl library void display() //Function to display { glClear(GL_COLOR_BUFFER_BIT); /* this function use to clear the buffer before draw any shape */ glPointSize(8); glBegin(GL_POINTS); /* function to declare the type of the shape “here to draw point” */ glVertex2f(0.0,0.0); /* function to determine the place of the shape on the screen */ glEnd(); /*used to determine the end of the shape point */ glFlush(); //function to view the shape }
14
// For user interface int main(int argc, char **argv) { glutInit(&argc,argv); /* Open gl utility toolkit: use to call glut function to view window */ glutCreateWindow("draw point"); /* name of the window (any name) */ glutDisplayFunc(display); /* call the function display */ glutMainLoop(); /* function for looping the program, then all ways come at the end (Display the window until you close) */ return 0; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.