Tuesday, 31 December 2013

Initialization of variables

Initialization of variables:                                               When declaring a variable, its value is by default undetermined. But you may want a variable to store a determined value when you declared it. In order to do that, you can initialize the...


Scope of a variable

Scope of a variable: A variable can has global scope or local scope. Local scope:          If we declare a variable within main function. Then its scope will be local. We can only use these variable only main function if we use it other  than main function then compiler will generate the error .So we can say that...


Monday, 30 December 2013

Declaration of variables:

Declaration of variables:                                          In order to use variable in c++ we must declare a variable . declaration mean specify the data  which store in the variable. The syntax of declaration of variable is  syntax: Int a; Char c;...


Saturday, 28 December 2013

Data Type in C++:

Data Type in C++: we store variable in computer memory. but computer has to know what kind of data we store in a variable. for this purpose we use data type that tell the computer what kind of data we are store in a variable. There are 4 basic data types  : int char float double int: —used...


variable and keyword in C++.

what is variable in c++?                            An entity that may vary during program execution is called variable. variable name in c++ programming is the name of location in memory . different type of variable use in c++ programming. e.g integer variable etc certain type can hold...


Tuesday, 17 December 2013

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...


Saturday, 14 December 2013

All in one (draw hut)

All in one GL_QUADS ,GL_TRIANGLES,rotation,scaling and traslation: we have discuss these all function in our first lesson. now we will discuss a example in which we use all these function we will draw a hut  Draw hut:                    first of all we will create the window for drawing that we...


Use glScalef function

glScalef function:                                         glScalef() function is use for scaling in OpenGL so the question is what is scaling? scaling: Scaling is about the origin. If Sx = Sy the scaling is uniform; otherwise it distorts the image. If Sx or Sy...


Friday, 13 December 2013

ROTATION IN OpenGL

ROTATION IN OpenGL: first of all we will create a window for drawing here is the code for creation of window here and naw draw a rectangle or triangle by using GL_QUADS function you can see that how to draw rectangle here  for rotation we use the builtian function glRotatef() syntax: glRotatef(angle  ,  float x   ,  float y  ,   float...


use GL_QUADS function and Translation.

Use GL_QUADS function and Transformation: Use this primitive to draw individual convex quadrilaterals. OpenGL renders a quadrilateral for each group of four vertices. . If n isn't a multiple of 4, OpenGL ignores the excess vertices. so we can say that GL_QUADS require vertices. so we take a example that is clear how to use GL_QUADS function in openGL  first...


Saturday, 7 December 2013

Use the GL_TRIANGLES function:

GL_TRIANGLES function: This primitive takes three vertices at a time and draws a triangle using them. If your application specifies n vertices, OpenGL renders n/3 triangles. If n isn't a multiple of 3, OpenGL ignores the excess vertices. Example: include header file #include "stdafx.h" #include<glut.h> Defination of draw_trinagle function: void Draw_triangle() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 0.0, 0.0); glBegin(GL_TRIANGLES); glVertex2f(0.20,0.95);...


Use the GL_LINES function:

Use the GL_LINES function: This primitive takes two vertices and draws a line segment between them. If the vertices are more than two, OpenGL draws a vertex for each pair of vertices of two vertices. If the application specifies n vertices, OpenGL renders n/2 line segments. If n is odd, OpenGL ignores the final vertex. Example: Main function:...


Friday, 6 December 2013

HOW TO OPEN THE WINDOW FOR DRAWING?? (OpenGL utility library)

Open the window for drawing: Here is the sample code for opening window for drawing using OpenGL Toolkit.  code for intializiation window for drawing : int main(int argc, char **argv) { glutInit(&argc, argv);                                                  ...