Git Product home page Git Product logo

solution-to-graphics.h's Introduction

Author

Setting up graphics library (graphics.h) in Visual Studio Code (c++)

Table Of Content

My Workspace Dir and code example

graphics example

General information

It like a tradition to use Turbo in our Indian CS sector. Its because the syllabus haven't been changed since long time.

The graphics. h header file 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. The second step is initialize the graphics drivers on the computer using initgraph method of graphics. h library.

<graphics.h> is very old library. It's better to use something that is new.

Trust Me There are much better option

Allegro or SDL libraries may be for you. You could also try SFML. It has quite a following. You'll have a large community behind you if you needed any help.


Now To set up graphics.h in vs code:

files

Setup

Get all the files needed graphics.h, winbgim.h and libbgi.a

If you don't have MinGW installed get it from official and follow the steps.

Know the difference between MINGW, Mingw-w64 && TDM learn more go, go, go...

  • Copy graphics.h and winbgim.h files to MinGW/include folder.

location might be ("C:\MinGW\include")

  • Copy libbgi.a to file to MinGW/lib folder.

location might be ("C:\MinGW\lib")

Open Vs Code Smart way:

  • Select a folder and open Terminal
   mkdir turbographics
   cd turbographics
   code .

if you are using template with task and c_cpp_properties json file then you directory should look like this:

  • All you code should o inside src and the task.json will build the .exe in build folder
turbographics
β”œβ”€β”€β”€.vscode
└───Home
    β”œβ”€β”€β”€build
    └───src
  • Create or Add .vscode folder in that workspace which will contain task.json, c_cpp_properties.json

image

//create a file name it example.cpp or any other name with .cpp extension

#include <graphics.h> 
    int main()
    {
        int gd = DETECT, gm;
        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;
    }

Running the file using command in termainl:

    g++ -o example hut.cpp -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

    //after u'll get example.exe run using command: .\example

image

OR => πŸ‘ŒπŸ€©

  • Just Ctrl+Shift+B to run the build task you will get the executable file in build folder

graphics example2 graphics example3

Easy run template for graphics.h => repo If your dont want to write that command again and again you can create task.json

solution-to-graphics.h's People

Contributors

ullaskunder3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.