Tuesday 17 December 2013

Filled Under:

Use glRecti() function

Use glRecti() function:

glRecti function is use in opengl for draw rectangle. it optimize our code. in our previous lecture we draw a rectangle by using GL_QUADS function. in which we use four vertices . but in glrecti() function we only use two vertices. so we simply say that abut glRecti() function

Defination:

opposite corners  filled with current color. by using glRecti() function we can also draw the aligned rectangles. it mean  later rectangles are drawn on top of previous ones.

Syntax:

                           glRecti (int x1,       int y1,     int x2,    int y2);
Note:
             Main function is glRect we use 'i' for integer value for float value we use 'f' .
here x1 and y1 are the vertex of  first corner and x2 and y2 are the vertex of  second corner.

code:

in glutDisplayFunc() we call a function draw_rect function for example glutDisplayFunc(draw_rect)
so that 


void draw_rect(void)
{
glColor3f( 1.0, 0.0, 0.0);
glRecti(100,100,250, 250); 
glColor3f( 0.0, 1.0, 0.0);
glRecti(240,240,350, 350); 
    glFlush();
}

screen short:

 source code:                                                               


                                                                 Download:




0 comments:

Post a Comment