FirstRanker Logo

FirstRanker.com - FirstRanker's Choice is a hub of Question Papers & Study Materials for B-Tech, B.E, M-Tech, MCA, M.Sc, MBBS, BDS, MBA, B.Sc, Degree, B.Sc Nursing, B-Pharmacy, D-Pharmacy, MD, Medical, Dental, Engineering students. All services of FirstRanker.com are FREE

📱

Get the MBBS Question Bank Android App

Access previous years' papers, solved question papers, notes, and more on the go!

Install From Play Store

Download OU BE (B-Tech) CSE Mini Projects Code program on display list, mouse,keyboard events, Menus

Download OU (Osmania University)BE (B-Tech) (Bachelor of Engineering) CSE Best Practicle Programs And Code program on display list, mouse,keyboard events, Menus

This post was last modified on 27 January 2020

OU B.Com 2020 Important Question Bank || Osmania University (Important Questions)


#include<windows.h>

#include<GL/glut.h>

#define QSTRIP 1

--- Content provided by FirstRanker.com ---

//function to define display list

void display()

{

glClearColor(0.0,0.0,0.0,0.0);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

--- Content provided by‍ FirstRanker.com ---

glNewList(QSTRIP, GL_COMPILE);//display list

glBegin(GL_QUAD_STRIP);

glColor3f(0.0,0.0,1.0);

glVertex3f(0.0,0.0,0.0);//v0

glVertex3f(2.0,0.0,0.0);//v1

--- Content provided by FirstRanker.com ---

glColor3f(0.0,1.0,0.0);

glVertex3f(0.0,2.0,0.0);//v2

glVertex3f(2.0,2.0,0.0);//v3

glColor3f(1.0,0.0,0.0);

glVertex3f(0.0,4.0,0.0);//v4

--- Content provided by​ FirstRanker.com ---

glVertex3f(2.0,4.0,0.0);//v5

glEnd();

glEndList();

}

//functions which calls display list

--- Content provided by⁠ FirstRanker.com ---

void quad()

{

glCallList(QSTRIP);

glFlush();

}

--- Content provided by FirstRanker.com ---

//reshape event handling function

void reshape(GLint w, GLint h)

{

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

--- Content provided by‌ FirstRanker.com ---

gluOrtho2D(-5,5,-5,5);

glMatrixMode(GL_MODELVIEW);

glViewport(0,0,w,h);

}

//mouse event handling function

--- Content provided by​ FirstRanker.com ---

void myMouse (int button, int state, int x, int y)

{

if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)

quad();

if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN)

--- Content provided by⁠ FirstRanker.com ---

exit(0);

}

int main(int argc, char **argv)

{

glutInit(&argc, argv);

--- Content provided by​ FirstRanker.com ---

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);

glutInitWindowSize(400,400);

glutInitWindowPosition(100,100);

glutCreateWindow("display list");

glutDisplayFunc(display);

--- Content provided by⁠ FirstRanker.com ---

glutMouseFunc(myMouse);

glutReshapeFunc(reshape);

glutMainLoop();

}


/*program to draw a small square on the screen.

--- Content provided by‌ FirstRanker.com ---

left button is Clicked and window is closed when 'q' key is pressed*/

#include<windows.h>

#include<GL/glut.h>

#define QSTRIP 1

GLfloat size=50.0;

--- Content provided by​ FirstRanker.com ---

GLsizei wh=300, ww=300;

void display()

{

glClearColor(0.0,0.0,0.0,0.0);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

--- Content provided by‍ FirstRanker.com ---

}

void drawsquare(int x, int y)

{

glBegin(GL_POLYGON);

glColor3f(0.0,0.0,1.0);

--- Content provided by FirstRanker.com ---

glVertex2f(x+size, y+size);

glVertex2f(x-size, y+size);

glVertex2f(x-size, y-size);

glVertex2f(x+size, y-size);

glEnd();

--- Content provided by‌ FirstRanker.com ---

glFlush();

}

void reshape(GLint w, GLint h)

{

glMatrixMode(GL_PROJECTION);

--- Content provided by‌ FirstRanker.com ---

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble)h);

glMatrixMode(GL_MODELVIEW);

glViewport(0,0,w,h);

ww=w;

--- Content provided by‌ FirstRanker.com ---

wh=h;

}

void myMouse(int button, int state, int x, int y)

{

if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)

--- Content provided by​ FirstRanker.com ---

drawsquare(x,y);

}

void myKey(unsigned char key, int x, int y)

{

if(key=='q'||key=='Q')

--- Content provided by⁠ FirstRanker.com ---

exit(0);

}

int main(int argc, char **argv)

{

glutInit(&argc, argv);

--- Content provided by‍ FirstRanker.com ---

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);

glutInitWindowSize(ww,wh);

glutInitWindowPosition(100,100);

glutCreateWindow("display list");

glutDisplayFunc(display);

--- Content provided by⁠ FirstRanker.com ---

glutMouseFunc(myMouse);

glutReshapeFunc(reshape);

glutKeyboardFunc(myKey);

glutMainLoop();

}

--- Content provided by​ FirstRanker.com ---


#include<windows.h>

#include<GL/glut.h>

GLint size=2;

void display()

{

--- Content provided by FirstRanker.com ---

}

glClearColor(0.0,0.0,0.0,1.0);

glClear(GL_COLOR_BUFFER_BIT);

void reshape(GLint w, GLint h)

{

--- Content provided by FirstRanker.com ---

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(-10,10,-10,10);

glMatrixMode(GL_MODELVIEW);

glViewport(0,0,w,h);

--- Content provided by FirstRanker.com ---

}

void draw(int size)

{

glBegin(GL_POLYGON);

glVertex2f(-size, -size);

--- Content provided by‌ FirstRanker.com ---

glVertex2f(size, -size);

glVertex2f(size, size);

glVertex2f(-size, size);

glEnd();

glFlush();

--- Content provided by‍ FirstRanker.com ---

}

void demo_menu(int id)

{

switch(id)

{

--- Content provided by⁠ FirstRanker.com ---

case 1: exit(0);

break;

case 3: size=2*size;

glColor3f(0.0,0.0,1.0);

draw(size);

--- Content provided by‍ FirstRanker.com ---

break;

case 4: if(size>3)

size=size/2;

glColor3f(0.0,1.0,0.0);

draw(size);

--- Content provided by‌ FirstRanker.com ---

break;

case 2: glColor3f(1.0,0.0,1.0);

draw(size);

}

}

--- Content provided by‍ FirstRanker.com ---

glutPostRedisplay();

int main(int argc, char **argv)

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);

--- Content provided by‍ FirstRanker.com ---

glutInitWindowPosition(50,50);

glutInitWindowSize(500,500);

glutCreateWindow("sample menu");

glutCreateMenu(demo_menu);

glutAddMenuEntry("Quit", 1);

--- Content provided by‍ FirstRanker.com ---

glutAddMenuEntry("original",2);

glutAddMenuEntry("Increase",3);

glutAddMenuEntry("Decrease",4);

glutAttachMenu(GLUT_RIGHT_BUTTON);

glutDisplayFunc(display);

--- Content provided by​ FirstRanker.com ---


/* Program on Menu and sub menu*/

#include<windows.h>

#include<GL/glut.h>

GLint size=2;

int sub_menu;

--- Content provided by​ FirstRanker.com ---

void display()

{

glClearColor(0.0,0.0,0.0,1.0);

glClear(GL_COLOR_BUFFER_BIT);

}

--- Content provided by​ FirstRanker.com ---

void reshape(GLint w, GLint h)

{

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(-10,10,-10,10);

--- Content provided by⁠ FirstRanker.com ---

glMatrixMode(GL_MODELVIEW);

glViewport(0,0,w,h);

}

void draw(int size)

{

--- Content provided by‌ FirstRanker.com ---

glBegin(GL_POLYGON);

glVertex2f(-size, -size);

glVertex2f(size, -size);

glVertex2f(size, size);

glVertex2f(-size, size);

--- Content provided by⁠ FirstRanker.com ---

glEnd();

glFlush();

}

void demo_menu(int id)

{

--- Content provided by‌ FirstRanker.com ---

switch(id)

{

case 1: exit(0);

break;

case 2: glColor3f(1.0,0.0,1.0);

--- Content provided by‍ FirstRanker.com ---

draw(size);

break;

case 3: size=2*size;

glColor3f(0.0,0.0,1.0);

draw(size);

--- Content provided by​ FirstRanker.com ---

break;

case 4: if(size>3)

size=size/2;

glColor3f(0.0,1.0,0.0);

draw(size);

--- Content provided by‍ FirstRanker.com ---

break;

}

}

glutPostRedisplay();

int main(int argc, char **argv)

--- Content provided by FirstRanker.com ---

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);

glutInitWindowPosition(50,50);

glutInitWindowSize(500,500);

--- Content provided by⁠ FirstRanker.com ---

glutCreateWindow("sample menu");

sub_menu=glutCreateMenu(demo_menu);

glutAddMenuEntry("Increase",3);


glutAddMenuEntry("Decrease",4);

glutCreateMenu(demo_menu);

--- Content provided by⁠ FirstRanker.com ---

glutAddMenuEntry("Quit", 1);

glutAddMenuEntry("original", 2);

glutAddSubMenu("Resize", sub_menu);

glutAttachMenu(GLUT_RIGHT_BUTTON);

glutDisplayFunc(display);

--- Content provided by⁠ FirstRanker.com ---

glutReshapeFunc(reshape);

glutMainLoop();}

/*Program for displaying stroke and raster text*/

#include<windows.h>

#include<GL/glut.h>

--- Content provided by‌ FirstRanker.com ---

void displayText(int r, int g, int b, const char *string) {

int j = strlen(string);

glColor3f(r, g, b);

glRasterPos2f(100.0, 10.0 );

for(int i = 0; i < j; i++ ) {

--- Content provided by​ FirstRanker.com ---

//glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, string[i]);

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, string[i]);

}

glFlush();

}

--- Content provided by​ FirstRanker.com ---

void display()

{

glClearColor(0.0,0.0,0.0,1.0);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

displayText(1.0,0.0,0.0,"M. Praveen Kumar, Assistant Professor, MECS");

--- Content provided by‍ FirstRanker.com ---

}

void reshape(GLsizei w, GLsizei h)

{

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

--- Content provided by‍ FirstRanker.com ---

gluOrtho2D (0.0, (GLdouble)w, 0.0, (GLdouble)h);

glMatrixMode(GL_MODELVIEW);

}

int main(int argc, char **argv)

{

--- Content provided by‌ FirstRanker.com ---

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB|GLUT_SINGLE);

glutInitWindowSize(400,400);

glutInitWindowPosition(100,100);

glutCreateWindow("Text Display");

--- Content provided by FirstRanker.com ---

glutDisplayFunc(display);

glutReshapeFunc(reshape);

glutMainLoop();

}

For more visit: FirstRanker.com

--- Content provided by‌ FirstRanker.com ---



This download link is referred from the post: OU B.Com 2020 Important Question Bank || Osmania University (Important Questions)

--- Content provided by​ FirstRanker.com ---