0% found this document useful (0 votes)
263 views

C++ Graphics For Windows Using Winbgim: Download and Install The Winbgim Devpak File "Winbgim-6.0-1G17L.Devpak"

This document provides instructions for using the WINBGIm graphics library in C++ projects in Dev C++. It explains how to install WINBGIm, create a new project, add source code, compile the project, and run the executable. It then demonstrates basic graphics functions like initializing a window, drawing text and shapes, animation, and creating a Ball class.

Uploaded by

Dinesh Valmiki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
263 views

C++ Graphics For Windows Using Winbgim: Download and Install The Winbgim Devpak File "Winbgim-6.0-1G17L.Devpak"

This document provides instructions for using the WINBGIm graphics library in C++ projects in Dev C++. It explains how to install WINBGIm, create a new project, add source code, compile the project, and run the executable. It then demonstrates basic graphics functions like initializing a window, drawing text and shapes, animation, and creating a Ball class.

Uploaded by

Dinesh Valmiki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

C++ Graphics for Windows using WINBGIm

Download and install the WINBGIm devpak file


"WinBGIm-!"-#g#$l!Dev%ak"!
www.onecore.net/winbgim-graphics.htm
&pen Dev C++ and create a new pro'ect!
File -> New -> Project...
Choose the WinBGIm tab.
Choose either with our without console.
Gie !our project a name.
"he newl! create# project will contain source co#e.
$ae the cpp %ile with an! name !ou choose.
Put it in the same %ol#er as the project.
Compile the project.
"he project %ol#er now will contain & %iles'
()sing the project name Project*+ an# the %ile name %ile*,
Project*.ico - a #e%ault icon %or the e.e %ile+ an# application %rame.
File*.cpp - /our C00 source co#e.
1a2e%ile.win - $peci%ies %iles to use in project+ compiler to use...
Project*.#e - 3e C00 Project %ile. 3ouble clic2 this to open project.
Project*4priate.h - 5ea#er %ile that woul# hol# complicate# stu%% i% we ha# an!.
Project*4priate.rc - Precompile# resource %ile+ has name o% icon %ile.
File*.o - 6utput %ile %rom compiling File*.cpp
Project*.e.e - 7in2e# e.ecutable %or entire project.
Project*4priate.rc - Compile# resource %ile.
(he source code
#include <iostream>
#include <graphics.h>
using namespace std;
int main( )
{
initwindow( 640 , 480 , !in"#$m );
outte%t%&( 0 , 0 , 'ello !in"#$m( );
)giout << 'ello !in"#$m*+tream( ;
outstream%&( 0 , ,- );
while( (.)hit() );
closegraph( );
return( 0 );
/
void initwindow(int width, int height, string title)
"he initwin#ow(, %unction opens a win#ow that we can ma2e graphics calls to. /ou can
speci%! the wi#th+ height+ an# title.
void outtextxy(int x, int, y, string text)
"he outte.t.!(, %unction #ispla!s te.t in the win#ow. /ou can speci%! the .+! coor#inate
an# the te.t.
"he closegraph(, %unction en#s the graphics session an# closes the win#ow.
"he clear#eice(, %unction clears the win#ow to the current bac2groun# color.
)*amples+
int main( )
{
initwindow( 640 , 480 , #raphics );
outte%t%&( -0 , -0 , 0he $nternet is 0u)es( );
s&stem(pause);
closegraph( );
return( 0 );
/
int main( )
{
initwindow( 640 , 480 , 0iming );
outte%t%&( -0 , -0 , 0he $nternet is 0u)es( );
dela&(1000);
outte%t%&( ,00 , ,00 , 0he $nternet is 2ot a "ig 0ruc.( );
dela&(1000);
closegraph( );
return( 0 );
/
int main( )
{
initwindow( 640 , 480 , 3epetition );
while(true)
{
outte%t%&( -0 , -0 , 0he $nternet is 0u)es( );
dela&(1000);
clearde4ice();
outte%t%&( ,00 , ,00 , 0he $nternet is 2ot a "ig 0ruc.( );
dela&(1000);
clearde4ice();
/
closegraph( );
return( 0 );
/
Drawing shapes
void setcolor(int color)

$ets the #rawing (outlining, color.
"he argument can be one o% the integers in the table to the right+ or a new color can be
create# using the C6768 %unction.
int COLOR(int red, int green, int blue)
Creates a new 8GB color an# represents it as an integer.
void setbkcolor(int color)
$ets the bac2groun# color.
void setfillstyle(int pattern, int color)
$ets the %ill pattern an# the %ill color.
"he table to the right shows allowable %ill constants.
B79C: ;
B7)< *
G8<<N =
C/9N >
8<3 ?
19G<N"9 @
B86WN A
7IG5"G89/ B
398:G89/ C
7IG5"B7)< &
7IG5"G8<<N *;
7IG5"C/9N **
7IG5"8<3 *=
7IG5"19G<N"9 *>
/<776W *?
W5I"< *@
<1P"/4FI77 ; Fill with bac2groun# color
$67I34FI77 * $oli# %ill
7IN<4FI77 = Fill with ---
7"$79$54FI77 > Fill with ///
$79$54FI77 ? Fill with ///+ thic2 lines
B:$79$54FI77 @ Fill with DDD+ thic2 lines
7"B:$79$54FI77 A Fill with DDD
59"C54FI77 B 7ight hatch %ill
E59"C54FI77 C 5ea! crosshatch %ill
IN"<87<9F<4FI77 & Interleaing line %ill
WI3<436"4FI77 *; Wi#el! space# #ot %ill
C76$<436"4FI77 ** Closel! space# #ot %ill
)$<84FI77 *= )ser-#e%ine# %ill pattern
void arc(int x, int y, int a1, int a, int r)
3raws an arc.
. an# ! are the center coor#inates.
a* an# a= are the starting an# en#ing angles measures countercloc2wise in #egrees with
Gero #egrees being in the positie . #irection.
r is the ra#ius o% the circle #e%ining the arc.
void bar(int left, int top, int right, int botto!)
Fills a rectangular area with the current %ill color.

void circle(int x, int y, int r)
3raws a circle centere# at .+! with ra#ius r using the current #rawing color.
void floodfill(int x, int y, int boundcolor)
Fills the area aroun# .+! with the current %ill color boun#e# b! the argument boun#color.
void line(int x1, int y1, int x, int y)
3raws a line %rom .*+!* to .=+!= using the current #rawing color.
void pieslice(int x, int y, int a1, int a, int r)
3raws an arc using the current #rawing color an# %ills the arc using the current %ill color.
. an# ! are the center coor#inates.
a* an# a= are the starting an# en#ing angles measures countercloc2wise in #egrees with
Gero #egrees being in the positie . #irection.
r is the ra#ius o% the circle #e%ining the arc.
void rectangle(int left, int top, int right, int botto!)
3raws a rectangle outline using the current #rawing color.
)*ample+
int main( )
{
initwindow( 640 , 480 , +hapes );
int dcolor 5 67873(,--, 0, 1--);
int 9color 5 67873(1--, 0, ,--);
int )color 5 67873(0, ,00, 0);
setcolor(dcolor);
set9illst&le(+78$:;<$88, 9color);
set).color()color);
clearde4ice();
arc(100, 100, 0, =0, ,00);
)ar(10, >00, >00, >-0);
circle(,00, ,00, ,00);
circle(400, 400, -0);
9lood9ill(400, 400, dcolor);
line(10, 10, 400, 400);
rectangle(>00, -0, 400, 400);
pieslice(100, 100, 0, ,10, -0);
s&stem(pause);
closegraph( );
return( 0 );
/
,nimation
int main( )
{
int % 5 1-0;
int %4 5 -;

initwindow( -00 , 100 , "ouncing"all );
int dcolor 5 67873(,--, 0, 1--);
int 9color 5 67873(1--, 0, ,--);
int )color 5 67873(0, --, 0);
setcolor(dcolor);
set9illst&le(+78$:;<$88, 9color);
set).color()color);
while(true)
{
% ?5 %4;
i9(% > >00)
{
%4 5 * ,0;
/
i9(% < 100)
{
%4 5 ,0;
/

clearde4ice();
circle(%, ,00, ,0);
9lood9ill(%, ,00, dcolor);
dela&(-0);
/
closegraph( );
return( 0 );
/
class "all
{
pri4ate@
int %;
int %4;
int dcolor;
pu)lic@
"all()
{
% 5 1-0;
%4 5 ,0;
dcolor 5 67873(1--, 0, --);
setcolor(dcolor);
set9illst&le(+78$:;<$88, 67873(,--, 0, --));
/
4oid paint()
{
% ?5 %4;
i9(% > >00)
{
%4 5 * ,0;
/
i9(% < 100)
{
%4 5 ,0;
/
circle(%, ,00, ,0);
9lood9ill(%, ,00, dcolor);
/
/;
int main( )
{
initwindow( -00 , 100 , "ouncing"all );
"all )all;
int )color 5 67873(0, --, 0);
set).color()color);
while(true)
{
clearde4ice();
)all.paint();
dela&(-0);
/
closegraph();
return(0);
/
<or Aore !$2"#$m@
[email protected],>00BdocB)giBinde%.html

You might also like