Oopcgl Mini Project
Oopcgl Mini Project
Oopcgl Mini Project
Introduction:
The main purpose of this mini project is to understand the how to use the graphics files and OpenGL to make
amazing animations and games.
OPENGL BASICS:
Open Graphics Library (OpenGL) is a cross-language (language independent), cross-platform (platform
independent) API for rendering 2D and 3D Vector Graphics (use of polygons to represent image). OpenGL is a
low-level, widely supported modeling and rendering software package, available across all platforms. It can be
used in a range of graphics applications, such as games, CAD design, or modeling. OpenGL API is designed
mostly in hardware.
Design: This API is defined as a set of functions which may be called by the client program. Although functions
are similar to those of C language but it is language independent.
Development: It is an evolving API and Khronos Group regularly releases its new version having some
extended feature compare to previous one. GPU vendors may also provide some additional functionality in the
form of extension.
Associated Libraries: The earliest version is released with a companion library called OpenGL utility library.
Since OpenGL is quite a complex process. So in order to make it easier other library such as OpenGL Utility
Toolkit is added which is later superseded by freeglut. Later included library were GLEE, GLEW and glbinding.
2.<conio.h>
The conio.h header file used in C programming language contains functions for console input/output.
Some of its most commonly used functions are clrscr, getch, getche,kbhit etc. They can be used to clear
screen, change color of text and background, move text, check whether a key is pressed or not and to perform
other tasks.
3.<iostream.h> is a header file of c++ program , it’s stands for input output system.
It contains declaration for the identifier cout and cin.
4. <dos.h>
The header file <dos. h> was created to facilitate calls to System API and the OS, so that programmers could
use system calls such as delay (int) or sleep (int) in their programs.
5..Stdlib.h
Standard Library
The header file stdlib. h stands for Standard Library.
It has the information of memory Dynamic Memory allocation and other Standard Functions. ... The getch()
function requires the stdlib header to be Included.
6. time.h
The time.h header file contains definitions of functions to get and manipulate date and time information.
It describes three time-related data types.
7. clock_t: clock_t represents the date as an integer which is a part of the calendar time.
time_t: time_t represents the clock time as an integer which is a part of the calendar time.
struct tm: struct tm holds the date and time
It also contains CLOCKS_PER_SEC macro which holds the number of times does the system clock ticks per
sec.
CODE:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
#include<time.h>
void main()
{
clrscr();
char count[2]="0";
int swapnum=0; //for number of times to swap the cards
int driver,mode;
driver=DETECT;
setfillstyle(SOLID_FILL,YELLOW);
fillpoly(5,card1);
fillpoly(5,card2);
fillpoly(5,card3);
settextstyle(GOTHIC_FONT,HORIZ_DIR,6);
setcolor(BLUE);
moveto(25,25);
outtext(val[0]);
moveto(85,25);
outtext(val[1]);
moveto(145,25);
outtext(val[2]);
do
{
int num=0;
int choice[2];
count[0]++;
delay(1500);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
moveto(20,150);
outtext("No. of Times Cards have been swapped:");
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
moveto(20 + swapnum*20,170);
outtext(count);
setfillstyle(SOLID_FILL,YELLOW);
fillpoly(5,card1);
fillpoly(5,card2);
fillpoly(5,card3);
do
{
randomize();
choice[num]= (rand() + num) % 3;
switch(choice[num])
{
case 0:
setfillstyle(CLOSE_DOT_FILL,BLUE);
fillpoly(5,card1);
break;
case 1:
setfillstyle(CLOSE_DOT_FILL,BLUE);
fillpoly(5,card2);
break;
case 2:
setfillstyle(CLOSE_DOT_FILL,BLUE);
fillpoly(5,card3);
break;
}
num++;
}while(num<2);
swap(val[(choice[0])],val[(choice[1])]);
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
moveto(20,200);
outtext("What is card number 2");
char ans;
ans=getch();
if(ans==val[1][0])
{
moveto(20,230);
outtext("HURRAY");
}
else
{
moveto(20,230);
outtext("YOU DUMBO");
}
getch();
closegraph();
}
Case 1:
In case if user is able to detect the position of card after shuffling then he
will get a message as “HURRAY’
Case 2:
In case if user is not able to detect the position of card after shuffling then
he will get a message as “YOU DUMBO”
PROJECT BY:
1.Nisha Gawai
Roll number: SECO2122A059
2.Rushikesh Rathod
Roll number: SECO2122A066
3.Shrinidhi Kukde
Roll number:SECO2122A069