Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
129 views

Programming Languages For Graphics

Uploaded by

Daniel Izevbuwa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views

Programming Languages For Graphics

Uploaded by

Daniel Izevbuwa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROGRAMMING LANGUAGES FOR GRAPHICS

A high-level language and programming interface used to create graphics images is known as
graphics lanaguage. Graphics applications make programming calls to the application
programming interfaces (APIs) of the language, and the graphics drivers (Note: a computer to
run this language must have a graphics card like Nvidia) render the images on the screen or
printer. The major graphics languages are GDI, DirectX, QuickDraw, Display PDF and OpenGL.
Windows uses GDI and DirectX, while the Mac uses QuickDraw and Display PDF. OpenGL
drivers are available for Windows and Unix and the Mac via X Window.

A visual programming language (VPL) allows the programmers to perform the coding
graphically. We can classify a VPL on a higher level than text-based high-level environments like
C, Java, Python, etc.

The visual programming languages provide a collection of graphical elements such as spatial texts,
nodes, and icons that users assemble to program.

Hence, an interconnected set of objects refers to a method accomplishing a specific result with or
without inputs. A system may execute a graphical program with an interpreter or a compiler.

Like syntax in a text-based language, the users have to follow some particular spatial grammar
while writing visual programs.

The graphical program may have a graphical user interface. For example, in creating a graphical
program, the user can create a front panel or a user interface panel.

The front panel may include various graphical user interface elements or front panel items, such
as user interface controls and indicators, which represent or display the relevant input and output
that will be used by the graphical program, and this may include other icons that represent. Devices
are being controlled.

Necessary software/hardware for Graphics Programming


1. Graphics Device Interface (GDI)
The traditional programming interface (API) for output in Windows. When an application needs
to display or print, it makes a call to a GDI function and sends it the parameters for the object that
must be created. GDI in turn "draws" the object by sending commands to the screen and printer
drivers, which actually render the images.
2. Graphics Engine
Hardware that performs graphics processing tasks independently of the computer's CPU. Today's
graphics engine is known as a graphics processing unit (GPU)
3. Graphics Processing Unit (GPU)
A programmable processor specialized for rendering all images on the computer's screen. A
GPU provides the fastest graphics processing, and for gamers, the GPU is a stand-alone card
plugged into the PCI Express (PCIe) bus. GPU circuitry can also be part of the motherboard
chipset or on the CPU chip itself
4. DirectX
A set of Windows interfaces from Microsoft for programming graphics and sound. Windows
developers program to the DirectX APIs, and the manufacturers of sound and graphics cards write
DirectX drivers to be included with their hardware. DirectX provides a high-level interface for
accessing low-level functions "directly." It accesses the hardware abstraction layer in Windows

Highlight of some Graphics Programming Languages


1. QuickDraw
The graphics language in the Mac prior to Mac OS Version 10. It translates elementary
commands in an application to graphics and text elements for the printer and screen. QuickDraw
GX added special effects, better font handling and printer management
2. Display PostScript
The graphics language used in the NeXT machine. It migrated to the Mac as of OS X in the form
of Display PDF. Display PostScript is the screen counterpart of the PostScript printer language.
It translates elementary commands in an application to graphics and text elements on screen.
3. Display PDF
The graphics language used in the Mac starting with Mac OS X, superseding QuickDraw.
Display PDF is the screen counterpart of the PDF printer language. It translates elementary
commands in an application to graphics and text elements on screen. Display PDF is a superset
of Display PostScript with more advanced features including improved color management and
better internal compression.
4. C++

Use the following steps for the graphical program in C++.

Step1: Download the Graphics header files and other stuff needed.

Step 2: Extract the contents of the zip/rar file.

Step 3: Navigate to the file manager location where DevC++ is installed. Go to the MinGW64
folder. Copy the graphics. h and winbgim.h in the include folder and D:\Dev-
Cpp\MinGW64\x86_64-w64-mingw32\include folder.
Step 4: Copy the libbgi.a file into lib folder and in D:\Dev-Cpp\MinGW64\x86_64-w64-
mingw32\lib folder.

Step 5: Copy the ConsoleAppGraphics.template, ConsoleApp_cpp_graph.txt files, and paste them


inside the template folder of the dev c++ installer location.

Step 6: Open a new project in Dev C++.

Step 7: click the “Project” and then go to “Project Options.”

Step 8: In the “parameter” tab write the following text in “Linker” field.

 -lbgi
 -lgdi32
 -lcomdlg32
 -luuid
 -loleaut32
 -lole32
 Click OK.

Step 9: Now you can write and compile any graphics program in C++. You can check the following
code

#include<graphics.h>

#include <conio.h>

int main()

int gd = DETECT, gm;

initgraph(&gd,&gm, “C:\\tc\\bgi”);

circle(300,300,50);

closegraph();

getch();

 The intigraph() a graphic driver to initialize the graphic system from disk.
5. LabVIEW

In the graphics applications, there is a graphing window call the front panel. Another window is
the block diagram, which serves the functional graphical code that a programmer writes. By right-
clicking on the front panel, you will see a control palette.

You can drop any object such as buttons, text block, graphs, displays, etc., from the front panel’s
palette. You can select any of these objects and resize or recolour from the status bar menus.

On creating an object, a corresponding item is created on the block diagram associated with it.

On clicking on the block diagram object, you will see different functions like numerical, structures
and Boolean, string, and mathematical functions you can use to program by that object. Block
diagram allows programmers to create an object such as variables in the area.

When clicking on an item in the front panel, we get a control palette, and on a block diagram
object, we see a function palette. You can drag an object in the front panel to position its
corresponding item in the block diagram.

On hovering over a block diagram item, you will see a cursor enabling you to make a wire and
attach it to another object on the same side of the LabVIEW.

These wires are the flow of data from one item or function to another one. On the top left corner,
click the button ‘run’ to execute your graphical program.

6. Scratch

What to do first

 You need to access Scratch from the website or application.

Main components of Scratch

 Scratch is a small graphical character that performs actions. A programmer can use a sprite
in his/her project from several in-built sprites in Scratch.
 The stage is the working area where the sprite(s) perform actions as per the instructions. It
is a two-dimensional x-y coordinate by which you can see the position of the sprite. You
can run your projects, play games, and watch stories that you programmed in the area.
 Sprite list shows all the thumbnails of available sprites in Scratch.
 Presentation mode is a button located at the top left corner. By clicking the button, you can
see the project running on the computer screen in full screen.
 Cursor tools have different options for a sprite, such as duplicate, resize, etc.
 New sprite buttons allow you to create a new sprite of your own, import, or use an existing
one.
 Block palettes are an area where you can add multiple blocks to program your project and
give actions to the sprite. Different blocks are connected like a puzzle, and the sequence
determines the execution flow.
 This script area is a place where you create a script of a particular task. You can drag a
block from the blocks palette and drop in the script are stepwise to define the instruction.
You can edit the parameters in scripts to program with your own needs. For instance, in
the move steps block, you can change the numbers of steps.

That’s all about the scratch introduction and its components. You can use them for creating an
interactive program or story.

Figure 1: Scratch Interface: Example of Visual Programming Language

Other languages like C, Python and Java may require additional header files, packages or libraries
to run graphics easily.

You might also like