Thoughts Of The Day

GRAPHICS BASIC - 2


                           Welcome in Advance learning Tutorial of C/C ++. Today we are starting Graphics Mode in C/C++ but first it is must to get quick review that you learned from this tutorial.

You have already learned from this tutorial-


  • What is Graphics ?

  • Turbo C Compiler (Installation)

  • Text Mode (Works with coordinate system)

  • Colours in C / C ++

  • textcolor () and textbackground () Functions

  • Blink Keyword

  • gotoxy (int x, int y)

  • Delay


                     If you don’t have knowledge about these Topics so you can read from Previous Chapters.


Graphics Mode -

                                To make program in Graphics Mode you have to include an important header file "graphics.h" in your program. In Graphics programming this header file is important so do not forget it. Then you have to initialize the Graphics.

                      C Language supports of 16 Bit MS-DOS environment. To initialize Graphics mode in a program you have to call function "initgraph" firstly. In this tutorial we are trying to explain in a simple way that how the “initgraph” function works . First lets have a look on prototype of the function.


void initgraph(int *graphdriver, int *graphmode, char *pathtodriver);


This function takes 3 parameter.

  1) * graphdriver -

                                It is an integer that specifies the graphics driver used.



  2) * graphmode -



                               It is also an integer value, which detect available graphics driver and initialize the highest resolution graphics mode according to the detected driver.



 3) * pathtodriver -

                              

                              This is the path of a directory where the initgraph function search graphics driver. if it does not located here then system will search graphics driver in the current directory.



                               It is necessary to pass true values in parameter of the initgraph function. Otherwise output would be unpredictable.

See the example -


int gd = DETECT , gm;
initgraph(&gd,&gm,"");





                                             To initialize Graphics mode, you just have to write two lines. Here we create two integer variables 'gd' and 'gm'.

                                            Now pay attention on this point that “DETECT” is an enumeration type variable which identifies the proper graphics driver and load it. In initgraph function you have to pass the address of both variables.



                              If you don’t know what is the path of the directory so you can leave it blank. Compiler or c/c++ environment will auto detect the path of the driver.

                              Now it’s enough for today’s C/C++ Advance learning tutorial. If you have any doubt or have any question regarding this discussion so you can ask your questions. You can also discuss your problem in our facebook page. Share it with your friends on Facebook, linked in, Twitter, Google+  etc.

                                          In next chapter we will learn how to draw circle and rectangle in C/C++ using graphics.



                            Our efforts in writing this blog will be rewarded if readers send their constructive  suggestions and objectives.

                                        
http://programmingworld-in-english.blogspot.in/

1 comment:

  1. good .keep up your good work.I will visit again if I got stuck learning c.

    ReplyDelete


For MNCs Interview Preparation And Practice set of C,C++,JAVA,PHP Questions Like our page.