添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Introduction

Hello everyone, today we are going to set up Visual Studio Community Edition for Computer Graphical Programming using graphic.h in C++.

What is "graphic.h"

The graphics.h is a header file in C/C++ that provides access to a simple graphics library that makes it possible to draw lines, rectangles, ovals, arcs, polygons, images, and strings on a graphical window.

Why you should use "graphic.h"

In India, in the field of computer science, most of the degree courses have at least Computer Graphical Programming, be it B.Tech, BCA, BSc Cs, or any other degree in Computer science department.

So, if you are taking one of the courses listed above, it is mandatory to use graphic.h for Computer Graphical Programming.

Why you shouldn't use "graphic.h"

  • graphics.h is for DOS based graphics with max support of 640x480 resolution based on graphics driver and mode selection.
  • Because “graphics.h” is really old library and not used anymore.
  • graphics.h is a 35 years old header that used to exist in Borland version of Turbo C. It is simply outdated & unsupported.
  • I would also suggest not using Bloodshed Dev-C++ as it is also quite outdated.

    If you are not taking any course that "Strictly" requires you to use graphic.h for Computer Graphical Programming, and just want to learn graphic programming in general or as a hobby we highly recommend that you use one of the many libraries out there which are better (but complicated) than graphics.h. Some of them are:

    OpenGL using GLFW (modern openGL)(Recommended)

    OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) that use graphic hardware(GPU or Video card) for rendering 2D and 3D vector graphics.

    DirectX(Recommended)

    DirectX is an application program interface (API) that uses graphic hardware(GPU or Video card) for creating and managing graphic and multimedia effects in applications such as games or Dynamic Web pages that will run in MS's Windows operating systems.

    Latest DirectX 12 is included in Windows 10, 11

    Simple and Fast Multimedia Library (SFML) is a cross-platform software development library that uses graphic hardware(GPU or Video card) it is designed to provide a simple application programming interface (API) to various multimedia components in Modern computers.

    SDL (Specification and Description Language) is a program design and implementation language that uses graphic hardware(GPU or Video card) for rendering 2D and 3D graphics. that is used to build actual-time event-driven systems that involve parallel processing

    you can setup graphic.h to work with both Visual studio Community / Professional and Visual Studio Code

    IF THE IMAGES SEEM BLURRED OUT, TRY AND ZOOM IN THE WEBPAGE OR OPEN IMAGE IN A NEW TAB. THIS CAN HAPPEN DUE TO MOST OF THE IMAGES BEING IN 4:3 ASPECT RATIO.

    Step-by-step Instructions

    Step 1

    First of all, for using "graphics.h" in the visual studio community, you should have Visual Studio Community installed on your computer. You can download its official version from Microsoft's Visual studio website CLICK HERE

    Step 2

    Install Visual Studio Community. After installing Visual Studio Community, open Visual studio community installer by searching it in the start menu as shown in the below screenshots.

    Step 3

    Once Visual Studio Community Installer opens up click on modify to modify your installation.

    Step 4

    Choose the Highlighted workload below to download and install it in your Visual Studio Community Installation.

    Step 5

    After installing the workload, we would also need to download one more file that is WinBGIm Graphics Library for Visual Studio . Here BGI Stands for ( Borland Graphics Interface ) Click Here , download the “BGI2010.zip” File

    Step 6

    After downloading, right-click the file and select "Extract All" to unarchive the files in your desired path/directory.

    The new directory will be created, named BGI, it has all the necessary files that you will need (including the WinBGIm which contains graphic.h, winbgim.h and winbgi.h Libraries and a pre-set project that is already set up to you to test them) in order to create a computer graphics programs in Visual Studio community.

    You should now rename this folder to a name for your own liking that is easy to remember, such as “ Graphical Programming Workspace ”. And copy it to an easily accessible location such as your Document folder or your desktop.

    Navigate to that directory. And you will see a bunch of files there which also include Graphics Library files and a sample project.

    Step 7

    In this folder, open the file named “bgi.vcxproj”. and the project will open in Visual Studio Community.

    Step 8

    As the Project opens you will see a prompt that asks you to retarget the Project to target the Latest Version of Visual Studio Community.

    In this pop-up window choose the latest Windows SDK and Microsoft Platform Toolset version and click on the Ok Button as shown in the below Screenshot.

    And Visual Studio Community will Reconfigure the Project to target the Current Version of Visual studio community, Windows SDK and Platform Toolset version.

    Step 9

    In Visual Studio Community, Open the solution explorer then open the source file and you will see a bunch of files there here create a new source code file(. cpp )

    char data[] = "C:\\MinGW\\lib\\libbgi.a"; initgraph( & gd, & gm, data); //you can also pass NULL for third parameter if you did above setup successfully //example: initgraph(&gd, &gm, NULL); circle(200, 200, 100); getch(); closegraph(); return 0;

    Step 12

    Now build and run the Code by Clicking on Debug the click on Start without Debugger in drop-down menu.

    And you will see that your Program runs and a Circle is drawn on the console that opens up as shown in the screenshot.

    Now, whenever you would need to write a new code just create a new file and write code in it and run just as we did for test.cpp

    Summary

    In this article, we have learned how we can use graphic.h in Visual Studio Community which is a part of the Borland Graphics Interface . This article is especially useful for College students who are taking a Computer Graphics Course. I hope this article helped you, if you liked it please share it with your friends.