Download OU BE (B-Tech) CSE Mini Projects Code Programs on Logical operations in GLUT

Download OU (Osmania University)BE (B-Tech) (Bachelor of Engineering) CSE Best Practicle Programs And Code Programs on Logical operations in GLUT

/* program to draw erasable rectangle */
#include
#include
?oat xm,ym,xmm,ymm;
void display()
{
glClearColor(1.0,1.0,1.0,1.0);
g1Clear(GL_COLOR_BUFFER_BIT);
glEnable(GL_COLOR_LOGIC_OP);
void myMouse(int btn, int state, int x, int y)
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
xm=x;
ym=(500-y);
glColor3f(0.0,0.0,1.0);
glLogicOp(GL_XOR);
}
if(btn==GLUT_LEFT_BUTTON && state==GLUT_UP)
{
xmm=x;
ymm=(500-y);
glLogicOp(GL_XOR);
glRectf(xm,ym,xmm,ymm);
glFlushO;
}
void reshape(GLsizei w, GLsizei h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentityO;
gluOrth02D(0,500,O,500);
g1MatrixMode(GL_MODELVIEW);
}
int main(int argc, char **argV)
{
glutInit(&argc, argv);
g1utInitDisplayMode(GLUT_SINGLE| GLUT_DEPTH|GLUT_RGB);
glutlnitWindowS ize(500,5 00);
g1utInitWindowPosition(100,100);
glutCreateWindow(?erasable lines?);
g1utDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(myMouse);
glutMainLoopO;

/* Program to draw erasable |ines*/
#include
#include
?oat xm,ym,xmm,ymm;
void displayO
}
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
g1Enable(GL_COLOR_LOGIC_OP)',
void myMouse(int btn, int state, int x, int y)
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
xm=x;
ym=(500-y);
glColor3f(0.0,0.0,1.0);
glLogicOp(GL_XOR);
}
if(btn==GLUT_LEFT_BUTTON && state==GLUT_UP)
{
glColor3f(0.0,1.0,0.0);
xmrn=x;
ymm=(500-y);
glLogicOp(GL_XOR);
ngegin(GL_LINES);
glVertex2f(xm,ym);
glVertex2f(xmm,ymm);
glEndo;
glFlushO;
}
}
void reshape(GLsizei w, GLsizei h)
{
}
g1MatriXMode(GL_PROJECTION);
glLoadIdentityO;
gluOrtho2D(O,500,0,500);
glMatriXMode(GL_MODELVIEW);
int main(int argc, char **argV)
{
glutlnit(&argc, argV);
glutlnitDisplayMode(GLUT_SINGLE|GLUT_DEPTH|GLUT_RGB);
glutInitWindowSize(500,500);
glutlnitWindowPosition(100, 100);
glutCreateWindow("erasable lines");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(myMouse);
glutMainLoopO;

/* Program on Mouse motion event */
#include
#include
?oat xm,ym,xmm,ymm;
int first=0;
void display()
{
glClearColor(1.0,1.0,1.0,1.0);
g1Clear(GL_COLOR_BUFFER_BIT);
g1Enable(GL_COLOR_LOGIC_OP);
void myMouse(int btn, int state, int x, int y)
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
xm=x;
ym=(500-y);
glColor3f(0.0,1.0,1.0);
glLogicOp(GL_XOR);
first=1;
}
}
void Move(int x, int y)
if(first= 1)
{
xmm=x;
ymm=500-y;
ngegin(GL_LINES);
glVertex2f(xm,ym);
glVertex2f(xmm,ymm);
glEndO;
glFlushO;
}
}
void reshape(GLsizei w, GLsizei h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentityO;
gluOrth02D(0,500,O,500);
g1MatrixMode(GL_MODELVIEW);
}
int main(int argc, char **argV)
{
glutInit(&argc, argv);
g1utInitDisplayMode(GLUT_SINGLE|GLUT_DEPTH|GLUT_RGB);
glutInitWindowSize(500,500);
g1utInitWindowPosition(100,100);
glutCreateWindow("erasable lines?);
g1utDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(myMouse);
glutMotionFunc(Move);
glutMainLoopO;

This post was last modified on 27 January 2020