Академический Документы
Профессиональный Документы
Культура Документы
LAB Manual
PART A
Experiment No.11
A.1 Aim:
Study and apply basic opengl functions to draw basic primitives.Implement sierpinsky
gasket using openGL.
A.2 Prerequisite:
1. C Language.
2. Geometric Concepts.
3. Concept of 2D and 3Dbasic Transformations.
4. Projection Concepts.
A.3 Outcome:
After successful completion of this experiment students will be able to,
Apply OpengL
Step 5:
Select Win32 from the Installed Templates panel and then Win32 Console
Application from the next panel. Name your project and select the folder where you
want to save it. Uncheck the box which says \Create directory for solution". Click OK to
bring up a wizard welcome window.
Step 6:
Click Application Settings for the settings dialog box.
Step 7:
Uncheck the Precompiled header box, check the Empty project box and choose
Console application. Click Finish to see a new project window.
Step 8:
Right click on Source Files and choose Add ! New Item to bring up a dialog box.
Step 9:
Select Code from the Installed Templates panel and C++ File(.cpp) from the next
panel. Name your file and click Add to see an empty code panel in the project window
titled with your chosen name. or write your own program in the code panel.
Step 10:
Save and build your project by going to Debug ! Build Solution.Then execute the
program with Debug ! Start Debugging. If the program has been built successfully, then
you should see no error in the output window.
Failure case handling method
If the build process of program is failed then do the following steps
(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the
concerned lab in charge faculties at the end of the practical in case the there is no
Black board access available)
#include <Windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <stdlib.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
glFlush ();
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}
OUTPUT:
#include<GL/glut.h>
int Height=650,Width=650;
struct GLintPoint
{
GLint x,y;
};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void myinit()
{
glClearColor(0.0,0.0,0.0,1.0);
glColor3f(1.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,650.0,0.0,650.0);
}
vertex[0].x=x;
vertex[0].y=Height-y;
}
glFlush();
}
Output:
B.3 Observations and learning:
2. Extendibility
Graphics card manufacturers have the possibility to extend the interface with further
functions. Special commands can be executed directly, instead of having to take a
detour over an emulator with this (very important in the CAD field). This influences the
functionality, velocity and stability.
3. Platform independency
Due to this advantage, OpenGL is mainly found in the professional field of Windows. In
opposition, the opponent dominates the computer-gaming division in which OpenGL
only plays a subordinate role. OpenGL is primarily used in various game consoles (Xbox
360, PlayStation 2/3) and in MacOS game software in the gaming field.
B.4 Conclusion:
Ans:
o Number Of Arguments: 2, 3, or 4
o Data Types:
`f' float
`d' double float
`s' signed short integer
`i' signed integer
`b' character
`ub' unsigned character
`us' unsigned short integer
`ui' unsigned integer
o Formats:
`v' indicates vector format
absence of `v' indicates scalar format
************************